Thanks, I use TraverseForStmt to solve this problem. And this makes me know TraverseXXX methods better. <br><div><div><br></div><div><br></div><div style="font-size: 12px;font-family: Arial Narrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="font-size: 12px;background:#efefef;padding:8px;"><div><b>From: </b> "Philip Craig"<philipjcraig@gmail.com>;</div><div><b>Date: </b> Tue, Jan 8, 2013 03:47 PM</div><div><b>To: </b> "kevinlynx"<kevinlynx@gmail.com>; <wbr></div><div><b>Cc: </b> "cfe-dev"<cfe-dev@cs.uiuc.edu>; <wbr></div><div><b>Subject: </b> Re: [cfe-dev] check an AST node's parent node ?</div></div><div><br></div>On 8 January 2013 16:48, kevinlynx <kevinlynx@gmail.com> wrote:<br>> In my coding standard checking tool, it limits comma expression usage,<br>> except in a for statment, i.e:<br>><br>>     x++, x+=1; // this will be marked as invalid usage<br>>     for (x = 0, y = 0; ...) // but this comma expression is valid<br>><br>> I can implement `VisitBinComma`, this function will be called when parsed<br>> comma expression. But how to know if this comma expression is in a for<br>> statment ?<br><br>The simplest way is to implement TraverseForStmt, and set a flag to<br>indicate you are within a for statement.<br><br>Another option may be to use a ParentMap<br>(http://clang.llvm.org/doxygen/classclang_1_1ParentMap.html). I<br>haven't experimented with it yet though.<br><br>><br>> Thanks.<br>><br>><br>> _______________________________________________<br>> cfe-dev mailing list<br>> cfe-dev@cs.uiuc.edu<br>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br>><br></div>