]> granicus.if.org Git - clang/commitdiff
Objective-C migrator: when inferring 'readonly' property of an
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 12 Dec 2013 01:02:00 +0000 (01:02 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 12 Dec 2013 01:02:00 +0000 (01:02 +0000)
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

lib/ARCMigrate/ObjCMT.cpp
test/ARCMT/objcmt-atomic-property.m.result
test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result
test/ARCMT/objcmt-property.m.result

index d25831abbc59d530c1ba6ef70f03cdbfe0c410d0..cd0d01957e41156ddd42c3469c13bdd8ea81b129 100644 (file)
@@ -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<ObjCObjectPointerType>()) {
       ObjCInterfaceDecl *IDecl = ObjPtrTy->getObjectType()->getInterface();
index 7bde087ce9063c7ab8bd4f11c77d521fed481d2e..3378ff1e487f931c0fe4ad0ee66a2d4ba6b179de 100644 (file)
@@ -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
index 5513fce80cc7a7e6fcad7096d1208bb7121bca96..8e9e3a0c21ca53e5589e1744d53c2f8bef43d407 100644 (file)
@@ -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
index eb2f5fea908991e60ab8e65a9d8dceb99161b298..ec4ac85127efe39533ea4f73fbe1d7348abcd130 100644 (file)
@@ -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