Objective-C: Warn when IBOutletCollection property

is declared to have 'assign' attribute.
// rdar://14212998


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184863 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Fariborz Jahanian 2013-06-25 17:34:50 +00:00
Родитель a7732c7499
Коммит 548fba9625
4 изменённых файлов: 15 добавлений и 2 удалений

Просмотреть файл

@ -207,6 +207,7 @@ def ObjCPropertyNoAttribute : DiagGroup<"objc-property-no-attribute">;
def ObjCMissingSuperCalls : DiagGroup<"objc-missing-super-calls">;
def ObjCRetainBlockProperty : DiagGroup<"objc-noncopy-retain-block-property">;
def ObjCReadonlyPropertyHasSetter : DiagGroup<"objc-readonly-with-setter-property">;
def ObjCInvalidIBOutletProperty : DiagGroup<"invalid-iboutlet">;
def ObjCRootClass : DiagGroup<"objc-root-class">;
def ObjCPointerIntrospectPerformSelector : DiagGroup<"deprecated-objc-pointer-introspection-performSelector">;
def ObjCPointerIntrospect : DiagGroup<"deprecated-objc-pointer-introspection", [ObjCPointerIntrospectPerformSelector]>;

Просмотреть файл

@ -2345,8 +2345,11 @@ def err_iboutletcollection_type : Error<
"invalid type %0 as argument of iboutletcollection attribute">;
def warn_iboutlet_object_type : Warning<
"%select{instance variable|property}2 with %0 attribute must "
"be an object type (invalid %1)">,
InGroup<DiagGroup<"invalid-iboutlet">>;
"be an object type (invalid %1)">, InGroup<ObjCInvalidIBOutletProperty>;
def warn_iboutletcollection_property_assign : Warning<
"IBOutletCollection properties should be copy/strong and not assign">,
InGroup<ObjCInvalidIBOutletProperty>;
def err_attribute_overloadable_not_function : Error<
"'overloadable' attribute can only be applied to a function">;
def err_attribute_overloadable_missing : Error<

Просмотреть файл

@ -2218,6 +2218,8 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl,
<< "assign" << "weak";
Attributes &= ~ObjCDeclSpec::DQ_PR_weak;
}
if (PropertyDecl->getAttr<IBOutletCollectionAttr>())
Diag(Loc, diag::warn_iboutletcollection_property_assign);
} else if (Attributes & ObjCDeclSpec::DQ_PR_unsafe_unretained) {
if (Attributes & ObjCDeclSpec::DQ_PR_copy) {
Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)

Просмотреть файл

@ -41,3 +41,10 @@ typedef void *PV;
@property (nonatomic, strong)
__attribute__((iboutletcollection(RDar10296078_OtherClass<RDar10296078_Protocol>))) NSArray *stuff;
@end
// rdar://14212998
@class UILabel;
@class NSArray;
@interface OCTViewController
@property (nonatomic, assign) __attribute__((iboutletcollection(UILabel))) NSArray *labels; // expected-warning {{IBOutletCollection properties should be copy/strong and not assign}}
@end