[cfe-commits] r64658 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaObjC/attr-deprecated.m
Chris Lattner
sabre at nondot.org
Mon Feb 16 11:35:30 PST 2009
Author: lattner
Date: Mon Feb 16 13:35:30 2009
New Revision: 64658
URL: http://llvm.org/viewvc/llvm-project?rev=64658&view=rev
Log:
do not warn about uses of deprecated decls when in an out-of-line objc method
whose declaration was declared as deprecated.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/attr-deprecated.m
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=64658&r1=64657&r2=64658&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Feb 16 13:35:30 2009
@@ -32,11 +32,31 @@
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();
}
Modified: cfe/trunk/test/SemaObjC/attr-deprecated.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-deprecated.m?rev=64658&r1=64657&r2=64658&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/attr-deprecated.m (original)
+++ cfe/trunk/test/SemaObjC/attr-deprecated.m Mon Feb 16 13:35:30 2009
@@ -22,7 +22,7 @@
- (void)f
{
- [self f]; // expected-warning{{'f' is deprecated}}
+ [self f]; // no warning, the caller is deprecated in its interface.
}
@end
@@ -81,4 +81,3 @@
return f.FooBar; // expected-warning {{warning: 'FooBar' is deprecated}}
}
-
More information about the cfe-commits
mailing list