<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Thanks for the reply Doug!<br><br>I have following situation, I have a variable T of class Type which is the type of the array size expression.<br><br>My function progress following way.<br>ArrayType *AT = dyn_cast<ArrayType>(T);<br>if (VariableArrayType::classof(AT)<br> ......................<br>else if (ConstantArrayType::classof(AT) {<br> ConstantArrayType *CAT = cast<ConstantArrayType>(AT);<br>}<br><br>For the structure field the type will be ConstantArrayType. Can you tell me how I can get TypeSourceInfo from it.<br><br>Thanks,<br>Murat<br><br><br>--- On <b>Mon, 8/23/10, 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] Array with
size of an Enum Constant<br>To: "Murat B" <murat8307@yahoo.com><br>Cc: cfe-dev@cs.uiuc.edu<br>Date: Monday, August 23, 2010, 10:47 AM<br><br><div id="yiv1400542699"><br><div><div>On Aug 18, 2010, at 10:55 AM, Murat B wrote:</div><br class="yiv1400542699Apple-interchange-newline"><blockquote type="cite"><table style="" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font: inherit;" valign="top">Dear all,<br><br>I have an enum declaration and a structure declaration of following kind:<br><br>typedef enum<br>{<br> BITS_HEADER,<br> BITS_TOTAL_MB,<br> BITS_MB_MODE,<br> BITS_INTER_MB,<br> BITS_CBP_MB,<br> BITS_COEFF_Y_MB,<br> BITS_COEFF_UV_MB,<br> BITS_DELTA_QUANT_MB,<br> MAX_BITCOUNTER_MB<br>} BitCountType;<br><br>typedef struct macroblock<br>{<br> ....... <br> int bitcounter[MAX_BITCOUNTER_MB];<br> .......<br>} Macroblock;<br><br>In my clang plugin, the type of
the field bitcounter is shown as ConstantArrayType of size 8.<br><br>Is there a way to determine that the size of this array is MAX_BITCOUNTER_MB and not 8, so I can make this structure dependent to the enum.<br></td></tr></tbody></table></blockquote></div><br><div>Get the TypeSourceInfo (and, then, the TypeLoc) of the field. From there, you can find the actual size expression as written in the source code. It will be a DeclRefExpr pointing to the enumerator.</div><div><br></div><div><span class="yiv1400542699Apple-tab-span" style="white-space: pre;"> </span>- Doug</div></div></blockquote></td></tr></table><br>