aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExprObjC.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-03-04 17:50:39 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-03-04 17:50:39 +0000
commitb1006c7f5647025541b1b1cc64a196a417e6c6ac (patch)
tree356d5a29f28e237511611e9f869342fd2a20607a /lib/Sema/SemaExprObjC.cpp
parent3f75c43bd77e063342bc888ac276daf64ba0ce07 (diff)
Fix a corner case of message lookup looking for class methods.
If all else failed, find the message in class's root's list of instacne methods! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66040 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprObjC.cpp')
-rw-r--r--lib/Sema/SemaExprObjC.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 8705baffcb..80120a7b7a 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -314,8 +314,14 @@ Sema::ExprResult Sema::ActOnClassMessage(
Method = LookupPrivateMethod(Sel, ClassDecl);
// Before we give up, check if the selector is an instance method.
- if (!Method)
- Method = ClassDecl->lookupInstanceMethod(Sel);
+ // But only in the root. This matches gcc's behaviour and what the
+ // runtime expects.
+ if (!Method) {
+ ObjCInterfaceDecl *Root = ClassDecl;
+ while (Root->getSuperClass())
+ Root = Root->getSuperClass();
+ Method = Root->lookupInstanceMethod(Sel);
+ }
if (Method && DiagnoseUseOfDecl(Method, receiverLoc))
return true;
@@ -400,6 +406,15 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
if (!Method)
Method = LookupPrivateMethod(Sel, ClassDecl);
+ // Before we give up, check if the selector is an instance method.
+ // But only in the root. This matches gcc's behaviour and what the
+ // runtime expects.
+ if (!Method) {
+ ObjCInterfaceDecl *Root = ClassDecl;
+ while (Root->getSuperClass())
+ Root = Root->getSuperClass();
+ Method = Root->lookupInstanceMethod(Sel);
+ }
}
if (Method && DiagnoseUseOfDecl(Method, receiverLoc))
return true;
@@ -408,9 +423,12 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
// If not messaging 'self', look for any factory method named 'Sel'.
if (!isSelfExpr(RExpr)) {
Method = FactoryMethodPool[Sel].Method;
- if (!Method)
+ if (!Method) {
Method = LookupInstanceMethodInGlobalPool(
Sel, SourceRange(lbrac,rbrac));
+ if (Method)
+ Diag(receiverLoc, diag::warn_maynot_respond) << Sel;
+ }
}
}
if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, false,