[cfe-users] How to I match all parameters?
Bill White
bill.white at griggsinst.com
Mon Mar 24 14:25:17 PDT 2014
I'm trying to create an AST matcher which matches parameters to functions
whose type is a pointer to a particular class. Let's say I care about a
class named C. Then I want to match all calls to functions which pass a C*
parameter.
I've tried this matcher:
functionDecl(
forEachDescendant(
callExpr(
hasAnyArgument(
expr(
hasType(
pointerType(
pointee(
hasDeclaration(
recordDecl(
hasName("C"))))))).bind("argument"))))).bind("root")
But when I match it with this function:
int g(C*, const C*, int);
int h(C*);
int hereitis()
{
C bd, bdtoo;
return g(&bd, &bdtoo, h(&bd));
// ^A
// ^B
}
I only get two matches at the locations A and B above. I don't
get the match when bdtoo is passed,
I've tried sprinkling forEach around in various places, but I either
get ambiguous matchers, because forEach is polymorphic, or I don't
get any matches.
Thanks if you can offer any help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20140324/82e6f39a/attachment.html>
More information about the cfe-users
mailing list