Open widberg opened 10 months ago
@llvm/issue-subscribers-clang-frontend
Author: widberg (widberg)
There is some mistakes in your source code that lead the crash.
template <typename Callable> int bindingFunctionVTable;
Callable
used here has already declared in template <typename> using Callable = ZeroArgFunctor;
replace Callable
with Callable1
like
template <typename Callable1> int bindingFunctionVTable;
works fine.
I think the code is valid since both Clang and GCC are fine with it https://godbolt.org/z/3rd8TnKxz. The AST importer just gets tripped up by the reused identifier or something. That's how the original Qt source code is https://github.com/qt/qtbase/blob/50bce440/src/corelib/kernel/qobjectdefs_impl.h#L353 and https://github.com/qt/qtbase/blob/50bce440/src/corelib/kernel/qpropertyprivate.h#L209. I'd prefer to not have to edit the source code to analyze it.
I think the code is valid since both Clang and GCC are fine with it https://godbolt.org/z/3rd8TnKxz. The AST importer just gets tripped up by the reused identifier or something. That's how the original Qt source code is https://github.com/qt/qtbase/blob/50bce440/src/corelib/kernel/qobjectdefs_impl.h#L353 and https://github.com/qt/qtbase/blob/50bce440/src/corelib/kernel/qpropertyprivate.h#L209. I'd prefer to not have to edit the source code to analyze it.
This patch could fix the crash and no need to edit the source code.
Thank you for all of the work you have put into the issues I've opened! The patch for this issue allows more source files to be processed without crashing but I'm getting a near identical backtrace with this shorter snippet now
qminimalintegration.cpp
struct QPropertyBindingSourceLocation {};
void makePropertyBinding(
QPropertyBindingSourceLocation = QPropertyBindingSourceLocation());
template <typename> class QBindableInterfaceForProperty {
int iface{[] { makePropertyBinding; }};
};
can you verify if this is causing problems or have I done something wrong applying the patch. Same commands as in the original comment. I found this while trying to reduce a different bug, I'm not sure that this exact case would be encountered normally.
Thank you for all of the work you have put into the issues I've opened! The patch for this issue allows more source files to be processed without crashing but I'm getting a near identical backtrace with this shorter snippet now
qminimalintegration.cpp
struct QPropertyBindingSourceLocation {}; void makePropertyBinding( QPropertyBindingSourceLocation = QPropertyBindingSourceLocation()); template <typename> class QBindableInterfaceForProperty { int iface{[] { makePropertyBinding; }}; };
can you verify if this is causing problems or have I done something wrong applying the patch. Same commands as in the original comment. I found this while trying to reduce a different bug, I'm not sure that this exact case would be encountered normally.
Thanks for your feedback! I have test it and this code makes it crash. I will look into this patch.
Thank you for all of the work you have put into the issues I've opened! The patch for this issue allows more source files to be processed without crashing but I'm getting a near identical backtrace with this shorter snippet now
qminimalintegration.cpp
struct QPropertyBindingSourceLocation {}; void makePropertyBinding( QPropertyBindingSourceLocation = QPropertyBindingSourceLocation()); template <typename> class QBindableInterfaceForProperty { int iface{[] { makePropertyBinding; }}; };
can you verify if this is causing problems or have I done something wrong applying the patch. Same commands as in the original comment. I found this while trying to reduce a different bug, I'm not sure that this exact case would be encountered normally.
clang++-18 -cc1 -x c++ -ast-merge qnetworkaccessmanager.cpp.oclango /dev/null -ast-dump-all=json
This command make it work. -x c++
makes merge front end
knows it in cpp
context.
I am aware of that there are many problems when importing Qt source code with ASTImporter
. These PR's are currently in progress and fix some of the problems, so you could include it in tests. @jcsxky You could check or review these because the review looks to be stuck and I have still one patch (variable template related) that can be applied only after these fixes?
https://github.com/llvm/llvm-project/pull/74627
https://github.com/llvm/llvm-project/pull/72841
https://github.com/llvm/llvm-project/pull/72242
Thank you both for the patches. They have improved my outcomes greatly. I will wait for more PRs to go through before opening new issues. It doesn't look like I'm experiencing any bugs caused by the in-flight patches, so all good on that front!
When running the following on trunk (3d1172813fc640514c6cb421394c34f4b42cb634)
test.sh
qnetworkaccessmanager.cpp
The second command crashes with this backtrace
This is similar to https://github.com/llvm/llvm-project/issues/53757 but only happens with
-ast-merge
and is not a regression of the issue. The following runs fine without crashing.