Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang][ASTImporter] clang/lib/AST/Decl.cpp:1605: clang::LinkageInfo clang::LinkageComputer::getLVForDecl(const clang::NamedDecl *, clang::LVComputationKind): Assertion `!Old || Old->getCachedLinkage() == D->getCachedLinkage()' failed. #65913

Closed
danix800 opened this issue Sep 10, 2023 · 1 comment · Fixed by #76226
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@danix800
Copy link
Member

clang/lib/AST/Decl.cpp:1605: clang::LinkageInfo clang::LinkageComputer::getLVForDecl(const clang::NamedDecl *, clang::LVComputationKind): Assertion '!Old || Old->getCachedLinkage() == D->getCachedLinkage()' failed.
when importing the following

template <typename T> struct B {
    template <typename U> friend void f(const B&, const B<U>&) {}
};
template <typename T> struct A : public B<T> {
   friend void f(const A&, const A&) {}
};

template <typename T> struct O {
  struct M {};
};

namespace { struct I {}; }

namespace NS {
  typedef O<int>::M MT1;
  A<MT1> A1;

  typedef O<I>::M MT2;
  A<MT2> A2;
}

into

template <typename T> struct B {
    template <typename U> friend void f(const B&, const B<U>&) {}
};
template <typename T> struct A : public B<T> {
   friend void f(const A&, const A&) {}
};

Stack:

ASTTests: /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1605: clang::LinkageInfo clang::LinkageComputer::getLVForDecl(const clang::NamedDecl *, clang::LVComputationKind): Assertion `!Old || Old->getCachedLinkage() == D->getCachedLinkage()' failed.
 #0 0x00007f669aa0669a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/xxxxx/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:723:11
 #1 0x00007f669aa0689b PrintStackTraceSignalHandler(void*) /home/xxxxx/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:798:1
 #2 0x00007f669aa04bb6 llvm::sys::RunSignalHandlers() /home/xxxxx/Sources/llvm-project-main/llvm/lib/Support/Signals.cpp:105:5
 #3 0x00007f669aa070b5 SignalHandler(int) /home/xxxxx/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x00007f669a45afd0 (/lib/x86_64-linux-gnu/libc.so.6+0x3bfd0)
 #5 0x00007f669a4a9d3c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x00007f669a45af32 raise ./signal/../sysdeps/posix/raise.c:27:6
 #7 0x00007f669a445472 abort ./stdlib/abort.c:81:7
 #8 0x00007f669a445395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #9 0x00007f669a453e32 (/lib/x86_64-linux-gnu/libc.so.6+0x34e32)
#10 0x00007f669c6b376a clang::LinkageComputer::getLVForDecl(clang::NamedDecl const*, clang::LVComputationKind) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1608:10
#11 0x00007f669c6b648d clang::NamedDecl::getLinkageInternal() const /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1190:8
#12 0x00007f669c40ea05 bool clang::ASTNodeImporter::hasSameVisibilityContextAndLinkage<clang::FunctionDecl>(clang::FunctionDecl*, clang::FunctionDecl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1016:7
#13 0x00007f669c3ce3d1 clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:3653:13
#14 0x00007f669c42ad18 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:433:1
#15 0x00007f669c3f63ad clang::ASTImporter::ImportImpl(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8856:19
#16 0x00007f669c3d9cd5 clang::ASTImporter::Import(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9255:8
#17 0x00007f669c411c87 llvm::Error clang::ASTNodeImporter::importInto<clang::NamedDecl>(clang::NamedDecl*&, clang::NamedDecl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:193:11
#18 0x00007f669c3d2612 clang::ASTNodeImporter::VisitFriendDecl(clang::FriendDecl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:4243:15
#19 0x00007f669c42a924 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:71:1
#20 0x00007f669c3f63ad clang::ASTImporter::ImportImpl(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8856:19
#21 0x00007f669c3d9cd5 clang::ASTImporter::Import(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9255:8
#22 0x00007f669c405143 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/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12
#23 0x00007f669c3c5b6d clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext*, bool) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1992:10
#24 0x00007f669c3c5254 clang::ASTNodeImporter::ImportDefinition(clang::RecordDecl*, clang::RecordDecl*, clang::ASTNodeImporter::ImportDefinitionKind) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2266:21
#25 0x00007f669c3e0c53 clang::ASTNodeImporter::VisitClassTemplateSpecializationDecl(clang::ClassTemplateSpecializationDecl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:6202:15
#26 0x00007f669c42abb8 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:299:1
#27 0x00007f669c3f63ad clang::ASTImporter::ImportImpl(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8856:19
#28 0x00007f669c3d9cd5 clang::ASTImporter::Import(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9255:8
#29 0x00007f669c407663 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/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12
#30 0x00007f669c3c0730 clang::ASTNodeImporter::VisitRecordType(clang::RecordType const*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1480:8
#31 0x00007f669c42b8f6 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:70:1
#32 0x00007f669c3f66a9 clang::ASTImporter::Import(clang::Type const*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8888:8
#33 0x00007f669c3f6808 clang::ASTImporter::Import(clang::QualType) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8902:8
#34 0x00007f669c403f09 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:218:23
#35 0x00007f669c3c108a clang::ASTNodeImporter::VisitTemplateSpecializationType(clang::TemplateSpecializationType const*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1560:22
#36 0x00007f669c42b90c clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:71:1
#37 0x00007f669c3f66a9 clang::ASTImporter::Import(clang::Type const*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8888:8
#38 0x00007f669c3f6808 clang::ASTImporter::Import(clang::QualType) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8902:8
#39 0x00007f669c403f09 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:218:23
#40 0x00007f669c3c1293 clang::ASTNodeImporter::VisitElaboratedType(clang::ElaboratedType const*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1577:8
#41 0x00007f669c42b728 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:45:1
#42 0x00007f669c3f66a9 clang::ASTImporter::Import(clang::Type const*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8888:8
#43 0x00007f669c3f6808 clang::ASTImporter::Import(clang::QualType) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8902:8
#44 0x00007f669c403f09 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:218:23
#45 0x00007f669c4067f1 clang::QualType clang::ASTNodeImporter::importChecked<clang::QualType>(llvm::Error&, clang::QualType const&) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:654:12
#46 0x00007f669c3d3ef3 clang::ASTNodeImporter::VisitVarDecl(clang::VarDecl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:4437:17
#47 0x00007f669c42adc8 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:485:1
#48 0x00007f669c3f63ad clang::ASTImporter::ImportImpl(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8856:19
#49 0x00007f669c3d9cd5 clang::ASTImporter::Import(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9255:8
#50 0x00007f669c405143 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/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12
#51 0x00007f669c3c6014 clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext*, bool) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2062:10
#52 0x00007f669c3c84c1 clang::ASTNodeImporter::VisitNamespaceDecl(clang::NamespaceDecl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2585:13
#53 0x00007f669c42aa00 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:143:1
#54 0x00007f669c3f63ad clang::ASTImporter::ImportImpl(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8856:19
#55 0x00007f669c3d9cd5 clang::ASTImporter::Import(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9255:8
#56 0x0000557c64ce6f1a clang::ast_matchers::ASTImporterTestBase::TU::import(std::shared_ptr<clang::ASTImporterSharedState> const&, clang::ASTUnit*, clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/unittests/AST/ASTImporterFixtures.cpp:83:12
#57 0x0000557c64ce7798 clang::ast_matchers::ASTImporterTestBase::getImportedDecl(llvm::StringRef, clang::TestLanguage, llvm::StringRef, clang::TestLanguage, llvm::StringRef) /home/xxxxx/Sources/llvm-project-main/clang/unittests/AST/ASTImporterFixtures.cpp:166:9
#58 0x0000557c64d1e095 clang::ast_matchers::ImportFriendFunctions_ImportFriendRedecls_Test::TestBody() /home/xxxxx/Sources/llvm-project-main/clang/unittests/AST/ASTImporterTest.cpp:3016:3
#59 0x00007f669db6d76b void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2433:3
#60 0x00007f669db52e07 void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2488:5
#61 0x00007f669db3b963 testing::Test::Run() /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2515:3
#62 0x00007f669db3c1ba testing::TestInfo::Run() /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2687:12
#63 0x00007f669db3c71b testing::TestSuite::Run() /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2815:44
#64 0x00007f669db44ef9 testing::internal::UnitTestImpl::RunAllTests() /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:5337:24
#65 0x00007f669db70a3b bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2433:3
#66 0x00007f669db55247 bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2488:5
#67 0x00007f669db44adf testing::UnitTest::Run() /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:4925:10
#68 0x00007f669e66ed71 RUN_ALL_TESTS() /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/include/gtest/gtest.h:2472:3
#69 0x00007f669e66ecb4 main /home/xxxxx/Sources/llvm-project-main/third-party/unittest/UnitTestMain/TestMain.cpp:55:3
#70 0x00007f669a4461ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#71 0x00007f669a446285 call_init ./csu/../csu/libc-start.c:128:20
#72 0x00007f669a446285 __libc_start_main ./csu/../csu/libc-start.c:347:5
#73 0x0000557c64c89f01 _start (./build/tools/clang/unittests/AST/ASTTests+0x4a0f01)
@github-actions github-actions bot added clang Clang issues not falling into any other category new issue labels Sep 10, 2023
@danix800 danix800 changed the title [ASTImporter] clang/lib/AST/Decl.cpp:1605: clang::LinkageInfo clang::LinkageComputer::getLVForDecl(const clang::NamedDecl *, clang::LVComputationKind): Assertion `!Old || Old->getCachedLinkage() == D->getCachedLinkage()' failed. [clang][ASTImporter] clang/lib/AST/Decl.cpp:1605: clang::LinkageInfo clang::LinkageComputer::getLVForDecl(const clang::NamedDecl *, clang::LVComputationKind): Assertion `!Old || Old->getCachedLinkage() == D->getCachedLinkage()' failed. Sep 10, 2023
@Endilll Endilll added clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] and removed clang Clang issues not falling into any other category new issue labels Sep 15, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Sep 15, 2023

@llvm/issue-subscribers-clang-frontend

`clang/lib/AST/Decl.cpp:1605: clang::LinkageInfo clang::LinkageComputer::getLVForDecl(const clang::NamedDecl *, clang::LVComputationKind): Assertion '!Old || Old->getCachedLinkage() == D->getCachedLinkage()' failed.` when importing the following ``` template struct B { template friend void f(const B&, const B&) {} }; template struct A : public B { friend void f(const A&, const A&) {} };

template struct O {
struct M {};
};

namespace { struct I {}; }

namespace NS {
typedef O::M MT1;
A A1;

typedef O::M MT2;
A A2;
}

into

template struct B {
template friend void f(const B&, const B&) {}
};
template struct A : public B {
friend void f(const A&, const A&) {}
};


Stack:

ASTTests: /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1605: clang::LinkageInfo clang::LinkageComputer::getLVForDecl(const clang::NamedDecl , clang::LVComputationKind): Assertion `!Old || Old->getCachedLinkage() == D->getCachedLinkage()' failed.
#0 0x00007f669aa0669a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/xxxxx/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:723:11
#1 0x00007f669aa0689b PrintStackTraceSignalHandler(void
) /home/xxxxx/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:798:1
#2 0x00007f669aa04bb6 llvm::sys::RunSignalHandlers() /home/xxxxx/Sources/llvm-project-main/llvm/lib/Support/Signals.cpp:105:5
#3 0x00007f669aa070b5 SignalHandler(int) /home/xxxxx/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:413:1
#4 0x00007f669a45afd0 (/lib/x86_64-linux-gnu/libc.so.6+0x3bfd0)
#5 0x00007f669a4a9d3c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#6 0x00007f669a45af32 raise ./signal/../sysdeps/posix/raise.c:27:6
#7 0x00007f669a445472 abort ./stdlib/abort.c:81:7
#8 0x00007f669a445395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
#9 0x00007f669a453e32 (/lib/x86_64-linux-gnu/libc.so.6+0x34e32)
#10 0x00007f669c6b376a clang::LinkageComputer::getLVForDecl(clang::NamedDecl const*, clang::LVComputationKind) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1608:10
#11 0x00007f669c6b648d clang::NamedDecl::getLinkageInternal() const /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/Decl.cpp:1190:8
#12 0x00007f669c40ea05 bool clang::ASTNodeImporter::hasSameVisibilityContextAndLinkageclang::FunctionDecl(clang::FunctionDecl*, clang::FunctionDecl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1016:7
#13 0x00007f669c3ce3d1 clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:3653:13
#14 0x00007f669c42ad18 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expectedclang::Decl*>::Visit(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:433:1
#15 0x00007f669c3f63ad clang::ASTImporter::ImportImpl(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8856:19
#16 0x00007f669c3d9cd5 clang::ASTImporter::Import(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9255:8
#17 0x00007f669c411c87 llvm::Error clang::ASTNodeImporter::importIntoclang::NamedDecl(clang::NamedDecl*&, clang::NamedDecl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:193:11
#18 0x00007f669c3d2612 clang::ASTNodeImporter::VisitFriendDecl(clang::FriendDecl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:4243:15
#19 0x00007f669c42a924 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expectedclang::Decl*>::Visit(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:71:1
#20 0x00007f669c3f63ad clang::ASTImporter::ImportImpl(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8856:19
#21 0x00007f669c3d9cd5 clang::ASTImporter::Import(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9255:8
#22 0x00007f669c405143 std::conditional<std::is_base_of_v<clang::Type, clang::Decl>, llvm::Expected<clang::Decl const*>, llvm::Expectedclang::Decl*>::type clang::ASTNodeImporter::importclang::Decl(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12
#23 0x00007f669c3c5b6d clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext*, bool) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1992:10
#24 0x00007f669c3c5254 clang::ASTNodeImporter::ImportDefinition(clang::RecordDecl*, clang::RecordDecl*, clang::ASTNodeImporter::ImportDefinitionKind) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2266:21
#25 0x00007f669c3e0c53 clang::ASTNodeImporter::VisitClassTemplateSpecializationDecl(clang::ClassTemplateSpecializationDecl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:6202:15
#26 0x00007f669c42abb8 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expectedclang::Decl*>::Visit(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:299:1
#27 0x00007f669c3f63ad clang::ASTImporter::ImportImpl(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8856:19
#28 0x00007f669c3d9cd5 clang::ASTImporter::Import(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9255:8
#29 0x00007f669c407663 std::conditional<std::is_base_of_v<clang::Type, clang::RecordDecl>, llvm::Expected<clang::RecordDecl const*>, llvm::Expectedclang::RecordDecl*>::type clang::ASTNodeImporter::importclang::RecordDecl(clang::RecordDecl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12
#30 0x00007f669c3c0730 clang::ASTNodeImporter::VisitRecordType(clang::RecordType const*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1480:8
#31 0x00007f669c42b8f6 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expectedclang::QualType>::Visit(clang::Type const*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:70:1
#32 0x00007f669c3f66a9 clang::ASTImporter::Import(clang::Type const*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8888:8
#33 0x00007f669c3f6808 clang::ASTImporter::Import(clang::QualType) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8902:8
#34 0x00007f669c403f09 llvm::Expectedclang::QualType clang::ASTNodeImporter::importclang::QualType(clang::QualType const&) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:218:23
#35 0x00007f669c3c108a clang::ASTNodeImporter::VisitTemplateSpecializationType(clang::TemplateSpecializationType const*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1560:22
#36 0x00007f669c42b90c clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expectedclang::QualType>::Visit(clang::Type const*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:71:1
#37 0x00007f669c3f66a9 clang::ASTImporter::Import(clang::Type const*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8888:8
#38 0x00007f669c3f6808 clang::ASTImporter::Import(clang::QualType) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8902:8
#39 0x00007f669c403f09 llvm::Expectedclang::QualType clang::ASTNodeImporter::importclang::QualType(clang::QualType const&) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:218:23
#40 0x00007f669c3c1293 clang::ASTNodeImporter::VisitElaboratedType(clang::ElaboratedType const*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:1577:8
#41 0x00007f669c42b728 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expectedclang::QualType>::Visit(clang::Type const*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/TypeNodes.inc:45:1
#42 0x00007f669c3f66a9 clang::ASTImporter::Import(clang::Type const*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8888:8
#43 0x00007f669c3f6808 clang::ASTImporter::Import(clang::QualType) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8902:8
#44 0x00007f669c403f09 llvm::Expectedclang::QualType clang::ASTNodeImporter::importclang::QualType(clang::QualType const&) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:218:23
#45 0x00007f669c4067f1 clang::QualType clang::ASTNodeImporter::importCheckedclang::QualType(llvm::Error&, clang::QualType const&) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:654:12
#46 0x00007f669c3d3ef3 clang::ASTNodeImporter::VisitVarDecl(clang::VarDecl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:4437:17
#47 0x00007f669c42adc8 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expectedclang::Decl*>::Visit(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:485:1
#48 0x00007f669c3f63ad clang::ASTImporter::ImportImpl(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8856:19
#49 0x00007f669c3d9cd5 clang::ASTImporter::Import(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9255:8
#50 0x00007f669c405143 std::conditional<std::is_base_of_v<clang::Type, clang::Decl>, llvm::Expected<clang::Decl const*>, llvm::Expectedclang::Decl*>::type clang::ASTNodeImporter::importclang::Decl(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:205:12
#51 0x00007f669c3c6014 clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext*, bool) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2062:10
#52 0x00007f669c3c84c1 clang::ASTNodeImporter::VisitNamespaceDecl(clang::NamespaceDecl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:2585:13
#53 0x00007f669c42aa00 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expectedclang::Decl*>::Visit(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/build/tools/clang/include/clang/AST/DeclNodes.inc:143:1
#54 0x00007f669c3f63ad clang::ASTImporter::ImportImpl(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:8856:19
#55 0x00007f669c3d9cd5 clang::ASTImporter::Import(clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/lib/AST/ASTImporter.cpp:9255:8
#56 0x0000557c64ce6f1a clang::ast_matchers::ASTImporterTestBase::TU::import(std::shared_ptrclang::ASTImporterSharedState const&, clang::ASTUnit*, clang::Decl*) /home/xxxxx/Sources/llvm-project-main/clang/unittests/AST/ASTImporterFixtures.cpp:83:12
#57 0x0000557c64ce7798 clang::ast_matchers::ASTImporterTestBase::getImportedDecl(llvm::StringRef, clang::TestLanguage, llvm::StringRef, clang::TestLanguage, llvm::StringRef) /home/xxxxx/Sources/llvm-project-main/clang/unittests/AST/ASTImporterFixtures.cpp:166:9
#58 0x0000557c64d1e095 clang::ast_matchers::ImportFriendFunctions_ImportFriendRedecls_Test::TestBody() /home/xxxxx/Sources/llvm-project-main/clang/unittests/AST/ASTImporterTest.cpp:3016:3
#59 0x00007f669db6d76b void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::)(), char const) /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2433:3
#60 0x00007f669db52e07 void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::)(), char const) /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2488:5
#61 0x00007f669db3b963 testing::Test::Run() /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2515:3
#62 0x00007f669db3c1ba testing::TestInfo::Run() /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2687:12
#63 0x00007f669db3c71b testing::TestSuite::Run() /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2815:44
#64 0x00007f669db44ef9 testing::internal::UnitTestImpl::RunAllTests() /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:5337:24
#65 0x00007f669db70a3b bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::)(), char const) /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2433:3
#66 0x00007f669db55247 bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::)(), char const) /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:2488:5
#67 0x00007f669db44adf testing::UnitTest::Run() /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/src/gtest.cc:4925:10
#68 0x00007f669e66ed71 RUN_ALL_TESTS() /home/xxxxx/Sources/llvm-project-main/third-party/unittest/googletest/include/gtest/gtest.h:2472:3
#69 0x00007f669e66ecb4 main /home/xxxxx/Sources/llvm-project-main/third-party/unittest/UnitTestMain/TestMain.cpp:55:3
#70 0x00007f669a4461ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#71 0x00007f669a446285 call_init ./csu/../csu/libc-start.c:128:20
#72 0x00007f669a446285 __libc_start_main ./csu/../csu/libc-start.c:347:5
#73 0x0000557c64c89f01 _start (./build/tools/clang/unittests/AST/ASTTests+0x4a0f01)


</details>

jcsxky added a commit that referenced this issue Jan 5, 2024
…ence on recordType (#76226)

Types comparison in `StructuralEquivalence` ignores its `DeclContext`
when they are generated by template specialization implicitly and this
will produce incorrect result. Add comparison of `DeclContext` of
ClassTemplateSpecializationDecl to improve result.
fix [issue](#65913)

Co-authored-by: huqizhi <836744285@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
3 participants