[llvm-branch-commits] [cfe-branch] r119249 - in /cfe/branches/Apple/whitney: lib/Sema/SemaObjCProperty.cpp test/SemaObjC/attr-deprecated.m
Daniel Dunbar
daniel at zuster.org
Mon Nov 15 13:46:03 PST 2010
Author: ddunbar
Date: Mon Nov 15 15:46:03 2010
New Revision: 119249
URL: http://llvm.org/viewvc/llvm-project?rev=119249&view=rev
Log:
Merge r118676:
--
Author: John McCall <rjmccall at apple.com>
Date: Wed Nov 10 07:01:40 2010 +0000
Propagate the deprecated and unavailable attributes from a
@property declaration to the autogenerated methods. I'm uncertain
whether this should apply to attributes in general, but these are
a reasonable core.
Implements rdar://problem/8617301
Modified:
cfe/branches/Apple/whitney/lib/Sema/SemaObjCProperty.cpp
cfe/branches/Apple/whitney/test/SemaObjC/attr-deprecated.m
Modified: cfe/branches/Apple/whitney/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/SemaObjCProperty.cpp?rev=119249&r1=119248&r2=119249&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/SemaObjCProperty.cpp Mon Nov 15 15:46:03 2010
@@ -1076,6 +1076,17 @@
}
}
+/// AddPropertyAttrs - Propagates attributes from a property to the
+/// implicitly-declared getter or setter for that property.
+static void AddPropertyAttrs(Sema &S, ObjCMethodDecl *PropertyMethod,
+ ObjCPropertyDecl *Property) {
+ // Should we just clone all attributes over?
+ if (DeprecatedAttr *A = Property->getAttr<DeprecatedAttr>())
+ PropertyMethod->addAttr(A->clone(S.Context));
+ if (UnavailableAttr *A = Property->getAttr<UnavailableAttr>())
+ PropertyMethod->addAttr(A->clone(S.Context));
+}
+
/// ProcessPropertyDecl - Make sure that any user-defined setter/getter methods
/// have the property type and issue diagnostics if they don't.
/// Also synthesize a getter/setter method if none exist (and update the
@@ -1133,6 +1144,9 @@
ObjCMethodDecl::Optional :
ObjCMethodDecl::Required);
CD->addDecl(GetterMethod);
+
+ AddPropertyAttrs(*this, GetterMethod, property);
+
// FIXME: Eventually this shouldn't be needed, as the lexical context
// and the real context should be the same.
if (lexicalDC)
@@ -1173,6 +1187,9 @@
SC_None,
0);
SetterMethod->setMethodParams(Context, &Argument, 1, 1);
+
+ AddPropertyAttrs(*this, SetterMethod, property);
+
CD->addDecl(SetterMethod);
// FIXME: Eventually this shouldn't be needed, as the lexical context
// and the real context should be the same.
Modified: cfe/branches/Apple/whitney/test/SemaObjC/attr-deprecated.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/SemaObjC/attr-deprecated.m?rev=119249&r1=119248&r2=119249&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/SemaObjC/attr-deprecated.m (original)
+++ cfe/branches/Apple/whitney/test/SemaObjC/attr-deprecated.m Mon Nov 15 15:46:03 2010
@@ -97,3 +97,14 @@
@end
+ at interface Test2
+ at property int test2 __attribute__((deprecated));
+ at end
+
+void test(Test2 *foo) {
+ int x;
+ x = foo.test2; // expected-warning {{'test2' is deprecated}}
+ x = [foo test2]; // expected-warning {{'test2' is deprecated}}
+ foo.test2 = x; // expected-warning {{'test2' is deprecated}}
+ [foo setTest2: x]; // expected-warning {{'setTest2:' is deprecated}}
+}
More information about the llvm-branch-commits
mailing list