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

David Come via cfe-dev cfe-dev at lists.llvm.org
Mon Aug 29 09:29:00 PDT 2016


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.
>>
>>
>
>




More information about the cfe-dev mailing list