[cfe-dev] [PATCH]: Preparing AST for C++ declarations

Eli Friedman eli.friedman at gmail.com
Wed Jun 4 12:49:47 PDT 2008

On Wed, Jun 4, 2008 at 12:39 PM, Argiris Kirtzidis <akyrtzi at gmail.com> wrote:
> Eli Friedman wrote:
>> [...]
>>>> The instance fields of CXXRecord are stored in the members array of
>>>> RecordDecl, thus the data layout of CXXRecord is calculated through the
>>>> Record.
>>>> All the other members (including the static fields), are ScopedDecls
>>>> with
>>>> the CXXRecord as declaration context, so they can be iterated through a
>>>> general DeclContext member iterator (not implemented yet).
>>>> Name lookup for class members will be efficient through the use of the
>>>> IdentifierResolver.
>>> The Nth member (as "getMember(N)") will be the Nth instance field of a
>>> specific Record. It seems to me that it makes sense even when inheritance
>>> comes into the picture, do you disagree ?
>> The issue is the following: class B inherits from class A.  class A
>> has a member x.  Is x accessible through getMember(N)?  If so, how do
>> you figure out the ownership of a FieldDecl once it's in the
>> RecordDecl?
> The way I see it, getMember() will only return the instance fields of class
> B. When in C++, name lookup for members will be done through
> IdentifierResolver, not RecordDecl::getMember(IdentifierInfo *)

That works, I guess.  And I suppose CodeGen and other similar users
will have to look up the inheritance tree to come up with the right
layout anyway.


More information about the cfe-dev mailing list