[cfe-dev] [Patch] IDNS_NoLookup?

Fariborz Jahanian fjahanian at apple.com
Mon Jan 19 09:42:40 PST 2009


On Jan 18, 2009, at 5:02 PM, Douglas Gregor wrote:

> 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.

There are couple of situations that @implementation is not tied to its  
interface;
  case of an @implementation without an interface
case of a category @implementation which ties it to its category even  
though
there must be an interface as well. But this case need go though  
ObjCCategoryDecl
(which then has the ObjCInterfaceDecl). There might  be other corner  
cases that I cannot
recall at this time.

- Fariborz

>
>
> 	- Doug
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list