<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/76425>76425</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
ast_matcher capturesVar assertion failed in debug mode
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
qqiangwu
</td>
</tr>
</table>
<pre>
https://github.com/llvm/llvm-project/blob/2476e2a91140b57ca3ad0792597be4f4d20ddb1a/clang/include/clang/ASTMatchers/ASTMatchers.h#L4818
```C++
AST_MATCHER_P(LambdaCapture, capturesVar, internal::Matcher<ValueDecl>,
InnerMatcher) {
auto *capturedVar = Node.getCapturedVar();
return capturedVar && InnerMatcher.matches(*capturedVar, Finder, Builder);
}
```
```C++
ValueDecl *getCapturedVar() const {
assert(capturesVariable() && "No variable available for capture");
return static_cast<ValueDecl *>(DeclAndBits.getPointer());
}
```
The matcher relies on getCapturedVar returns nullptr if not captured, but the implementation asserts `capturesVariable()`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlN-P4yYQx_-a8QtqhAf_fPBDflzUSnenU2-1rysME5uKQA7wnvrfV_Y62aRatToLmQE8zHw_I4-M0QyOqINyB-Uhk1Mafeh-_DDSDT-nrPf6725M6RJBbAGPgMfBpHHqN8qfAY_Wvl6n3y7B_0UqAR5763vAIxZ1RSjbPC94X9ZKCql53WLZ1j0Vp0Ij17rPJeBRWekGwKNxyk6a7na235--yKRGCvFxtRkBxeeiyRvgB-Db9V3xt7EH3M1j2d1-f3r5sn3a__7pz5dvgM1nee613MtLmgIB7pl6M-OzDPPSuETBSTuLFts1Ioj9s7QTHUhZEJ8A92-Xs4fnD-coXD2wZVDvrp_JKXkGuF2D6WcZGIgD--o1bQZK-_d9wAawBXHzDZSm4NiDK1aA1UPAzXmZ4-J-H2cWdTRO02LtJmMX8z0C1Id_Afx_qozdeMyyPlLAlHcx3UNgTMZIIQE2d9CN7C2tLqsuQPzq2et6xuSrNHaxTj5cOQDiI6YbqJhkMupFyZju6zbnudSumVdbp3cmxZn9N7_UfOX-cOd_o3kaib1RDyyQNRSZd-yRxZpUZG6y9pICMyfmfLpVc65JPyWWRmLmfLF0Jjfn790KKzKo-Me4oOKZ7oRuRSsz6vKai6qseMGzsWtr1Z4aIcqTLutSKKUUVSLv24KkVrzNTIccRY5Y87KokW-KmpqKS6HynNqmrqHgdJbGbuY_fOPDkJkYJ-rqqsAys7InG5fegejoJ1sO56KUhyx0S1fopyFCwa2JKb7fkkyy1MmYXq7s7tStomf5J2ksaWYc09RPAzt7TdkU7K_3pCW1uYUsqf8TAAD__50yhws">