[cfe-dev] Expr walk up? Looking for Enum name not value?
lukedirtwalkerdev at gmail.com
Sun Apr 21 02:15:18 PDT 2013
If you use VisitEnumDecl(ed) you can use an iterator to loop over all
EnumConstantDecl and from those you can get the name with getNameAsString()
I implemented this myself just few days ago (if you want to take a look:
2013/4/20 Gábor Kozár <kozargabor at gmail.com>
> If I understand your problem correctly, what you need is to look for
> typecasts (e.g. ImplicitCast) where the source type is an enum. I actually
> do not know how enum values appear in the AST, i.e. whether they are
> expanded to their values, but I'm assuming that they are not: in this case
> the typecast AST node probably has an EnumConstantDecl as a child
> (somewhere below an Expr), which you should be able to find without too
> much of an issue, and it will give you the information you need. Try
> dumping some example code (using enums) AST to figure out what is it you
> exactly need to do.
> Also consult the documentation for EnumDecl and EnumConstantDecl types:
> Hope this helps!
> 2013/4/18 steveneliuk <s.eliuk at sisa.samsung.com>
>> Hi there,
>> There are various implemented visit*() statements in
>> and I am looking for a way to obtain the actual enum name before it is
>> converted to a value. The value works fine for Source-to-Source
>> but some have complained because it is not as easy to read. I guess it is
>> MacroID and therefore is not contained in the original source. I can think
>> of many laborious ways to obtain this but I know there has to be a built
>> function to obtain the name,
>> cl_device_type CL_DEVICE_TYPE_ALL has a value of 4294967295U, but I need
>> CL_DEVICE_TYPE_ALL to keep the translation easy to read.
>> Any advice would be appreciated!!!
>> View this message in context:
>> Sent from the Clang Developers mailing list archive at Nabble.com.
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev