Issue 141493
Summary AST Matcher varDecl() in lambda bug
Labels new issue
Assignees
Reporter segoon
    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?
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to