diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-11-17 20:53:53 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-11-17 20:53:53 +0000 |
commit | 5fa667612e0466982407ae678cdfeb68b878ed65 (patch) | |
tree | c6bffcfc0c1ed772de6fc65ac4065f2e4653aeeb /lib | |
parent | 6d926ae667cca926e77ddce1734514911706ed0a (diff) |
objective-C: Do not issue deprecated warning about implementation
of a deprecated method in original class (or category), only
in overrides. // rdar://12717705
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168270 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index c4e91e8501..59f93af465 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/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<ObjCImplDecl>(MDecl->getDeclContext()); + ObjCContainerDecl *ContDeclOfMethodDecl = + dyn_cast<ObjCContainerDecl>(IMD->getDeclContext()); + ObjCImplDecl *ImplDeclOfMethodDecl = 0; + if (ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(ContDeclOfMethodDecl)) + ImplDeclOfMethodDecl = OID->getImplementation(); + else if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(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<NamedDecl>(IMD), MDecl->getLocation(), 0); + } // If this is "dealloc" or "finalize", set some bit here. // Then in ActOnSuperMessage() (SemaExprObjC), set it back to false. |