[cfe-dev] Iterating through an Expression in the Clang AST

David Blaikie dblaikie at gmail.com
Sun Feb 10 08:52:15 PST 2013


On Feb 10, 2013 8:40 AM, "Robert Ankeney" <rrankene at gmail.com> wrote:
>
> You can use if (isa<BinaryOperator>(stmt))  and if true, recast it as
BinaryOperator.

Just as a aide note, we usually write that with a single dyn_cast rather
than isa+cast, to use just one check instead of two.

>  Have a look at the tutorials at:
> https://github.com/loarabia/Clang-tutorial
>
> The CIrewriter.cpp example gives numerous examples of using visitors like
VisitBinaryOperator, handy if you use a recursive AST visitor to walk the
tree.
>
> Robert
>
>> Date: Sat, 9 Feb 2013 19:48:47 -0800 (PST)
>> From: beni <sonaldanak at gmail.com>
>> To: cfe-dev at cs.uiuc.edu
>> Subject: Re: [cfe-dev] Iterating through an Expression in the Clang
>>         AST
>> Message-ID: <1360468127775-4030391.post at n3.nabble.com>
>> Content-Type: text/plain; charset=us-ascii
>>
>>
>> thanks! i used the iterators to iterate through a stmt but how do i check
>> what type the sub statement contains? eg. how do i find out if the sub
>> statement is say, a binary operator?
>>
>
>
> _______________________________________________
> 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/20130210/fc34d76a/attachment.html>


More information about the cfe-dev mailing list