]> granicus.if.org Git - clang/commitdiff
ObjectiveC migrator: Don't infer a property from isXXX method
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 17 Sep 2013 19:38:55 +0000 (19:38 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 17 Sep 2013 19:38:55 +0000 (19:38 +0000)
of retainable object (readonly or otherwise).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190881 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ARCMigrate/ObjCMT.cpp
test/ARCMT/objcmt-property.m.result

index b859c0b19d689fca59e2f0a1f8adf6f2881d50d7..b51f8bb4938486f710eab0746aa1b2db9b5a24ab 100644 (file)
@@ -741,8 +741,11 @@ bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx,
     // try a different naming convention for getter: isXxxxx
     StringRef getterNameString = getterName->getName();
     bool IsPrefix = getterNameString.startswith("is");
-    if ((IsPrefix && !GRT->isObjCRetainableType()) ||
-        getterNameString.startswith("get")) {
+    // Note that we don't want to change an isXXX method of retainable object
+    // type to property (readonly or otherwise).
+    if (IsPrefix && GRT->isObjCRetainableType())
+      return false;
+    if (IsPrefix || getterNameString.startswith("get")) {
       LengthOfPrefix = (IsPrefix ? 2 : 3);
       const char *CGetterName = getterNameString.data() + LengthOfPrefix;
       // Make sure that first character after "is" or "get" prefix can
@@ -759,6 +762,7 @@ bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx,
       }
     }
   }
+  
   if (SetterMethod) {
     // Is this a valid setter, matching the target getter?
     QualType SRT = SetterMethod->getResultType();
index eff89294cf3bb3e180cb6c6109e0d81ce809a883..355a8c124cca351da7f1c1c59d408f1dd06b4bcf 100644 (file)
@@ -86,7 +86,7 @@ typedef char BOOL;
 @property(nonatomic, getter=isContinuous) BOOL continuous;
 
 
-@property(nonatomic, readonly) id isAnObject;
+- (id) isAnObject;
 - (void)setAnObject : (id) object;
 
 @property(nonatomic, getter=isinValid, readonly) BOOL inValid;
@@ -138,7 +138,7 @@ typedef char BOOL;
 @property(nonatomic, getter=isContinuous) BOOL continuous;
 
 
-@property(nonatomic, readonly) id isAnObject;
+- (id) isAnObject;
 - (void)setAnObject : (id) object;
 
 @property(nonatomic, getter=isinValid, readonly) BOOL inValid;