]> granicus.if.org Git - clang/commitdiff
A strong property of block type has "copy" setter semantics, not "retain".
authorJohn McCall <rjmccall@apple.com>
Tue, 13 Sep 2011 18:49:24 +0000 (18:49 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 13 Sep 2011 18:49:24 +0000 (18:49 +0000)
This is consistent with the behavior of assigning into a __strong l-value,
and it's also necessary for ensuring that the ivar doesn't end up a dangling
reference.  We decided not to change the behavior of "retain" properties, but
just to make them warnings/errors when of block type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139619 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
test/CodeGenObjC/arc.m

index 618fe367cf0deda7d4bb2f653238d1ded2eb72f5..b9d2ba3a7bccb6c2560638790c65b2b6118ec653 100644 (file)
@@ -1510,7 +1510,9 @@ public:
   /// the property setter. This is only valid if the property has been
   /// defined to have a setter.
   SetterKind getSetterKind() const {
-    if (PropertyAttributes & (OBJC_PR_retain|OBJC_PR_strong))
+    if (PropertyAttributes & OBJC_PR_strong)
+      return getType()->isBlockPointerType() ? Copy : Retain;
+    if (PropertyAttributes & OBJC_PR_retain)
       return Retain;
     if (PropertyAttributes & OBJC_PR_copy)
       return Copy;
index 7982fd6ebc7c11dfdc254b8d8956238e3b3dd87e..ebbc3473166c625268b1d2bc5e1bed7953115637 100644 (file)
@@ -1892,3 +1892,23 @@ void test64b(void) {
   // CHECK-NEXT: call void @objc_release(i8* [[T5]])
   // CHECK-NEXT: ret void
 }
+
+// rdar://problem/9979150
+@interface Test65
+@property (strong) void(^ablock)(void);
+@property (nonatomic, strong) void(^nblock)(void);
+@end
+@implementation Test65
+@synthesize ablock, nblock;
+// CHECK:    define internal void ()* @"\01-[Test65 ablock]"(
+// CHECK:    call i8* @objc_getProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i1 zeroext true)
+
+// CHECK:    define internal void @"\01-[Test65 setAblock:]"(
+// CHECK:    call void @objc_setProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i8* {{%.*}}, i1 zeroext true, i1 zeroext true)
+
+// CHECK:    define internal void ()* @"\01-[Test65 nblock]"(
+// CHECK:    call i8* @objc_getProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i1 zeroext false)
+
+// CHECK:    define internal void @"\01-[Test65 setNblock:]"(
+// CHECK:    call void @objc_setProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i8* {{%.*}}, i1 zeroext false, i1 zeroext true)
+@end