<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Thanks for reply,<br>              Given an EnumConstantDecl(E::e1) and DeclStmt( E eVar1 = ec1;), how to find that the DeclStmt covers the EnumConstantDecl.<br><br>--- On <b>Fri, 3/4/11, Douglas Gregor <i><dgregor@apple.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Douglas Gregor <dgregor@apple.com><br>Subject: Re: [cfe-dev] AST structrue of enums in clang<br>To: "Talespin Kit" <talespin_kit@yahoo.com><br>Cc: cfe-dev@cs.uiuc.edu<br>Date: Friday, March 4, 2011, 3:22 PM<br><br><div id="yiv1122945531"><br><div><div>On Mar 4, 2011, at 3:31 AM, Talespin Kit wrote:</div><br class="yiv1122945531Apple-interchange-newline"><blockquote type="cite"><table style="" border="0" cellpadding="0"
 cellspacing="0"><tbody><tr><td style="font: inherit;" valign="top"><div>Assume the follwing code</div>
<div> </div>
<div>class A</div>
<div>{</div>
<div>    public:</div>
<div>        enum E { // E is EnumDecl</div>
<div>                        ec1,  // EnumConstantDecl</div>
<div>                        ec2</div>
<div>                   };</div>
<div> </div>
<div>       void foo()</div>
<div>       {</div>
<div>               E eVar = ec1; // this is a DeclStmt, but what is the type of eVar and ec1?</div>
<div>       }</div>
<div>};</div>
<div> </div>
<div>In the above code we know that the line E eVar = ec1; is a DeclStmt. What are the subcomponents of that.</div>
<div> </div>
<div>What is the type of ec1?.</div>
<div> </div></td></tr></tbody></table>

      _______________________________________________<br></blockquote><div><table style="" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font: inherit;" valign="top"><div><br></div><div><br></div></td></tr></tbody></table></div></div>The AST dump is a good way to see this information:<div><br></div><div><div>$ clang -cc1 -ast-dump t3.cpp </div><div>typedef __int128_t __int128_t;</div><div>typedef __uint128_t __uint128_t;</div><div>struct __va_list_tag {</div><div>    struct __va_list_tag;</div><div>    unsigned int gp_offset;</div><div>    unsigned int fp_offset;</div><div>    void *overflow_arg_area;</div><div>    void *reg_save_area;</div><div>};</div><div>typedef struct __va_list_tag __va_list_tag;</div><div>typedef __va_list_tag __builtin_va_list[1];</div><div>class A {</div><div>    class A;</div><div>public:</div><div>  
  enum E {</div><div>        ec1,</div><div>        ec2</div><div>    };</div><div>    void foo() (CompoundStmt 0x101843320 <t3.cpp:10:8, line:12:8></div><div>  (DeclStmt 0x101843300 <line:11:16, col:28></div><div>    0x101843280 "A::E eVar =</div><div>      (DeclRefExpr 0x1018432d0 <col:25> 'enum A::E' EnumConstant='ec1' 0x1018430f0)"))</div><div><br></div><div><br></div><div>};</div></div><div><br></div><div><span class="yiv1122945531Apple-tab-span" style="white-space: pre;">      </span>- Doug</div></div></blockquote></td></tr></table><br>