aaron.ballman added a comment. I'm a bit confused as to why this is necessary. We already have `lambdaExpr(hasAnyCapture(varDecl(hasName("whatever"))))` and `lambdaExpr(hasAnyCapture(cxxThisExpr()))`, so I'm not certain why we need this as a parallel construct?
================ Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4629-4630 +/// matches `[x](){}`. +AST_MATCHER_P(LambdaCapture, refersToVarDecl, internal::Matcher<VarDecl>, + InnerMatcher) { + auto *capturedVar = Node.getCapturedVar(); ---------------- The name here is a bit unclear -- whether it is the matcher matching `int x;` or the `x` from the capture is not clear from the name. The comment suggests it's matching `x` from the capture, but I think it's actually matching the `int x;` variable declaration. Being clear on what's matched here is important when we think about initializers: ``` void foo() { int x = 12; auto f = [x = 100](){}; } ``` and ``` lambdaExpr(hasAnyCapture(lambdaCapture(refersToVarDecl(hasName("x"), hasInitializer(integerLiteral(equals(100)))))) ``` Would you expect this to match? (This might be a good test case to add.) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112491/new/ https://reviews.llvm.org/D112491 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits