diff options
author | Steve Naroff <snaroff@apple.com> | 2007-11-13 04:10:18 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2007-11-13 04:10:18 +0000 |
commit | 817da7c77c50f3ef215daf72d3a6ed85302bf45d (patch) | |
tree | 5b24c84107e9939c85c9d1e72b430abdb5dd37e9 | |
parent | 0b9cc05556c47b8aa02aea57c7679ff68f196051 (diff) |
Tune the lookup logic in Sema::ActOnInstanceMessage() to handle private methods (declared within the implementation).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44041 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Sema/SemaExpr.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp index 976069e669..87b3d081da 100644 --- a/Sema/SemaExpr.cpp +++ b/Sema/SemaExpr.cpp @@ -2139,6 +2139,23 @@ Sema::ExprResult Sema::ActOnInstanceMessage( 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) { Diag(lbrac, diag::warn_method_not_found, std::string("-"), Sel.getName(), SourceRange(lbrac, rbrac)); |