[cfe-dev] Normalizing the AST across languages

Argiris Kirtzidis akyrtzi at gmail.com
Thu Oct 30 18:20:45 PDT 2008


Doug Gregor wrote:
> I'm concerned that putting the instance fields into one place and the
> rest of the members into another place will complicate name lookup.
> For example,
>
> struct C {
>   enum type { };
>   char type;
> };
>
> We've already taught the IdentifierResolver to deal with these cases
> appropriately, but if the first and second "type" declarations end up
> in different places in the AST, we'll end up doing two name lookups
> for each name, one through members and one through
>   

The problem is not actually 2 name lookups of the same name; both the 
field and nested type in your example can be treated uniformly and can 
be found by just the IdentifierResolver.
This is because IdentifierResolver doesn't actually go through the 
DeclContext declaration chain but, rather, it maintains its own data 
structures for optimized lookup.

The problem is having to check first whether 'struct C' is a C-like 
struct or a C++ class, so that the right name lookup is performed, 
through the getMember or through the IdentifierResolver respectively.
It will certainly complicate things.

> I'm really starting to like the idea of just making FieldDecls into
> ScopedDecls, and having the DeclContext associated with RecordType
> store all of the declarations for name lookup. Auxiliary information
> not found through normal lookup (base classes, constructors, etc.)
> could still go into a CXXRecordDefInfo, of course. Does that seem
> feasible to you?
>   

Well, I love the idea, but Chris will probably freak out when he sees 
the FieldDecls getting bigger :-)

-Argiris




More information about the cfe-dev mailing list