[cfe-dev] Normalizing the AST across languages

Chris Lattner clattner at apple.com
Thu Oct 30 16:07:41 PDT 2008


On Oct 30, 2008, at 4:04 PM, Doug Gregor wrote:

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

Yeah, I think this is the best approach.  By this point you have the  
full definition, and we have to do an allocation *anyway* to hold the  
field pointers.  It should be straight-forward to make it "optionally"  
have the C++ fields or not. The only issue is that RecordDecl will  
unconditionally be a DeclContext, but this is probably a good thing  
for C anyway.

-Chris



More information about the cfe-dev mailing list