[cfe-dev] Name lookup in ObjC methods

Chris Lattner clattner at apple.com
Sun Mar 30 17:40:00 PDT 2008

On Mar 21, 2008, at 4:53 AM, Argiris Kirtzidis wrote:
> Chris Lattner wrote:
>>>> int foo::test2(q r) {
>>>>  return X+r;
>>>> }
>>> This is actually quite tricky, because clang currently assumes  
>>> that a
>>> declaration can be "found"
>>> only by using an identifier (support for '::' in "foo::test2"  
>>> needed),
>>> and for name lookup it
>>> assumes that the declaration is accessible at the current scope or
>>> at an
>>> enclosing scope of the
>>> current one (support for resolving X in "return X+r;" needed).
>> It's not that bad, we already handle it for instance variables in  
>> ObjC.
> Actually, name lookup in ObjC methods is not working correctly. For  
> example:

You're right.  I fixed the logic of this in this patch:

Thanks a lot for noticing this!

> I'm not familiar with Objective C, but isn't it supposed to pick up  
> the
> 'x' instance variable instead of the global one ?

Yes, absolutely.

There are two remaining issues listed in the patch, the first is an  
internal objc implementation detail (making the AST more consistent  
with the code by eliminating implicit 'self->'s).

The second is more interesting for your namespace patch.  I think we  
really do need an AST-side concept of "scope", which is similar to the  
parser one, but is also a bit different.  This would allow the  
implementation of ScopedDecl::isDefinedOutsideFunctionOrMethod to  
correctly handle typedefs defined inside functions etc.

I'll follow up after catching up on your namespace patch.


More information about the cfe-dev mailing list