]> granicus.if.org Git - clang/commitdiff
Objective-C: Warn when IBOutletCollection property
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 25 Jun 2013 17:34:50 +0000 (17:34 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 25 Jun 2013 17:34:50 +0000 (17:34 +0000)
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

include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaObjCProperty.cpp
test/SemaObjC/iboutletcollection-attr.m

index c1734506bce6f8f63140eba338f31061a0aa314e..e44e1407513748e734fccdb7e8e23d14f903bcf3 100644 (file)
@@ -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]>;
index bb532eb04c651cb456d4169f21f38d690fc52fd7..05f71d5b9172efb3e03f89854ba02842c9d75daf 100644 (file)
@@ -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<
index 84752d99bd8ddb7e12919d3f5d32e8341f47aaca..90abe7fd52afb37e576c2359a020adc56635c23d 100644 (file)
@@ -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)
index 82cb96fbede74f4b175beb034838b016421db0a3..fbb6a291f3adfcc1ab8dafbc103799e76b5f8779 100644 (file)
@@ -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