Getting a field's access class

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting a field's access class

chris nuernberger
Hey all,

Phase two of what I am doing is starting.

Given a c++ record in clang, I need to get whether it is public or
not.  Is this done using the linkage member?

I will also need to, given an enumeration, get the names and the
values of the enumeration type.  Given a field's type, how do I get to
the enumeration declaration?

Chris

--
A foolish consistency is the hobgoblin of little minds - Emerson
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting a field's access class

Douglas Gregor

On Aug 9, 2010, at 3:11 PM, chris nuernberger wrote:

> Hey all,
>
> Phase two of what I am doing is starting.
>
> Given a c++ record in clang, I need to get whether it is public or
> not.  Is this done using the linkage member?
>

Decl::getAccess()

> I will also need to, given an enumeration, get the names and the
> values of the enumeration type.  

Use EnumType::getDecl() to get to the EnumDecl, then EnumDecl::enumerator_begin()/EnumDecl::enumerator_end() to iterate over the enumerators, each of which has a name and a value.

> Given a field's type, how do I get to
> the enumeration declaration?


FieldDecl is a ValueDecl, which has ValueDecl::getType(). Then use ->getAs<EnumType>() to see if it has enumeration type.

        - Doug
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev