[Clang][ASTMergeAction] Assertion `clang::NamedDecl* getLambdaCallOperatorHelper(const clang::CXXRecordDecl&): Assertion `!Calls.empty() && "Missing lambda call operator!"' failed.
When running the following on trunk (3d1172813fc640514c6cb421394c34f4b42cb634)
test.sh
clang++-18 -cc1 -std=c++17 -emit-pch -o qnetworkaccessmanager.cpp.oclango qnetworkaccessmanager.cpp
clang++-18 -cc1 -ast-merge qnetworkaccessmanager.cpp.oclango /dev/null -ast-dump-all=json
qnetworkaccessmanager.cpp
namespace QtPrivate {
template <typename> void assertObjectType();
struct ZeroArgFunctor;
template <typename> using Callable = ZeroArgFunctor;
} // namespace QtPrivate
struct QMetaObject {
template <typename Func> void invokeMethod(QtPrivate::Callable<Func>);
};
void operator-(QMetaObject);
namespace QtPrivate {
template <typename Callable> int bindingFunctionVTable;
class QTagPreservingPointerToPointer;
} // namespace QtPrivate
template <typename Property> class QBindableInterfaceForProperty {
int iface{[] { -Property(); }};
};
namespace QtPrivate {
void setObserver(QTagPreservingPointerToPointer);
template <typename> void assertObjectType();
} // namespace QtPrivate
The second command crashes with this backtrace
clang++-18: /data/llvm-project/clang/lib/AST/DeclCXX.cpp:1542: clang::NamedDecl* getLambdaCallOperatorHelper(const clang::CXXRecordDecl&): Assertion `!Calls.empty() && "Missing lambda call operator!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: clang++-18 -cc1 -O0 -x c++ -ast-merge qnetworkaccessmanager.cpp.oclango /dev/null -ast-dump-all=json
1. <eof> parser at end of file
#0 0x000055555adf59e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /data/llvm-project/llvm/lib/Support/Unix/Signals.inc:727:0
#1 0x000055555adf3524 llvm::sys::RunSignalHandlers() /data/llvm-project/llvm/lib/Support/Signals.cpp:105:0
#2 0x000055555adf413e SignalHandler(int) /data/llvm-project/llvm/lib/Support/Unix/Signals.inc:403:0
#3 0x00007ffff7bc6980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#4 0x00007ffff67f4e87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#5 0x00007ffff67f67f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
#6 0x00007ffff67e63fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
#7 0x00007ffff67e6472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
#8 0x000055555dc39831 getLambdaCallOperatorHelper(clang::CXXRecordDecl const&) /data/llvm-project/clang/lib/AST/DeclCXX.cpp:1546:0
#9 0x000055555dc39879 clang::CXXRecordDecl::getLambdaCallOperator() const /data/llvm-project/clang/lib/AST/DeclCXX.cpp:1556:0
#10 0x000055555dc166ae clang::FunctionDecl::isImmediateFunction() const /data/llvm-project/clang/lib/AST/Decl.cpp:3252:0
#11 0x000055555de87d1c clang::JSONNodeDumper::VisitFunctionDecl(clang::FunctionDecl const*) /data/llvm-project/clang/lib/AST/JSONNodeDumper.cpp:937:0
#12 0x000055555de8f5d6 clang::JSONNodeDumper::Visit(clang::Decl const*) /data/llvm-project/clang/lib/AST/JSONNodeDumper.cpp:132:0
#13 0x000055555dab8b2e clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()::operator()() const /data/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:93:0
#14 0x000055555dac3322 void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)::operator()(bool) const /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:82:0
#15 0x000055555dac3322 std::_Function_handler<void (bool), void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)>::_M_invoke(std::_Any_data const&, bool&&) /usr/include/c++/7/bits/std_function.h:316:0
#16 0x000055555dac3356 void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)::operator()(bool) const /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:74:0
#17 0x000055555dac3356 std::_Function_handler<void (bool), void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)>::_M_invoke(std::_Any_data const&, bool&&) /usr/include/c++/7/bits/std_function.h:316:0
#18 0x000055555dab8f63 void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()) /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:103:0
#19 0x000055555dab8c6b llvm::PointerIntPairInfo<clang::Decl*, 3u, llvm::PointerLikeTypeTraits<clang::Decl*>>::getPointer(long) /data/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:192:0
#20 0x000055555dab8c6b llvm::PointerIntPair<clang::Decl*, 3u, clang::Decl::ModuleOwnershipKind, llvm::PointerLikeTypeTraits<clang::Decl*>, llvm::PointerIntPairInfo<clang::Decl*, 3u, llvm::PointerLikeTypeTraits<clang::Decl*>>>::getPointer() const /data/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:94:0
#21 0x000055555dab8c6b clang::Decl::getNextDeclInContext() /data/llvm-project/clang/include/clang/AST/DeclBase.h:450:0
#22 0x000055555dab8c6b clang::DeclContext::decl_iterator::operator++() /data/llvm-project/clang/include/clang/AST/DeclBase.h:2297:0
#23 0x000055555dab8c6b clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::dumpDeclContext(clang::DeclContext const*) /data/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:303:0
#24 0x000055555dab8c6b clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()::operator()() const /data/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:117:0
#25 0x000055555dac3322 void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)::operator()(bool) const /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:82:0
#26 0x000055555dac3322 std::_Function_handler<void (bool), void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)>::_M_invoke(std::_Any_data const&, bool&&) /usr/include/c++/7/bits/std_function.h:316:0
#27 0x000055555dac3356 void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)::operator()(bool) const /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:74:0
#28 0x000055555dac3356 std::_Function_handler<void (bool), void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)>::_M_invoke(std::_Any_data const&, bool&&) /usr/include/c++/7/bits/std_function.h:316:0
#29 0x000055555dab8f63 void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()) /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:103:0
#30 0x000055555dab8c6b llvm::PointerIntPairInfo<clang::Decl*, 3u, llvm::PointerLikeTypeTraits<clang::Decl*>>::getPointer(long) /data/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:192:0
#31 0x000055555dab8c6b llvm::PointerIntPair<clang::Decl*, 3u, clang::Decl::ModuleOwnershipKind, llvm::PointerLikeTypeTraits<clang::Decl*>, llvm::PointerIntPairInfo<clang::Decl*, 3u, llvm::PointerLikeTypeTraits<clang::Decl*>>>::getPointer() const /data/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:94:0
#32 0x000055555dab8c6b clang::Decl::getNextDeclInContext() /data/llvm-project/clang/include/clang/AST/DeclBase.h:450:0
#33 0x000055555dab8c6b clang::DeclContext::decl_iterator::operator++() /data/llvm-project/clang/include/clang/AST/DeclBase.h:2297:0
#34 0x000055555dab8c6b clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::dumpDeclContext(clang::DeclContext const*) /data/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:303:0
#35 0x000055555dab8c6b clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()::operator()() const /data/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:117:0
#36 0x000055555dab90fb void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()) /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:58:0
#37 0x000055555dab93f6 clang::JSONNodeDumper::~JSONNodeDumper() /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:116:0
#38 0x000055555dab93f6 clang::JSONDumper::~JSONDumper() /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:370:0
#39 0x000055555dab93f6 clang::Decl::dump(llvm::raw_ostream&, bool, clang::ASTDumpOutputFormat) const /data/llvm-project/clang/lib/AST/ASTDumper.cpp:216:0
#40 0x000055555b9e9809 print /data/llvm-project/clang/lib/Frontend/ASTConsumers.cpp:101:0
#41 0x000055555b9e9809 (anonymous namespace)::ASTPrinter::HandleTranslationUnit(clang::ASTContext&) /data/llvm-project/clang/lib/Frontend/ASTConsumers.cpp:48:0
#42 0x000055555cd2f829 clang::ParseAST(clang::Sema&, bool, bool) /data/llvm-project/clang/lib/Parse/ParseAST.cpp:176:0
#43 0x000055555ba24e1f llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine>::operator bool() const /data/llvm-project/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:206:0
#44 0x000055555ba24e1f clang::CompilerInstance::getDiagnostics() const /data/llvm-project/clang/include/clang/Frontend/CompilerInstance.h:344:0
#45 0x000055555ba24e1f clang::ASTMergeAction::ExecuteAction() /data/llvm-project/clang/lib/Frontend/ASTMerge.cpp:80:0
#46 0x000055555bac0b49 clang::FrontendAction::Execute() /data/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1069:0
#47 0x000055555ba4c470 llvm::Error::setChecked(bool) /data/llvm-project/llvm/include/llvm/Support/Error.h:307:0
#48 0x000055555ba4c470 llvm::Error::operator bool() /data/llvm-project/llvm/include/llvm/Support/Error.h:239:0
#49 0x000055555ba4c470 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /data/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1057:0
#50 0x000055555bb515f3 std::__shared_ptr_access<clang::FrontendOptions, (__gnu_cxx::_Lock_policy)2, false, false>::_M_get() const /usr/include/c++/7/bits/shared_ptr_base.h:975:0
#51 0x000055555bb515f3 std::__shared_ptr_access<clang::FrontendOptions, (__gnu_cxx::_Lock_policy)2, false, false>::operator*() const /usr/include/c++/7/bits/shared_ptr_base.h:961:0
#52 0x000055555bb515f3 clang::CompilerInvocation::getFrontendOpts() /data/llvm-project/clang/include/clang/Frontend/CompilerInvocation.h:254:0
#53 0x000055555bb515f3 clang::CompilerInstance::getFrontendOpts() /data/llvm-project/clang/include/clang/Frontend/CompilerInstance.h:291:0
#54 0x000055555bb515f3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /data/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:273:0
#55 0x000055555956561e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /data/llvm-project/clang/tools/driver/cc1_main.cpp:294:0
#56 0x000055555955c8f8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /data/llvm-project/clang/tools/driver/driver.cpp:366:0
#57 0x000055555955fd64 clang_main(int, char**, llvm::ToolContext const&) /data/llvm-project/clang/tools/driver/driver.cpp:407:0
#58 0x0000555559571681 main /data/llvm-project/build/tools/clang/tools/driver/clang-driver.cpp:16:0
#59 0x00007ffff67d7c87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#60 0x000055555955bc2a _start (/data/llvm-project/build/bin/clang-18+0x4007c2a)
./test.sh: line 3: 69463 Aborted (core dumped) clang++-18 -cc1 -O0 -x c++ -ast-merge qnetworkaccessmanager.cpp.oclango /dev/null -ast-dump-all=json > /dev/null
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.
clang++-18 -cc1 qnetworkaccessmanager.cpp -emit-pch -o qnetworkaccessmanager.cpp.oclango -std=c++17
clang++-18 -cc1 -x c++ /dev/null -include-pch qnetworkaccessmanager.cpp.oclango -std=c++17
@llvm/issue-subscribers-clang-frontend
Author: widberg (widberg)
test.sh
clang++-18 -cc1 -std=c++17 -emit-pch -o qnetworkaccessmanager.cpp.oclango qnetworkaccessmanager.cpp
clang++-18 -cc1 -ast-merge qnetworkaccessmanager.cpp.oclango /dev/null -ast-dump-all=json
qnetworkaccessmanager.cpp
namespace QtPrivate {
template <typename> void assertObjectType();
struct ZeroArgFunctor;
template <typename> using Callable = ZeroArgFunctor;
} // namespace QtPrivate
struct QMetaObject {
template <typename Func> void invokeMethod(QtPrivate::Callable<Func>);
};
void operator-(QMetaObject);
namespace QtPrivate {
template <typename Callable> int bindingFunctionVTable;
class QTagPreservingPointerToPointer;
} // namespace QtPrivate
template <typename Property> class QBindableInterfaceForProperty {
int iface{[] { -Property(); }};
};
namespace QtPrivate {
void setObserver(QTagPreservingPointerToPointer);
template <typename> void assertObjectType();
} // namespace QtPrivate
The second command crashes with this backtrace
clang++-18: /data/llvm-project/clang/lib/AST/DeclCXX.cpp:1542: clang::NamedDecl* getLambdaCallOperatorHelper(const clang::CXXRecordDecl&): Assertion `!Calls.empty() && "Missing lambda call operator!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: clang++-18 -cc1 -O0 -x c++ -ast-merge qnetworkaccessmanager.cpp.oclango /dev/null -ast-dump-all=json
1. <eof> parser at end of file
#<!-- -->0 0x000055555adf59e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /data/llvm-project/llvm/lib/Support/Unix/Signals.inc:727:0
#<!-- -->1 0x000055555adf3524 llvm::sys::RunSignalHandlers() /data/llvm-project/llvm/lib/Support/Signals.cpp:105:0
#<!-- -->2 0x000055555adf413e SignalHandler(int) /data/llvm-project/llvm/lib/Support/Unix/Signals.inc:403:0
#<!-- -->3 0x00007ffff7bc6980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#<!-- -->4 0x00007ffff67f4e87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#<!-- -->5 0x00007ffff67f67f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
#<!-- -->6 0x00007ffff67e63fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
#<!-- -->7 0x00007ffff67e6472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
#<!-- -->8 0x000055555dc39831 getLambdaCallOperatorHelper(clang::CXXRecordDecl const&) /data/llvm-project/clang/lib/AST/DeclCXX.cpp:1546:0
#<!-- -->9 0x000055555dc39879 clang::CXXRecordDecl::getLambdaCallOperator() const /data/llvm-project/clang/lib/AST/DeclCXX.cpp:1556:0
#<!-- -->10 0x000055555dc166ae clang::FunctionDecl::isImmediateFunction() const /data/llvm-project/clang/lib/AST/Decl.cpp:3252:0
#<!-- -->11 0x000055555de87d1c clang::JSONNodeDumper::VisitFunctionDecl(clang::FunctionDecl const*) /data/llvm-project/clang/lib/AST/JSONNodeDumper.cpp:937:0
#<!-- -->12 0x000055555de8f5d6 clang::JSONNodeDumper::Visit(clang::Decl const*) /data/llvm-project/clang/lib/AST/JSONNodeDumper.cpp:132:0
#<!-- -->13 0x000055555dab8b2e clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()::operator()() const /data/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:93:0
#<!-- -->14 0x000055555dac3322 void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)::operator()(bool) const /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:82:0
#<!-- -->15 0x000055555dac3322 std::_Function_handler<void (bool), void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)>::_M_invoke(std::_Any_data const&, bool&&) /usr/include/c++/7/bits/std_function.h:316:0
#<!-- -->16 0x000055555dac3356 void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)::operator()(bool) const /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:74:0
#<!-- -->17 0x000055555dac3356 std::_Function_handler<void (bool), void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)>::_M_invoke(std::_Any_data const&, bool&&) /usr/include/c++/7/bits/std_function.h:316:0
#<!-- -->18 0x000055555dab8f63 void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()) /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:103:0
#<!-- -->19 0x000055555dab8c6b llvm::PointerIntPairInfo<clang::Decl*, 3u, llvm::PointerLikeTypeTraits<clang::Decl*>>::getPointer(long) /data/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:192:0
#<!-- -->20 0x000055555dab8c6b llvm::PointerIntPair<clang::Decl*, 3u, clang::Decl::ModuleOwnershipKind, llvm::PointerLikeTypeTraits<clang::Decl*>, llvm::PointerIntPairInfo<clang::Decl*, 3u, llvm::PointerLikeTypeTraits<clang::Decl*>>>::getPointer() const /data/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:94:0
#<!-- -->21 0x000055555dab8c6b clang::Decl::getNextDeclInContext() /data/llvm-project/clang/include/clang/AST/DeclBase.h:450:0
#<!-- -->22 0x000055555dab8c6b clang::DeclContext::decl_iterator::operator++() /data/llvm-project/clang/include/clang/AST/DeclBase.h:2297:0
#<!-- -->23 0x000055555dab8c6b clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::dumpDeclContext(clang::DeclContext const*) /data/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:303:0
#<!-- -->24 0x000055555dab8c6b clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()::operator()() const /data/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:117:0
#<!-- -->25 0x000055555dac3322 void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)::operator()(bool) const /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:82:0
#<!-- -->26 0x000055555dac3322 std::_Function_handler<void (bool), void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)>::_M_invoke(std::_Any_data const&, bool&&) /usr/include/c++/7/bits/std_function.h:316:0
#<!-- -->27 0x000055555dac3356 void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)::operator()(bool) const /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:74:0
#<!-- -->28 0x000055555dac3356 std::_Function_handler<void (bool), void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'())::'lambda'(bool)>::_M_invoke(std::_Any_data const&, bool&&) /usr/include/c++/7/bits/std_function.h:316:0
#<!-- -->29 0x000055555dab8f63 void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()) /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:103:0
#<!-- -->30 0x000055555dab8c6b llvm::PointerIntPairInfo<clang::Decl*, 3u, llvm::PointerLikeTypeTraits<clang::Decl*>>::getPointer(long) /data/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:192:0
#<!-- -->31 0x000055555dab8c6b llvm::PointerIntPair<clang::Decl*, 3u, clang::Decl::ModuleOwnershipKind, llvm::PointerLikeTypeTraits<clang::Decl*>, llvm::PointerIntPairInfo<clang::Decl*, 3u, llvm::PointerLikeTypeTraits<clang::Decl*>>>::getPointer() const /data/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:94:0
#<!-- -->32 0x000055555dab8c6b clang::Decl::getNextDeclInContext() /data/llvm-project/clang/include/clang/AST/DeclBase.h:450:0
#<!-- -->33 0x000055555dab8c6b clang::DeclContext::decl_iterator::operator++() /data/llvm-project/clang/include/clang/AST/DeclBase.h:2297:0
#<!-- -->34 0x000055555dab8c6b clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::dumpDeclContext(clang::DeclContext const*) /data/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:303:0
#<!-- -->35 0x000055555dab8c6b clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()::operator()() const /data/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:117:0
#<!-- -->36 0x000055555dab90fb void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()) /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:58:0
#<!-- -->37 0x000055555dab93f6 clang::JSONNodeDumper::~JSONNodeDumper() /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:116:0
#<!-- -->38 0x000055555dab93f6 clang::JSONDumper::~JSONDumper() /data/llvm-project/clang/include/clang/AST/JSONNodeDumper.h:370:0
#<!-- -->39 0x000055555dab93f6 clang::Decl::dump(llvm::raw_ostream&, bool, clang::ASTDumpOutputFormat) const /data/llvm-project/clang/lib/AST/ASTDumper.cpp:216:0
#<!-- -->40 0x000055555b9e9809 print /data/llvm-project/clang/lib/Frontend/ASTConsumers.cpp:101:0
#<!-- -->41 0x000055555b9e9809 (anonymous namespace)::ASTPrinter::HandleTranslationUnit(clang::ASTContext&) /data/llvm-project/clang/lib/Frontend/ASTConsumers.cpp:48:0
#<!-- -->42 0x000055555cd2f829 clang::ParseAST(clang::Sema&, bool, bool) /data/llvm-project/clang/lib/Parse/ParseAST.cpp:176:0
#<!-- -->43 0x000055555ba24e1f llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine>::operator bool() const /data/llvm-project/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:206:0
#<!-- -->44 0x000055555ba24e1f clang::CompilerInstance::getDiagnostics() const /data/llvm-project/clang/include/clang/Frontend/CompilerInstance.h:344:0
#<!-- -->45 0x000055555ba24e1f clang::ASTMergeAction::ExecuteAction() /data/llvm-project/clang/lib/Frontend/ASTMerge.cpp:80:0
#<!-- -->46 0x000055555bac0b49 clang::FrontendAction::Execute() /data/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1069:0
#<!-- -->47 0x000055555ba4c470 llvm::Error::setChecked(bool) /data/llvm-project/llvm/include/llvm/Support/Error.h:307:0
#<!-- -->48 0x000055555ba4c470 llvm::Error::operator bool() /data/llvm-project/llvm/include/llvm/Support/Error.h:239:0
#<!-- -->49 0x000055555ba4c470 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /data/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1057:0
#<!-- -->50 0x000055555bb515f3 std::__shared_ptr_access<clang::FrontendOptions, (__gnu_cxx::_Lock_policy)2, false, false>::_M_get() const /usr/include/c++/7/bits/shared_ptr_base.h:975:0
#<!-- -->51 0x000055555bb515f3 std::__shared_ptr_access<clang::FrontendOptions, (__gnu_cxx::_Lock_policy)2, false, false>::operator*() const /usr/include/c++/7/bits/shared_ptr_base.h:961:0
#<!-- -->52 0x000055555bb515f3 clang::CompilerInvocation::getFrontendOpts() /data/llvm-project/clang/include/clang/Frontend/CompilerInvocation.h:254:0
#<!-- -->53 0x000055555bb515f3 clang::CompilerInstance::getFrontendOpts() /data/llvm-project/clang/include/clang/Frontend/CompilerInstance.h:291:0
#<!-- -->54 0x000055555bb515f3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /data/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:273:0
#<!-- -->55 0x000055555956561e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /data/llvm-project/clang/tools/driver/cc1_main.cpp:294:0
#<!-- -->56 0x000055555955c8f8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /data/llvm-project/clang/tools/driver/driver.cpp:366:0
#<!-- -->57 0x000055555955fd64 clang_main(int, char**, llvm::ToolContext const&) /data/llvm-project/clang/tools/driver/driver.cpp:407:0
#<!-- -->58 0x0000555559571681 main /data/llvm-project/build/tools/clang/tools/driver/clang-driver.cpp:16:0
#<!-- -->59 0x00007ffff67d7c87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#<!-- -->60 0x000055555955bc2a _start (/data/llvm-project/build/bin/clang-18+0x4007c2a)
./test.sh: line 3: 69463 Aborted (core dumped) clang++-18 -cc1 -O0 -x c++ -ast-merge qnetworkaccessmanager.cpp.oclango /dev/null -ast-dump-all=json > /dev/null
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.
clang++-18 -cc1 qnetworkaccessmanager.cpp -emit-pch -o qnetworkaccessmanager.cpp.oclango -std=c++17
clang++-18 -cc1 -x c++ /dev/null -include-pch qnetworkaccessmanager.cpp.oclango -std=c++17
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!
The original example no longer crashes on trunk (6a898832ff382b1a288f9eb3bc5cd1f37d0fc29f), and all relevant PRs have been merged. Not that it matters, but the original example was valid code reduced from Qt, so I disagree with the crash-on-invalid tag. If someone could retag it for the history books, they will have my eternal gratitude.
The secondary unrelated crash discovered in my comment is now being tracked by #213441. Participants from this thread are welcome to join me over there.