[cfe-dev] How to find all class-member-variables
Peeter Joot
peeter.joot at gmail.com
Mon Dec 17 08:35:01 PST 2012
Here's one way:
// Member's within class/struct/union:
bool VisitFieldDecl( FieldDecl * f )
{
RecordDecl * r = f->getParent() ;
const QualType & theMembersClassType = context.getRecordType( r ) ;
TypeSourceInfo * pThisFieldSourceInfo = f->getTypeSourceInfo() ;
TypeLoc thisFieldTypeLoc =
pThisFieldSourceInfo->getTypeLoc() ;
const QualType & thisFieldQualType = thisFieldTypeLoc.getType() ;
cout
<< theMembersClassType.getAsString()
<< " : " << thisFieldQualType.getAsString() << endl ;
return true ;
}
--
Peeter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121217/678c2658/attachment.html>
More information about the cfe-dev
mailing list