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

On 06/13/2014 11:22 AM, Adrien G wrote:
Hi everyone !

I'm trying to do some analysis of C code, I'm mainly interested in C
structures analysis. But I cant find out how to get all the fields of a
struct.
Indeed I'm getting my Structure object like this:

public int visit(IASTDeclaration node)
{
     if(node instanceof CASTSimpleDeclaration)
     {

Note that also IASTFunctionDefinition can declare a struct (quite uncommon though).

         CASTSimpleDeclaration cnode = (CASTSimpleDeclaration) node;
         IASTCompositeTypeSpecifier type =
(IASTCompositeTypeSpecifier)cnode.getDeclSpecifier();
         if(type.getKey() == IASTCompositeTypeSpecifier.k_struct)
         {
             // Here I want to get all the fields of this struct.

type.getMembers()

         }
     }
     return PROCESS_SKIP; // Tells the visitor to not visit children nodes.
}

Once I get my CASTSimpleDeclaration object, how can I get its members?

Thank you for your advise.

Also I'm wondering if CDT can handle multiple files at once, include
statement and macros ?
Like I'm declaring struct using a macro defined in a file that is included.

Yes.

Hope that helps
Marco

All the best,
Adrien G.


_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev



Back to the top