[cfe-dev] Normalizing the AST across languages

Argiris Kirtzidis akyrtzi at gmail.com
Thu Oct 30 12:34:30 PDT 2008


Doug Gregor wrote:
> So, here is my suggestion: instead of making a distinction between
> what the two languages support at the AST level, use a single AST node
> (RecordDecl) that has a pointer to an optionally-allocated "extras"
> data structure containing that extra information when we need to store
> it. For RecordDecl, the "extras" structure should definitely have
> information about C++ classes that isn't needed in C and isn't used by
> the majority of C++ classes. For example, base classes, friends,
> user-defined constructors/destructor/copy-assignment operators,  and
> user-defined conversion operators.
>   

It may be beneficial to "pull out" the 'members' fields from RecordDecl 
and put them into a RecordDefInfo, which is like the "extras" structure 
you mention with the purpose of
storing the info about the definition.
Currently there's a new RecordDecl created for each record reference and 
the 'Members' fields is wasted space for them.

After a class definition is parsed, we will know if it's a simple C-like 
struct or not, and we will create a RecordDefInfo or CXXRecordDefInfo 
accordingly (to add to RecordDecl).
RecordDefInfo will keep the instance members, while CXXRecordDefInfo 
will also keep the other C++ specific stuff (base classes, etc.).

-Argiris




More information about the cfe-dev mailing list