Skip to main content

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

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)
        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.
    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.

All the best,
Adrien G.

Back to the top