[PATCH] D102213: [ASTMatchers] Add forCallable(), a generalization of forFunction().

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 11 05:34:39 PDT 2021


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:7563
+  llvm::SmallVector<DynTypedNode, 8> Stack(Parents.begin(), Parents.end());
+  while (!Stack.empty()) {
+    const auto &CurNode = Stack.back();
----------------
The formatting changes are good, but should be done in a separate NFC commit as they're unrelated.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:7583-7585
+/// Matches declaration of the function, method, or block
+/// the statement belongs to. Similar to 'forFunction' but additionally covers
+/// Objective-C methods and blocks.
----------------
It looks like you can re-flow the comments a bit, and add lambdas to the description.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:7597
+///   but does not match 'int y = 2'.
+AST_MATCHER_P(Stmt, forCallable, internal::Matcher<Decl>, InnerMatcher) {
+  const auto &Parents = Finder->getASTContext().getParents(Node);
----------------
You should also update Registry.cpp to expose this via the dynamic matchers.


Repository:
  rC Clang

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

https://reviews.llvm.org/D102213



More information about the cfe-commits mailing list