[cfe-dev] ast_matchers::MatchFinder to CallExpr that's a macro call
Manuel Klimek
klimek at google.com
Fri Apr 26 09:15:14 PDT 2013
On Fri, Apr 26, 2013 at 6:08 PM, Peeter Joot <peeter.joot at gmail.com> wrote:
>
> On Fri, Apr 26, 2013 at 11:07 AM, Manuel Klimek <klimek at google.com> wrote:
>
>> Sorry, of course expr(hasType(...)).bind(...) :)
>
>
> Okay thanks, that compiles now. However, it appears that my attempt to
> match to the void ** itself is not working. Even if I take out the attempt
> to bind to the parameter and just bind to the whole call statement, it
> doesn't trigger. Example:
>
> Finder.addMatcher(
> callExpr( callee(functionDecl(hasName("myfunc"))) ).bind("x"),
> &gmblkCallBack);
>
> triggers the callback:
>
> match callback
> <s>myfunc( &r )</s>
> match callback
> <s>myfunc( (void **)&r )</s>
>
> where the source was:
>
> int myfunc( void ** ppBlkPtr ) ;
>
> void blah(void)
> {
> //int * r ;
> void * r ;
>
> myfunc( &r ) ;
> myfunc( (void **)&r ) ;
> }
>
> But this matcher doesn't trigger:
>
> Finder.addMatcher(
> callExpr( allOf(
> callee(functionDecl(hasName("myfunc"))),
> hasArgument(0,
> // expr(
> hasType(
> pointsTo(
> pointsTo( recordDecl(hasName("void")) )
> )
> )
> // ).bind("x")
> )
> ))
> .bind("x")
> ,
> &gmblkCallBack);
>
> Maybe my best bet is not to try to use this matcher infrastructure for
> anything bug the call itself, and then manipulate or navigate that portion
> of the AST directly in the callback.
>
void cannot be matched with recordDecl - that's where your match fails. I
haven't played around with void pointers yet, but I'd assume you'll want
something with builtinType(asString("void")) or something similar...
Cheers,
/Manuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130426/57fafbb2/attachment.html>
More information about the cfe-dev
mailing list