From d91d21cc335dba0f704fbc404366fefaabd4d4ed Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Sat, 17 Nov 2012 20:53:53 +0000 Subject: objective-C: Do not issue deprecated warning about implementation of a deprecated method in original class (or category), only in overrides. // rdar://12717705 llvm-svn: 168270 --- clang/lib/Sema/SemaDeclObjC.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'clang/lib') diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index c4e91e85015..59f93af465a 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -373,10 +373,23 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) { ObjCMethodDecl *IMD = IC->lookupMethod(MDecl->getSelector(), MDecl->isInstanceMethod()); - if (IMD) - DiagnoseObjCImplementedDeprecations(*this, + if (IMD) { + ObjCImplDecl *ImplDeclOfMethodDef = + dyn_cast(MDecl->getDeclContext()); + ObjCContainerDecl *ContDeclOfMethodDecl = + dyn_cast(IMD->getDeclContext()); + ObjCImplDecl *ImplDeclOfMethodDecl = 0; + if (ObjCInterfaceDecl *OID = dyn_cast(ContDeclOfMethodDecl)) + ImplDeclOfMethodDecl = OID->getImplementation(); + else if (ObjCCategoryDecl *CD = dyn_cast(ContDeclOfMethodDecl)) + ImplDeclOfMethodDecl = CD->getImplementation(); + // No need to issue deprecated warning if deprecated mehod in class/category + // is being implemented in its own implementation (no overriding is involved). + if (!ImplDeclOfMethodDecl || ImplDeclOfMethodDecl != ImplDeclOfMethodDef) + DiagnoseObjCImplementedDeprecations(*this, dyn_cast(IMD), MDecl->getLocation(), 0); + } // If this is "dealloc" or "finalize", set some bit here. // Then in ActOnSuperMessage() (SemaExprObjC), set it back to false. -- cgit v1.2.3