[cfe-dev] [Patch] IDNS_NoLookup?

Douglas Gregor dgregor at apple.com
Sun Jan 18 17:02:58 PST 2009


Hi Piotr,

On Jan 14, 2009, at 12:17 PM, Piotr Rak wrote:
> I would like to introduce new identifier namespace, which would cause
> ScopedDecl not be added to DeclContext lookup structure. Currently it
> IdentifierResolver saves us somehow from building lookup structure for
> TranslationUnit, however, as i mentioned few weeks earlier I store
> using-directives in lookup structure. This causes it to be build for
> TranslationUnitDecl too in my local copy.

using-directives won't have names, right? So it doesn't really matter  
that they won't have any identifier namespace defined for them.

> This fails for
> ObjCImplementation (there might be more somewhere in ObjC code, not
> really sure...), which has associated name but getIdentifierNamespace
> is not defined for it. I could probably workaround it, but this way
> feels `less hackish`. Please note that this change also saves from
> crash client code, that would call TranslationUnitDecl::lookup(), when
> it owns ObjCImplementationDecls.
>

Ah, so that's the issue... the ObjCImplementationDecls need to have an  
identifier namespace, because they have  name, but they aren't  
supposed to be found by name lookup (rather, we see them through the  
ObjCInterfaceDecl).

Adding another namespace will work, but I don't know if it's the best  
answer. Perhaps what we really mean is that ObjCImplementationDecls  
really don't have names at all: they're just unnamed entities that  
attach to other entities, and the only reason they have a name in the  
source code is to tie them to the appropriate interface:

@interface Blah
@end

@implementation Blah /* ties this ObjCImplementationDecl to the  
ObjCInterfaceDecl above */
@end

One could certainly ask an ObjCImplementationDecl what the name of its  
corresponding interface is, through a separate operation, even though  
the ObjCImplementationDecl itself is unnamed.

I'm not quite sure which way to go with this. IDNS_NoLookup works, but  
I think an unnamed ObjCImplementationDecl will be better. Let's see if  
someone with a better understanding of Objective-C semantics can chime  
in to see if my understanding of ObjCImplementationDecl is reasonable.

	- Doug



More information about the cfe-dev mailing list