]> granicus.if.org Git - clang/commitdiff
Lookup methods in the global pool even when a statically typed object's class interfa...
authorSteve Naroff <snaroff@apple.com>
Fri, 7 Dec 2007 20:41:14 +0000 (20:41 +0000)
committerSteve Naroff <snaroff@apple.com>
Fri, 7 Dec 2007 20:41:14 +0000 (20:41 +0000)
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".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44682 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaExpr.cpp

index 56b792eaf58b8f1ac526ad71c17b6eed92dfd227..e7102aa0a2613173b10fc8a3f465f15c560eadd5 100644 (file)
@@ -2245,6 +2245,10 @@ Sema::ExprResult Sema::ActOnInstanceMessage(
       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(),