[cfe-dev] (no subject)
Peeter Joot
peeter.joot at gmail.com
Tue Dec 18 22:01:08 PST 2012
On Tue, Dec 18, 2012 at 10:04 PM, Eli Friedman <eli.friedman at gmail.com>wrote:
> you can use something like
> T->castAs<RecordType>()->getDecl()->getName() to grab the name of a
> struct/class/union,
>
With the following input:
typedef struct foo
{
unsigned char m;
unsigned char n;
} foo;
typedef struct Foo
{
unsigned char m;
unsigned char n;
} bar;
typedef Foo moo ;
and this AST visitor fragment:
bool VisitTypedefDecl( TypedefDecl * dtDecl )
{
const QualType & qtUnderLying = dtDecl->getUnderlyingType() ;
const Type * tUnderlying = qtUnderLying.getTypePtr() ;
string theUnderlyingType = qtUnderLying.getAsString( ) ;
string typeDefinitionName = dtDecl->getName().str() ;
string * pName = NULL ;
bool ignore = false ;
if ( const RecordType * r = dyn_cast<RecordType>( tUnderlying ) )
{
cout << "RecordType: " << typeDefinitionName << ","<< theUnderlyingType <<
":" << r->getDecl()->getName().str() << endl ;
That RecordType cast is only successful for the moo typedef, giving:
RecordType: moo,struct Foo:Foo
What sort of type would tUnderLying be for the bar and foo typedefs?
--
Peeter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121219/f8c9fb13/attachment.html>
More information about the cfe-dev
mailing list