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

    <tr>
        <th>Summary</th>
        <td>
            clang-tidy 21.1.2 crashes on JUCE-based GhostLatheProcessor.cpp
        </td>
    </tr>

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

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

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

<pre>
    ### Summary

`clang-tidy` 21.1.2 from Homebrew (`llvm@21`, arm64) segfaults when analyzing JUCE-heavy translation units in the GhostLathe audio plugin project. The crash is deterministic on macOS 14.5 when running against `GhostLatheProcessor.cpp` or the associated unit tests.

### Version

21.1.2 (Homebrew `llvm@21` build, arm64)

### OS

macOS 14.5 (arm64)

### Steps to Reproduce

1. Install llvm@21 via Homebrew: `brew install llvm@21`.
2. Configure GhostLathe with compile commands:
   ```
 cmake -S . -B build -G Ninja \
     -DCMAKE_BUILD_TYPE=Debug \
 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
   ```
3. Ensure `/opt/homebrew/opt/llvm@21/bin` is first on `PATH`.
4. Run clang-tidy against the problematic TU:
   ```
   run-clang-tidy -p build \
 -clang-tidy-binary clang-tidy \
     src/plugin/GhostLatheProcessor.cpp
 ```

### Expected Behavior

clang-tidy completes analysis and emits diagnostics for the translation unit.

### Actual Behavior

clang-tidy terminates with a segmentation fault while traversing JUCE-generated constructs in `GhostLatheProcessor.cpp`. The crash reproduces consistently on related unit tests (`tests/plugin/GhostLatheProcessorTests.cpp`) as well. A sanitized backtrace and logs are included in the attachments.

### Additional Context

- Downgrading to llvm@20 (clang-tidy 20.1.x) avoids the crash; we currently pin CI to that toolchain.
- JUCE version: 8.0.10. Project builds with CMake 3.30.2 and Ninja 1.12.1; SDKROOT points to the Xcode 16 macOS 14.4/26.0 SDK.
- Sanitized reproduction bundle (sources subset, compile commands, logs) plus stack trace are published here: <https://gist.github.com/DavidDanielSauce/e5cea023e78b31b9b0de0572ed7fef1f>.
 - The gist contains `clang_tidy_crash_report.md`, `clang_tidy_crash_20250930.log`, and a base64-encoded `clang_tidy_crash_bundled.tgz` (decode with `base64 -d clang_tidy_crash_bundled.tgz.base64 > clang_tidy_crash_bundled.tgz`).
- Happy to provide additional sanitized artefacts (e.g., full compile database) if needed.

Thanks for taking a look!

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyEVk1v27oS_TX0ZmCComzZXnjh-OO277ZNUKcP960CShxLbChSICmn6a9_ICUnbvpxAQMS5CFn5sw5hxTeq9ogrsn8hsx3E9GHxrr1TpyV3AmjUB9FX-GktPJ5TXg-_ODYt61wz4Rt4q9glRamngYln0nBgGc0oxxOzrbwzrZYOnwCwpekYFqfWzJjPCMFI3wLwrXFjPAVeKxPotfBw1ODBoQR-vm7MjX858t2P21QnJ8hOGG8FkFZA71RwYMyEBqEvxrrwwcRX0UvlYVO97Uy0Dn7FatA4b5BqJzwDSgPEgO6Vhnlg6rAGmhFdXuEbEbnQ3LXGxNTi1oo4wOQgr1muHO2Qu-to1XXxW6tSzUI722lRECZaoOAPng6IvQC3H_ReWXN8HnEifDlK0o_QgRlr7S8BurthrfH4ctVD4Qvfxd9DNh5CBY-Y-es7CscIjIK740PQmt4SQ9nJV7GR_JNrC3VqN5GkoLFRjmFrTUnVffuh5E8qdBAZdtOaYzPVhjpSR7zAsRdxx_bQNWKR4TpEShMb4bmYfoXfFLmqwAy3w5LAKa77cfN3_uHmy_vP-we7v93tyf5bodlX1-iLhH7f-5uP98_bG8_3r3_sI_Pj5tPuyPJd7effi4gp7A3Ptaf-HmwXSD80FxAuHx47ZwfSmXioJSHk3I-RD6Rgt1t7t-NsMwofO4NvErkhVcRnM7ZUmMrIhXvv_waFYiMnF5tMO1GbC7Nvv43LZUR7vk63RVu3lWEHwZ1EH74HavZ5ocCfqDQ_luHVWT5DTbirKwbA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