How to I match all parameters?

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.