[cfe-dev] getting info about fields in a RecursiveASTVisitor::VisitFieldDecl override

Manuel Klimek klimek at google.com
Sun Dec 2 09:21:05 PST 2012


On Sat, Dec 1, 2012 at 1:09 AM, Peeter Joot <peeter.joot at gmail.com> wrote:

> I've answered part of my own question, by grepping the clang source tree
> for ArrayTypeLoc, and found I can do something like:
>
>
>       TypeLoc TL = t->getTypeLoc() ;
>
>       // don't care if it's an array, just want the basic underlying type
> of the array.
>       if ( const ArrayTypeLoc *Arr = dyn_cast<ArrayTypeLoc>(&TL) )
>       {
>          TL = Arr->getElementLoc() ;
>       }
>
> Am guessing I can probably do something similar to see if the type is a
> pointer or reference.
>
> Is there any easy way to determine if the underlying type is one of the
> fundamental types: char, short, int, long (not caring about
> sign/const/volatile/... variations of these)?
>

Is you need to drill through the layers until you hit a BuiltinType...

Cheers,
/Manuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121202/faf7c996/attachment.html>


More information about the cfe-dev mailing list