[cfe-commits] r148607 - in /cfe/trunk: lib/ARCMigrate/TransProperties.cpp test/ARCMT/GC-no-arc-runtime.m.result test/ARCMT/GC.m test/ARCMT/GC.m.result

Fariborz Jahanian fjahanian at apple.com
Fri Jan 20 16:43:53 PST 2012


Author: fjahanian
Date: Fri Jan 20 18:43:53 2012
New Revision: 148607

URL: http://llvm.org/viewvc/llvm-project?rev=148607&view=rev
Log:
arg migrator: change all "assign" of object properties
to "strong" when migrating from GC. // rdar://10532449

Modified:
    cfe/trunk/lib/ARCMigrate/TransProperties.cpp
    cfe/trunk/test/ARCMT/GC-no-arc-runtime.m.result
    cfe/trunk/test/ARCMT/GC.m
    cfe/trunk/test/ARCMT/GC.m.result

Modified: cfe/trunk/lib/ARCMigrate/TransProperties.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransProperties.cpp?rev=148607&r1=148606&r2=148607&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/TransProperties.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransProperties.cpp Fri Jan 20 18:43:53 2012
@@ -201,10 +201,8 @@
     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 @@
   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,

Modified: cfe/trunk/test/ARCMT/GC-no-arc-runtime.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/GC-no-arc-runtime.m.result?rev=148607&r1=148606&r2=148607&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/GC-no-arc-runtime.m.result (original)
+++ cfe/trunk/test/ARCMT/GC-no-arc-runtime.m.result Fri Jan 20 18:43:53 2012
@@ -52,12 +52,12 @@
 @end
 
 @interface I4Impl {
-  I4Impl *pds2;
+  I4Impl *__strong pds2;
 }
 @property (unsafe_unretained) I4Impl * pw1, * pw2;
- at property  I4Impl * ps;
- at property  I4Impl * pds;
- at property  I4Impl * pds2;
+ at property (strong) I4Impl * ps;
+ at property (strong) I4Impl * pds;
+ at property (strong) I4Impl * pds2;
 @end
 
 @implementation I4Impl

Modified: cfe/trunk/test/ARCMT/GC.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/GC.m?rev=148607&r1=148606&r2=148607&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/GC.m (original)
+++ cfe/trunk/test/ARCMT/GC.m Fri Jan 20 18:43:53 2012
@@ -79,3 +79,14 @@
   id x = NSMakeCollectable(cft);
 }
 @end
+
+// rdar://10532449
+ at interface rdar10532449
+ at property (assign) id assign_prop;
+ at property (assign, readonly) id __strong strong_readonly_prop;
+ at property (assign) id __weak weak_prop;
+ at end
+
+ at implementation rdar10532449
+ at synthesize assign_prop, strong_readonly_prop, weak_prop;
+ at end

Modified: cfe/trunk/test/ARCMT/GC.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/GC.m.result?rev=148607&r1=148606&r2=148607&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/GC.m.result (original)
+++ cfe/trunk/test/ARCMT/GC.m.result Fri Jan 20 18:43:53 2012
@@ -52,15 +52,15 @@
 @end
 
 @interface I4Impl {
-  I4Impl *pds2;
+  I4Impl *__strong pds2;
   I4Impl *pds3;
   __weak I4Impl *pw3;
   __weak I4Impl *pw4;
 }
 @property (weak) I4Impl * pw1, * pw2;
- at property  I4Impl * ps;
- at property  I4Impl * pds;
- at property  I4Impl * pds2;
+ at property (strong) I4Impl * ps;
+ at property (strong) I4Impl * pds;
+ at property (strong) I4Impl * pds2;
 @property (readwrite) I4Impl * pds3;
 @property (readonly) I4Impl * pds4;
 @property (weak, readonly)  I4Impl *pw3;
@@ -74,3 +74,14 @@
   id x = CFBridgingRelease(cft);
 }
 @end
+
+// rdar://10532449
+ at interface rdar10532449
+ at property (strong) id assign_prop;
+ at property (strong, readonly) id  strong_readonly_prop;
+ at property (weak) id  weak_prop;
+ at end
+
+ at implementation rdar10532449
+ at synthesize assign_prop, strong_readonly_prop, weak_prop;
+ at end





More information about the cfe-commits mailing list