From: Fariborz Jahanian Date: Fri, 20 Jan 2012 19:15:02 +0000 (+0000) Subject: arc migrator: replace "retain" attribute with "strong" X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=86f960143c73f573919255c4465de71f85793c2e;p=clang arc migrator: replace "retain" attribute with "strong" which have same semantics in mrr as well as arr. // rdar://10688312 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148559 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/ARCMigrate/TransProperties.cpp b/lib/ARCMigrate/TransProperties.cpp index f8bc8a3c5f..b36acbb205 100644 --- a/lib/ARCMigrate/TransProperties.cpp +++ b/lib/ARCMigrate/TransProperties.cpp @@ -50,7 +50,7 @@ class PropertiesRewriter { enum PropActionKind { PropAction_None, - PropAction_RetainRemoved, + PropAction_RetainReplacedWithStrong, PropAction_AssignRemoved, PropAction_AssignRewritten, PropAction_MaybeAddWeakOrUnsafe @@ -161,9 +161,11 @@ private: switch (kind) { case PropAction_None: return; - case PropAction_RetainRemoved: - removeAttribute("retain", atLoc); + case PropAction_RetainReplacedWithStrong: { + StringRef toAttr = "strong"; + MigrateCtx.rewritePropertyAttribute("retain", toAttr, atLoc); return; + } case PropAction_AssignRemoved: return removeAssignForDefaultStrong(props, atLoc); case PropAction_AssignRewritten: @@ -193,7 +195,7 @@ private: if (propAttrs & ObjCPropertyDecl::OBJC_PR_retain) { // strong is the default. - return doPropAction(PropAction_RetainRemoved, props, atLoc); + return doPropAction(PropAction_RetainReplacedWithStrong, props, atLoc); } bool HasIvarAssignedAPlusOneObject = hasIvarAssignedAPlusOneObject(props); diff --git a/test/ARCMT/GC-no-arc-runtime.m.result b/test/ARCMT/GC-no-arc-runtime.m.result index 8493b0de7b..983af62c4a 100644 --- a/test/ARCMT/GC-no-arc-runtime.m.result +++ b/test/ARCMT/GC-no-arc-runtime.m.result @@ -26,7 +26,7 @@ void test1(CFTypeRef *cft) { @end @interface I2 -@property id prop; +@property (strong) id prop; @end @implementation I2 diff --git a/test/ARCMT/GC.m.result b/test/ARCMT/GC.m.result index 0df6aa89e8..2cf6b8e244 100644 --- a/test/ARCMT/GC.m.result +++ b/test/ARCMT/GC.m.result @@ -26,7 +26,7 @@ void test1(CFTypeRef *cft) { @end @interface I2 -@property id prop; +@property (strong) id prop; @end @implementation I2 diff --git a/test/ARCMT/assign-prop-with-arc-runtime.m.result b/test/ARCMT/assign-prop-with-arc-runtime.m.result index 9551e305a1..30a9caa844 100644 --- a/test/ARCMT/assign-prop-with-arc-runtime.m.result +++ b/test/ARCMT/assign-prop-with-arc-runtime.m.result @@ -38,9 +38,9 @@ typedef _NSCachedAttributedString *BadClassForWeak; @property (weak) Foo *no_user_ivar1; @property (weak, readonly) Foo *no_user_ivar2; -@property id def1; -@property (atomic) id def2; -@property (atomic) id def3; +@property (strong) id def1; +@property (atomic,strong) id def2; +@property (strong,atomic) id def3; @end @@ -58,12 +58,12 @@ typedef _NSCachedAttributedString *BadClassForWeak; @end @interface TestExt -@property (readonly) TestExt *x1; +@property (strong,readonly) TestExt *x1; @property (weak, readonly) TestExt *x2; @end @interface TestExt() -@property (readwrite) TestExt *x1; +@property (strong,readwrite) TestExt *x1; @property (weak, readwrite) TestExt *x2; @end diff --git a/test/ARCMT/releases-driver.m.result b/test/ARCMT/releases-driver.m.result index 14aecce8e9..70c0aecaf4 100644 --- a/test/ARCMT/releases-driver.m.result +++ b/test/ARCMT/releases-driver.m.result @@ -20,7 +20,7 @@ id IhaveSideEffect(); @interface Foo : NSObject { id bar; } -@property id bar; +@property (strong) id bar; -(void)test:(id)obj; @end diff --git a/test/ARCMT/releases.m.result b/test/ARCMT/releases.m.result index 2b6240b10e..556610ab2a 100644 --- a/test/ARCMT/releases.m.result +++ b/test/ARCMT/releases.m.result @@ -20,7 +20,7 @@ id IhaveSideEffect(); @interface Foo : NSObject { id bar; } -@property id bar; +@property (strong) id bar; -(void)test:(id)obj; @end diff --git a/test/ARCMT/remove-dealloc-method.m.result b/test/ARCMT/remove-dealloc-method.m.result index 5e1efa8687..47e31f9d24 100644 --- a/test/ARCMT/remove-dealloc-method.m.result +++ b/test/ARCMT/remove-dealloc-method.m.result @@ -5,10 +5,10 @@ #define nil ((void*) 0) @interface Foo -@property id x; -@property id y; -@property id w; -@property id z; +@property (strong) id x; +@property (strong) id y; +@property (strong) id w; +@property (strong) id z; @end @implementation Foo diff --git a/test/ARCMT/remove-dealloc-zerouts.m.result b/test/ARCMT/remove-dealloc-zerouts.m.result index c857760bc3..9ae831abac 100644 --- a/test/ARCMT/remove-dealloc-zerouts.m.result +++ b/test/ARCMT/remove-dealloc-zerouts.m.result @@ -3,10 +3,10 @@ // RUN: diff %t %s.result @interface Foo -@property id x; -@property id y; -@property id w; -@property id z; +@property (strong) id x; +@property (strong) id y; +@property (strong) id w; +@property (strong) id z; @property (strong) id q; @end @@ -23,7 +23,7 @@ @end @interface Bar -@property Foo *a; +@property (strong) Foo *a; - (void) setA:(Foo*) val; - (id) a; @end diff --git a/test/ARCMT/retains.m.result b/test/ARCMT/retains.m.result index 19f8972942..2011e50636 100644 --- a/test/ARCMT/retains.m.result +++ b/test/ARCMT/retains.m.result @@ -9,7 +9,7 @@ id IhaveSideEffect(); @interface Foo : NSObject { id bar; } -@property id bar; +@property (strong) id bar; -(id)test:(id)obj; -(id)something; @end