From: Fariborz Jahanian Date: Thu, 12 Dec 2013 01:02:00 +0000 (+0000) Subject: Objective-C migrator: when inferring 'readonly' property of an X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7f86ffd5597fa70bec7fce8636925b4a54ff78c4;p=clang Objective-C migrator: when inferring 'readonly' property of an Objective-C object conforming to 'NSCopying' protocol, infer a 'copy' property, instead of 'strong'. // rdar://15525937 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197102 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp index d25831abbc..cd0d01957e 100644 --- a/lib/ARCMigrate/ObjCMT.cpp +++ b/lib/ARCMigrate/ObjCMT.cpp @@ -324,7 +324,9 @@ void MigrateBlockOrFunctionPointerTypeVariable(std::string & PropertyString, static const char *PropertyMemoryAttribute(ASTContext &Context, QualType ArgType) { Qualifiers::ObjCLifetime propertyLifetime = ArgType.getObjCLifetime(); bool RetainableObject = ArgType->isObjCRetainableType(); - if (RetainableObject && propertyLifetime == Qualifiers::OCL_Strong) { + if (RetainableObject && + (propertyLifetime == Qualifiers::OCL_Strong + || propertyLifetime == Qualifiers::OCL_None)) { if (const ObjCObjectPointerType *ObjPtrTy = ArgType->getAs()) { ObjCInterfaceDecl *IDecl = ObjPtrTy->getObjectType()->getInterface(); diff --git a/test/ARCMT/objcmt-atomic-property.m.result b/test/ARCMT/objcmt-atomic-property.m.result index 7bde087ce9..3378ff1e48 100644 --- a/test/ARCMT/objcmt-atomic-property.m.result +++ b/test/ARCMT/objcmt-atomic-property.m.result @@ -87,7 +87,7 @@ typedef char BOOL; @property (getter=getStringValue, strong) NSString *stringValue; @property (getter=getCounterValue, readonly) BOOL counterValue; -@property (getter=getns_dixtionary, readonly, strong) NSDictionary *ns_dixtionary; +@property (getter=getns_dixtionary, readonly, copy) NSDictionary *ns_dixtionary; - (BOOL)is3bar; // watch out - (NSString *)get3foo; // watch out diff --git a/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result b/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result index 5513fce80c..8e9e3a0c21 100644 --- a/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result +++ b/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result @@ -94,7 +94,7 @@ typedef char BOOL; @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, strong) NSDictionary *ns_dixtionary; +@property (NS_NONATOMIC_IOSONLY, getter=getns_dixtionary, readonly, copy) NSDictionary *ns_dixtionary; - (BOOL)is3bar; // watch out - (NSString *)get3foo; // watch out diff --git a/test/ARCMT/objcmt-property.m.result b/test/ARCMT/objcmt-property.m.result index eb2f5fea90..ec4ac85127 100644 --- a/test/ARCMT/objcmt-property.m.result +++ b/test/ARCMT/objcmt-property.m.result @@ -90,7 +90,7 @@ typedef char BOOL; @property (nonatomic, getter=getStringValue, strong) NSString *stringValue; @property (nonatomic, getter=getCounterValue, readonly) BOOL counterValue; -@property (nonatomic, getter=getns_dixtionary, readonly, strong) NSDictionary *ns_dixtionary; +@property (nonatomic, getter=getns_dixtionary, readonly, copy) NSDictionary *ns_dixtionary; - (BOOL)is3bar; // watch out - (NSString *)get3foo; // watch out