[cfe-dev] AST representation constant time arrays defined with enums

chris nuernberger cnuernber at gmail.com
Mon Mar 14 13:05:07 PDT 2011


I am using clang to do some code generation and one thing that is
tripping me up is a pattern like:

struct ArrayMembers
{
enum Enum
{
First,
Second,
Third,
Count,
};
};

struct GenericData
{
int NamedArray[ArrayMembers::Count];
};

>From the AST, I get that the array is a statically-sized array of
length 3.  This works fine.  I can't get that that 3 was derived from
the ArrayMembers::Count declaration.

This is useful for something that analyzes code because people use
this system to give the entries in the array names that are
meaningful.  I lose those meanings right now perhaps because I don't
understand clang's AST very well.

Is there a way from the array declaration in the clang AST can I
figure out 1.  If it was declared using an enumeration value and 2.
what enumeration that value came from?

Chris

-- 
A foolish consistency is the hobgoblin of little minds - Emerson



More information about the cfe-dev mailing list