[PATCH] D94127: [ASTMatchers] Add mapAnyOf matcher

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 5 15:31:29 PST 2021


steveire created this revision.
steveire added a reviewer: aaron.ballman.
steveire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Make it possible to compose a matcher for different base nodes.

This accepts one or more node matcher functors and zero or more
matchers, composing the latter into the former.

This allows composing of matchers where the same inner matcher name is
used for the same concept, but with a different node functor. Currently,
there is a limitation that the nodes must be in the same "clade", so
while

  mapAnyOf(ifStmt, forStmt).with(hasBody(stmt()))

can be used, functionDecl can not be added to the tuple.

It is possible to use this in clang-query, but it will require changes
to the QueryParser, so is deferred to a future review.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94127

Files:
  clang/docs/LibASTMatchersReference.html
  clang/docs/tools/dump_ast_matchers.py
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94127.314733.patch
Type: text/x-patch
Size: 9714 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210105/b41ff648/attachment.bin>


More information about the cfe-commits mailing list