<div dir="ltr"><div><div><div><div><div><div><div><div><div><div>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.<br>
<br></div>I've tried this matcher:<br>functionDecl(<br>  forEachDescendant(<br>    callExpr(<br>      hasAnyArgument(<br>        expr(<br>          hasType(<br>            pointerType(<br>              pointee(<br>                hasDeclaration(<br>
                  recordDecl(<br>                    hasName("C"))))))).bind("argument"))))).bind("root")<br><br></div>But when I match it with this function:<br><br></div><div>int g(C*, const C*, int);<br>
</div><div>int h(C*);<br></div>int hereitis()<br>{<br></div>    C bd, bdtoo;<br></div>    return g(&bd, &bdtoo, h(&bd));<br></div><div>   //                                        ^A<br></div><div>   //             ^B<br>
</div><div>}<br><br></div>I only get two matches at the locations A and B above.  I don't<br>get the match when bdtoo is passed,<br><br></div>I've tried sprinkling forEach  around in various places, but I either<br>
</div>get ambiguous matchers, because forEach is polymorphic, or I don't<br></div>get any matches.<br><br></div>Thanks if you can offer any help.<br><br></div>