[cfe-dev] Normalizing the AST across languages

Doug Gregor doug.gregor at gmail.com
Thu Oct 30 16:04:39 PDT 2008


On Thu, Oct 30, 2008 at 7:02 PM, Chris Lattner <clattner at apple.com> wrote:
> On Oct 30, 2008, at 12:52 PM, Doug Gregor wrote:
>>>>
>>>> The intent of CXXRecordDecl is clear: since C++ requires us to keep
>>>> additional information about classes in the AST (which isn't needed in
>>>> C), all that extra information goes into CXXRecordDecl so that we
>>>> don't bloat the C compilation with unused data.  This means that
>>>> compiling a C program as C++ uses different ASTs and requires more
>>>> memory.
>>>
>>> Right, this is something I asked Argiris to do.  The intent was for "C
>>> like"
>>> struct definitions in C++ to use the lighter weight RecordDecl when
>>> possible
>>> (which is what the fixme is about).
>>
>> I don't see how it can work. The problem is that we need to allocate
>> the RecordDecl as soon as we see the "struct Blah". After we've done
>> that, we can't go back and make it into a CXXRecordDecl if we then
>> find out that it has friend declarations.
>
> Yep, this is a very good point.  Perhaps Argiris' suggestion of making *all*
> instance variables be a separate allocation from the decl would help?

Yeah, this I really like. It makes forward declarations relatively
cheap, and we can still keep C and simple C++ structs smaller than
full-fledged C++ structs.

  - Doug



More information about the cfe-dev mailing list