Hi, please could somebody help me?
I would like to find out if a ValueDecl is an array or not.
Is this possible, and how .....
Thanks, best regards
Fritz Franz
Hi, please could somebody help me?
I would like to find out if a ValueDecl is an array or not.
Is this possible, and how .....
Thanks, best regards
Fritz Franz
I use some code like so:
inline QualType getQualTypeForDecl( DeclaratorDecl * f )
{
TypeSourceInfo * pThisFieldSourceInfo = f->getTypeSourceInfo() ;
TypeLoc thisFieldTypeLoc = pThisFieldSourceInfo->getTypeLoc() ;
// don’t care if it’s an array, just want the basic underlying type of the array.
if ( const ArrayTypeLoc * pTypeLocIfArray = dyn_cast( &thisFieldTypeLoc ) )
{
thisFieldTypeLoc = pTypeLocIfArray->getElementLoc() ;
}
return thisFieldTypeLoc.getType() ;
}
to strip off one level of array from a field declaration. Can you use something like that?
Hmm... that isn't actually checking whether the type of the decl is an
array type; it's checking whether the outermost declarator is an array
declarator. (This makes a difference for e.g. "typedef int T[2]; T
x;", where x is an array but does not have an array declarator.) My
first reaction to "is this decl an array" would be
"VD->getType()->isArrayType()", which checks the actual type. But I
guess both are useful, depending on what you're doing.
-Eli
Thank you very much!