[cfe-dev] Finding all instances of calls to a specific function using ASTMatcher

Riyad Parvez riyad.parvez at gmail.com
Mon Apr 6 17:49:16 PDT 2015


Hi All,

I want to find all the instances of calls to a specific function. Right 
now, I can find all the function calls using ASTMatcher using following 
code:

Finder.addMatcher(
callExpr(hasParent(binaryOperator(hasOperatorName("=")).bind("assignment"))).bind("functionCall"),
       &HandlerForFunctionCall);

But I want to find all the function calls whose name is say "malloc". I 
know how do that using classic "RecursiveASTVisitor" class, but how can 
I do this using ASTMatcher?

Thanks
Riyad



More information about the cfe-dev mailing list