[cfe-dev] check an AST node's parent node ?
kevinlynx
kevinlynx at gmail.com
Tue Jan 8 00:10:22 PST 2013
Thanks, I use TraverseForStmt to solve this problem. And this makes me know TraverseXXX methods better.
------------------ Original ------------------
From: "Philip Craig"<philipjcraig at gmail.com>;
Date: Tue, Jan 8, 2013 03:47 PM
To: "kevinlynx"<kevinlynx at gmail.com>;
Cc: "cfe-dev"<cfe-dev at cs.uiuc.edu>;
Subject: Re: [cfe-dev] check an AST node's parent node ?
On 8 January 2013 16:48, kevinlynx <kevinlynx at gmail.com> wrote:
> In my coding standard checking tool, it limits comma expression usage,
> except in a for statment, i.e:
>
> x++, x+=1; // this will be marked as invalid usage
> for (x = 0, y = 0; ...) // but this comma expression is valid
>
> I can implement `VisitBinComma`, this function will be called when parsed
> comma expression. But how to know if this comma expression is in a for
> statment ?
The simplest way is to implement TraverseForStmt, and set a flag to
indicate you are within a for statement.
Another option may be to use a ParentMap
(http://clang.llvm.org/doxygen/classclang_1_1ParentMap.html). I
haven't experimented with it yet though.
>
> Thanks.
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130108/8f23e1e3/attachment.html>
More information about the cfe-dev
mailing list