Improve how we find private method decls. This involved:
- Changed Sema::ObjcActOnStartOfMethodDef() to register the methods with the global pools.
- Changed Sema::ActOnInstanceMessage() to look in global pools (should be much less error prone).
- Added a test case to message.m (for lookup that was broken).
Misc changes while I was investigating this...
- Changed Sema::ActOnAtEnd() to call AddFactoryMethodToGlobalPool (this looked like a cut/paste error).
- Added a comment and tweaked another where I was using the first person.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45142 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 45d0470..e5f748f 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -2264,23 +2264,8 @@
if (receiverType == Context.getObjcIdType() ||
receiverType == Context.getObjcClassType()) {
Method = InstanceMethodPool[Sel].Method;
- // If we didn't find an public method, look for a private one.
- if (!Method && CurMethodDecl) {
- NamedDecl *impCxt = CurMethodDecl->getMethodContext();
- if (ObjcImplementationDecl *IMD =
- dyn_cast<ObjcImplementationDecl>(impCxt)) {
- if (receiverType == Context.getObjcIdType())
- Method = IMD->lookupInstanceMethod(Sel);
- else
- Method = IMD->lookupClassMethod(Sel);
- } else if (ObjcCategoryImplDecl *CID =
- dyn_cast<ObjcCategoryImplDecl>(impCxt)) {
- if (receiverType == Context.getObjcIdType())
- Method = CID->lookupInstanceMethod(Sel);
- else
- Method = CID->lookupClassMethod(Sel);
- }
- }
+ if (!Method)
+ Method = FactoryMethodPool[Sel].Method;
if (!Method) {
Diag(lbrac, diag::warn_method_not_found, std::string("-"), Sel.getName(),
SourceRange(lbrac, rbrac));