<div dir="ltr">Hi,<div><br></div><div style>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()</div><div style>I implemented this myself just few days ago (if you want to take a look: <a href="https://github.com/lukedirtwalker/Envision/blob/cppimport/CppImport/src/ClangAstVisitor.cpp#L321">https://github.com/lukedirtwalker/Envision/blob/cppimport/CppImport/src/ClangAstVisitor.cpp#L321</a> )</div>
<div style><br></div><div style>Cheers</div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/4/20 Gábor Kozár <span dir="ltr"><<a href="mailto:kozargabor@gmail.com" target="_blank">kozargabor@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi,<br></div><div><br></div><div>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.</div>


<div><br></div><div>Also consult the documentation for EnumDecl and EnumConstantDecl types:</div><div><a href="http://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html</a></div>


<div><a href="http://clang.llvm.org/doxygen/classclang_1_1EnumConstantDecl.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1EnumConstantDecl.html</a></div><div><br></div><div>Hope this helps!</div><div><br>
</div><div>Gabor</div>

</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">2013/4/18 steveneliuk <span dir="ltr"><<a href="mailto:s.eliuk@sisa.samsung.com" target="_blank">s.eliuk@sisa.samsung.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi there,<br>
<br>
There are various implemented visit*() statements in myRecursiveASTVisitor()<br>
and I am looking for a way to obtain the actual enum name before it is<br>
converted to a value. The value works fine for Source-to-Source translation<br>
but some have complained because it is not as easy to read. I guess it is a<br>
MacroID and therefore is not contained in the original source. I can think<br>
of many laborious ways to obtain this but I know there has to be a built in<br>
function to obtain the name,<br>
<br>
ie)<br>
cl_device_type CL_DEVICE_TYPE_ALL has a value of 4294967295U, but I need<br>
CL_DEVICE_TYPE_ALL to keep the translation easy to read.<br>
<br>
Any advice would be appreciated!!!<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://clang-developers.42468.n3.nabble.com/Expr-walk-up-Looking-for-Enum-name-not-value-tp4031582.html" target="_blank">http://clang-developers.42468.n3.nabble.com/Expr-walk-up-Looking-for-Enum-name-not-value-tp4031582.html</a><br>



Sent from the Clang Developers mailing list archive at Nabble.com.<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>