Open
Description
In test program:
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?