зеркало из https://github.com/microsoft/clang-1.git
objc: use objc_suppress_autosynthesis attribute on classes
which should not be default synthesized. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147468 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
c13a34b690
Коммит
eb4f2c56c2
|
@ -1665,9 +1665,10 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,
|
||||||
// Check and see if properties declared in the interface have either 1)
|
// Check and see if properties declared in the interface have either 1)
|
||||||
// an implementation or 2) there is a @synthesize/@dynamic implementation
|
// an implementation or 2) there is a @synthesize/@dynamic implementation
|
||||||
// of the property in the @implementation.
|
// of the property in the @implementation.
|
||||||
if (isa<ObjCInterfaceDecl>(CDecl) &&
|
if (const ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl))
|
||||||
!(LangOpts.ObjCDefaultSynthProperties && LangOpts.ObjCNonFragileABI2))
|
if (!(LangOpts.ObjCDefaultSynthProperties && LangOpts.ObjCNonFragileABI2) ||
|
||||||
DiagnoseUnimplementedProperties(S, IMPDecl, CDecl, InsMap);
|
IDecl->isObjCSuppressAutosynthesis())
|
||||||
|
DiagnoseUnimplementedProperties(S, IMPDecl, CDecl, InsMap);
|
||||||
|
|
||||||
llvm::DenseSet<Selector> ClsMap;
|
llvm::DenseSet<Selector> ClsMap;
|
||||||
for (ObjCImplementationDecl::classmeth_iterator
|
for (ObjCImplementationDecl::classmeth_iterator
|
||||||
|
|
|
@ -856,7 +856,8 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S,
|
||||||
}
|
}
|
||||||
IC->addPropertyImplementation(PIDecl);
|
IC->addPropertyImplementation(PIDecl);
|
||||||
if (getLangOptions().ObjCDefaultSynthProperties &&
|
if (getLangOptions().ObjCDefaultSynthProperties &&
|
||||||
getLangOptions().ObjCNonFragileABI2) {
|
getLangOptions().ObjCNonFragileABI2 &&
|
||||||
|
!IDecl->isObjCSuppressAutosynthesis()) {
|
||||||
// Diagnose if an ivar was lazily synthesdized due to a previous
|
// Diagnose if an ivar was lazily synthesdized due to a previous
|
||||||
// use and if 1) property is @dynamic or 2) property is synthesized
|
// use and if 1) property is @dynamic or 2) property is synthesized
|
||||||
// but it requires an ivar of different name.
|
// but it requires an ivar of different name.
|
||||||
|
@ -1355,7 +1356,8 @@ void Sema::DefaultSynthesizeProperties(Scope *S, Decl *D) {
|
||||||
if (!IC)
|
if (!IC)
|
||||||
return;
|
return;
|
||||||
if (ObjCInterfaceDecl* IDecl = IC->getClassInterface())
|
if (ObjCInterfaceDecl* IDecl = IC->getClassInterface())
|
||||||
DefaultSynthesizeProperties(S, IC, IDecl);
|
if (!IDecl->isObjCSuppressAutosynthesis())
|
||||||
|
DefaultSynthesizeProperties(S, IC, IDecl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
|
void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-default-synthesize-properties -verify %s
|
||||||
|
// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -verify %s
|
||||||
|
|
||||||
|
__attribute ((objc_suppress_autosynthesis))
|
||||||
|
@interface NoAuto
|
||||||
|
@property int NoAutoProp; // expected-note 2 {{property declared here}}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NoAuto // expected-warning {{property 'NoAutoProp' requires method 'NoAutoProp' to be defined}} \
|
||||||
|
// expected-warning {{property 'NoAutoProp' requires method 'setNoAutoProp:'}}
|
||||||
|
@end
|
||||||
|
|
||||||
|
__attribute ((objc_suppress_autosynthesis)) // redundant, just for testing
|
||||||
|
@interface Sub : NoAuto
|
||||||
|
@property (copy) id SubProperty; // expected-note 2 {{property declared here}}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation Sub // expected-warning {{property 'SubProperty' requires method 'SubProperty' to be defined}} \
|
||||||
|
// expected-warning {{property 'SubProperty' requires method 'setSubProperty:' to be defined}}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface Deep : Sub
|
||||||
|
@property (copy) id DeepProperty;
|
||||||
|
@property (copy) id DeepSynthProperty;
|
||||||
|
@property (copy) id DeepMustSynthProperty; // expected-note {{property declared here}}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation Deep // expected-warning {{property 'DeepMustSynthProperty' requires method 'setDeepMustSynthProperty:' to be defined}}
|
||||||
|
@dynamic DeepProperty;
|
||||||
|
@synthesize DeepSynthProperty;
|
||||||
|
- (id) DeepMustSynthProperty { return 0; }
|
||||||
|
@end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче