<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/141493>141493</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
AST Matcher varDecl() in lambda bug
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
segoon
</td>
</tr>
</table>
<pre>
In test program:
```void lambdaCaptureValueTester3() {
int Mov{};
auto Lambda = [=]() mutable {
Mov = 1;
};
Lambda();
}
```
AST matcher `declRefExpr(to(varDecl().bind("decl"))).bind("expr")` matches:
```
Match #2:
/home/segoon/projects/llvm-project/build/../clang-tools-extra/test/clang-tidy/checkers/performance/lambda.cpp:2:3: note: "decl" binds here
2 | int Mov{};
| ^~~~~~~~~
/home/segoon/projects/llvm-project/build/../clang-tools-extra/test/clang-tidy/checkers/performance/lambda.cpp:4:5: note: "expr" binds here
4 | Mov = 1;
|
```
I would expect varDecl of Mov inside of lambda to be equal to lambda's catched parameter, not the outer variable that was the source of catched parameter. If it is expected varDecl() behaviour (IOW, it's not a bug), then how can I catch lambda's Mov field?
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVMGOpDYQ_ZriUhpEG2joAwd2epFayihSskrONi7AicHENj2zl3x7ZMNkZneS-yKkxn7tV--5ns2dU-NC1ED5Ccprwjc_Gds4Go1ZEmHk1-a2oCfncbVmtHyGvIWshXO2v3ejJGo-C8kf-eo3S79xvdEXcp5sDqwGdkGoPkHWIqrF45O5h2F1hXyf5Js3-FNkQMivGJTkVyivx-J581xo-pcEA0X85-mV4h3bTrQv3ecC-E5w-M7a9tcvOHPfT2QRzpmkXv9Cw-eX1QKrvQFW37m9Uq93plSoRcZPJuMkC_TxfQdRXB6hc3bQu-_2C7L2KQAILGcHlrXAusnMBKzbdx5Yt1rzB_XeAeu0vs8PxxhYJzalJbAuTYF1vebL-OCN0e6BXrzlwLrQrjdIya9hMFH_J9lAt5IdjJ350oeCe-_Sfl0hb4OiHPIWF-Mp_L4ZxuDT4USWjjYwhOoR_6er4QkwlJ__Pp4fyGcBeVt-5_Po3kefxeHzP4L36hLxY8Ru-Gw2LZFeVuo9HnlCM0QatTglKYx2YegNCkL6a-M6fOsjx5XDPgZJ4sotn8mTBfYYhKOfCM3myQZyFQ-Jn7jHZ-4i5sxm-1jjA0WKtwGVR-UOfSTxm8SjoInfldksAqtvP_8eiiofBYXaHMU2xhPwGGotOJln7PmCt73YewPB76BIS8i7RDa5vOQXnlBzqoqanStW18nU9Px8EhUNQogsO_GhL7OhPzMiojPvB0pUwzJWZiU7n_KizupUDqeqvlAhBJcVHyQUGc1c6TTkKDV2TJRzGzWn4lRc8kRzQdrFi46xhZ4xouG8ltfENjF8YhsdFJlWzrs3Gq-8piZcGU_HlfHtVqnltYliG5PN6mbyfo0nn3XAulH5aRNpb-Yj5B-zHrWE0B5i7w37JwAA__9zgbdm">