<div dir="ltr"><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Dec 18, 2012 at 10:04 PM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div id=":5g"> you can use something like<br>
T->castAs<RecordType>()->getDecl()->getName() to grab the name of a<br>
struct/class/union,</div></blockquote></div><br><div class="gmail_extra"><br>With the following input:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">typedef struct foo</div><div class="gmail_extra">
{</div><div class="gmail_extra">   unsigned char m;</div><div class="gmail_extra">   unsigned char n;</div><div class="gmail_extra">} foo;</div><div class="gmail_extra"><br></div><div class="gmail_extra">typedef struct Foo</div>
<div class="gmail_extra">{</div><div class="gmail_extra">   unsigned char m;</div><div class="gmail_extra">   unsigned char n;</div><div class="gmail_extra">} bar;</div><div class="gmail_extra"><br></div><div class="gmail_extra">
typedef Foo moo ;</div><div><br></div><div><br></div><div>and this AST visitor fragment:</div><div><br></div><div><div>   bool VisitTypedefDecl( TypedefDecl * dtDecl )</div><div>   {</div><div>      const QualType &  qtUnderLying         = dtDecl->getUnderlyingType() ;</div>
<div>      const Type *      tUnderlying          = qtUnderLying.getTypePtr() ;</div><div>      string            theUnderlyingType    = qtUnderLying.getAsString( ) ;</div><div>      string            typeDefinitionName   = dtDecl->getName().str() ;</div>
<div>      string *          pName                = NULL ;</div><div>      bool              ignore               = false ;</div><div><br></div><div>      if ( const RecordType * r = dyn_cast<RecordType>( tUnderlying ) )</div>
<div>      {</div><div>cout << "RecordType: " << typeDefinitionName << ","<< theUnderlyingType << ":" << r->getDecl()->getName().str() << endl ;</div>
<div><br></div><div><br></div><div>That RecordType cast is only successful for the moo typedef, giving:</div><div><br></div><div>RecordType: moo,struct Foo:Foo<br></div></div><div><br></div><div>What sort of type would tUnderLying be for the bar and foo typedefs?</div>
<div><br></div></div>-- <br>Peeter<br>
</div></div>