]> granicus.if.org Git - clang/commitdiff
arg migrator: change all "assign" of object properties
authorFariborz Jahanian <fjahanian@apple.com>
Sat, 21 Jan 2012 00:43:53 +0000 (00:43 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sat, 21 Jan 2012 00:43:53 +0000 (00:43 +0000)
to "strong" when migrating from GC. // rdar://10532449

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

lib/ARCMigrate/TransProperties.cpp
test/ARCMT/GC-no-arc-runtime.m.result
test/ARCMT/GC.m
test/ARCMT/GC.m.result

index b36acbb205d148a4aa220f33d43a7d4874cad212..7eb2a9bfc7e7f063fc02fb3cd34be56ca6f31f14 100644 (file)
@@ -201,10 +201,8 @@ private:
     bool HasIvarAssignedAPlusOneObject = hasIvarAssignedAPlusOneObject(props);
 
     if (propAttrs & ObjCPropertyDecl::OBJC_PR_assign) {
-      if (HasIvarAssignedAPlusOneObject ||
-          (Pass.isGCMigration() && !hasGCWeak(props, atLoc))) {
+      if (HasIvarAssignedAPlusOneObject)
         return doPropAction(PropAction_AssignRemoved, props, atLoc);
-      }
       return doPropAction(PropAction_AssignRewritten, props, atLoc);
     }
 
@@ -231,19 +229,23 @@ private:
   void rewriteAssign(PropsTy &props, SourceLocation atLoc) const {
     bool canUseWeak = canApplyWeak(Pass.Ctx, getPropertyType(props),
                                   /*AllowOnUnknownClass=*/Pass.isGCMigration());
+    const char *toWhich = 
+      (Pass.isGCMigration() && !hasGCWeak(props, atLoc)) ? "strong" :
+      (canUseWeak ? "weak" : "unsafe_unretained");
 
-    bool rewroteAttr = rewriteAttribute("assign",
-                                     canUseWeak ? "weak" : "unsafe_unretained",
-                                         atLoc);
+    bool rewroteAttr = rewriteAttribute("assign", toWhich, atLoc);
     if (!rewroteAttr)
       canUseWeak = false;
 
     for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) {
       if (isUserDeclared(I->IvarD)) {
         if (I->IvarD &&
-            I->IvarD->getType().getObjCLifetime() != Qualifiers::OCL_Weak)
-          Pass.TA.insert(I->IvarD->getLocation(),
-                         canUseWeak ? "__weak " : "__unsafe_unretained ");
+            I->IvarD->getType().getObjCLifetime() != Qualifiers::OCL_Weak) {
+          const char *toWhich = 
+            (Pass.isGCMigration() && !hasGCWeak(props, atLoc)) ? "__strong " :
+              (canUseWeak ? "__weak " : "__unsafe_unretained ");
+          Pass.TA.insert(I->IvarD->getLocation(), toWhich);
+        }
       }
       if (I->ImplD)
         Pass.TA.clearDiagnostic(diag::err_arc_assign_property_ownership,
index 983af62c4a6422f1529e4b360ed1fefcdb950134..983a5b174271a32c9779020c46d59acd1c13bb9f 100644 (file)
@@ -52,12 +52,12 @@ __attribute__((objc_arc_weak_reference_unavailable))
 @end
 
 @interface I4Impl {
-  I4Impl *pds2;
+  I4Impl *__strong pds2;
 }
 @property (unsafe_unretained) I4Impl * pw1, * pw2;
-@property  I4Impl * ps;
-@property  I4Impl * pds;
-@property  I4Impl * pds2;
+@property (strong) I4Impl * ps;
+@property (strong) I4Impl * pds;
+@property (strong) I4Impl * pds2;
 @end
 
 @implementation I4Impl
index d309dabf68ee82061ecc91a1b90af1915d5649ff..f241e430085347ad2e461c6d839728e3528ba512 100644 (file)
@@ -79,3 +79,14 @@ __attribute__((objc_arc_weak_reference_unavailable))
   id x = NSMakeCollectable(cft);
 }
 @end
+
+// rdar://10532449
+@interface rdar10532449
+@property (assign) id assign_prop;
+@property (assign, readonly) id __strong strong_readonly_prop;
+@property (assign) id __weak weak_prop;
+@end
+
+@implementation rdar10532449
+@synthesize assign_prop, strong_readonly_prop, weak_prop;
+@end
index 2cf6b8e24481cf56c2c2451c6e29698f4253224f..f9e954af5a8152dab71ff9cdc69c70ff28399ab5 100644 (file)
@@ -52,15 +52,15 @@ __attribute__((objc_arc_weak_reference_unavailable))
 @end
 
 @interface I4Impl {
-  I4Impl *pds2;
+  I4Impl *__strong pds2;
   I4Impl *pds3;
   __weak I4Impl *pw3;
   __weak I4Impl *pw4;
 }
 @property (weak) I4Impl * pw1, * pw2;
-@property  I4Impl * ps;
-@property  I4Impl * pds;
-@property  I4Impl * pds2;
+@property (strong) I4Impl * ps;
+@property (strong) I4Impl * pds;
+@property (strong) I4Impl * pds2;
 @property (readwrite) I4Impl * pds3;
 @property (readonly) I4Impl * pds4;
 @property (weak, readonly)  I4Impl *pw3;
@@ -74,3 +74,14 @@ __attribute__((objc_arc_weak_reference_unavailable))
   id x = CFBridgingRelease(cft);
 }
 @end
+
+// rdar://10532449
+@interface rdar10532449
+@property (strong) id assign_prop;
+@property (strong, readonly) id  strong_readonly_prop;
+@property (weak) id  weak_prop;
+@end
+
+@implementation rdar10532449
+@synthesize assign_prop, strong_readonly_prop, weak_prop;
+@end