summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-02-15 00:59:30 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-02-15 00:59:30 +0000
commitd33ab8c63546beb925338c1131bb23e8ada84553 (patch)
treedb041f53af25addf7ff0144bfe6adeaf6e1340b9 /clang/lib
parentdf01939065a3d8be3344759478e0c6ef63a5fa77 (diff)
downloadbcm5719-llvm-d33ab8c63546beb925338c1131bb23e8ada84553.tar.gz
bcm5719-llvm-d33ab8c63546beb925338c1131bb23e8ada84553.zip
Warn if method for a deprecated method is implemented.
Warn if class for a deprecated class is implemented. Warn if category for a deprecated class is implemented. All under control of -Wdeprecated-implementations. // rdar://8973810. llvm-svn: 125545
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index a3d93ab85e7..3aeb50b032d 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -64,6 +64,21 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) {
if ((*PI)->getIdentifier())
PushOnScopeChains(*PI, FnBodyScope);
}
+ // Warn on implementating deprecated methods under
+ // -Wdeprecated-implementations flag.
+ // FIXME. Refactor using common routine.
+ unsigned DIAG = diag::warn_depercated_def;
+ if (Diags.getDiagnosticLevel(DIAG, MDecl->getLocation())
+ != Diagnostic::Ignored)
+ if (ObjCInterfaceDecl *IC = MDecl->getClassInterface()) {
+ if (ObjCMethodDecl *IMD =
+ IC->lookupMethod(MDecl->getSelector(), MDecl->isInstanceMethod()))
+ if (NamedDecl *ND = dyn_cast<NamedDecl>(IMD))
+ if (ND->getAttr<DeprecatedAttr>()) {
+ Diag(MDecl->getLocation(), DIAG) << 0;
+ Diag(IMD->getLocation(), diag::note_method_declared_at);
+ }
+ }
}
Decl *Sema::
@@ -537,8 +552,21 @@ Decl *Sema::ActOnStartCategoryImplementation(
<< CatName;
Diag(CatIDecl->getImplementation()->getLocation(),
diag::note_previous_definition);
- } else
+ } else {
CatIDecl->setImplementation(CDecl);
+ // Warn on implementating category of deprecated class under
+ // -Wdeprecated-implementations flag.
+ // FIXME. Refactor using common routine.
+ unsigned DIAG = diag::warn_depercated_def;
+ if (Diags.getDiagnosticLevel(DIAG, CDecl->getLocation())
+ != Diagnostic::Ignored)
+ if (NamedDecl *ND = dyn_cast<NamedDecl>(IDecl))
+ if (ND->getAttr<DeprecatedAttr>()) {
+ Diag(CDecl->getLocation(), DIAG) << 2;
+ Diag(IDecl->getLocation(), diag::note_previous_decl) << "class";
+ }
+
+ }
}
CheckObjCDeclScope(CDecl);
@@ -647,6 +675,17 @@ Decl *Sema::ActOnStartClassImplementation(
} else { // add it to the list.
IDecl->setImplementation(IMPDecl);
PushOnScopeChains(IMPDecl, TUScope);
+ // Warn on implementating deprecated class under
+ // -Wdeprecated-implementations flag.
+ // FIXME. Refactor using common routine.
+ unsigned DIAG = diag::warn_depercated_def;
+ if (Diags.getDiagnosticLevel(DIAG, IMPDecl->getLocation())
+ != Diagnostic::Ignored)
+ if (NamedDecl *ND = dyn_cast<NamedDecl>(IDecl))
+ if (ND->getAttr<DeprecatedAttr>()) {
+ Diag(IMPDecl->getLocation(), DIAG) << 1;
+ Diag(IDecl->getLocation(), diag::note_previous_decl) << "class";
+ }
}
return IMPDecl;
}
OpenPOWER on IntegriCloud