[cfe-dev] Transform Enum constants in the source to their integral values

Manasij Mukherjee manasij7479 at gmail.com
Wed Aug 6 23:47:14 PDT 2014


That makes sense.
How do I get the value of 'One' from the VarDecl.
I ultimately want to do:
Enum e = 0; // if the enum constant One is defaulted to 0



On Thu, Aug 7, 2014 at 5:14 AM, Nikola Smiljanic <popizdeh at gmail.com> wrote:

> enum Enum { One, Two };
> Enum e = One;
>
> 'One' and 'Two' are EnumConstantDecls but 'e' is a VarDecl whose type is
> Enum (EnumType).
>
>
>
> On Thu, Aug 7, 2014 at 5:37 AM, Manasij Mukherjee <manasij7479 at gmail.com>
> wrote:
>
>> Hi,
>> I want to transform a source file so that Enum constants are replaced by
>> their respective integral values.
>> More specifically, this should work on variable initializations and
>> function or template default argument values.
>>
>> I can obtain a VarDecl for functions and variables and a
>> NonTypeTemplateParmDecl for the templates.
>> (By using DeclVisitor)
>>
>> How can I detect if these represent Enum Constants ?
>> And then get their value, possibly.
>>
>> I tried implementing VisitEnumConstantDecl, but that doesn't seem to get
>> called for these cases.
>>
>> Thanks,
>> Manasij Mukherjee
>>
>>
>> _______________________________________________
>> 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/20140807/b8aed3ac/attachment.html>


More information about the cfe-dev mailing list