[cfe-dev] Running AST matchers on part of the AST

Manuel Klimek via cfe-dev cfe-dev at lists.llvm.org
Mon Aug 29 10:04:55 PDT 2016


Use hasDescendant. Also, just use the free standing match function.

On Mon, Aug 29, 2016, 6:27 PM David Come via cfe-dev <cfe-dev at lists.llvm.org>
wrote:

> That's what I tried but it didn't work. If S is function's body, it will
> not run the matcher on child nodes.
>
> I assumed it would run the matcher on the node only and doesn't do the
> traversal to match S'child nodes.
>
>
> On 29/08/2016 17:20, Aleksei Sidorin via cfe-dev wrote:
> > Hello David,
> >
> > You can use MatchFinder::match<...>() method.
> > Example:
> >
> > void matchStmt(const Stmt *S, ASTContext &Ctx) {
> >   MatchFinder Finder;
> >   Finder.addMatcher(someMatcher, &Callback);
> >   Finder.match<Stmt>(*S, Ctx);
> > }
> >
> >>
> >> Hi,
> >>
> >> I would like to run some dynamic matchers on a single function body or I
> >> can either run it the full AST (MatchFinder::matchAST) or on a single
> >> node (MatchFinder::match).
> >>
> >>
> >> What is the best way to achieve what I want ? Do you think it is worth I
> >> change clang's code and submit a patch ?
> >>
> >>
> >> Thanks,
> >>
> >> David.
> >>
> >>
> >
> >
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160829/c7c4ec6f/attachment.html>


More information about the cfe-dev mailing list