[cfe-dev] Getting a field's access class
Douglas Gregor
dgregor at apple.com
Mon Aug 9 15:51:43 PDT 2010
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
More information about the cfe-dev
mailing list