<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/92972>92972</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang-Doc hits an assertion in Sema when run on LLVM
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            bug,
            clang-doc
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ilovepi
      </td>
    </tr>
</table>

<pre>
    When using clang-doc to generate documentation for LLVM, I'm seeing an assertion failure in Sema.
```
[1476/5643] Processing file /usr/local/google/home/paulkirth/llvm-project/llvm/lib/Support/FileCollector.cpp
clang-doc: /usr/local/google/home/paulkirth/llvm-project/clang/lib/Sema/SemaExprMember.cpp:993: ExprResult clang::Sema::BuildMemberReferenceExpr(Expr *, QualType, SourceLocation, bool, const CXXScopeSpec &, SourceLocation, NamedDecl *, LookupResult &, const TemplateArgumentListInfo *, const Scope *, bool, ActOnMemberAccessExtraArgs *): Assertion `!SS.isInvalid() && "nested-name-specifier cannot be invalid"' failed.
1 error generated.
 #0 0x000056425e24eb88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (bin/clang-doc+0xe43b88)
 #1 0x000056425e24c85c llvm::sys::RunSignalHandlers() (bin/clang-doc+0xe4185c)
 #2 0x000056425e24f240 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007fa2dafd0510 (/lib/x86_64-linux-gnu/libc.so.6+0x3c510)
 #4 0x00007fa2db01e16c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007fa2dafd0472 raise ./signal/../sysdeps/posix/raise.c:27:6
 #6 0x00007fa2dafba4b2 abort ./stdlib/abort.c:81:7
 #7 0x00007fa2dafba3d5 _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #8 0x00007fa2dafc93a2 (/lib/x86_64-linux-gnu/libc.so.6+0x353a2)
 #9 0x000056425f538966 clang::Sema::BuildMemberReferenceExpr(clang::Expr*, clang::QualType, clang::SourceLocation, bool, clang::CXXScopeSpec const&, clang::SourceLocation, clang::NamedDecl*, clang::LookupResult&, clang::TemplateArgumentListInfo const*, clang::Scope const*, bool, clang::Sema::ActOnMemberAccessExtraArgs*) (bin/clang-doc+0x212d966)
#10 0x000056425f535aa1 clang::Sema::BuildMemberReferenceExpr(clang::Expr*, clang::QualType, clang::SourceLocation, bool, clang::CXXScopeSpec&, clang::SourceLocation, clang::NamedDecl*, clang::DeclarationNameInfo const&, clang::TemplateArgumentListInfo const*, clang::Scope const*, clang::Sema::ActOnMemberAccessExtraArgs*) (bin/clang-doc+0x212aaa1)
#11 0x000056425f539843 clang::Sema::ActOnMemberAccessExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, clang::tok::TokenKind, clang::CXXScopeSpec&, clang::SourceLocation, clang::UnqualifiedId&, clang::Decl*) (bin/clang-doc+0x212e843)
#12 0x000056425ec061da clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) (bin/clang-doc+0x17fb1da)
#13 0x000056425ec08409 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (bin/clang-doc+0x17fd409)
#14 0x000056425ec02dec clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (bin/clang-doc+0x17f7dec)
#15 0x000056425ec02d19 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (bin/clang-doc+0x17f7d19)
#16 0x000056425eccc911 clang::Parser::ParseReturnStatement() (bin/clang-doc+0x18c1911)
#17 0x000056425ecc5251 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (bin/clang-doc+0x18ba251)
#18 0x000056425ecc36d2 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (bin/clang-doc+0x18b86d2)
#19 0x000056425eccf451 clang::Parser::ParseCompoundStatementBody(bool) (bin/clang-doc+0x18c4451)
#20 0x000056425ecd0732 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (bin/clang-doc+0x18c5732)
#21 0x000056425ecfa080 clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) (bin/clang-doc+0x18ef080)
#22 0x000056425ecf863a clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) (bin/clang-doc+0x18ed63a)
#23 0x000056425ec3a7a7 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (bin/clang-doc+0x182f7a7)
#24 0x000056425ec378e7 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (bin/clang-doc+0x182c8e7)
#25 0x000056425ec639cb clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (bin/clang-doc+0x18589cb)
#26 0x000056425ebdfb1c clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (bin/clang-doc+0x17d4b1c)
#27 0x000056425ebdf78b clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (bin/clang-doc+0x17d478b)
#28 0x000056425ebde5a9 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (bin/clang-doc+0x17d35a9)
#29 0x000056425ec2cbff clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (bin/clang-doc+0x1821bff)
#30 0x000056425ec2beb7 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (bin/clang-doc+0x1820eb7)
#31 0x000056425ec5c9af clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (bin/clang-doc+0x18519af)
#32 0x000056425ebde0fd clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (bin/clang-doc+0x17d30fd)
#33 0x000056425ebdc466 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (bin/clang-doc+0x17d1466)
#34 0x000056425ebd762e clang::ParseAST(clang::Sema&, bool, bool) (bin/clang-doc+0x17cc62e)
#35 0x000056425e91decf clang::FrontendAction::Execute() (bin/clang-doc+0x1512ecf)
#36 0x000056425e33e82d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (bin/clang-doc+0xf3382d)
#37 0x000056425e2a906b clang::tooling::FrontendActionFactory::runInvocation(std::__2::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::__2::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (bin/clang-doc+0xe9e06b)
#38 0x000056425e2a8fc4 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::__2::shared_ptr<clang::CompilerInvocation>, std::__2::shared_ptr<clang::PCHContainerOperations>) (bin/clang-doc+0xe9dfc4)
#39 0x000056425e2a7e48 clang::tooling::ToolInvocation::run() (bin/clang-doc+0xe9ce48)
#40 0x000056425e2aa99b clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (bin/clang-doc+0xe9f99b)
#41 0x000056425e251ed5 void std::__2::__function::__policy_invoker<void ()>::__call_impl[abi:nn190000]<std::__2::__function::__default_alloc_func<std::__2::__bind<clang::tooling::AllTUsToolExecutor::execute(llvm::ArrayRef<std::__2::pair<std::__2::unique_ptr<clang::tooling::FrontendActionFactory, std::__2::default_delete<clang::tooling::FrontendActionFactory>>, std::__2::function<std::__2::vector<std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>, std::__2::allocator<std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>>> (std::__2::vector<std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>, std::__2::allocator<std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>>> const&, llvm::StringRef)>>>)::$_0, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>&>, void ()>>(std::__2::__function::__policy_storage const*) AllTUsExecution.cpp:0:0
#42 0x000056425e1cddfe std::__2::__deferred_assoc_state<void, std::__2::__async_func<std::__2::function<void ()>>>::__execute() ClangDocMain.cpp:0:0
#43 0x000056425e20afec llvm::StdThreadPool::processTasks(llvm::ThreadPoolTaskGroup*) (bin/clang-doc+0xdfffec)
#44 0x000056425e20c65c void* llvm::thread::ThreadProxy<std::__2::tuple<llvm::StdThreadPool::grow(int)::$_0>>(void*) ThreadPool.cpp:0:0
#45 0x00007fa2db01c45c start_thread ./nptl/pthread_create.c:444:8
#46 0x00007fa2db09cbbc clone3 ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:83:0
[1]    290300 IOT instruction  bin/clang-doc --output=docs --executor=all-TUs ./compile_commands.json
```

cmake invocation:
```
cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DLLVM_ENABLE_PROJECTS=clang-tools-extra -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON ../llvm -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
```

command run in the build directory:
`bin/clang-doc --output=docs --executor=all-TUs ./compile_commands.json`

I'll try and see if I can get it to repoduce w/ `-gen-reproducer`, but that may take a while.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWltT6zqW_jXmRRXKlu8PPIQEupmGDUM4Z_Y8pWR5OejgSD6SzIZ_PyU5F8tJDHTTPT1VUwWVxJLW5VtLn5ZkEaXYigNcePGlF8_PSKufhbxgtXiFhp0Vony_-K9n4KhVjK8QrQlfTUpBkRZoBRwk0YBKQds1cE00ExxVQqLb29_vPDxDNx5O10gBmMGEI6IUyK4XYXUrATGOFrAm554_9_ypl_ibv-5nfBlEaeLh6ziJQi-eowcpKChrS8VqQB6-bpX08HUtKKk9fL0SYlWDh6-fxdp8NKStX5jUz6ZP_bqeNFL8AVRvfpoPVnj4etE2jZDm8TWrYSbqGqgW8pw2TWfLznUvnP5Daq2gvV5Yk83H1Vsj72BdQKc1nOZ5aJSZ54-g2lp3-Hvh1AundqD9dtmyuuwGPkIFEjgFM8bDmflAHp6aWPxnS-qn9wbM94VoJYVbQW3IzJNCiNp8UsGVRrOfPxdUNLBogCIPJ8fH_CBrKOdA662KWyFe2mZj62ZYJ_AJ1k1NNEzlyqbKLVP6hldiO7LrZXVuH20tmlJ9zzv3ptQE_-pNSzKVK9X1zA1G011imeTBwWJxztQNfyU1Kz2ceTjv7EmQhzEHpaGccLKGiWqAsoqBRJRwLjQqTE5uxmEPpzZTodwkaIBASiF3ub99jjwc-sh_833fj5MIx4AjKLIM2SSzYVLvqvvyIBnXC03oy5MkFDyc7TtJ8msplJZA1hv8GNed9VnB-DZ9bB7iS_8NorDIjHt7M4KBGTSL6TEzHlu-YCtO6r8SXtYg1Q6nE5qCLKaOJjzQVOHIR45MD2cb-7vHapPZvv3fCQo3gtKK4JJUpR8HPrLmbGbJW5Ysk2hSM96-TVa87RrouRLnibUupHHgO8ZFfZmFH0CQULRcNvpZAimXL6yul2zd1LBnrnMPX_NGm_nc73ZupnwUeeE0Tfby46HNUYqRJEyB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