<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi,</div><div dir="ltr"><br></div><div dir="ltr">The scene of my usage is I want to analyze multiple source code files with CSA and CTU enabled. Since it will report a header file not found error when using `clang -cc1` to analyze source code files (*.cpp), I turn to AST files for simplicity.<div><br></div><div>Here is the bug. If I only analyze a single AST file, it works fine. However, when I append multiple AST files for analysis, it crashes all the time. It has been reproduced both on my fedora-29 desktop and ubuntu-18.04 server with the code from git commit e03301a3b32.</div><div><br></div><div>The code I use to trigger this bug is provided in the attachments. See core dump file (./coredump) for more details. According to the stack trace, I think the bug is not in CSA and CTU.</div><div><br></div><div>**Besides, could you please tell me how to make cc1 to parse AST with the compile commands provided in the compile_commands.json file? Or make clang-check enable CTU IPA? I did not find any code to enable CTU IPA in clang-check, and if it is useful to others, I would like to share my customized clang-check.**</div><div><br></div><div>Regards,</div><div>Ella</div><div><br></div><div>P.S. I do not know whether it is allowed to ask a question together with a bug report here. Sorry for annoying you.</div><div><br></div><div>---</div><div><br></div><div><font face="monospace, monospace">$ clang --version</font></div><div><div><font face="monospace, monospace">clang version 9.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a> e03301a3b32d048d8975e0fe21d80489505415c8)</font></div><div><font face="monospace, monospace">Target: x86_64-unknown-linux-gnu</font></div><div><font face="monospace, monospace">Thread model: posix</font></div><div><font face="monospace, monospace">InstalledDir: /home/ella/workspace/llvm-project/build/bin</font></div></div><div><br></div><div>ERROR MESSAGE:</div><div><div><font face="monospace, monospace">clang: /home/ella/workspace/llvm-project/clang/include/clang/Basic/Diagnostic.h:528: void clang::DiagnosticsEngine::setSourceManager(clang::SourceManager*): Assertion `DiagStatesByLoc.empty() && "Leftover diag state from a different SourceManager."' failed.</font></div><div><font face="monospace, monospace">Stack dump:</font></div><div><font face="monospace, monospace">0.<span style="white-space:pre">  </span>Program arguments: ../bin/clang -cc1 -analyze -analyzer-checker=core,debug.ExprInspection -o reports/ home/ella/workspace/llvm-project/build/analyzer-test/src/getzero.cpp.ast home/ella/workspace/llvm-project/build/analyzer-test/src/test.cpp.ast </font></div><div><font face="monospace, monospace"> #0 0x000000000457075a llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/ella/workspace/llvm-project/llvm/lib/Support/Unix/Signals.inc:494:22</font></div><div><font face="monospace, monospace"> #1 0x00000000045707ed PrintStackTraceSignalHandler(void*) /home/ella/workspace/llvm-project/llvm/lib/Support/Unix/Signals.inc:558:1</font></div><div><font face="monospace, monospace"> #2 0x000000000456eabf llvm::sys::RunSignalHandlers() /home/ella/workspace/llvm-project/llvm/lib/Support/Signals.cpp:68:20</font></div><div><font face="monospace, monospace"> #3 0x0000000004570250 SignalHandler(int) /home/ella/workspace/llvm-project/llvm/lib/Support/Unix/Signals.inc:357:1</font></div><div><font face="monospace, monospace"> #4 0x00007f52db212070 __restore_rt (/lib64/libpthread.so.0+0x13070)</font></div><div><font face="monospace, monospace"> #5 0x00007f52d94ec57f __GI_raise (/lib64/libc.so.6+0x3857f)</font></div><div><font face="monospace, monospace"> #6 0x00007f52d94d6895 __GI_abort (/lib64/libc.so.6+0x22895)</font></div><div><font face="monospace, monospace"> #7 0x00007f52d94d6769 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x22769)</font></div><div><font face="monospace, monospace"> #8 0x00007f52d94e4a26 (/lib64/libc.so.6+0x30a26)</font></div><div><font face="monospace, monospace"> #9 0x000000000476fa4b clang::DiagnosticsEngine::setSourceManager(clang::SourceManager*) /home/ella/workspace/llvm-project/clang/include/clang/Basic/Diagnostic.h:527:5</font></div><div><font face="monospace, monospace">#10 0x0000000004768d72 clang::SourceManager::SourceManager(clang::DiagnosticsEngine&, clang::FileManager&, bool) /home/ella/workspace/llvm-project/clang/lib/Basic/SourceManager.cpp:319:1</font></div><div><font face="monospace, monospace">#11 0x0000000004fba66c clang::ASTUnit::LoadFromASTFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, clang::PCHContainerReader const&, clang::ASTUnit::WhatToLoad, llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine>, clang::FileSystemOptions const&, bool, bool, llvm::ArrayRef<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, llvm::MemoryBuffer*> >, bool, bool, bool) /home/ella/workspace/llvm-project/clang/lib/Frontend/ASTUnit.cpp:760:58</font></div><div><font face="monospace, monospace">#12 0x0000000004eb1850 clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, clang::FrontendInputFile const&) /home/ella/workspace/llvm-project/clang/lib/Frontend/FrontendAction.cpp:632:69</font></div><div><font face="monospace, monospace">#13 0x0000000004e5576f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/ella/workspace/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:949:5</font></div><div><font face="monospace, monospace">#14 0x0000000004ff5b4b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/ella/workspace/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:271:38</font></div><div><font face="monospace, monospace">#15 0x000000000221e5d9 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/ella/workspace/llvm-project/clang/tools/driver/cc1_main.cpp:225:40</font></div><div><font face="monospace, monospace">#16 0x0000000002214598 ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) /home/ella/workspace/llvm-project/clang/tools/driver/driver.cpp:309:64</font></div><div><font face="monospace, monospace">#17 0x0000000002214bea main /home/ella/workspace/llvm-project/clang/tools/driver/driver.cpp:381:26</font></div><div><font face="monospace, monospace">#18 0x00007f52d94d8413 __libc_start_main (/lib64/libc.so.6+0x24413)</font></div><div><font face="monospace, monospace">#19 0x0000000002212f3e _start (../bin/clang+0x2212f3e)</font></div><div><font face="monospace, monospace">[1]    32214 abort (core dumped)  ../bin/clang -cc1 -analyze -analyzer-checker=core,debug.ExprInspection -o   </font></div></div><div><br></div></div></div></div></div></div>