Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] C Structure fields analysis

It depends on what do you want to do next.

If you are interested in some sort of a data model for this struct, analyzing ICPPClassType as mentioned below is preferable (since all necessary semantic analysis is already performed).
If you, for some reason, still need AST-level stuff (e.g., you want to reorder field declarations somehow), you need to look into individual declarators for each member declaration.

On Wed, Jun 18, 2014 at 9:38 PM, Nathan Ridge <zeratul976@xxxxxxxxxxx> wrote:
> For each member I want to know the name, the type,
> if it is an array (in that case the size) and if it is a pointer.
> But I don't see how to retrieve those informations from
> a CASTSimpleDeclaration instance.

Once you have the IASTCompositeTypeSpecifier, you can
get the struct's name from it (getName()), and call
resolveBinding() on it to get an ICPPClassType. I believe
that has a getFields() method which returns an IField[],
and IField has a getType() method.

Hope that helps,

cdt-dev mailing list

Back to the top