aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExprObjC.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-03-03 22:19:15 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-03-03 22:19:15 +0000
commit268bc8c1f3a27d2fbd73c3115e4d633d31422ca5 (patch)
tree49ce5c0faf663644d1afdd119062494d4973ec94 /lib/Sema/SemaExprObjC.cpp
parentf4c00ffdfdaacf0e3f664e5b535191a9efa1443a (diff)
Implement an important missing warning when a selector
is searched for in the global pool. It already uncovered a clang bug in message selection. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65974 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprObjC.cpp')
-rw-r--r--lib/Sema/SemaExprObjC.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 8b452af9e8..39a89d6d94 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -450,16 +450,28 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
}
if (!Method) {
// If we have an implementation in scope, check "private" methods.
- if (ClassDecl)
+ if (ClassDecl) {
if (ObjCImplementationDecl *ImpDecl =
ObjCImplementations[ClassDecl->getIdentifier()])
Method = ImpDecl->getInstanceMethod(Sel);
- // If we still haven't found a method, look in the global pool. This
- // behavior isn't very desirable, however we need it for GCC
- // compatibility. FIXME: should we deviate??
- if (!Method && OCIType->qual_empty())
- Method = LookupInstanceMethodInGlobalPool(
- Sel, SourceRange(lbrac,rbrac));
+ // Look through local category implementations associated with the class.
+ if (!Method) {
+ for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Method; i++) {
+ if (ObjCCategoryImpls[i]->getClassInterface() == ClassDecl)
+ Method = ObjCCategoryImpls[i]->getInstanceMethod(Sel);
+ }
+ }
+ }
+ // If we still haven't found a method, look in the global pool. This
+ // behavior isn't very desirable, however we need it for GCC
+ // compatibility. FIXME: should we deviate??
+ if (!Method && OCIType->qual_empty()) {
+ Method = LookupInstanceMethodInGlobalPool(
+ Sel, SourceRange(lbrac,rbrac));
+ if (Method && !OCIType->getDecl()->isForwardDecl())
+ Diag(lbrac, diag::warn_maynot_respond)
+ << OCIType->getDecl()->getIdentifier()->getName() << Sel;
+ }
}
if (Method && DiagnoseUseOfDecl(Method, receiverLoc))
return true;