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

    <tr>
        <th>Summary</th>
        <td>
            clang-repl: SIGSEGV in libclang
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          pavel-the-best
      </td>
    </tr>
</table>

<pre>
    ## Minimal example
```
echo "{ int x; a::b(x); }" | clang-repl
```

## Expected result
Error is shown, but the evaluation continues

## Actual result
Error is shown, `clang-repl` gets terminated by SIGSEGV.

## Stack trace
LLVM 17.0.4
```* thread #1, name = 'clang-repl', stop reason = signal SIGSEGV: invalid address (fault address: 0x1c)
  * frame #0: 0x00007ffff5188a90 libclang-cpp.so.17`clang::Decl::getTranslationUnitDecl()
    frame #1: 0x00007ffff7b72f60 libclang-cpp.so.17`clang::IncrementalParser::CleanUpPTU(clang::PartialTranslationUnit&) + 192
    frame #2: 0x00007ffff7b74308 libclang-cpp.so.17`clang::IncrementalParser::ParseOrWrapTopLevelDecl() + 2264
    frame #3: 0x00007ffff7b74f4d libclang-cpp.so.17`clang::IncrementalParser::Parse(llvm::StringRef) + 1165
    frame #4: 0x00007ffff7b782b8 libclang-cpp.so.17`clang::Interpreter::ParseAndExecute(llvm::StringRef, clang::Value*) + 184
    frame #5: 0x00005555555614be clang-repl`main + 3534
    frame #6: 0x00007fffeaa5078a libc.so.6`___lldb_unnamed_symbol3154 + 122
    frame #7: 0x00007fffeaa50845 libc.so.6`__libc_start_main + 133
    frame #8: 0x000055555555c3b1 clang-repl`_start + 33
```

Also tested with current master (commit 0d77978e), same result.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyklVtvqzgQxz-N8zJqZMZczAMPadMeHalHW20v-xgZGBLvGoNs06bffgX0krbsntWeKEpgbP7zm7H9R3mv95aoYMk5S7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