aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-16 19:35:30 +0000
committerChris Lattner <sabre@nondot.org>2009-02-16 19:35:30 +0000
commitf15970cff7d53cd29f7f85aa6edeec2cac0d2d59 (patch)
tree3cd5aa4eb78f1ba2c5a1f4a98940ebed44dadbe9 /lib/Sema/SemaExpr.cpp
parenta5afdd0ef9ff4a7a3f26145b6536a84dd340c897 (diff)
do not warn about uses of deprecated decls when in an out-of-line objc method
whose declaration was declared as deprecated. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64658 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 553c29e897..9a44a087c7 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -32,11 +32,31 @@ using namespace clang;
void Sema::DiagnoseUseOfDeprecatedDeclImpl(NamedDecl *D, SourceLocation Loc) {
// See if the decl is deprecated.
if (D->getAttr<DeprecatedAttr>()) {
- // If this reference happens *in* a deprecated function or method, don't
- // warn. Implementing deprecated stuff requires referencing depreated
- // stuff.
- NamedDecl *ND = getCurFunctionOrMethodDecl();
- if (ND == 0 || !ND->getAttr<DeprecatedAttr>())
+ // Implementing deprecated stuff requires referencing depreated stuff. Don't
+ // warn if we are implementing a deprecated construct.
+ bool isSilenced = false;
+
+ if (NamedDecl *ND = getCurFunctionOrMethodDecl()) {
+ // If this reference happens *in* a deprecated function or method, don't
+ // warn.
+ isSilenced = ND->getAttr<DeprecatedAttr>();
+
+ // If this is an Objective-C method implementation, check to see if the
+ // method was deprecated on the declaration, not the definition.
+ if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(ND)) {
+ // The semantic decl context of a ObjCMethodDecl is the
+ // ObjCImplementationDecl.
+ if (ObjCImplementationDecl *Impl
+ = dyn_cast<ObjCImplementationDecl>(MD->getParent())) {
+
+ MD = Impl->getClassInterface()->getMethod(MD->getSelector(),
+ MD->isInstanceMethod());
+ isSilenced |= MD && MD->getAttr<DeprecatedAttr>();
+ }
+ }
+ }
+
+ if (!isSilenced)
Diag(Loc, diag::warn_deprecated) << D->getDeclName();
}