[cfe-commits] r145210 - in /cfe/trunk: lib/ARCMigrate/TransGCAttrs.cpp lib/ARCMigrate/TransProperties.cpp test/ARCMT/GC.m test/ARCMT/GC.m.result

Argyrios Kyrtzidis akyrtzi at gmail.com
Sun Nov 27 16:23:12 PST 2011


Author: akirtzidis
Date: Sun Nov 27 18:23:12 2011
New Revision: 145210

URL: http://llvm.org/viewvc/llvm-project?rev=145210&view=rev
Log:
[arcmt] Don't add __weak if there is already a GC __weak and make sure to clear
__weak from a readonly property.

Modified:
    cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
    cfe/trunk/lib/ARCMigrate/TransProperties.cpp
    cfe/trunk/test/ARCMT/GC.m
    cfe/trunk/test/ARCMT/GC.m.result

Modified: cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp?rev=145210&r1=145209&r2=145210&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp Sun Nov 27 18:23:12 2011
@@ -326,7 +326,8 @@
   for (unsigned i = 0, e = AllProps.size(); i != e; ++i) {
     ObjCPropertyDecl *PD = AllProps[i];
     if (PD->getPropertyAttributesAsWritten() &
-          ObjCPropertyDecl::OBJC_PR_assign) {
+          (ObjCPropertyDecl::OBJC_PR_assign |
+           ObjCPropertyDecl::OBJC_PR_readonly)) {
       SourceLocation AtLoc = PD->getAtLoc();
       if (AtLoc.isInvalid())
         continue;

Modified: cfe/trunk/lib/ARCMigrate/TransProperties.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransProperties.cpp?rev=145210&r1=145209&r2=145210&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/TransProperties.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransProperties.cpp Sun Nov 27 18:23:12 2011
@@ -237,9 +237,12 @@
       canUseWeak = false;
 
     for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) {
-      if (isUserDeclared(I->IvarD))
-        Pass.TA.insert(I->IvarD->getLocation(),
-                       canUseWeak ? "__weak " : "__unsafe_unretained ");
+      if (isUserDeclared(I->IvarD)) {
+        if (I->IvarD &&
+            I->IvarD->getType().getObjCLifetime() != Qualifiers::OCL_Weak)
+          Pass.TA.insert(I->IvarD->getLocation(),
+                         canUseWeak ? "__weak " : "__unsafe_unretained ");
+      }
       if (I->ImplD)
         Pass.TA.clearDiagnostic(diag::err_arc_assign_property_ownership,
                                 I->ImplD->getLocation());
@@ -257,9 +260,12 @@
       canUseWeak = false;
 
     for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) {
-      if (isUserDeclared(I->IvarD))
-        Pass.TA.insert(I->IvarD->getLocation(),
-                       canUseWeak ? "__weak " : "__unsafe_unretained ");
+      if (isUserDeclared(I->IvarD)) {
+        if (I->IvarD &&
+            I->IvarD->getType().getObjCLifetime() != Qualifiers::OCL_Weak)
+          Pass.TA.insert(I->IvarD->getLocation(),
+                         canUseWeak ? "__weak " : "__unsafe_unretained ");
+      }
       if (I->ImplD) {
         Pass.TA.clearDiagnostic(diag::err_arc_assign_property_ownership,
                                 I->ImplD->getLocation());

Modified: cfe/trunk/test/ARCMT/GC.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/GC.m?rev=145210&r1=145209&r2=145210&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/GC.m (original)
+++ cfe/trunk/test/ARCMT/GC.m Sun Nov 27 18:23:12 2011
@@ -58,6 +58,8 @@
 @interface I4Impl {
   I4Impl *pds2;
   I4Impl *pds3;
+  __weak I4Impl *pw3;
+  __weak I4Impl *pw4;
 }
 @property (assign) I4Impl *__weak pw1, *__weak pw2;
 @property (assign) I4Impl *__strong ps;
@@ -65,10 +67,12 @@
 @property (assign) I4Impl * pds2;
 @property (readwrite) I4Impl * pds3;
 @property (readonly) I4Impl * pds4;
+ at property (readonly) __weak I4Impl *pw3;
+ at property (assign) __weak I4Impl *pw4;
 @end
 
 @implementation I4Impl
- at synthesize pw1, pw2, ps, pds, pds2, pds3, pds4;
+ at synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
 
 -(void)test1:(CFTypeRef *)cft {
   id x = NSMakeCollectable(cft);

Modified: cfe/trunk/test/ARCMT/GC.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/GC.m.result?rev=145210&r1=145209&r2=145210&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/GC.m.result (original)
+++ cfe/trunk/test/ARCMT/GC.m.result Sun Nov 27 18:23:12 2011
@@ -53,6 +53,8 @@
 @interface I4Impl {
   I4Impl *pds2;
   I4Impl *pds3;
+  __weak I4Impl *pw3;
+  __weak I4Impl *pw4;
 }
 @property (weak) I4Impl * pw1, * pw2;
 @property  I4Impl * ps;
@@ -60,10 +62,12 @@
 @property  I4Impl * pds2;
 @property (readwrite) I4Impl * pds3;
 @property (readonly) I4Impl * pds4;
+ at property (weak, readonly)  I4Impl *pw3;
+ at property (weak)  I4Impl *pw4;
 @end
 
 @implementation I4Impl
- at synthesize pw1, pw2, ps, pds, pds2, pds3, pds4;
+ at synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
 
 -(void)test1:(CFTypeRef *)cft {
   id x = CFBridgingRelease(cft);





More information about the cfe-commits mailing list