[cfe-dev] How can I foint out if a ValueDecl is an array?

Peeter Joot peeter.joot at gmail.com
Tue Dec 18 18:57:14 PST 2012


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<ArrayTypeLoc>(
&thisFieldTypeLoc ) )
   {
      thisFieldTypeLoc = pTypeLocIfArray->getElementLoc() ;
   }

   return thisFieldTypeLoc.getType() ;
}

to strip off one level of array from a field declaration.  Can you use
something like that?

Peeter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121218/4c2ed5bb/attachment.html>


More information about the cfe-dev mailing list