[cfe-dev] check an AST node's parent node ?

kevinlynx kevinlynx at gmail.com
Tue Jan 8 17:42:48 PST 2013


> Careful with this; the body of a for-statement is also within the for statement:
>

> for (int i = 0; i < 10; ++i) {
>   ++i, --i;
> }

Thanks. To solve this problem, i implement TraverseForStmt below:
   
     virtual bool TraverseForStmt(ForStmt *s) {
        if (!WalkUpFromForStmt(s))
            return false;
        m_inForLine = true;
        for (Stmt::child_range range = s->children(); range; ++range) {
            if (*range == s->getBody())
                m_inForLine = false;
            TraverseStmt(*range);
        }
        return true;
    }




------------------ Original ------------------
From:  "Jordan Rose"<jordan_rose at apple.com>;
Date:  Wed, Jan 9, 2013 01:31 AM
Thanks.



To:  "kevinlynx"<kevinlynx at gmail.com>; 
Cc:  "Philip Craig"<philipjcraig at gmail.com>; "cfe-dev"<cfe-dev at cs.uiuc.edu>; 
Subject:  Re: [cfe-dev] check an AST node's parent node ?



Careful with this; the body of a for-statement is also within the for statement:


for (int i = 0; i < 10; ++i) {
  ++i, --i;
}


Not familiar with the RecursiveASTVisitor traversal, so I can't tell you exactly how to do it. Maybe you already got this correct.


Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130109/1b6ce819/attachment.html>


More information about the cfe-dev mailing list