[cfe-commits] r64562 - in /cfe/trunk: lib/Sema/SemaExprObjC.cpp test/SemaObjC/attr-deprecated.m
Anders Carlsson
andersca at mac.com
Sat Feb 14 11:08:59 PST 2009
Author: andersca
Date: Sat Feb 14 13:08:58 2009
New Revision: 64562
URL: http://llvm.org/viewvc/llvm-project?rev=64562&view=rev
Log:
Add support for deprecated Obj-C methods. The semantics mostly match what gcc has.
Added:
cfe/trunk/test/SemaObjC/attr-deprecated.m
Modified:
cfe/trunk/lib/Sema/SemaExprObjC.cpp
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=64562&r1=64561&r2=64562&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Sat Feb 14 13:08:58 2009
@@ -268,6 +268,9 @@
if (!Method)
Method = ClassDecl->lookupInstanceMethod(Sel);
+ if (Method && Method->getAttr<DeprecatedAttr>())
+ Diag(receiverLoc, diag::warn_deprecated) << Method->getDeclName();
+
if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, true,
lbrac, rbrac, returnType))
return true;
@@ -313,6 +316,9 @@
Method = SuperDecl->lookupInstanceMethod(Sel);
}
+ if (Method && Method->getAttr<DeprecatedAttr>())
+ Diag(receiverLoc, diag::warn_deprecated) << Method->getDeclName();
+
if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, false,
lbrac, rbrac, returnType))
return true;
@@ -343,6 +349,9 @@
if (ObjCImplementationDecl *ImpDecl =
ObjCImplementations[ClassDecl->getIdentifier()])
Method = ImpDecl->getClassMethod(Sel);
+
+ if (Method && Method->getAttr<DeprecatedAttr>())
+ Diag(receiverLoc, diag::warn_deprecated) << Method->getDeclName();
}
if (!Method)
Method = FactoryMethodPool[Sel].Method;
@@ -393,6 +402,9 @@
if (!Method && !OCIReceiver->qual_empty())
Diag(lbrac, diag::warn_method_not_found_in_protocol)
<< Sel << SourceRange(lbrac, rbrac);
+
+ if (Method && Method->getAttr<DeprecatedAttr>())
+ Diag(receiverLoc, diag::warn_deprecated) << Method->getDeclName();
} else {
Diag(lbrac, diag::error_bad_receiver_type)
<< RExpr->getType() << RExpr->getSourceRange();
Added: cfe/trunk/test/SemaObjC/attr-deprecated.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-deprecated.m?rev=64562&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/attr-deprecated.m (added)
+++ cfe/trunk/test/SemaObjC/attr-deprecated.m Sat Feb 14 13:08:58 2009
@@ -0,0 +1,65 @@
+// RUN: clang %s -fsyntax-only -verify
+
+ at interface A
++ (void)F __attribute__((deprecated));
+- (void)f __attribute__((deprecated));
+ at end
+
+ at implementation A
++ (void)F __attribute__((deprecated))
+{
+ [self F]; // expected-warning{{'F' is deprecated}}
+}
+
+- (void)g
+{
+ [self f]; // expected-warning{{'f' is deprecated}}
+}
+
+- (void)f
+{
+ [self f]; // expected-warning{{'f' is deprecated}}
+}
+ at end
+
+ at interface B: A
+ at end
+
+ at implementation B
++ (void)G
+{
+ [super F]; // expected-warning{{'F' is deprecated}}
+}
+
+- (void)g
+{
+ [super f]; // // expected-warning{{'f' is deprecated}}
+}
+ at end
+
+ at protocol P
+- (void)p __attribute__((deprecated));
+ at end
+
+void t1(A *a)
+{
+ [A F]; // expected-warning{{'F' is deprecated}}
+ [a f]; // expected-warning{{'f' is deprecated}}
+}
+
+void t2(id a)
+{
+ [a f];
+}
+
+void t3(A<P>* a)
+{
+ [a f]; // expected-warning{{'f' is deprecated}}
+ [a p]; // expected-warning{{'p' is deprecated}}
+}
+
+void t4(Class c)
+{
+ [c F];
+}
+
More information about the cfe-commits
mailing list