[cfe-commits] r44682 - /cfe/trunk/Sema/SemaExpr.cpp

PARIBORZ JAHANIAN fjahanian at apple.com
Sat Dec 8 14:48:56 PST 2007


On Dec 8, 2007, at 11:58 AM, Chris Lattner wrote:

>> URL: http://llvm.org/viewvc/llvm-project?rev=44682&view=rev
>> Log:
>>
>> Lookup methods in the global pool even when a statically typed
>> object's class interface isn't in scope!
>> As the comment in the code indicates, I'm not fond of this.
>> Nevertheless, gcc compat is a goal.
>> Here is the case I'm talking about...
>>
>> #import <Foundation/Foundation.h>
>>
>> @interface AnyClass : NSObject
>> - (NSRect)rect;
>> @end
>>
>> @class Helicopter;
>>
>> static void func(Helicopter *obj) {
>> NSRect r = [obj rect];
>> }
>>
>> ..before this patch, we would warn/error. With this patch,
>> everything "just works".
>
> Yuck :).  Please add this to the testsuite.
>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- cfe/trunk/Sema/SemaExpr.cpp (original)
>> +++ cfe/trunk/Sema/SemaExpr.cpp Fri Dec  7 14:41:14 2007
>> @@ -2245,6 +2245,10 @@
>>      if (ObjcImplementationDecl *ImpDecl =
>>            ObjcImplementations[ClassDecl->getIdentifier()])
>>        Method = ImpDecl->lookupInstanceMethod(Sel);
>> +	  // If we still haven't found a method, look in the global pool.
>> +	  // I am not fond of this behavior, however we conform to what
>> gcc does.
>> +	  if (!Method)
>> +	    Method = InstanceMethodPool[Sel].Method;
>
> Generally, please avoid the first person in comments: "This behavior
> isn't very desirable, however we need it for GCC compatibility."

I think I can find a radar somewhere in my queue that user is annoyed  
by this gcc behavior and expect at least a warning.

- fj

>
>
> Thanks!
>
> -Chris
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list