aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaObjCProperty.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-11-10 07:01:40 +0000
committerJohn McCall <rjmccall@apple.com>2010-11-10 07:01:40 +0000
commit5de74d19ddcf84cfe9d7d973192ba93fd0c64d4f (patch)
treed230e8549de96aec7fbcb36478911a7d3b320157 /lib/Sema/SemaObjCProperty.cpp
parent8113ecfa4e41e2c888b1794389dfe3bce6386493 (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118676 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaObjCProperty.cpp')
-rw-r--r--lib/Sema/SemaObjCProperty.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp
index 1e7c1f8508..37f9db1e5b 100644
--- a/lib/Sema/SemaObjCProperty.cpp
+++ b/lib/Sema/SemaObjCProperty.cpp
@@ -1076,6 +1076,17 @@ Sema::AtomicPropertySetterGetterRules (ObjCImplDecl* IMPDecl,
}
}
+/// 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 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
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 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
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.