[PATCH] D49840: [AST] Add MatchFinder::matchSubtree

Manuel Klimek via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 27 06:27:22 PDT 2018


On Fri, Jul 27, 2018 at 12:43 PM Gabor Marton via Phabricator <
reviews at reviews.llvm.org> wrote:

> martong added a comment.
>
> > Finder.match also has an overload that takes the node. Can you wrap
> "Pattern" above in the anyOf(hasDescendant(...), ...) and match on the node
> instead of the full AST?
>
> Ok, I changed and wrapped the pattern:
>
>   template <typename MatcherType>
>   NodeType *match(const Decl *D, const MatcherType &AMatcher) {
>     MatchFinder Finder;
>     auto WrappedMatcher = anyOf(AMatcher.bind(""),
> hasDescendant(AMatcher.bind("")));
>     Finder.addMatcher(WrappedMatcher, this);
>     // ...
>   }
>

If you know the node is a decl, wrapping it in decl() should be enough.
Does this work?
auto WrappedMatcher = decl(anyOf(...));
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180727/3786e2da/attachment.html>


More information about the cfe-commits mailing list