llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.05k stars 11.98k forks source link

ASTImporter crashes: clang/include/clang/AST/Type.h:957: const clang::ExtQualsTypeCommonBase *clang::QualType::getCommonPtr() const: Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed. #104622

Open danix800 opened 2 months ago

danix800 commented 2 months ago

Importing:

namespace { template <typename> auto m = [] {}; }
void bar() { auto n = m<int>; }

stacktrace:

ASTTests: /home/danis/Sources/llvm-project-main/clang/include/clang/AST/Type.h:957: const clang::ExtQualsTypeCommonBase *clang::QualType::getCommonPtr() const: Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed.
  #0 0x00007f6e4a2379aa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/danis/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:723:11
  #1 0x00007f6e4a237bab PrintStackTraceSignalHandler(void*) /home/danis/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:798:1
  #2 0x00007f6e4a235ec6 llvm::sys::RunSignalHandlers() /home/danis/Sources/llvm-project-main/llvm/lib/Support/Signals.cpp:105:5
  #3 0x00007f6e4a2383c5 SignalHandler(int) /home/danis/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:413:1
  #4 0x00007f6e49c5b050 (/lib/x86_64-linux-gnu/libc.so.6+0x3c050)
  #5 0x00007f6e49ca9e2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
  #6 0x00007f6e49c5afb2 raise ./signal/../sysdeps/posix/raise.c:27:6
  #7 0x00007f6e49c45472 abort ./stdlib/abort.c:81:7
  #8 0x00007f6e49c45395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
  #9 0x00007f6e49c53eb2 (/lib/x86_64-linux-gnu/libc.so.6+0x34eb2)
 #10 0x00007f6e4bd74147 clang::QualType::getCommonPtr() const /home/danis/Sources/llvm-project-main/clang/include/clang/AST/Type.h:0:5
 #11 0x00007f6e4bd73e45 clang::QualType::getTypePtr() const /home/danis/Sources/llvm-project-main/clang/include/clang/AST/Type.h:7751:26
 #12 0x00007f6e4bd6ff35 clang::QualType::operator->() const /home/danis/Sources/llvm-project-main/clang/include/clang/AST/Type.h:1001:5
 #13 0x00007f6e4c246761 clang::LinkageComputer::getLVForClosure(clang::DeclContext const*, clang::Decl*, clang::LVComputationKind) /home/danis/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1335:13
 #14 0x00007f6e4c2459a2 clang::LinkageComputer::computeLVForDecl(clang::NamedDecl const*, clang::LVComputationKind, bool) /home/danis/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1516:16
 #15 0x00007f6e4c2430c0 clang::LinkageComputer::getLVForDecl(clang::NamedDecl const*, clang::LVComputationKind) /home/danis/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1580:20
 #16 0x00007f6e4c244e24 clang::LinkageComputer::getLVForClassMember(clang::NamedDecl const*, clang::LVComputationKind, bool) /home/danis/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:958:5
 #17 0x00007f6e4c245aa5 clang::LinkageComputer::computeLVForDecl(clang::NamedDecl const*, clang::LVComputationKind, bool) /home/danis/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1546:12
 #18 0x00007f6e4c2430c0 clang::LinkageComputer::getLVForDecl(clang::NamedDecl const*, clang::LVComputationKind) /home/danis/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1580:20
 #19 0x00007f6e4c2460cd clang::NamedDecl::getLinkageInternal() const /home/danis/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1180:8
 #20 0x00007f6e4bf707a5 bool clang::ASTNodeImporter::hasSameVisibilityContextAndLinkage<clang::FunctionDecl>(clang::FunctionDecl*, clang::FunctionDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1077:14
 #21 0x00007f6e4bf30b92 clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:3805:13
 #22 0x00007f6e4bf3333b clang::ASTNodeImporter::VisitCXXMethodDecl(clang::CXXMethodDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:4140:10
 #23 0x00007f6e4bf3337b clang::ASTNodeImporter::VisitCXXConstructorDecl(clang::CXXConstructorDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:4144:10
 #24 0x00007f6e4bf8cca6 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:258:1
 #25 0x00007f6e4bf57cbd clang::ASTImporter::ImportImpl(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9098:19
 #26 0x00007f6e4bf3c005 clang::ASTImporter::Import(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9494:8
 #27 0x00007f6e4bf66e23 std::conditional<std::is_base_of_v<clang::Type, clang::Decl>, llvm::Expected<clang::Decl const*>, llvm::Expected<clang::Decl*>>::type clang::ASTNodeImporter::import<clang::Decl>(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12
 #28 0x00007f6e4bf28b5e clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext*, bool) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2176:10
 #29 0x00007f6e4bf26972 clang::ASTNodeImporter::ImportDefinition(clang::RecordDecl*, clang::RecordDecl*, clang::ASTNodeImporter::ImportDefinitionKind) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2298:11
 #30 0x00007f6e4bf2efd3 clang::ASTNodeImporter::VisitRecordDecl(clang::RecordDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:3323:15
 #31 0x00007f6e4bff6ecb clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::VisitCXXRecordDecl(clang::CXXRecordDecl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:414:1
 #32 0x00007f6e4bf8ce74 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:414:1
 #33 0x00007f6e4bf57cbd clang::ASTImporter::ImportImpl(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9098:19
 #34 0x00007f6e4bf3c005 clang::ASTImporter::Import(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9494:8
 #35 0x00007f6e4bf693d3 std::conditional<std::is_base_of_v<clang::Type, clang::RecordDecl>, llvm::Expected<clang::RecordDecl const*>, llvm::Expected<clang::RecordDecl*>>::type clang::ASTNodeImporter::import<clang::RecordDecl>(clang::RecordDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12
 #36 0x00007f6e4bf22fb0 clang::ASTNodeImporter::VisitRecordType(clang::RecordType const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1570:8
 #37 0x00007f6e4bf8da58 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:75:1
 #38 0x00007f6e4bf57fb9 clang::ASTImporter::Import(clang::Type const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9130:8
 #39 0x00007f6e4bf58118 clang::ASTImporter::Import(clang::QualType) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9144:8
 #40 0x00007f6e4bf659c9 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:218:23
 #41 0x00007f6e4bf22a64 clang::ASTNodeImporter::VisitAutoType(clang::AutoType const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1523:8
 #42 0x00007f6e4bf8d7c4 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:41:1
 #43 0x00007f6e4bf57fb9 clang::ASTImporter::Import(clang::Type const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9130:8
 #44 0x00007f6e4bf58118 clang::ASTImporter::Import(clang::QualType) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9144:8
 #45 0x00007f6e4bfe2f6f llvm::Error clang::ASTImporter::importInto<clang::QualType>(clang::QualType&, clang::QualType const&) /home/danis/Sources/llvm-project-main/clang/include/clang/AST/ASTImporter.h:309:11
 #46 0x00007f6e4bf7bd96 llvm::Error clang::ASTNodeImporter::importInto<clang::QualType>(clang::QualType&, clang::QualType const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:186:23
 #47 0x00007f6e4bf4450b clang::ASTNodeImporter::VisitVarTemplateSpecializationDecl(clang::VarTemplateSpecializationDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:6632:13
 #48 0x00007f6e4bf8cce8 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:282:1
 #49 0x00007f6e4bf57cbd clang::ASTImporter::ImportImpl(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9098:19
 #50 0x00007f6e4bf3c005 clang::ASTImporter::Import(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9494:8
 #51 0x00007f6e4bf66e23 std::conditional<std::is_base_of_v<clang::Type, clang::Decl>, llvm::Expected<clang::Decl const*>, llvm::Expected<clang::Decl*>>::type clang::ASTNodeImporter::import<clang::Decl>(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12
 #52 0x00007f6e4bf28b5e clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext*, bool) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2176:10
 #53 0x00007f6e4bf2aefb clang::ASTNodeImporter::VisitNamespaceDecl(clang::NamespaceDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2699:13
 #54 0x00007f6e4bf8cb72 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:170:1
 #55 0x00007f6e4bf57cbd clang::ASTImporter::ImportImpl(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9098:19
 #56 0x00007f6e4bf3c005 clang::ASTImporter::Import(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9494:8
 #57 0x00007f6e4bf28c83 clang::ASTImporter::ImportContext(clang::DeclContext*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9621:8
 #58 0x00007f6e4bf25f62 clang::ASTNodeImporter::ImportDeclContext(clang::Decl*, clang::DeclContext*&, clang::DeclContext*&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2220:8
 #59 0x00007f6e4bf25bc7 clang::ASTNodeImporter::ImportDeclParts(clang::NamedDecl*, clang::DeclContext*&, clang::DeclContext*&, clang::DeclarationName&, clang::NamedDecl*&, clang::SourceLocation&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1959:19
 #60 0x00007f6e4bf2d8d3 clang::ASTNodeImporter::VisitRecordDecl(clang::RecordDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:3089:13
 #61 0x00007f6e4bff6ecb clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::VisitCXXRecordDecl(clang::CXXRecordDecl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:414:1
 #62 0x00007f6e4bf8ce74 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:414:1
 #63 0x00007f6e4bf57cbd clang::ASTImporter::ImportImpl(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9098:19
 #64 0x00007f6e4bf3c005 clang::ASTImporter::Import(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9494:8
 #65 0x00007f6e4bf693d3 std::conditional<std::is_base_of_v<clang::Type, clang::RecordDecl>, llvm::Expected<clang::RecordDecl const*>, llvm::Expected<clang::RecordDecl*>>::type clang::ASTNodeImporter::import<clang::RecordDecl>(clang::RecordDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12
 #66 0x00007f6e4bf22fb0 clang::ASTNodeImporter::VisitRecordType(clang::RecordType const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1570:8
 #67 0x00007f6e4bf8da58 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:75:1
 #68 0x00007f6e4bf57fb9 clang::ASTImporter::Import(clang::Type const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9130:8
 #69 0x00007f6e4bf58118 clang::ASTImporter::Import(clang::QualType) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9144:8
 #70 0x00007f6e4bf659c9 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:218:23
 #71 0x00007f6e4bf22a64 clang::ASTNodeImporter::VisitAutoType(clang::AutoType const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1523:8
 #72 0x00007f6e4bf8d7c4 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:41:1
 #73 0x00007f6e4bf57fb9 clang::ASTImporter::Import(clang::Type const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9130:8
 #74 0x00007f6e4bf58118 clang::ASTImporter::Import(clang::QualType) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9144:8
 #75 0x00007f6e4bf659c9 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:218:23
 #76 0x00007f6e4bf22a64 clang::ASTNodeImporter::VisitAutoType(clang::AutoType const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1523:8
 #77 0x00007f6e4bf8d7c4 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:41:1
 #78 0x00007f6e4bf57fb9 clang::ASTImporter::Import(clang::Type const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9130:8
 #79 0x00007f6e4bf58118 clang::ASTImporter::Import(clang::QualType) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9144:8
 #80 0x00007f6e4bf659c9 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:218:23
 #81 0x00007f6e4bf68521 clang::QualType clang::ASTNodeImporter::importChecked<clang::QualType>(llvm::Error&, clang::QualType const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:703:12
 #82 0x00007f6e4bf36374 clang::ASTNodeImporter::VisitVarDecl(clang::VarDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:4596:17
 #83 0x00007f6e4bf8ccd2 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:278:1
 #84 0x00007f6e4bf57cbd clang::ASTImporter::ImportImpl(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9098:19
 #85 0x00007f6e4bf3c005 clang::ASTImporter::Import(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9494:8
 #86 0x00007f6e4bf66e23 std::conditional<std::is_base_of_v<clang::Type, clang::Decl>, llvm::Expected<clang::Decl const*>, llvm::Expected<clang::Decl*>>::type clang::ASTNodeImporter::import<clang::Decl>(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12
 #87 0x00007f6e4bf1a666 llvm::Expected<clang::DeclGroupRef> clang::ASTNodeImporter::import<clang::DeclGroupRef>(clang::DeclGroupRef const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:973:14
 #88 0x00007f6e4bf7e761 clang::DeclGroupRef clang::ASTNodeImporter::importChecked<clang::DeclGroupRef>(llvm::Error&, clang::DeclGroupRef const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:703:12
 #89 0x00007f6e4bf46023 clang::ASTNodeImporter::VisitDeclStmt(clang::DeclStmt*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:6884:15
 #90 0x00007f6e4bf91cb0 clang::StmtVisitorBase<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Stmt*>>::Visit(clang::Stmt*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/StmtNodes.inc:1532:1
 #91 0x00007f6e4bf5d5f1 clang::ASTImporter::Import(clang::Stmt*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9702:8
 #92 0x00007f6e4bf70393 std::conditional<std::is_base_of_v<clang::Type, clang::Stmt>, llvm::Expected<clang::Stmt const*>, llvm::Expected<clang::Stmt*>>::type clang::ASTNodeImporter::import<clang::Stmt>(clang::Stmt*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12
 #93 0x00007f6e4bfe8081 llvm::Error clang::ASTNodeImporter::ImportArrayChecked<clang::Stmt**, clang::Stmt**>(clang::Stmt**, clang::Stmt**, clang::Stmt**) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:715:14
 #94 0x00007f6e4bf7ead6 llvm::Error clang::ASTNodeImporter::ImportContainerChecked<llvm::iterator_range<clang::Stmt**>, llvm::SmallVector<clang::Stmt*, 8u>>(llvm::iterator_range<clang::Stmt**> const&, llvm::SmallVector<clang::Stmt*, 8u>&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:729:14
 #95 0x00007f6e4bf462c2 clang::ASTNodeImporter::VisitCompoundStmt(clang::CompoundStmt*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:6903:13
 #96 0x00007f6e4bf91d08 clang::StmtVisitorBase<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Stmt*>>::Visit(clang::Stmt*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/StmtNodes.inc:1556:1
 #97 0x00007f6e4bf5d5f1 clang::ASTImporter::Import(clang::Stmt*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9702:8
 #98 0x00007f6e4bf70393 std::conditional<std::is_base_of_v<clang::Type, clang::Stmt>, llvm::Expected<clang::Stmt const*>, llvm::Expected<clang::Stmt*>>::type clang::ASTNodeImporter::import<clang::Stmt>(clang::Stmt*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12
 #99 0x00007f6e4bf30205 clang::ASTNodeImporter::ImportFunctionDeclBody(clang::FunctionDecl*, clang::FunctionDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:3510:22
#100 0x00007f6e4bf32d09 clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:4109:9
#101 0x00007f6e4bf8cc4e clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:238:1
#102 0x00007f6e4bf57cbd clang::ASTImporter::ImportImpl(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9098:19
#103 0x00007f6e4bf3c005 clang::ASTImporter::Import(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9494:8
#104 0x0000558170bb3d9a clang::ast_matchers::ASTImporterTestBase::TU::import(std::shared_ptr<clang::ASTImporterSharedState> const&, clang::ASTUnit*, clang::Decl*) /home/danis/Sources/llvm-project-main/clang/unittests/AST/ASTImporterFixtures.cpp:83:12
#105 0x0000558170bb4a19 clang::ast_matchers::ASTImporterTestBase::Import(clang::Decl*, clang::TestLanguage) /home/danis/Sources/llvm-project-main/clang/unittests/AST/ASTImporterFixtures.cpp:199:9
#106 0x0000558170c513d3 clang::FunctionDecl* clang::ast_matchers::ASTImporterTestBase::Import<clang::FunctionDecl>(clang::FunctionDecl*, clang::TestLanguage) /home/danis/Sources/llvm-project-main/clang/unittests/AST/ASTImporterFixtures.h:185:32
#107 0x0000558170c1c821 clang::ast_matchers::ASTImporterOptionSpecificTestBase_VarTemplatedLambdaInGlobalScope_Test::TestBody() /home/danis/Sources/llvm-project-main/clang/unittests/AST/ASTImporterTest.cpp:6803:17
#108 0x00007f6e4d9daa0b void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2612:3
#109 0x00007f6e4d9b9357 void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2667:5
#110 0x00007f6e4d99ed43 testing::Test::Run() /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2694:3
#111 0x00007f6e4d99f510 testing::TestInfo::Run() /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2839:12
#112 0x00007f6e4d99fbfc testing::TestSuite::Run() /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:3017:35
#113 0x00007f6e4d9aaa78 testing::internal::UnitTestImpl::RunAllTests() /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:5921:41
#114 0x00007f6e4d9df3cb bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2612:3
#115 0x00007f6e4d9bb4b7 bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2667:5
#116 0x00007f6e4d9aa64f testing::UnitTest::Run() /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:5484:10
#117 0x00007f6e4e400d71 RUN_ALL_TESTS() /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/include/gtest/gtest.h:2317:30
#118 0x00007f6e4e400cb4 main /home/danis/Sources/llvm-project-main/third-party/unittest/UnitTestMain/TestMain.cpp:55:3
#119 0x00007f6e49c4624a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#120 0x00007f6e49c46305 call_init ./csu/../csu/libc-start.c:128:20
#121 0x00007f6e49c46305 __libc_start_main ./csu/../csu/libc-start.c:347:5
#122 0x0000558170b444c1 _start (./tools/clang/unittests/AST/ASTTests+0x4e84c1)
Aborted

Testcase:

TEST_P(ASTImporterOptionSpecificTestBase, VarTemplatedLambdaInGlobalScope) {
  Decl *FromTU = getTuDecl(
      R"(
        namespace { template <typename> auto m = [] {}; }
        void bar() { auto n = m<int>; }
      )",
      Lang_CXX14, "input0.cc");
  FunctionDecl *FromF = FirstDeclMatcher<FunctionDecl>().match(
      FromTU, functionDecl(hasName("bar")));
  FunctionDecl *ToF = Import(FromF, Lang_CXX14);
  EXPECT_TRUE(ToF);
}
llvmbot commented 2 months ago

@llvm/issue-subscribers-clang-frontend

Author: Ding Fei (danix800)

Importing: ```c namespace { template <typename> auto m = [] {}; } void bar() { auto n = m<int>; } ``` stacktrace: ``` ASTTests: /home/danis/Sources/llvm-project-main/clang/include/clang/AST/Type.h:957: const clang::ExtQualsTypeCommonBase *clang::QualType::getCommonPtr() const: Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed. #0 0x00007f6e4a2379aa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/danis/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:723:11 #1 0x00007f6e4a237bab PrintStackTraceSignalHandler(void*) /home/danis/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:798:1 #2 0x00007f6e4a235ec6 llvm::sys::RunSignalHandlers() /home/danis/Sources/llvm-project-main/llvm/lib/Support/Signals.cpp:105:5 #3 0x00007f6e4a2383c5 SignalHandler(int) /home/danis/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:413:1 #4 0x00007f6e49c5b050 (/lib/x86_64-linux-gnu/libc.so.6+0x3c050) #5 0x00007f6e49ca9e2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76 #6 0x00007f6e49c5afb2 raise ./signal/../sysdeps/posix/raise.c:27:6 #7 0x00007f6e49c45472 abort ./stdlib/abort.c:81:7 #8 0x00007f6e49c45395 _nl_load_domain ./intl/loadmsgcat.c:1177:9 #9 0x00007f6e49c53eb2 (/lib/x86_64-linux-gnu/libc.so.6+0x34eb2) #10 0x00007f6e4bd74147 clang::QualType::getCommonPtr() const /home/danis/Sources/llvm-project-main/clang/include/clang/AST/Type.h:0:5 #11 0x00007f6e4bd73e45 clang::QualType::getTypePtr() const /home/danis/Sources/llvm-project-main/clang/include/clang/AST/Type.h:7751:26 #12 0x00007f6e4bd6ff35 clang::QualType::operator->() const /home/danis/Sources/llvm-project-main/clang/include/clang/AST/Type.h:1001:5 #13 0x00007f6e4c246761 clang::LinkageComputer::getLVForClosure(clang::DeclContext const*, clang::Decl*, clang::LVComputationKind) /home/danis/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1335:13 #14 0x00007f6e4c2459a2 clang::LinkageComputer::computeLVForDecl(clang::NamedDecl const*, clang::LVComputationKind, bool) /home/danis/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1516:16 #15 0x00007f6e4c2430c0 clang::LinkageComputer::getLVForDecl(clang::NamedDecl const*, clang::LVComputationKind) /home/danis/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1580:20 #16 0x00007f6e4c244e24 clang::LinkageComputer::getLVForClassMember(clang::NamedDecl const*, clang::LVComputationKind, bool) /home/danis/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:958:5 #17 0x00007f6e4c245aa5 clang::LinkageComputer::computeLVForDecl(clang::NamedDecl const*, clang::LVComputationKind, bool) /home/danis/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1546:12 #18 0x00007f6e4c2430c0 clang::LinkageComputer::getLVForDecl(clang::NamedDecl const*, clang::LVComputationKind) /home/danis/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1580:20 #19 0x00007f6e4c2460cd clang::NamedDecl::getLinkageInternal() const /home/danis/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1180:8 #20 0x00007f6e4bf707a5 bool clang::ASTNodeImporter::hasSameVisibilityContextAndLinkage<clang::FunctionDecl>(clang::FunctionDecl*, clang::FunctionDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1077:14 #21 0x00007f6e4bf30b92 clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:3805:13 #22 0x00007f6e4bf3333b clang::ASTNodeImporter::VisitCXXMethodDecl(clang::CXXMethodDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:4140:10 #23 0x00007f6e4bf3337b clang::ASTNodeImporter::VisitCXXConstructorDecl(clang::CXXConstructorDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:4144:10 #24 0x00007f6e4bf8cca6 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:258:1 #25 0x00007f6e4bf57cbd clang::ASTImporter::ImportImpl(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9098:19 #26 0x00007f6e4bf3c005 clang::ASTImporter::Import(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9494:8 #27 0x00007f6e4bf66e23 std::conditional<std::is_base_of_v<clang::Type, clang::Decl>, llvm::Expected<clang::Decl const*>, llvm::Expected<clang::Decl*>>::type clang::ASTNodeImporter::import<clang::Decl>(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12 #28 0x00007f6e4bf28b5e clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext*, bool) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2176:10 #29 0x00007f6e4bf26972 clang::ASTNodeImporter::ImportDefinition(clang::RecordDecl*, clang::RecordDecl*, clang::ASTNodeImporter::ImportDefinitionKind) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2298:11 #30 0x00007f6e4bf2efd3 clang::ASTNodeImporter::VisitRecordDecl(clang::RecordDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:3323:15 #31 0x00007f6e4bff6ecb clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::VisitCXXRecordDecl(clang::CXXRecordDecl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:414:1 #32 0x00007f6e4bf8ce74 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:414:1 #33 0x00007f6e4bf57cbd clang::ASTImporter::ImportImpl(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9098:19 #34 0x00007f6e4bf3c005 clang::ASTImporter::Import(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9494:8 #35 0x00007f6e4bf693d3 std::conditional<std::is_base_of_v<clang::Type, clang::RecordDecl>, llvm::Expected<clang::RecordDecl const*>, llvm::Expected<clang::RecordDecl*>>::type clang::ASTNodeImporter::import<clang::RecordDecl>(clang::RecordDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12 #36 0x00007f6e4bf22fb0 clang::ASTNodeImporter::VisitRecordType(clang::RecordType const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1570:8 #37 0x00007f6e4bf8da58 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:75:1 #38 0x00007f6e4bf57fb9 clang::ASTImporter::Import(clang::Type const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9130:8 #39 0x00007f6e4bf58118 clang::ASTImporter::Import(clang::QualType) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9144:8 #40 0x00007f6e4bf659c9 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:218:23 #41 0x00007f6e4bf22a64 clang::ASTNodeImporter::VisitAutoType(clang::AutoType const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1523:8 #42 0x00007f6e4bf8d7c4 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:41:1 #43 0x00007f6e4bf57fb9 clang::ASTImporter::Import(clang::Type const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9130:8 #44 0x00007f6e4bf58118 clang::ASTImporter::Import(clang::QualType) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9144:8 #45 0x00007f6e4bfe2f6f llvm::Error clang::ASTImporter::importInto<clang::QualType>(clang::QualType&, clang::QualType const&) /home/danis/Sources/llvm-project-main/clang/include/clang/AST/ASTImporter.h:309:11 #46 0x00007f6e4bf7bd96 llvm::Error clang::ASTNodeImporter::importInto<clang::QualType>(clang::QualType&, clang::QualType const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:186:23 #47 0x00007f6e4bf4450b clang::ASTNodeImporter::VisitVarTemplateSpecializationDecl(clang::VarTemplateSpecializationDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:6632:13 #48 0x00007f6e4bf8cce8 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:282:1 #49 0x00007f6e4bf57cbd clang::ASTImporter::ImportImpl(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9098:19 #50 0x00007f6e4bf3c005 clang::ASTImporter::Import(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9494:8 #51 0x00007f6e4bf66e23 std::conditional<std::is_base_of_v<clang::Type, clang::Decl>, llvm::Expected<clang::Decl const*>, llvm::Expected<clang::Decl*>>::type clang::ASTNodeImporter::import<clang::Decl>(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12 #52 0x00007f6e4bf28b5e clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext*, bool) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2176:10 #53 0x00007f6e4bf2aefb clang::ASTNodeImporter::VisitNamespaceDecl(clang::NamespaceDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2699:13 #54 0x00007f6e4bf8cb72 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:170:1 #55 0x00007f6e4bf57cbd clang::ASTImporter::ImportImpl(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9098:19 #56 0x00007f6e4bf3c005 clang::ASTImporter::Import(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9494:8 #57 0x00007f6e4bf28c83 clang::ASTImporter::ImportContext(clang::DeclContext*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9621:8 #58 0x00007f6e4bf25f62 clang::ASTNodeImporter::ImportDeclContext(clang::Decl*, clang::DeclContext*&, clang::DeclContext*&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2220:8 #59 0x00007f6e4bf25bc7 clang::ASTNodeImporter::ImportDeclParts(clang::NamedDecl*, clang::DeclContext*&, clang::DeclContext*&, clang::DeclarationName&, clang::NamedDecl*&, clang::SourceLocation&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1959:19 #60 0x00007f6e4bf2d8d3 clang::ASTNodeImporter::VisitRecordDecl(clang::RecordDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:3089:13 #61 0x00007f6e4bff6ecb clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::VisitCXXRecordDecl(clang::CXXRecordDecl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:414:1 #62 0x00007f6e4bf8ce74 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:414:1 #63 0x00007f6e4bf57cbd clang::ASTImporter::ImportImpl(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9098:19 #64 0x00007f6e4bf3c005 clang::ASTImporter::Import(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9494:8 #65 0x00007f6e4bf693d3 std::conditional<std::is_base_of_v<clang::Type, clang::RecordDecl>, llvm::Expected<clang::RecordDecl const*>, llvm::Expected<clang::RecordDecl*>>::type clang::ASTNodeImporter::import<clang::RecordDecl>(clang::RecordDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12 #66 0x00007f6e4bf22fb0 clang::ASTNodeImporter::VisitRecordType(clang::RecordType const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1570:8 #67 0x00007f6e4bf8da58 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:75:1 #68 0x00007f6e4bf57fb9 clang::ASTImporter::Import(clang::Type const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9130:8 #69 0x00007f6e4bf58118 clang::ASTImporter::Import(clang::QualType) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9144:8 #70 0x00007f6e4bf659c9 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:218:23 #71 0x00007f6e4bf22a64 clang::ASTNodeImporter::VisitAutoType(clang::AutoType const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1523:8 #72 0x00007f6e4bf8d7c4 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:41:1 #73 0x00007f6e4bf57fb9 clang::ASTImporter::Import(clang::Type const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9130:8 #74 0x00007f6e4bf58118 clang::ASTImporter::Import(clang::QualType) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9144:8 #75 0x00007f6e4bf659c9 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:218:23 #76 0x00007f6e4bf22a64 clang::ASTNodeImporter::VisitAutoType(clang::AutoType const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1523:8 #77 0x00007f6e4bf8d7c4 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:41:1 #78 0x00007f6e4bf57fb9 clang::ASTImporter::Import(clang::Type const*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9130:8 #79 0x00007f6e4bf58118 clang::ASTImporter::Import(clang::QualType) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9144:8 #80 0x00007f6e4bf659c9 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:218:23 #81 0x00007f6e4bf68521 clang::QualType clang::ASTNodeImporter::importChecked<clang::QualType>(llvm::Error&, clang::QualType const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:703:12 #82 0x00007f6e4bf36374 clang::ASTNodeImporter::VisitVarDecl(clang::VarDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:4596:17 #83 0x00007f6e4bf8ccd2 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:278:1 #84 0x00007f6e4bf57cbd clang::ASTImporter::ImportImpl(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9098:19 #85 0x00007f6e4bf3c005 clang::ASTImporter::Import(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9494:8 #86 0x00007f6e4bf66e23 std::conditional<std::is_base_of_v<clang::Type, clang::Decl>, llvm::Expected<clang::Decl const*>, llvm::Expected<clang::Decl*>>::type clang::ASTNodeImporter::import<clang::Decl>(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12 #87 0x00007f6e4bf1a666 llvm::Expected<clang::DeclGroupRef> clang::ASTNodeImporter::import<clang::DeclGroupRef>(clang::DeclGroupRef const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:973:14 #88 0x00007f6e4bf7e761 clang::DeclGroupRef clang::ASTNodeImporter::importChecked<clang::DeclGroupRef>(llvm::Error&, clang::DeclGroupRef const&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:703:12 #89 0x00007f6e4bf46023 clang::ASTNodeImporter::VisitDeclStmt(clang::DeclStmt*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:6884:15 #90 0x00007f6e4bf91cb0 clang::StmtVisitorBase<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Stmt*>>::Visit(clang::Stmt*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/StmtNodes.inc:1532:1 #91 0x00007f6e4bf5d5f1 clang::ASTImporter::Import(clang::Stmt*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9702:8 #92 0x00007f6e4bf70393 std::conditional<std::is_base_of_v<clang::Type, clang::Stmt>, llvm::Expected<clang::Stmt const*>, llvm::Expected<clang::Stmt*>>::type clang::ASTNodeImporter::import<clang::Stmt>(clang::Stmt*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12 #93 0x00007f6e4bfe8081 llvm::Error clang::ASTNodeImporter::ImportArrayChecked<clang::Stmt**, clang::Stmt**>(clang::Stmt**, clang::Stmt**, clang::Stmt**) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:715:14 #94 0x00007f6e4bf7ead6 llvm::Error clang::ASTNodeImporter::ImportContainerChecked<llvm::iterator_range<clang::Stmt**>, llvm::SmallVector<clang::Stmt*, 8u>>(llvm::iterator_range<clang::Stmt**> const&, llvm::SmallVector<clang::Stmt*, 8u>&) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:729:14 #95 0x00007f6e4bf462c2 clang::ASTNodeImporter::VisitCompoundStmt(clang::CompoundStmt*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:6903:13 #96 0x00007f6e4bf91d08 clang::StmtVisitorBase<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Stmt*>>::Visit(clang::Stmt*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/StmtNodes.inc:1556:1 #97 0x00007f6e4bf5d5f1 clang::ASTImporter::Import(clang::Stmt*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9702:8 #98 0x00007f6e4bf70393 std::conditional<std::is_base_of_v<clang::Type, clang::Stmt>, llvm::Expected<clang::Stmt const*>, llvm::Expected<clang::Stmt*>>::type clang::ASTNodeImporter::import<clang::Stmt>(clang::Stmt*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12 #99 0x00007f6e4bf30205 clang::ASTNodeImporter::ImportFunctionDeclBody(clang::FunctionDecl*, clang::FunctionDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:3510:22 #100 0x00007f6e4bf32d09 clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:4109:9 #101 0x00007f6e4bf8cc4e clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/danis/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:238:1 #102 0x00007f6e4bf57cbd clang::ASTImporter::ImportImpl(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9098:19 #103 0x00007f6e4bf3c005 clang::ASTImporter::Import(clang::Decl*) /home/danis/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9494:8 #104 0x0000558170bb3d9a clang::ast_matchers::ASTImporterTestBase::TU::import(std::shared_ptr<clang::ASTImporterSharedState> const&, clang::ASTUnit*, clang::Decl*) /home/danis/Sources/llvm-project-main/clang/unittests/AST/ASTImporterFixtures.cpp:83:12 #105 0x0000558170bb4a19 clang::ast_matchers::ASTImporterTestBase::Import(clang::Decl*, clang::TestLanguage) /home/danis/Sources/llvm-project-main/clang/unittests/AST/ASTImporterFixtures.cpp:199:9 #106 0x0000558170c513d3 clang::FunctionDecl* clang::ast_matchers::ASTImporterTestBase::Import<clang::FunctionDecl>(clang::FunctionDecl*, clang::TestLanguage) /home/danis/Sources/llvm-project-main/clang/unittests/AST/ASTImporterFixtures.h:185:32 #107 0x0000558170c1c821 clang::ast_matchers::ASTImporterOptionSpecificTestBase_VarTemplatedLambdaInGlobalScope_Test::TestBody() /home/danis/Sources/llvm-project-main/clang/unittests/AST/ASTImporterTest.cpp:6803:17 #108 0x00007f6e4d9daa0b void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2612:3 #109 0x00007f6e4d9b9357 void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2667:5 #110 0x00007f6e4d99ed43 testing::Test::Run() /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2694:3 #111 0x00007f6e4d99f510 testing::TestInfo::Run() /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2839:12 #112 0x00007f6e4d99fbfc testing::TestSuite::Run() /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:3017:35 #113 0x00007f6e4d9aaa78 testing::internal::UnitTestImpl::RunAllTests() /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:5921:41 #114 0x00007f6e4d9df3cb bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2612:3 #115 0x00007f6e4d9bb4b7 bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2667:5 #116 0x00007f6e4d9aa64f testing::UnitTest::Run() /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:5484:10 #117 0x00007f6e4e400d71 RUN_ALL_TESTS() /home/danis/Sources/llvm-project-main/third-party/unittest/googletest/include/gtest/gtest.h:2317:30 #118 0x00007f6e4e400cb4 main /home/danis/Sources/llvm-project-main/third-party/unittest/UnitTestMain/TestMain.cpp:55:3 #119 0x00007f6e49c4624a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3 #120 0x00007f6e49c46305 call_init ./csu/../csu/libc-start.c:128:20 #121 0x00007f6e49c46305 __libc_start_main ./csu/../csu/libc-start.c:347:5 #122 0x0000558170b444c1 _start (./tools/clang/unittests/AST/ASTTests+0x4e84c1) Aborted ``` Testcase: ```c TEST_P(ASTImporterOptionSpecificTestBase, VarTemplatedLambdaInGlobalScope) { Decl *FromTU = getTuDecl( R"( namespace { template <typename> auto m = [] {}; } void bar() { auto n = m<int>; } )", Lang_CXX14, "input0.cc"); FunctionDecl *FromF = FirstDeclMatcher<FunctionDecl>().match( FromTU, functionDecl(hasName("bar"))); FunctionDecl *ToF = Import(FromF, Lang_CXX14); EXPECT_TRUE(ToF); } ```
danix800 commented 2 months ago

There's circular deps here when importing btw VarTemplateSpecializationDecl (m) and its type.

m is created with a null type QualType(), and the importing of its type will leads to linkage computation (for the templated lambda) which depends on the var's type (not yet imported).

A potential fix is to use a non-null type instead of a null one. But this seems still cannot ensure the computation is correct.

Any suggestions?