<div dir="ltr"><div dir="ltr"><div>Dear all,</div><div><br></div><div>Is there any AST matcher that can produce an iteration operation like:  FOR-EACH parameter of function?</div><div>I am trying to match call expressions where the caller arguments are the parameters of another, outer function. </div><div>For this solution I am using equalsBoundNode() as a narrowing matcher.</div><div><br></div><div>My problem is that I am unable to find a way to match all the function parameters. The matcher only matches the first parameter.</div><div><br></div><div>Here is the full matcher:</div><div><br></div><div>auto calleeArgVarDecl = declRefExpr(to(varDecl().bind("callerArg")))</div><div><br></div><div>auto innerCallExpr = callExpr(</div><div><span style="white-space:pre">                                               </span>forEachArgumentWithParam(</div><div><span style="white-space:pre">                                                     </span>anyOf(</div><div><span style="white-space:pre">                                                                </span>unaryOperator(hasDescendant(calleeArgVarDecl)),</div><div><span style="white-space:pre">                                                               </span>calleeArgVarDecl</div><div><span style="white-space:pre">                                                      </span>),</div><div><span style="white-space:pre">                                                    </span>parmVarDecl().bind("calleeParam")</div><div><span style="white-space:pre">                                           </span>),</div><div><span style="white-space:pre">                                            </span>callee(functionDecl().bind("calleeFunc")), unless(isExpansionInSystemHeader())).bind("callExpr")</div><div><br></div><div>auto fullMatcher =  functionDecl(</div><div><span style="white-space:pre">                                                </span>forEachDescendant(innerCallExpr),</div><div><span style="white-space:pre">                                             </span>hasAnyParameter(</div><div><span style="white-space:pre">                                                      </span>parmVarDecl(equalsBoundNode("callerArg")).bind("outerFuncParam")</div><div><span style="white-space:pre">                                          </span>)</div><div><span style="white-space:pre">                                     </span>).bind("outerFunc")</div><div><br></div><div><br></div><div>I tryed to use the folowing matchers but none of them solved my problem:</div><div>hasAnyParameter(...) - It only binds the first parameter that is matched.</div><div>hasParameter(n,...) - I can use this one only if the function has a known number of parameters. This solution is not so good because the number of parameters is unknown.</div><div>forEachArgumentWithParam - only works for caller expressions, and I am matching parameters of a functionDecl.</div><div><br></div><div>Any help would be greatly appreciated</div></div></div>