[cfe-commits] r139619 - in /cfe/trunk: include/clang/AST/DeclObjC.h test/CodeGenObjC/arc.m

John McCall rjmccall at apple.com
Tue Sep 13 11:49:24 PDT 2011


Author: rjmccall
Date: Tue Sep 13 13:49:24 2011
New Revision: 139619

URL: http://llvm.org/viewvc/llvm-project?rev=139619&view=rev
Log:
A strong property of block type has "copy" setter semantics, not "retain".
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.


Modified:
    cfe/trunk/include/clang/AST/DeclObjC.h
    cfe/trunk/test/CodeGenObjC/arc.m

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=139619&r1=139618&r2=139619&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Tue Sep 13 13:49:24 2011
@@ -1510,7 +1510,9 @@
   /// 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;

Modified: cfe/trunk/test/CodeGenObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc.m?rev=139619&r1=139618&r2=139619&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/arc.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc.m Tue Sep 13 13:49:24 2011
@@ -1892,3 +1892,23 @@
   // CHECK-NEXT: call void @objc_release(i8* [[T5]])
   // CHECK-NEXT: ret void
 }
+
+// rdar://problem/9979150
+ at interface Test65
+ at property (strong) void(^ablock)(void);
+ at property (nonatomic, strong) void(^nblock)(void);
+ at end
+ at implementation Test65
+ at 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)
+ at end





More information about the cfe-commits mailing list