<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Thanks,<br>       Calling VarDecl::getInit() to retrieve the DeclRefExpr is what i want to know. By the way, "coverage" wheather the enum has been used in the statment(as in code coverage).<br><br>--- On <b>Mon, 3/7/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: Monday, March 7, 2011, 3:03 PM<br><br><div id="yiv98626570">I don't know what you mean by "covers", but if you look at the AST dump<div><br></div><div>  <blockquote type="cite"><table style="" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td
 style="font: inherit;" valign="top"><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><div id="yiv98626570"><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></div></blockquote></td></tr></tbody></table></blockquote><div><div><br></div><div>You can see that that the DeclStmt has the declaration eVar as one of its child nodes, and the initializer of eVar is a DeclRefExpr that points back at the EnumConstantDecl ec1.</div><div><br></div><div><span class="yiv98626570Apple-tab-span" style="white-space: pre;">      </span>- Doug</div><div><br></div><div>On Mar 6, 2011, at 10:44 PM, Talespin Kit wrote:</div><br
 class="yiv98626570Apple-interchange-newline"><blockquote type="cite"><table style="" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font: inherit;" valign="top">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><<a rel="nofollow" ymailto="mailto:dgregor@apple.com" target="_blank" href="/mc/compose?to=dgregor@apple.com">dgregor@apple.com</a>></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Douglas Gregor <<a rel="nofollow" ymailto="mailto:dgregor@apple.com" target="_blank" href="/mc/compose?to=dgregor@apple.com">dgregor@apple.com</a>><br>Subject: Re: [cfe-dev] AST structrue of enums in clang<br>To: "Talespin Kit" <<a
 rel="nofollow" ymailto="mailto:talespin_kit@yahoo.com" target="_blank" href="/mc/compose?to=talespin_kit@yahoo.com">talespin_kit@yahoo.com</a>><br>Cc: <a rel="nofollow" ymailto="mailto:cfe-dev@cs.uiuc.edu" target="_blank" href="/mc/compose?to=cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>Date: Friday, March 4, 2011, 3:22 PM<br><br><div id="yiv98626570"><br><div><div>On Mar 4, 2011, at 3:31 AM, Talespin Kit wrote:</div><br class="yiv98626570Apple-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="yiv98626570Apple-tab-span" style="white-space: pre;">        </span>- Doug</div></div></blockquote></td></tr></tbody></table><br>

      </blockquote></div><br></div></div></blockquote></td></tr></table><br>