From 83b85b67053dd9e1232333f4aae9ddde7b14b94f Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Thu, 21 Nov 2013 00:58:17 +0000 Subject: [PATCH] ObjectiveC migrator. use strong instead of retain attribute for inferred properties. // rdar://15519923 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195292 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ARCMigrate/ObjCMT.cpp | 4 +- test/ARCMT/objcmt-atomic-property.m.result | 44 +++++++++---------- .../objcmt-ns-nonatomic-iosonly.m.result | 44 +++++++++---------- .../objcmt-property-availability.m.result | 10 ++--- test/ARCMT/objcmt-property.m.result | 44 +++++++++---------- 5 files changed, 73 insertions(+), 73 deletions(-) diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp index 0f0268572e..f35e981d94 100644 --- a/lib/ARCMigrate/ObjCMT.cpp +++ b/lib/ARCMigrate/ObjCMT.cpp @@ -301,7 +301,7 @@ static const char *PropertyMemoryAttribute(ASTContext &Context, QualType ArgType IDecl->lookupNestedProtocol(&Context.Idents.get("NSCopying"))) return "copy"; else - return "retain"; + return "strong"; } else if (ArgType->isBlockPointerType()) return "copy"; @@ -310,7 +310,7 @@ static const char *PropertyMemoryAttribute(ASTContext &Context, QualType ArgType // looking into setter's implementation for backing weak ivar. return "weak"; else if (RetainableObject) - return ArgType->isBlockPointerType() ? "copy" : "retain"; + return ArgType->isBlockPointerType() ? "copy" : "strong"; return 0; } diff --git a/test/ARCMT/objcmt-atomic-property.m.result b/test/ARCMT/objcmt-atomic-property.m.result index 1650cd23e3..7bde087ce9 100644 --- a/test/ARCMT/objcmt-atomic-property.m.result +++ b/test/ARCMT/objcmt-atomic-property.m.result @@ -23,14 +23,14 @@ typedef char BOOL; } @property (weak) NSString *WeakProp; -@property (retain) NSString *StrongProp; +@property (strong) NSString *StrongProp; -@property (retain) NSString *UnavailProp __attribute__((unavailable)); +@property (strong) NSString *UnavailProp __attribute__((unavailable)); - (void) setUnavailProp : (NSString *)Val; -@property (retain) NSString *UnavailProp1 __attribute__((unavailable)); +@property (strong) NSString *UnavailProp1 __attribute__((unavailable)); -@property (retain) NSString *UnavailProp2; +@property (strong) NSString *UnavailProp2; - (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable)); @property (copy) NSDictionary *undoAction; @@ -48,10 +48,10 @@ typedef char BOOL; NSArray *_names3; NSArray *_names4; } -@property (retain) NSArray *names2; -@property (retain) NSArray *names3; -@property (retain) NSArray *names4; -@property (retain) NSArray *names1; +@property (strong) NSArray *names2; +@property (strong) NSArray *names3; +@property (strong) NSArray *names4; +@property (strong) NSArray *names1; @end // Properties that contain the name "delegate" or "dataSource", @@ -64,9 +64,9 @@ typedef char BOOL; @property (assign) id xxxdelegateYYY; -@property (retain) id MYtarget; +@property (strong) id MYtarget; -@property (retain) id targetX; +@property (strong) id targetX; @property int value; @@ -80,14 +80,14 @@ typedef char BOOL; - (void) Nothing; @property (readonly) int Length; -@property (readonly, retain) id object; +@property (readonly, strong) id object; + (double) D; @property (readonly) void *JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); @property (getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents; -@property (getter=getStringValue, retain) NSString *stringValue; +@property (getter=getStringValue, strong) NSString *stringValue; @property (getter=getCounterValue, readonly) BOOL counterValue; -@property (getter=getns_dixtionary, readonly, retain) NSDictionary *ns_dixtionary; +@property (getter=getns_dixtionary, readonly, strong) NSDictionary *ns_dixtionary; - (BOOL)is3bar; // watch out - (NSString *)get3foo; // watch out @@ -108,9 +108,9 @@ typedef char BOOL; @property (assign) id xxxdelegateYYY; -@property (retain) id MYtarget; +@property (strong) id MYtarget; -@property (retain) id targetX; +@property (strong) id targetX; @property int value; @@ -124,7 +124,7 @@ typedef char BOOL; - (void) Nothing; @property (readonly) int Length; -@property (readonly, retain) id object; +@property (readonly, strong) id object; + (double) D; - (BOOL)is3bar; // watch out @@ -161,26 +161,26 @@ DEPRECATED @interface NSURL // Do not infer a property. -@property (retain) NSURL *appStoreReceiptURL NS_AVAILABLE; +@property (strong) NSURL *appStoreReceiptURL NS_AVAILABLE; - (void) setAppStoreReceiptURL : (NSURL *)object; -@property (retain) NSURL *appStoreReceiptURLX NS_AVAILABLE; +@property (strong) NSURL *appStoreReceiptURLX NS_AVAILABLE; // Do not infer a property. -@property (retain) NSURL *appStoreReceiptURLY ; +@property (strong) NSURL *appStoreReceiptURLY ; - (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE; -@property (readonly, retain) id OkToInfer NS_AVAILABLE; +@property (readonly, strong) id OkToInfer NS_AVAILABLE; // Do not infer a property. -@property (retain) NSURL *appStoreReceiptURLZ ; +@property (strong) NSURL *appStoreReceiptURLZ ; - (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE; // Do not infer a property. - (id) t1 NORETURN NS_AVAILABLE; - (void) setT1 : (id) arg NS_AVAILABLE; -@property (retain) id method1 ALIGNED NS_AVAILABLE; +@property (strong) id method1 ALIGNED NS_AVAILABLE; - (NSURL *)init; // No Change + (id)alloc; // No Change diff --git a/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result b/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result index 804142ee32..5513fce80c 100644 --- a/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result +++ b/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result @@ -30,14 +30,14 @@ typedef char BOOL; } @property (NS_NONATOMIC_IOSONLY, weak) NSString *WeakProp; -@property (NS_NONATOMIC_IOSONLY, retain) NSString *StrongProp; +@property (NS_NONATOMIC_IOSONLY, strong) NSString *StrongProp; -@property (NS_NONATOMIC_IOSONLY, retain) NSString *UnavailProp __attribute__((unavailable)); +@property (NS_NONATOMIC_IOSONLY, strong) NSString *UnavailProp __attribute__((unavailable)); - (void) setUnavailProp : (NSString *)Val; -@property (NS_NONATOMIC_IOSONLY, retain) NSString *UnavailProp1 __attribute__((unavailable)); +@property (NS_NONATOMIC_IOSONLY, strong) NSString *UnavailProp1 __attribute__((unavailable)); -@property (NS_NONATOMIC_IOSONLY, retain) NSString *UnavailProp2; +@property (NS_NONATOMIC_IOSONLY, strong) NSString *UnavailProp2; - (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable)); @property (NS_NONATOMIC_IOSONLY, copy) NSDictionary *undoAction; @@ -55,10 +55,10 @@ typedef char BOOL; NSArray *_names3; NSArray *_names4; } -@property (NS_NONATOMIC_IOSONLY, retain) NSArray *names2; -@property (NS_NONATOMIC_IOSONLY, retain) NSArray *names3; -@property (NS_NONATOMIC_IOSONLY, retain) NSArray *names4; -@property (NS_NONATOMIC_IOSONLY, retain) NSArray *names1; +@property (NS_NONATOMIC_IOSONLY, strong) NSArray *names2; +@property (NS_NONATOMIC_IOSONLY, strong) NSArray *names3; +@property (NS_NONATOMIC_IOSONLY, strong) NSArray *names4; +@property (NS_NONATOMIC_IOSONLY, strong) NSArray *names1; @end // Properties that contain the name "delegate" or "dataSource", @@ -71,9 +71,9 @@ typedef char BOOL; @property (NS_NONATOMIC_IOSONLY, assign) id xxxdelegateYYY; -@property (NS_NONATOMIC_IOSONLY, retain) id MYtarget; +@property (NS_NONATOMIC_IOSONLY, strong) id MYtarget; -@property (NS_NONATOMIC_IOSONLY, retain) id targetX; +@property (NS_NONATOMIC_IOSONLY, strong) id targetX; @property (NS_NONATOMIC_IOSONLY) int value; @@ -87,14 +87,14 @@ typedef char BOOL; - (void) Nothing; @property (NS_NONATOMIC_IOSONLY, readonly) int Length; -@property (NS_NONATOMIC_IOSONLY, readonly, retain) id object; +@property (NS_NONATOMIC_IOSONLY, readonly, strong) id object; + (double) D; @property (NS_NONATOMIC_IOSONLY, readonly) void *JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); @property (NS_NONATOMIC_IOSONLY, getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents; -@property (NS_NONATOMIC_IOSONLY, getter=getStringValue, retain) NSString *stringValue; +@property (NS_NONATOMIC_IOSONLY, getter=getStringValue, strong) NSString *stringValue; @property (NS_NONATOMIC_IOSONLY, getter=getCounterValue, readonly) BOOL counterValue; -@property (NS_NONATOMIC_IOSONLY, getter=getns_dixtionary, readonly, retain) NSDictionary *ns_dixtionary; +@property (NS_NONATOMIC_IOSONLY, getter=getns_dixtionary, readonly, strong) NSDictionary *ns_dixtionary; - (BOOL)is3bar; // watch out - (NSString *)get3foo; // watch out @@ -115,9 +115,9 @@ typedef char BOOL; @property (NS_NONATOMIC_IOSONLY, assign) id xxxdelegateYYY; -@property (NS_NONATOMIC_IOSONLY, retain) id MYtarget; +@property (NS_NONATOMIC_IOSONLY, strong) id MYtarget; -@property (NS_NONATOMIC_IOSONLY, retain) id targetX; +@property (NS_NONATOMIC_IOSONLY, strong) id targetX; @property (NS_NONATOMIC_IOSONLY) int value; @@ -131,7 +131,7 @@ typedef char BOOL; - (void) Nothing; @property (NS_NONATOMIC_IOSONLY, readonly) int Length; -@property (NS_NONATOMIC_IOSONLY, readonly, retain) id object; +@property (NS_NONATOMIC_IOSONLY, readonly, strong) id object; + (double) D; - (BOOL)is3bar; // watch out @@ -168,26 +168,26 @@ DEPRECATED @interface NSURL // Do not infer a property. -@property (NS_NONATOMIC_IOSONLY, retain) NSURL *appStoreReceiptURL NS_AVAILABLE; +@property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURL NS_AVAILABLE; - (void) setAppStoreReceiptURL : (NSURL *)object; -@property (NS_NONATOMIC_IOSONLY, retain) NSURL *appStoreReceiptURLX NS_AVAILABLE; +@property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURLX NS_AVAILABLE; // Do not infer a property. -@property (NS_NONATOMIC_IOSONLY, retain) NSURL *appStoreReceiptURLY ; +@property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURLY ; - (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE; -@property (NS_NONATOMIC_IOSONLY, readonly, retain) id OkToInfer NS_AVAILABLE; +@property (NS_NONATOMIC_IOSONLY, readonly, strong) id OkToInfer NS_AVAILABLE; // Do not infer a property. -@property (NS_NONATOMIC_IOSONLY, retain) NSURL *appStoreReceiptURLZ ; +@property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURLZ ; - (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE; // Do not infer a property. - (id) t1 NORETURN NS_AVAILABLE; - (void) setT1 : (id) arg NS_AVAILABLE; -@property (NS_NONATOMIC_IOSONLY, retain) id method1 ALIGNED NS_AVAILABLE; +@property (NS_NONATOMIC_IOSONLY, strong) id method1 ALIGNED NS_AVAILABLE; - (NSURL *)init; // No Change + (id)alloc; // No Change diff --git a/test/ARCMT/objcmt-property-availability.m.result b/test/ARCMT/objcmt-property-availability.m.result index 681f9a99bf..a5a45e3792 100644 --- a/test/ARCMT/objcmt-property-availability.m.result +++ b/test/ARCMT/objcmt-property-availability.m.result @@ -19,20 +19,20 @@ #define UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) @interface MKMapItem -@property (nonatomic, retain) MKMapItem *source NS_AVAILABLE(10_9, 6_0); +@property (nonatomic, strong) MKMapItem *source NS_AVAILABLE(10_9, 6_0); - (void)setSource:(MKMapItem *)source NS_AVAILABLE(10_9, 7_0); -@property (nonatomic, retain) MKMapItem *dest NS_AVAILABLE(10_9, 6_0); +@property (nonatomic, strong) MKMapItem *dest NS_AVAILABLE(10_9, 6_0); -@property (nonatomic, retain) MKMapItem *final; +@property (nonatomic, strong) MKMapItem *final; -@property (nonatomic, retain) MKMapItem *total NS_AVAILABLE(10_9, 6_0); +@property (nonatomic, strong) MKMapItem *total NS_AVAILABLE(10_9, 6_0); - (void)setTotal:(MKMapItem *)source; - (MKMapItem *)comp NS_AVAILABLE(10_9, 6_0); - (void)setComp:(MKMapItem *)source UNAVAILABLE; -@property (nonatomic, retain) MKMapItem *tally UNAVAILABLE NS_AVAILABLE(10_9, 6_0); +@property (nonatomic, strong) MKMapItem *tally UNAVAILABLE NS_AVAILABLE(10_9, 6_0); - (MKMapItem *)itally NS_AVAILABLE(10_9, 6_0); - (void)setItally:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0); diff --git a/test/ARCMT/objcmt-property.m.result b/test/ARCMT/objcmt-property.m.result index c6380c8052..1a82cb2052 100644 --- a/test/ARCMT/objcmt-property.m.result +++ b/test/ARCMT/objcmt-property.m.result @@ -23,14 +23,14 @@ typedef char BOOL; } @property (nonatomic, weak) NSString *WeakProp; -@property (nonatomic, retain) NSString *StrongProp; +@property (nonatomic, strong) NSString *StrongProp; -@property (nonatomic, retain) NSString *UnavailProp __attribute__((unavailable)); +@property (nonatomic, strong) NSString *UnavailProp __attribute__((unavailable)); - (void) setUnavailProp : (NSString *)Val; -@property (nonatomic, retain) NSString *UnavailProp1 __attribute__((unavailable)); +@property (nonatomic, strong) NSString *UnavailProp1 __attribute__((unavailable)); -@property (nonatomic, retain) NSString *UnavailProp2; +@property (nonatomic, strong) NSString *UnavailProp2; - (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable)); @property (nonatomic, copy) NSDictionary *undoAction; @@ -48,10 +48,10 @@ typedef char BOOL; NSArray *_names3; NSArray *_names4; } -@property (nonatomic, retain) NSArray *names2; -@property (nonatomic, retain) NSArray *names3; -@property (nonatomic, retain) NSArray *names4; -@property (nonatomic, retain) NSArray *names1; +@property (nonatomic, strong) NSArray *names2; +@property (nonatomic, strong) NSArray *names3; +@property (nonatomic, strong) NSArray *names4; +@property (nonatomic, strong) NSArray *names1; @end // Properties that contain the name "delegate" or "dataSource", @@ -64,9 +64,9 @@ typedef char BOOL; @property (nonatomic, assign) id xxxdelegateYYY; -@property (nonatomic, retain) id MYtarget; +@property (nonatomic, strong) id MYtarget; -@property (nonatomic, retain) id targetX; +@property (nonatomic, strong) id targetX; @property (nonatomic) int value; @@ -80,14 +80,14 @@ typedef char BOOL; - (void) Nothing; @property (nonatomic, readonly) int Length; -@property (nonatomic, readonly, retain) id object; +@property (nonatomic, readonly, strong) id object; + (double) D; @property (nonatomic, readonly) void *JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); @property (nonatomic, getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents; -@property (nonatomic, getter=getStringValue, retain) NSString *stringValue; +@property (nonatomic, getter=getStringValue, strong) NSString *stringValue; @property (nonatomic, getter=getCounterValue, readonly) BOOL counterValue; -@property (nonatomic, getter=getns_dixtionary, readonly, retain) NSDictionary *ns_dixtionary; +@property (nonatomic, getter=getns_dixtionary, readonly, strong) NSDictionary *ns_dixtionary; - (BOOL)is3bar; // watch out - (NSString *)get3foo; // watch out @@ -108,9 +108,9 @@ typedef char BOOL; @property (nonatomic, assign) id xxxdelegateYYY; -@property (nonatomic, retain) id MYtarget; +@property (nonatomic, strong) id MYtarget; -@property (nonatomic, retain) id targetX; +@property (nonatomic, strong) id targetX; @property (nonatomic) int value; @@ -124,7 +124,7 @@ typedef char BOOL; - (void) Nothing; @property (nonatomic, readonly) int Length; -@property (nonatomic, readonly, retain) id object; +@property (nonatomic, readonly, strong) id object; + (double) D; - (BOOL)is3bar; // watch out @@ -161,26 +161,26 @@ DEPRECATED @interface NSURL // Do not infer a property. -@property (nonatomic, retain) NSURL *appStoreReceiptURL NS_AVAILABLE; +@property (nonatomic, strong) NSURL *appStoreReceiptURL NS_AVAILABLE; - (void) setAppStoreReceiptURL : (NSURL *)object; -@property (nonatomic, retain) NSURL *appStoreReceiptURLX NS_AVAILABLE; +@property (nonatomic, strong) NSURL *appStoreReceiptURLX NS_AVAILABLE; // Do not infer a property. -@property (nonatomic, retain) NSURL *appStoreReceiptURLY ; +@property (nonatomic, strong) NSURL *appStoreReceiptURLY ; - (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE; -@property (nonatomic, readonly, retain) id OkToInfer NS_AVAILABLE; +@property (nonatomic, readonly, strong) id OkToInfer NS_AVAILABLE; // Do not infer a property. -@property (nonatomic, retain) NSURL *appStoreReceiptURLZ ; +@property (nonatomic, strong) NSURL *appStoreReceiptURLZ ; - (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE; // Do not infer a property. - (id) t1 NORETURN NS_AVAILABLE; - (void) setT1 : (id) arg NS_AVAILABLE; -@property (nonatomic, retain) id method1 ALIGNED NS_AVAILABLE; +@property (nonatomic, strong) id method1 ALIGNED NS_AVAILABLE; - (NSURL *)init; // No Change + (id)alloc; // No Change -- 2.40.0