[cfe-dev] Canonical representation of declaration names

Doug Gregor doug.gregor at gmail.com
Fri Nov 14 12:15:15 PST 2008


On Fri, Nov 14, 2008 at 2:48 PM, Chris Lattner <clattner at apple.com> wrote:
> On Nov 13, 2008, at 10:00 AM, Doug Gregor wrote:
>> Known Issues
>> ==========
>> There's a small layering violation in DeclarationName. DeclarationName
>> lives in the AST, because that's where it makes sense to talk about
>> the name of a declaration as a more abstract entity. However,
>> DeclarationNameExtras and Selector live in Basic, because Selector is
>> used in the Parse-Sema interaction and Selector's internal
>> implementation depends on DeclarationNameExtras.
>
> I'm missing something: how is that a layering violation?  From your
> description, it sounds like Sema will depend on Basic.  That is ok, but
> basic can't depend on sema.

The layering violation is that something in Basic declares a friend
that is in Sema, but it's admittedly a very weak form of Basic->Sema
dependency.

>> We could move DeclarationName into Basic and make the QualType stored
>> by a C++ constructor/destructor/conversion function into an opaque
>> type pointer, but that seems wrong somehow. Maybe the real issue is
>> that Selector doesn't belong in Basic.
>
> I'd be open to moving Selector up the stack, but this will impact ObjC
> actions callbacks that really do want to pass around selectors (iirc).
>  Another options is to introduce a parser-level abstraction similar to
> declspec if that were needed.  There are some other less appetizing options
> as well if this is a real problem.

One option would be to move DeclarationName to Basic and use it to
completely replace Selector. Then everything that can name a
declaration will use a single class type, across all languages.

  - Doug



More information about the cfe-dev mailing list