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

    <tr>
        <th>Summary</th>
        <td>
            [clang] clang-18 (seems) enters an endless loop
        </td>
    </tr>

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

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

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

<pre>
    ```
$ clang -v
clang version 18.0.0 (https://github.com/llvm/llvm-project.git 47b8763f8a814c0e755e154516537d8deb57e4b0)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/antipov/.local/llvm-18.0.0/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/13
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/13
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
$ clang -c test.i 1>/dev/null 2>&1
```
This seems hangs forever. After waiting for ~10 minutes and attaching `gdb`, I'm seeing the following:
```
#0 0x00007f8142b5df50 in clang::CodeGen::CodeGenFunction::BuildCountedByFieldExpr(clang::Expr const*, clang::ValueDecl const*) () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#1 0x00007f81429c8b76 in clang::CodeGen::CodeGenFunction::emitBuiltinObjectSize(clang::Expr const*, unsigned int, llvm::IntegerType*, llvm::Value*, bool) ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#2 0x00007f81429d06aa in clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(clang::GlobalDecl, unsigned int, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#3 0x00007f8142b71edb in clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#4 0x00007f8142baf438 in (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) ()
 from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#5 0x00007f8142ba245b in (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#6 0x00007f8142ba2412 in clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#7 0x00007f8142b3d1b7 in clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#8 0x00007f8142b3fde5 in clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission const&) () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#9 0x00007f8142b3b774 in clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) ()
 from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#10 0x00007f8142b3b3d5 in clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#11 0x00007f8142c9860b in clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#12 0x00007f8142c97b0f in clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#13 0x00007f8142ca2fdc in clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#14 0x00007f8142ca222d in clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#15 0x00007f8142bb29d5 in (anonymous namespace)::ScalarExprEmitter::VisitStmtExpr(clang::StmtExpr const*) ()
 from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#16 0x00007f8142ba2412 in clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#17 0x00007f8142b574c1 in clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) ()
 from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#18 0x00007f8142c97bef in clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#19 0x00007f8142c984a1 in clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#20 0x00007f8142c97b0f in clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#21 0x00007f8142c9a829 in clang::CodeGen::CodeGenFunction::EmitForStmt(clang::ForStmt const&, llvm::ArrayRef<clang::Attr const*>) () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#22 0x00007f8142c98002 in clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#23 0x00007f8142ca2fdc in clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#24 0x00007f8142cf7cf1 in clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#25 0x00007f8142d166e4 in clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#26 0x00007f8142d106ad in clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#27 0x00007f8142d04713 in clang::CodeGen::CodeGenModule::EmitDeferred() ()
 from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#28 0x00007f8142d0472f in clang::CodeGen::CodeGenModule::EmitDeferred() ()
 from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#29 0x00007f8142d0472f in clang::CodeGen::CodeGenModule::EmitDeferred() ()
 from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#30 0x00007f8142d0472f in clang::CodeGen::CodeGenModule::EmitDeferred() ()
 from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#31 0x00007f8142d0472f in clang::CodeGen::CodeGenModule::EmitDeferred() ()
 from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#32 0x00007f8142d026da in clang::CodeGen::CodeGenModule::Release() ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#33 0x00007f8142d9f128 in (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&)
 () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#34 0x00007f8142ce8bb6 in clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) ()
 from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#35 0x00007f8141a45f16 in clang::ParseAST(clang::Sema&, bool, bool) ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#36 0x00007f81436a0bb7 in clang::FrontendAction::Execute() ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#37 0x00007f8143622fb4 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#38 0x00007f814371211e in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#39 0x000055d062e72bdd in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) ()
#40 0x000055d062e6fde6 in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) ()
#41 0x00007f814330c899 in void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::$_0>(long) ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#42 0x00007f813ddd06bc in llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) ()
 from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libLLVM-18git.so
#43 0x00007f814330c236 in clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#44 0x00007f81432d74aa in clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const () from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#45 0x00007f81432d76ce in clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&, bool) const ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#46 0x00007f81432f1e0d in clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) ()
   from /home/antipov/.local/llvm-18.0.0/bin/../lib64/libclang-cpp.so.18git
#47 0x000055d062e6f81d in clang_main(int, char**, llvm::ToolContext const&) ()
#48 0x000055d062e7cf31 in main ()
```
Translation unit attached (renamed to `test.txt` to bypass attachment restrictions). 
[test.txt](https://github.com/llvm/llvm-project/files/13393449/test.txt)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW99z2yoW_muUFyYeQD_9kAfHibu50zu7U2e7jxkkjmy2CDyA0mQf9m-_gyTHluykiXtj37Z3plPHcEB8H4dzPkBm1oqFArgI4ssgvjpjtVtqc8ErppxY6fuzXPPHiyDB3T98FeBJQCNUSKYW6Py-LWm_3YOxQitEshEeYRTQbOncygbhJKCzgM4Wwi3rfFToKqAzKe_XH-cro_8LhRsthENRmmdpEpYZy0hUYEjjGEgcxSSJw5RnHPI4hSjHAR23z75lZgEuCCfoIUvukui8Vl-U_qrOpVD1w_lC1Z3d0gDjqNIcpLdeaSse2qobZR2TEviVML4qoLOlriCgs46GgM5GUhdMrkfcQgzoLBeq7WOma8VRwRQXnDlAH6ZTJNp-mRNadf3W1vg-RO75KI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