summaryrefslogtreecommitdiffstats
path: root/clang/lib
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
commitc2371eadd628be2815553d7cc8db899bf72806c1 (patch)
tree0fb5fe946de0707b134eaaceeef343ba0005a232 /clang/lib
parent5b15d01ff36a749d839b2ae149a66e91e3fa8ea2 (diff)
downloadbcm5719-llvm-c2371eadd628be2815553d7cc8db899bf72806c1.tar.gz
bcm5719-llvm-c2371eadd628be2815553d7cc8db899bf72806c1.zip
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! llvm-svn: 66040
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExprObjC.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index 8705baffcb6..80120a7b7a4 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/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,
OpenPOWER on IntegriCloud