[PATCH] D72414: Add new AST matchers `hasAnyCapture` and `capturesThis`

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 9 06:27:53 PST 2020


aaron.ballman added a comment.

Thank you for this patch! You should also register the matcher(s) in Registry.cpp so that they'll work from clang-query. Also, you need to regenerate the documentation by running `clang\docs\tools\dump_ast_matchers.py`



================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4056
+///   matches [this](){};
+AST_MATCHER(LambdaExpr, capturesThis) {
+  for (const LambdaCapture &Capture : Node.captures()) {
----------------
I'm a bit less certain about the utility of this matcher. I would have assumed you could do `hasAnyCapture(cxxThisExpr())` to get the same behavior, but I am guessing that won't work -- though you may be able to add an overload to `hasAnyCapture()` to make that work. I think that might be a better approach, if it works.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72414





More information about the cfe-commits mailing list