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

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] bugprone-unchecked-optional-access aborted with some AOSP source files
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          chih-hung
      </td>
    </tr>
</table>

<pre>
    This clang-tidy crash is reproducible with the latest clang-tidy source tree.
I found it when testing revision r468909.

The clang-tidy stack dump points to bugprone-unchecked-optional-access check.
If that check is disabled in the attached test.sh, clang-tidy will not abort.

To reproduce:

(1) unzip the attached test.zip file

(2) modify TIDY in test.sh to point to an clang-tidy built
    from r461044 or newer, when the bugprone-unchecked-optional-access
    check was added.

Note that attached test.i.cc is preprocessed from one of several
AOSP source files that have this problem.

The clang-tidy aborted with stack dump:
```
1.  <eof> parser at end of file
2.  ASTMatcher: Processing 'bugprone-unchecked-optional-access' against:
    FunctionDecl astc_codec::UnpackLogicalBlock : <device/generic/vulkan-cereal/third-party/astc-codec/src/decoder/logical_astc_block.cc:243:1, line:260:1>
--- Bound Nodes Begin --- 
    T - { RecordType : astc_codec::VoidExtentData 
    fun - { FunctionDecl astc_codec::UnpackLogicalBlock : <device/generic/vulkan-cereal/third-party/astc-codec/src/decoder/logical_astc_block.cc:243:1, line:260:1> }
--- Bound Nodes End ---
```


[test.zip](https://github.com/llvm/llvm-project/files/9295004/test.zip)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzVVF2v2ygQ_TXOy8iRg50PP_ghaW6kSrvdqs2u1KcKw8RmLwELcNLsr9_BvmmS9qrtPm4UYRjgzDmHgdrKS7VvlQehuWnSoOQFhOO-BYo57JyVvVC1Rjir0EJoETQP6MP9Bm97JxCCQ5wm2TbJ1m_hYHsjQQU4t2gg7lCmIcST8soac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