llvm / llvm-project

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

[clang][StaticAnalyzer] crash on imported `CXXRecordDecl`: Assertion `isValidBaseClass(RD, cast<TypedValueRegion>(Super), IsVirtual)` failed #112311

Open danix800 opened 1 month ago

danix800 commented 1 month ago

Testcases:

export TEST_DIR=/tmp/test-crash
mkdir -pv $TEST_DIR

# test files:
cat > $TEST_DIR/Common.h << EOF
namespace { struct A; }

template<typename T>
struct Base {
  void f() {}
};

struct Derived : public Base<A> {};

void foo();
EOF

cat > $TEST_DIR/Common.cpp << EOF
#include "Common.h"

void foo() {
  Derived().f();
}
EOF

cat > $TEST_DIR/Test.cpp << EOF
#include "Common.h"

void bar() {
  foo();
}
EOF

CTU_DIR=$TEST_DIR/ctu-dir/x86_64
mkdir -pv $CTU_DIR/ast$TEST_DIR

# test command:

clang $TEST_DIR/Common.cpp -emit-ast -o $CTU_DIR/ast$TEST_DIR/Common.cpp.ast
clang-extdef-mapping $TEST_DIR/Common.cpp -- | \
  sed "s: $TEST_DIR/Common\.cpp$: ast$TEST_DIR/Common.cpp.ast:" \
  > $CTU_DIR/externalDefMap.txt

clang-tidy $TEST_DIR/Test.cpp --checks=-*,clang-analyzer-core.DivideZero -- \
  -Xclang -analyzer-config \
  -Xclang experimental-enable-naive-ctu-analysis=true,ctu-dir=$CTU_DIR

Crash stacktrace:

clang-tidy: /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1278: const clang::ento::CXXBaseObjectRegion *clang::ento::MemRegionManager::getCXXBaseObjectRegion(const clang::CXXRecordDecl *, const clang::ento::SubRegion *, bool): Assertion `isValidBaseClass(RD, cast<TypedValueRegion>(Super), IsVirtual)' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.  Program arguments: clang-tidy /tmp/test-crash/Test.cpp --checks=-*,clang-analyzer-core.DivideZero -- -Xclang -analyzer-config -Xclang experimental-enable-naive-ctu-analysis=true,ctu-dir=/tmp/test-crash/ctu-dir/x86_64
1.  <eof> parser at end of file
2.  While analyzing stack: 
    #0 Calling foo() at line 4
    #1 Calling bar()
3.  /tmp/test-crash/Common.cpp:4:3: Error evaluating statement
4.  /tmp/test-crash/Common.cpp:4:3: Error evaluating statement
 #0 0x00007f6c1e64ca7a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/danis/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:723:11
 #1 0x00007f6c1e64cc7b PrintStackTraceSignalHandler(void*) /home/danis/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:798:1
 #2 0x00007f6c1e64af96 llvm::sys::RunSignalHandlers() /home/danis/Sources/llvm-project-main/llvm/lib/Support/Signals.cpp:105:5
 #3 0x00007f6c1e64d495 SignalHandler(int) /home/danis/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x00007f6c1e05b050 (/lib/x86_64-linux-gnu/libc.so.6+0x3c050)
 #5 0x00007f6c1e0a9e3c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x00007f6c1e05afb2 raise ./signal/../sysdeps/posix/raise.c:27:6
 #7 0x00007f6c1e045472 abort ./stdlib/abort.c:81:7
 #8 0x00007f6c1e045395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #9 0x00007f6c1e053eb2 (/lib/x86_64-linux-gnu/libc.so.6+0x34eb2)
#10 0x00007f6c188eaa9f clang::ento::MemRegionManager::getCXXBaseObjectRegion(clang::CXXRecordDecl const*, clang::ento::SubRegion const*, bool) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1281:9
#11 0x00007f6c189a9ba7 clang::ento::StoreManager::evalDerivedToBase(clang::ento::SVal, clang::QualType, bool) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/Store.cpp:296:20
#12 0x00007f6c189a9883 clang::ento::StoreManager::evalDerivedToBase(clang::ento::SVal, clang::CastExpr const*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/Store.cpp:261:14
#13 0x00007f6c188902d5 clang::ento::ExprEngine::VisitCast(clang::CastExpr const*, clang::Expr const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:424:33
#14 0x00007f6c18850243 clang::ento::ExprEngine::Visit(clang::Stmt const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:2287:7
#15 0x00007f6c1884c559 clang::ento::ExprEngine::ProcessStmt(clang::Stmt const*, clang::ento::ExplodedNode*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:1135:9
#16 0x00007f6c1884c26d clang::ento::ExprEngine::processCFGElement(clang::CFGElement, clang::ento::ExplodedNode*, unsigned int, clang::ento::NodeBuilderContext*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:976:7
#17 0x00007f6c188112ff clang::ento::CoreEngine::HandlePostStmt(clang::CFGBlock const*, unsigned int, clang::ento::ExplodedNode*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:486:1
#18 0x00007f6c18810ac0 clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*, clang::ProgramPoint, clang::ento::WorkListUnit const&) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:223:1
#19 0x00007f6c18810737 clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>)::$_0::operator()(unsigned int) const /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:140:5
#20 0x00007f6c18810434 clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:163:29
#21 0x00007f6c18c4b604 clang::ento::ExprEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int) /home/danis/Sources/llvm-project-main/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h:192:19
#22 0x00007f6c18bd2783 (anonymous namespace)::AnalysisConsumer::RunPathSensitiveChecks(clang::Decl*, clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*, llvm::DenseMapInfo<clang::Decl const*, void>>*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:729:7
#23 0x00007f6c18bd22ce (anonymous namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int, clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*, llvm::DenseMapInfo<clang::Decl const*, void>>*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:700:15
#24 0x00007f6c18b51168 (anonymous namespace)::AnalysisConsumer::HandleDeclsCallGraph(unsigned int) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:490:31
#25 0x00007f6c18b4fe16 (anonymous namespace)::AnalysisConsumer::runAnalysisOnTranslationUnit(clang::ASTContext&) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:0:5
#26 0x00007f6c18b4f89e (anonymous namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:613:3
#27 0x00007f6c180212b3 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) /home/danis/Sources/llvm-project-main/clang/lib/Frontend/MultiplexConsumer.cpp:338:23
#28 0x00007f6c1090cee8 clang::ParseAST(clang::Sema&, bool, bool) /home/danis/Sources/llvm-project-main/clang/lib/Parse/ParseAST.cpp:191:12
#29 0x00007f6c17fd61f7 clang::ASTFrontendAction::ExecuteAction() /home/danis/Sources/llvm-project-main/clang/lib/Frontend/FrontendAction.cpp:1194:1
#30 0x00007f6c17fd5bec clang::FrontendAction::Execute() /home/danis/Sources/llvm-project-main/clang/lib/Frontend/FrontendAction.cpp:1082:7
#31 0x00007f6c17ec2636 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/danis/Sources/llvm-project-main/clang/lib/Frontend/CompilerInstance.cpp:1060:23
#32 0x00007f6c21410ae3 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) /home/danis/Sources/llvm-project-main/clang/lib/Tooling/Tooling.cpp:465:14
#33 0x00007f6c2152b789 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef)::ActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) /home/danis/Sources/llvm-project-main/clang-tools-extra/clang-tidy/ClangTidy.cpp:581:37
#34 0x00007f6c2141097c clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) /home/danis/Sources/llvm-project-main/clang/lib/Tooling/Tooling.cpp:440:18
#35 0x00007f6c2140fa6d clang::tooling::ToolInvocation::run() /home/danis/Sources/llvm-project-main/clang/lib/Tooling/Tooling.cpp:425:3
#36 0x00007f6c21411d6d clang::tooling::ClangTool::run(clang::tooling::ToolAction*) /home/danis/Sources/llvm-project-main/clang/lib/Tooling/Tooling.cpp:623:11
#37 0x00007f6c2152725c clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef) /home/danis/Sources/llvm-project-main/clang-tools-extra/clang-tidy/ClangTidy.cpp:602:8
#38 0x00007f6c284a6a7d clang::tidy::clangTidyMain(int, char const**) /home/danis/Sources/llvm-project-main/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:686:7
#39 0x00005558f17273c2 main /home/danis/Sources/llvm-project-main/clang-tools-extra/clang-tidy/tool/ClangTidyToolMain.cpp:20:3
#40 0x00007f6c1e04624a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#41 0x00007f6c1e046305 call_init ./csu/../csu/libc-start.c:128:20
#42 0x00007f6c1e046305 __libc_start_main ./csu/../csu/libc-start.c:347:5
#43 0x00005558f17272d1 _start (/home/danis/Sources/llvm-project-main/build/bin/clang-tidy+0x22d1)
./test.sh: line 44: 320417 Aborted                 clang-tidy $TEST_DIR/Test.cpp --checks=-*,clang-analyzer-core.DivideZero -- -Xclang -analyzer-config -Xclang experimental-enable-naive-ctu-analysis=true,ctu-dir=$CTU_DIR
danix800 commented 1 month ago
namespace { struct A; }
namespace { struct A; }

Struct A in the same TU are linked together, but when imported from another TU they are not.

llvmbot commented 1 month ago

@llvm/issue-subscribers-clang-static-analyzer

Author: Ding Fei (danix800)

Testcases: ``` export TEST_DIR=/tmp/test-crash mkdir -pv $TEST_DIR # test files: cat > $TEST_DIR/Common.h << EOF namespace { struct A; } template<typename T> struct Base { void f() {} }; struct Derived : public Base<A> {}; void foo(); EOF cat > $TEST_DIR/Common.cpp << EOF #include "Common.h" void foo() { Derived().f(); } EOF cat > $TEST_DIR/Test.cpp << EOF #include "Common.h" void bar() { foo(); } EOF CTU_DIR=$TEST_DIR/ctu-dir/x86_64 mkdir -pv $CTU_DIR/ast$TEST_DIR # test command: clang $TEST_DIR/Common.cpp -emit-ast -o $CTU_DIR/ast$TEST_DIR/Common.cpp.ast clang-extdef-mapping $TEST_DIR/Common.cpp -- | \ sed "s: $TEST_DIR/Common\.cpp$: ast$TEST_DIR/Common.cpp.ast:" \ > $CTU_DIR/externalDefMap.txt clang-tidy $TEST_DIR/Test.cpp --checks=-*,clang-analyzer-core.DivideZero -- \ -Xclang -analyzer-config \ -Xclang experimental-enable-naive-ctu-analysis=true,ctu-dir=$CTU_DIR ``` Crash stacktrace: ``` clang-tidy: /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1278: const clang::ento::CXXBaseObjectRegion *clang::ento::MemRegionManager::getCXXBaseObjectRegion(const clang::CXXRecordDecl *, const clang::ento::SubRegion *, bool): Assertion `isValidBaseClass(RD, cast<TypedValueRegion>(Super), IsVirtual)' failed. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. Program arguments: clang-tidy /tmp/test-crash/Test.cpp --checks=-*,clang-analyzer-core.DivideZero -- -Xclang -analyzer-config -Xclang experimental-enable-naive-ctu-analysis=true,ctu-dir=/tmp/test-crash/ctu-dir/x86_64 1. <eof> parser at end of file 2. While analyzing stack: #0 Calling foo() at line 4 #1 Calling bar() 3. /tmp/test-crash/Common.cpp:4:3: Error evaluating statement 4. /tmp/test-crash/Common.cpp:4:3: Error evaluating statement #0 0x00007f6c1e64ca7a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/danis/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:723:11 #1 0x00007f6c1e64cc7b PrintStackTraceSignalHandler(void*) /home/danis/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:798:1 #2 0x00007f6c1e64af96 llvm::sys::RunSignalHandlers() /home/danis/Sources/llvm-project-main/llvm/lib/Support/Signals.cpp:105:5 #3 0x00007f6c1e64d495 SignalHandler(int) /home/danis/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:413:1 #4 0x00007f6c1e05b050 (/lib/x86_64-linux-gnu/libc.so.6+0x3c050) #5 0x00007f6c1e0a9e3c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76 #6 0x00007f6c1e05afb2 raise ./signal/../sysdeps/posix/raise.c:27:6 #7 0x00007f6c1e045472 abort ./stdlib/abort.c:81:7 #8 0x00007f6c1e045395 _nl_load_domain ./intl/loadmsgcat.c:1177:9 #9 0x00007f6c1e053eb2 (/lib/x86_64-linux-gnu/libc.so.6+0x34eb2) #10 0x00007f6c188eaa9f clang::ento::MemRegionManager::getCXXBaseObjectRegion(clang::CXXRecordDecl const*, clang::ento::SubRegion const*, bool) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1281:9 #11 0x00007f6c189a9ba7 clang::ento::StoreManager::evalDerivedToBase(clang::ento::SVal, clang::QualType, bool) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/Store.cpp:296:20 #12 0x00007f6c189a9883 clang::ento::StoreManager::evalDerivedToBase(clang::ento::SVal, clang::CastExpr const*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/Store.cpp:261:14 #13 0x00007f6c188902d5 clang::ento::ExprEngine::VisitCast(clang::CastExpr const*, clang::Expr const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:424:33 #14 0x00007f6c18850243 clang::ento::ExprEngine::Visit(clang::Stmt const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:2287:7 #15 0x00007f6c1884c559 clang::ento::ExprEngine::ProcessStmt(clang::Stmt const*, clang::ento::ExplodedNode*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:1135:9 #16 0x00007f6c1884c26d clang::ento::ExprEngine::processCFGElement(clang::CFGElement, clang::ento::ExplodedNode*, unsigned int, clang::ento::NodeBuilderContext*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:976:7 #17 0x00007f6c188112ff clang::ento::CoreEngine::HandlePostStmt(clang::CFGBlock const*, unsigned int, clang::ento::ExplodedNode*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:486:1 #18 0x00007f6c18810ac0 clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*, clang::ProgramPoint, clang::ento::WorkListUnit const&) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:223:1 #19 0x00007f6c18810737 clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>)::$_0::operator()(unsigned int) const /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:140:5 #20 0x00007f6c18810434 clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:163:29 #21 0x00007f6c18c4b604 clang::ento::ExprEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int) /home/danis/Sources/llvm-project-main/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h:192:19 #22 0x00007f6c18bd2783 (anonymous namespace)::AnalysisConsumer::RunPathSensitiveChecks(clang::Decl*, clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*, llvm::DenseMapInfo<clang::Decl const*, void>>*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:729:7 #23 0x00007f6c18bd22ce (anonymous namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int, clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*, llvm::DenseMapInfo<clang::Decl const*, void>>*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:700:15 #24 0x00007f6c18b51168 (anonymous namespace)::AnalysisConsumer::HandleDeclsCallGraph(unsigned int) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:490:31 #25 0x00007f6c18b4fe16 (anonymous namespace)::AnalysisConsumer::runAnalysisOnTranslationUnit(clang::ASTContext&) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:0:5 #26 0x00007f6c18b4f89e (anonymous namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:613:3 #27 0x00007f6c180212b3 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) /home/danis/Sources/llvm-project-main/clang/lib/Frontend/MultiplexConsumer.cpp:338:23 #28 0x00007f6c1090cee8 clang::ParseAST(clang::Sema&, bool, bool) /home/danis/Sources/llvm-project-main/clang/lib/Parse/ParseAST.cpp:191:12 #29 0x00007f6c17fd61f7 clang::ASTFrontendAction::ExecuteAction() /home/danis/Sources/llvm-project-main/clang/lib/Frontend/FrontendAction.cpp:1194:1 #30 0x00007f6c17fd5bec clang::FrontendAction::Execute() /home/danis/Sources/llvm-project-main/clang/lib/Frontend/FrontendAction.cpp:1082:7 #31 0x00007f6c17ec2636 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/danis/Sources/llvm-project-main/clang/lib/Frontend/CompilerInstance.cpp:1060:23 #32 0x00007f6c21410ae3 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) /home/danis/Sources/llvm-project-main/clang/lib/Tooling/Tooling.cpp:465:14 #33 0x00007f6c2152b789 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef)::ActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) /home/danis/Sources/llvm-project-main/clang-tools-extra/clang-tidy/ClangTidy.cpp:581:37 #34 0x00007f6c2141097c clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) /home/danis/Sources/llvm-project-main/clang/lib/Tooling/Tooling.cpp:440:18 #35 0x00007f6c2140fa6d clang::tooling::ToolInvocation::run() /home/danis/Sources/llvm-project-main/clang/lib/Tooling/Tooling.cpp:425:3 #36 0x00007f6c21411d6d clang::tooling::ClangTool::run(clang::tooling::ToolAction*) /home/danis/Sources/llvm-project-main/clang/lib/Tooling/Tooling.cpp:623:11 #37 0x00007f6c2152725c clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef) /home/danis/Sources/llvm-project-main/clang-tools-extra/clang-tidy/ClangTidy.cpp:602:8 #38 0x00007f6c284a6a7d clang::tidy::clangTidyMain(int, char const**) /home/danis/Sources/llvm-project-main/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:686:7 #39 0x00005558f17273c2 main /home/danis/Sources/llvm-project-main/clang-tools-extra/clang-tidy/tool/ClangTidyToolMain.cpp:20:3 #40 0x00007f6c1e04624a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3 #41 0x00007f6c1e046305 call_init ./csu/../csu/libc-start.c:128:20 #42 0x00007f6c1e046305 __libc_start_main ./csu/../csu/libc-start.c:347:5 #43 0x00005558f17272d1 _start (/home/danis/Sources/llvm-project-main/build/bin/clang-tidy+0x22d1) ./test.sh: line 44: 320417 Aborted clang-tidy $TEST_DIR/Test.cpp --checks=-*,clang-analyzer-core.DivideZero -- -Xclang -analyzer-config -Xclang experimental-enable-naive-ctu-analysis=true,ctu-dir=$CTU_DIR ```
danix800 commented 1 month ago
namespace { struct A; }
namespace { struct A; }

Struct A in the same TU are linked together, but when imported from another TU they are not.

Structs in anonymous namespace from different TUs should not be linked.

I think these two structs should be marked as conflicting to each other too. Thus types depending on them are not equivalent too. See potential fix #112534