[cfe-dev] Access specifiers and anonymous unions

John McCall rjmccall at apple.com
Mon May 31 11:42:39 PDT 2010


On May 31, 2010, at 7:21 AM, Abramo Bagnara wrote:

> Il 28/05/2010 19:53, John McCall ha scritto:
>>> 
>>> To represent correctly the above we might decide to have a node for
>>> access specifiers at the same level of other decls.
>> 
>> Yes, I've been wanting something like this for some time.
> 
> Would it be OK if we derive from Decl a new class modeling syntactic
> access specifiers occurring in the list of member specifiers of a C++
> class definition?
> 
> What about the name AccessSpecDecl ?

Decl actually has a lot of space overhead, and if we put these in the decl chain
we have to instantiate them, etc.  If we want to be really space-conserving, we
could just add an array of little structs to CXXRecordDecl::DefinitionData.
On the other hand, that would make them much more difficult to use;  I'm torn.

> Deriving from Decl already provides space for storing the access
> specifier (cannot be AS_none) and the corresponding source location.
> While at it, should we also provide a source location for the ':' ?

Probably not necessary.

> Am I right if I say that all code visiting CXXRecordDecl as a
> declaration context will automatically ignore this new class (which is
> actually a good thing)?

Well, if they were Decls, lookup would ignore them because they wouldn't
be NamedDecls, but they'd still show up in the lexical decl chain.  That's
probably fine.

John.



More information about the cfe-dev mailing list