]> granicus.if.org Git - clang/commitdiff
[arcmt] When checking whether properties needs to be strong or not, take into account
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 10 Aug 2011 21:46:48 +0000 (21:46 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 10 Aug 2011 21:46:48 +0000 (21:46 +0000)
that assigning result of -retain means it should be strong. rdar://9931757.

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

lib/ARCMigrate/TransProperties.cpp
test/ARCMT/assign-prop-with-arc-runtime.m
test/ARCMT/assign-prop-with-arc-runtime.m.result

index 943eea2646328b588349920821b64b9ebea20cb8..1ce02b11ef4aec9889803c3d334f9f93ad2cf72d 100644 (file)
@@ -330,6 +330,11 @@ private:
         if (RE->getDecl() != Ivar)
           return true;
 
+      if (ObjCMessageExpr *
+            ME = dyn_cast<ObjCMessageExpr>(E->getRHS()->IgnoreParenCasts()))
+        if (ME->getMethodFamily() == OMF_retain)
+          return false;
+
       ImplicitCastExpr *implCE = dyn_cast<ImplicitCastExpr>(E->getRHS());
       while (implCE && implCE->getCastKind() ==  CK_BitCast)
         implCE = dyn_cast<ImplicitCastExpr>(implCE->getSubExpr());
index 1671d6d02035d53c1c31ed1997e8f1138d2c99f1..b328bfe1583ae68e66aba73998a1eb6c9cfb6006 100644 (file)
@@ -32,20 +32,20 @@ typedef _NSCachedAttributedString *BadClassForWeak;
 @property Forw *not_safe3;
 @property (readonly) Foo *assign_plus1;
 @property (readonly) Foo *assign_plus2;
+@property (readonly) Foo *assign_plus3;
 
 @property (assign) Foo *no_user_ivar1;
 @property (readonly) Foo *no_user_ivar2;
-
--(void)test;
 @end
 
 @implementation Foo
 @synthesize x,w,q1,q2,oo,bcw,not_safe1,not_safe2,not_safe3;
 @synthesize no_user_ivar1, no_user_ivar2;
-@synthesize assign_plus1, assign_plus2;
+@synthesize assign_plus1, assign_plus2, assign_plus3;
 
--(void)test {
+-(void)test:(Foo *)parm {
   assign_plus1 = [[Foo alloc] init];
   assign_plus2 = [Foo new];
+  assign_plus3 = [parm retain];
 }
 @end
index d30a2ac00be48b4444e1e4da38eacacefd4cd807..3dd903ea5b9eba95cf71cf2970dceeb9770e00a1 100644 (file)
@@ -32,20 +32,20 @@ typedef _NSCachedAttributedString *BadClassForWeak;
 @property (unsafe_unretained) Forw *not_safe3;
 @property (readonly) Foo *assign_plus1;
 @property (strong, readonly) Foo *assign_plus2;
+@property (strong, readonly) Foo *assign_plus3;
 
 @property (weak) Foo *no_user_ivar1;
 @property (weak, readonly) Foo *no_user_ivar2;
-
--(void)test;
 @end
 
 @implementation Foo
 @synthesize x,w,q1,q2,oo,bcw,not_safe1,not_safe2,not_safe3;
 @synthesize no_user_ivar1, no_user_ivar2;
-@synthesize assign_plus1, assign_plus2;
+@synthesize assign_plus1, assign_plus2, assign_plus3;
 
--(void)test {
+-(void)test:(Foo *)parm {
   assign_plus1 = [[Foo alloc] init];
   assign_plus2 = [Foo new];
+  assign_plus3 = parm;
 }
 @end