forked from OSchip/llvm-project
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 llvm-svn: 118676
This commit is contained in:
parent
5eec2b0bd3
commit
ad31b5f2cb
|
@ -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
|
/// ProcessPropertyDecl - Make sure that any user-defined setter/getter methods
|
||||||
/// have the property type and issue diagnostics if they don't.
|
/// have the property type and issue diagnostics if they don't.
|
||||||
/// Also synthesize a getter/setter method if none exist (and update the
|
/// Also synthesize a getter/setter method if none exist (and update the
|
||||||
|
@ -1133,6 +1144,9 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
|
||||||
ObjCMethodDecl::Optional :
|
ObjCMethodDecl::Optional :
|
||||||
ObjCMethodDecl::Required);
|
ObjCMethodDecl::Required);
|
||||||
CD->addDecl(GetterMethod);
|
CD->addDecl(GetterMethod);
|
||||||
|
|
||||||
|
AddPropertyAttrs(*this, GetterMethod, property);
|
||||||
|
|
||||||
// FIXME: Eventually this shouldn't be needed, as the lexical context
|
// FIXME: Eventually this shouldn't be needed, as the lexical context
|
||||||
// and the real context should be the same.
|
// and the real context should be the same.
|
||||||
if (lexicalDC)
|
if (lexicalDC)
|
||||||
|
@ -1173,6 +1187,9 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
|
||||||
SC_None,
|
SC_None,
|
||||||
0);
|
0);
|
||||||
SetterMethod->setMethodParams(Context, &Argument, 1, 1);
|
SetterMethod->setMethodParams(Context, &Argument, 1, 1);
|
||||||
|
|
||||||
|
AddPropertyAttrs(*this, SetterMethod, property);
|
||||||
|
|
||||||
CD->addDecl(SetterMethod);
|
CD->addDecl(SetterMethod);
|
||||||
// FIXME: Eventually this shouldn't be needed, as the lexical context
|
// FIXME: Eventually this shouldn't be needed, as the lexical context
|
||||||
// and the real context should be the same.
|
// and the real context should be the same.
|
||||||
|
|
|
@ -97,3 +97,14 @@ __attribute ((deprecated))
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@interface Test2
|
||||||
|
@property int test2 __attribute__((deprecated));
|
||||||
|
@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}}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue