[cfe-dev] printing name of owning anonymous structure in RecursiveASTVisitor::VisitFieldDecl?
Yang Chen
chenyang at cs.utah.edu
Tue Dec 11 13:03:12 PST 2012
Peeter Joot wrote:
> Thanks Yang,
>
> That works nicely.
>
> However, any idea why this test attempt doesn't correctly identify the
> anonymous nature of the type:
>
> string s ;
> if ( r->isAnonymousStructOrUnion() )
> {
> const Type * RT = r->getTypeForDecl() ;
> QualType QT = RT->getCanonicalTypeInternal() ;
>
> s = QT.getAsString() ;
> }
> else
> {
> s = r->getName().str() ;
> }
>
> I can work around this by using the following instead:
>
> string s = r->getName().str() ;
> if ( "" == s )
> // else removed.
>
> but it seems like an odd thing to do (try to format the object as a
> string to test an attribute).
>
> Peeter
>
I am sorry I don't know the reason. Maybe others have better ideas on it.
- Yang
More information about the cfe-dev
mailing list