<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Treating nodes of a single type differently depending on their specifics might be much easier with AST Matchers.</div><div class=""><br class=""></div><div class="">What you’re looking for is <i class="">hasConditionVariableStatement</i> [<a href="http://clang.llvm.org/docs/LibASTMatchersReference.html#hasConditionVariableStatement0Anchor" class="">http://clang.llvm.org/docs/LibASTMatchersReference.html#hasConditionVariableStatement0Anchor</a>].</div><div class=""><br class=""></div><div class="">Generally, try to use RecursiveASTVisitor when what you want is exactly node traversal, i.e. almost no dispatching. Otherwise, use AST Matchers. They’re easy to use and yet very powerful.</div><div class=""><br class=""></div><div class="">—</div><div class="">Kirill Bobyrev </div><br class=""><div><blockquote type="cite" class=""><div class="">On 30 Jul 2016, at 19:45, Himanshu via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi All, <div class=""><br class=""></div><div class="">In my VisitBinaryOperator I want to treat assignments in IfStmt's predicate check part differently </div><div class="">than the assignments in its body. For example: </div><div class=""><br class=""></div><div class="">if( (*ptrI = malloc(sizeof(int) * 10)) == NULL)  // => this assignment is within predicate </div><div class="">        msg = "success"; // assignment in body (treat it differently than the above)</div><div class="">else</div><div class="">        msg = "fail"; // assignment in body</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Here, I would like to handle the ptrI = malloc assignment differently than the other two assignments of 'msg'. I tries setting a flag in VisitIfStmt, but that can't distinguish between the two different kind of assignments. </div><div class=""><br class=""></div><div class="">Thanks!</div></div>
_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></div></blockquote></div><br class=""></body></html>