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

Steve Naroff snaroff at apple.com
Fri Dec 7 12:41:14 PST 2007


Author: snaroff
Date: Fri Dec  7 14:41:14 2007
New Revision: 44682

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


Modified:
    cfe/trunk/Sema/SemaExpr.cpp

Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=44682&r1=44681&r2=44682&view=diff

==============================================================================
--- 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;
     }
     if (!Method) {
       Diag(lbrac, diag::warn_method_not_found, std::string("-"), Sel.getName(),





More information about the cfe-commits mailing list