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

    <tr>
        <th>Summary</th>
        <td>
            clangd dead loop in clang::dataflow::WatchedLiteralsSolverImpl::solve(long long)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          andy-yx-chen
      </td>
    </tr>
</table>

<pre>
    Reproduce step:
1. build https://github.com/ccache/ccache with compile_commands.json
2. with 17.02 clangd check src/ccache.cpp

Stack trace
```
 thread #1, queue = 'com.apple.main-thread', stop reason = instruction step over
  * frame #0: 0x00000001063b1a44 clangd`clang::dataflow::WatchedLiteralsSolverImpl::solve(long long) && + 228
    frame #1: 0x00000001063b17a4 clangd`clang::dataflow::WatchedLiteralsSolver::solve(llvm::ArrayRef<clang::dataflow::Formula const*>) + 64
    frame #2: 0x000000010639bc84 clangd`clang::dataflow::DataflowAnalysisContext::isUnsatisfiable(llvm::SetVector<clang::dataflow::Formula const*, std::__1::vector<clang::dataflow::Formula const*, std::__1::allocator<clang::dataflow::Formula const*>>, llvm::DenseSet<clang::dataflow::Formula const*, llvm::DenseMapInfo<clang::dataflow::Formula const*, void>>, 0u>) + 180
 frame #3: 0x000000010639b8d8 clangd`clang::dataflow::DataflowAnalysisContext::flowConditionImplies(clang::dataflow::Atom, clang::dataflow::Formula const&) + 196
    frame #4: 0x000000010638853c clangd`clang::dataflow::UncheckedOptionalAccessModel::compare(clang::QualType, clang::dataflow::Value const&, clang::dataflow::Environment const&, clang::dataflow::Value const&, clang::dataflow::Environment const&) + 280
 frame #5: 0x0000000106388978 clangd`clang::dataflow::UncheckedOptionalAccessModel::widen(clang::QualType, clang::dataflow::Value&, clang::dataflow::Environment const&, clang::dataflow::Value&, clang::dataflow::Environment&) + 44
    frame #6: 0x00000001063a1588 clangd`clang::dataflow::Environment::widen(clang::dataflow::Environment const&, clang::dataflow::Environment::ValueModel&) + 404
    frame #7: 0x00000001063aee8c clangd`clang::dataflow::runTypeErasedDataflowAnalysis(clang::dataflow::ControlFlowContext const&, clang::dataflow::TypeErasedDataflowAnalysis&, clang::dataflow::Environment const&, std::__1::function<void (clang::CFGElement const&, clang::dataflow::TypeErasedDataflowAnalysisState const&)>) + 1340
    frame #8: 0x000000010635f5b4 clangd`llvm::Expected<std::__1::vector<std::__1::optional<clang::dataflow::DataflowAnalysisState<clang::dataflow::UncheckedOptionalAccessModel::Lattice>>, std::__1::allocator<std::__1::optional<clang::dataflow::DataflowAnalysisState<clang::dataflow::UncheckedOptionalAccessModel::Lattice>>>>> clang::dataflow::runDataflowAnalysis<clang::dataflow::UncheckedOptionalAccessModel>(clang::dataflow::ControlFlowContext const&, clang::dataflow::UncheckedOptionalAccessModel&, clang::dataflow::Environment const&, std::__1::function<void (clang::CFGElement const&, clang::dataflow::DataflowAnalysisState<clang::dataflow::UncheckedOptionalAccessModel::Lattice> const&)>) + 216
    frame #9: 0x000000010635f13c clangd`clang::tidy::bugprone::UncheckedOptionalAccessCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) + 464
    frame #10: 0x0000000106c42058 clangd`clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch(clang::ast_matchers::BoundNodes const&) + 132
    frame #11: 0x0000000106c6d1a0 clangd`clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) + 256
    frame #12: 0x0000000106c419ac clangd`clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) + 1104
    frame #13: 0x0000000106c433fc clangd`clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) + 276
    frame #14: 0x0000000106c46728 clangd`clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDecl(clang::Decl*) + 13004
    frame #15: 0x0000000106c43408 clangd`clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) + 288
    frame #16: 0x0000000106c226bc clangd`clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) + 748
    frame #17: 0x0000000105fca154 clangd`clang::clangd::ParsedAST::build(llvm::StringRef, clang::clangd::ParseInputs const&, std::__1::unique_ptr<clang::CompilerInvocation, std::__1::default_delete<clang::CompilerInvocation>>, llvm::ArrayRef<clang::clangd::Diag>, std::__1::shared_ptr<clang::clangd::PreambleData const>) + 7508
    frame #18: 0x0000000105e63994 clangd`clang::clangd::check(llvm::StringRef, clang::clangd::ThreadsafeFS const&, clang::clangd::ClangdLSPServer::Options const&) + 7376
    frame #19: 0x0000000105e53294 clangd`clang::clangd::clangdMain(int, char**) + 8664
    frame #20: 0x000000018659bf28 dyld`start + 2236
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWVtz4jgW_jXiRRXKli_YDzwQCFtd1b07GzI9jylZOoBmZMkjyXTz77dkE242hCSbqU5RRJLlo_Od-xHUWrFSAGOU3KNkNqC1W2szpopv77Y_79ga1KDQfDt-hMpoXjPA1kGFogkKZiiYhENc1EJyvHausn6ZzBGZr4Rb18WQ6RKROWOUrWE_wD-EW2Omy0pIeGa6LKnidvin1aqlSYbtlnA0DAhmkqoVx2wN7C9sDdvTGbKqal9ovxeOsr-wM5TBbjkNdp9mit3aAOUYkShEZIr_rqEGjKIZRmTEdDmkVSVhWFKh7tqtiIz8Rut0hQ1Qq1WzXSjrTM2c0KoRBtYbMLszMCITvDS0BH9OgKIJDn4G7V8YpFER0jjeYUJp0Ay81KIJp44upf7Rzv6gjq2BfxUODJV2oeUGzJeyku1j6-eIZFKrFfZfiOQYkRSRFCNyjwnJXhjCB3bCHnZG9N3snLEiN2W7MjGGbh9hiaLpRYJzbcpaUsy0sg6RCYoeWgj3OI17WCcd1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