r188914 - ObjectiveC migrator: until we have beter understanding of

Fariborz Jahanian fjahanian at apple.com
Wed Aug 21 11:49:03 PDT 2013


Author: fjahanian
Date: Wed Aug 21 13:49:03 2013
New Revision: 188914

URL: http://llvm.org/viewvc/llvm-project?rev=188914&view=rev
Log:
ObjectiveC migrator: until we have beter understanding of
setter/getter implementations, migrate them to
nonatomic properties.

Modified:
    cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
    cfe/trunk/test/ARCMT/objcmt-property.m.result

Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=188914&r1=188913&r2=188914&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Wed Aug 21 13:49:03 2013
@@ -222,11 +222,9 @@ void ObjCMigrateASTConsumer::migrateDecl
   BodyMigrator(*this).TraverseDecl(D);
 }
 
-static void append_attr(std::string &PropertyString, const char *attr,
-                        bool GetterHasIsPrefix) {
-  PropertyString += (GetterHasIsPrefix ? ", " : "(");
+static void append_attr(std::string &PropertyString, const char *attr) {
+  PropertyString += ", ";
   PropertyString += attr;
-  PropertyString += ')';
 }
 
 static bool rewriteToObjCProperty(const ObjCMethodDecl *Getter,
@@ -234,11 +232,11 @@ static bool rewriteToObjCProperty(const
                                   const NSAPI &NS, edit::Commit &commit,
                                   bool GetterHasIsPrefix) {
   ASTContext &Context = NS.getASTContext();
-  std::string PropertyString = "@property";
+  std::string PropertyString = "@property(nonatomic";
   std::string PropertyNameString = Getter->getNameAsString();
   StringRef PropertyName(PropertyNameString);
   if (GetterHasIsPrefix) {
-    PropertyString += "(getter=";
+    PropertyString += ", getter=";
     PropertyString += PropertyNameString;
   }
   // Short circuit properties that contain the name "delegate" or "dataSource",
@@ -246,7 +244,7 @@ static bool rewriteToObjCProperty(const
   if (PropertyName.equals("target") ||
       (PropertyName.find("delegate") != StringRef::npos) ||
       (PropertyName.find("dataSource") != StringRef::npos))
-    append_attr(PropertyString, "unsafe_unretained", GetterHasIsPrefix);
+    append_attr(PropertyString, "unsafe_unretained");
   else {
     const ParmVarDecl *argDecl = *Setter->param_begin();
     QualType ArgType = Context.getCanonicalType(argDecl->getType());
@@ -258,20 +256,18 @@ static bool rewriteToObjCProperty(const
         ObjCInterfaceDecl *IDecl = ObjPtrTy->getObjectType()->getInterface();
         if (IDecl &&
             IDecl->lookupNestedProtocol(&Context.Idents.get("NSCopying")))
-          append_attr(PropertyString, "copy", GetterHasIsPrefix);
+          append_attr(PropertyString, "copy");
         else
-          append_attr(PropertyString, "retain", GetterHasIsPrefix);
-      } else if (GetterHasIsPrefix)
-          PropertyString += ')';
+          append_attr(PropertyString, "retain");
+      }
     } else if (propertyLifetime == Qualifiers::OCL_Weak)
       // TODO. More precise determination of 'weak' attribute requires
       // looking into setter's implementation for backing weak ivar.
-      append_attr(PropertyString, "weak", GetterHasIsPrefix);
+      append_attr(PropertyString, "weak");
     else if (RetainableObject)
-      append_attr(PropertyString, "retain", GetterHasIsPrefix);
-    else if (GetterHasIsPrefix)
-      PropertyString += ')';
+      append_attr(PropertyString, "retain");
   }
+  PropertyString += ')';
   
   QualType RT = Getter->getResultType();
   if (!isa<TypedefType>(RT)) {

Modified: cfe/trunk/test/ARCMT/objcmt-property.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-property.m.result?rev=188914&r1=188913&r2=188914&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-property.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-property.m.result Wed Aug 21 13:49:03 2013
@@ -17,9 +17,9 @@ typedef char BOOL;
   int ivarVal;
 }
 
- at property(weak) NSString * WeakProp;
+ at property(nonatomic, weak) NSString * WeakProp;
 
- at property(retain) NSString * StrongProp;
+ at property(nonatomic, retain) NSString * StrongProp;
 
 
 - (NSString *) UnavailProp  __attribute__((unavailable));
@@ -31,7 +31,7 @@ typedef char BOOL;
 - (NSString *) UnavailProp2;
 - (void) setUnavailProp2  : (NSString *)Val  __attribute__((unavailable));
 
- at property(copy) NSDictionary * undoAction;
+ at property(nonatomic, copy) NSDictionary * undoAction;
 
 @end
 
@@ -51,35 +51,35 @@ typedef char BOOL;
 
 
 
- at property(retain) NSArray * names2;
- at property(retain) NSArray * names3;
- at property(retain) NSArray * names4;
- at property(retain) NSArray * names1;
+ at property(nonatomic, retain) NSArray * names2;
+ at property(nonatomic, retain) NSArray * names3;
+ at property(nonatomic, retain) NSArray * names4;
+ at property(nonatomic, retain) NSArray * names1;
 @end
 
 // Properties that contain the name "delegate" or "dataSource",
 // or have exact name "target" have unsafe_unretained attribute.
 @interface NSInvocation 
- at property(unsafe_unretained) id target;
+ at property(nonatomic, unsafe_unretained) id target;
 
 
- at property(unsafe_unretained) id dataSource;
+ at property(nonatomic, unsafe_unretained) id dataSource;
 
- at property(unsafe_unretained) id xxxdelegateYYY;
+ at property(nonatomic, unsafe_unretained) id xxxdelegateYYY;
 
 
 
 
- at property(retain) id MYtarget;
+ at property(nonatomic, retain) id MYtarget;
 
 
- at property(retain) id targetX;
+ at property(nonatomic, retain) id targetX;
 
  
- at property int value;
+ at property(nonatomic) int value;
 
 
- at property(getter=isContinuous) BOOL continuous;
+ at property(nonatomic, getter=isContinuous) BOOL continuous;
 
 
 - (id) isAnObject;





More information about the cfe-commits mailing list