[cfe-dev] Normalizing the AST across languages

Doug Gregor doug.gregor at gmail.com
Thu Oct 30 17:09:33 PDT 2008

On Thu, Oct 30, 2008 at 7:07 PM, Chris Lattner <clattner at apple.com> wrote:
> 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.

It could certainly make things more uniform, because
RecordDecl::getMember can be replaced with a lookup into DeclContext.
Actually, maybe we just want all of the kinds of members to be
ScopedDecls stored within the DeclContext. That way there's only a
single lookup mechanism to implement (and optimize).

  - Doug

More information about the cfe-dev mailing list