[PATCH] D93688: [ASTMatchers] Ensure that we can match inside lambdas

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 4 09:44:42 PST 2021


aaron.ballman added inline comments.


================
Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:478-487
+    } else if (auto *LE = dyn_cast<LambdaExpr>(S)) {
+
+      for (unsigned I = 0, N = LE->capture_size(); I != N; ++I) {
+        const auto *C = LE->capture_begin() + I;
+        {
+          ASTNodeNotSpelledInSourceScope RAII(
+              this, TraversingASTNodeNotSpelledInSource || !C->isExplicit());
----------------



================
Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:512-513
+          // Visit parameters.
+          for (unsigned I = 0, N = Proto.getNumParams(); I != N; ++I)
+            TraverseDecl(Proto.getParam(I));
+        }
----------------



================
Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:516
+
+        auto *T = Proto.getTypePtr();
+        for (const auto &E : T->exceptions())
----------------



================
Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:526
+        TraverseStmt(LE->getTrailingRequiresClause());
+
+        TraverseStmt(LE->getBody());
----------------
Do we also need to traverse attributes of the lambda?


================
Comment at: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:3069
+
+  Code = R"cpp(
+void foo() {
----------------
Do we have other test coverage for the rest of lambda matching, or should you add coverage for things like parameters, trailing requires clauses, etc?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93688



More information about the cfe-commits mailing list