[PATCH] D113575: Add `isInitCapture` and `forEachLambdaCapture` matchers.

James King via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 11 10:24:13 PST 2021


jcking1034 marked an inline comment as done.
jcking1034 added inline comments.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4224
+///     float z;
+///     auto f = [=]() { return x + y + z; };
+///   }
----------------
fowles wrote:
> it would be nice to be able to do something like
> 
> ```
> int main() {
>   int x, y;
>   float z;
>   auto f = [=, z]() { return x+ y + z; };
> }
> ```
> 
> `lambdaExpr(forEachLambdaCapture(isImplicit())` matches `x` and `y` but not `z`
I believe that this should be possible, I've gone ahead and added some unit tests to demonstrate (see the tests named `MatchImplicitCapturesOnly` and `MatchExplicitCapturesOnly`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113575/new/

https://reviews.llvm.org/D113575



More information about the cfe-commits mailing list