r192853 - ObjectiveC migrator. Remove blank lines

Fariborz Jahanian fjahanian at apple.com
Wed Oct 16 15:35:19 PDT 2013


Author: fjahanian
Date: Wed Oct 16 17:35:19 2013
New Revision: 192853

URL: http://llvm.org/viewvc/llvm-project?rev=192853&view=rev
Log:
ObjectiveC migrator. Remove blank lines
when inferring property from setter/getter
methods. // rdar://15200949

Modified:
    cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
    cfe/trunk/test/ARCMT/objcmt-arc-cf-annotations.m.result
    cfe/trunk/test/ARCMT/objcmt-atomic-property.m.result
    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=192853&r1=192852&r2=192853&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Wed Oct 16 17:35:19 2013
@@ -273,7 +273,7 @@ void MigrateBlockOrFunctionPointerTypeVa
 }
 
 
-static bool rewriteToObjCProperty(const ObjCMethodDecl *Getter,
+static void rewriteToObjCProperty(const ObjCMethodDecl *Getter,
                                   const ObjCMethodDecl *Setter,
                                   const NSAPI &NS, edit::Commit &commit,
                                   unsigned LengthOfPrefix,
@@ -393,9 +393,12 @@ static bool rewriteToObjCProperty(const
     SourceLocation EndLoc = Setter->getDeclaratorEndLoc();
     // Get location past ';'
     EndLoc = EndLoc.getLocWithOffset(1);
-    commit.remove(CharSourceRange::getCharRange(Setter->getLocStart(), EndLoc));
+    SourceLocation BeginOfSetterDclLoc = Setter->getLocStart();
+    // FIXME. This assumes that setter decl; is immediately preceeded by eoln.
+    // It is trying to remove the setter method decl. line entirely.
+    BeginOfSetterDclLoc = BeginOfSetterDclLoc.getLocWithOffset(-1);
+    commit.remove(SourceRange(BeginOfSetterDclLoc, EndLoc));
   }
-  return true;
 }
 
 void ObjCMigrateASTConsumer::migrateObjCInterfaceDecl(ASTContext &Ctx,

Modified: cfe/trunk/test/ARCMT/objcmt-arc-cf-annotations.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-arc-cf-annotations.m.result?rev=192853&r1=192852&r2=192853&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-arc-cf-annotations.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-arc-cf-annotations.m.result Wed Oct 16 17:35:19 2013
@@ -2089,7 +2089,5 @@ CFAttributedStringRef CFAttributedCreate
 
 @interface Action
 @property (nonatomic) SEL action;
-
 @property (nonatomic, assign) id target;
-
 @end

Modified: cfe/trunk/test/ARCMT/objcmt-atomic-property.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-atomic-property.m.result?rev=192853&r1=192852&r2=192853&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-atomic-property.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-atomic-property.m.result Wed Oct 16 17:35:19 2013
@@ -21,23 +21,19 @@ typedef char BOOL;
 @interface I : NSObject {
   int ivarVal;
 }
-
 @property (weak) NSString *WeakProp;
 
 @property (retain) NSString *StrongProp;
 
-
 - (NSString *) UnavailProp  __attribute__((unavailable));
 - (void) setUnavailProp  : (NSString *)Val;
 
 @property (retain) NSString *UnavailProp1  __attribute__((unavailable));
 
-
 - (NSString *) UnavailProp2;
 - (void) setUnavailProp2  : (NSString *)Val  __attribute__((unavailable));
 
 @property (copy) NSDictionary *undoAction;
-
 @end
 
 @implementation I
@@ -52,10 +48,6 @@ typedef char BOOL;
     NSArray *_names3;
     NSArray *_names4;
 }
-
-
-
-
 @property (retain) NSArray *names2;
 @property (retain) NSArray *names3;
 @property (retain) NSArray *names4;
@@ -67,26 +59,19 @@ typedef char BOOL;
 @interface NSInvocation 
 @property (assign) id target;
 
-
 @property (assign) id dataSource;
 
 @property (assign) id xxxdelegateYYY;
 
 
-
-
 @property (retain) id MYtarget;
 
-
 @property (retain) id targetX;
-
  
 @property  int value;
 
-
 @property (getter=isContinuous) BOOL continuous;
 
-
 - (id) isAnObject;
 - (void)setAnObject : (id) object;
 
@@ -102,7 +87,6 @@ typedef char BOOL;
 
 @property (getter=getStringValue, retain) NSString *stringValue;
 @property (getter=getCounterValue, readonly) BOOL counterValue;
-
 @property (getter=getns_dixtionary, readonly) NSDictionary *ns_dixtionary;
 
 - (BOOL)is3bar; // watch out
@@ -119,26 +103,19 @@ typedef char BOOL;
 @interface NSInvocation(CAT)
 @property (assign) id target;
 
-
 @property (assign) id dataSource;
 
 @property (assign) id xxxdelegateYYY;
 
 
-
-
 @property (retain) id MYtarget;
 
-
 @property (retain) id targetX;
 
-
 @property  int value;
 
-
 @property (getter=isContinuous) BOOL continuous;
 
-
 - (id) isAnObject;
 - (void)setAnObject : (id) object;
 
@@ -189,7 +166,6 @@ DEPRECATED
 
 @property (retain) NSURL *appStoreReceiptURLX NS_AVAILABLE;
 
-
 // Do not infer a property.
 - (NSURL *)appStoreReceiptURLY ;
 - (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE;
@@ -206,7 +182,6 @@ DEPRECATED
 
 @property (retain) id method1 ALIGNED NS_AVAILABLE;
 
-
 - (NSURL *)init;  // No Change
 + (id)alloc;      // No Change
 
@@ -222,8 +197,6 @@ DEPRECATED
 @interface NSArray
 @property (readonly) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *);
 @property (copy) id (^MyBlock)(id, NSArray *, NSMutableDictionary *);
-
 @property (readonly) id (*expressionFuncptr)(id, NSArray *, NSMutableDictionary *);
 @property  id (*MyFuncptr)(id, NSArray *, NSMutableDictionary *);
-
 @end

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=192853&r1=192852&r2=192853&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-property.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-property.m.result Wed Oct 16 17:35:19 2013
@@ -21,23 +21,19 @@ typedef char BOOL;
 @interface I : NSObject {
   int ivarVal;
 }
-
 @property (nonatomic, weak) NSString *WeakProp;
 
 @property (nonatomic, retain) NSString *StrongProp;
 
-
 - (NSString *) UnavailProp  __attribute__((unavailable));
 - (void) setUnavailProp  : (NSString *)Val;
 
 @property (nonatomic, retain) NSString *UnavailProp1  __attribute__((unavailable));
 
-
 - (NSString *) UnavailProp2;
 - (void) setUnavailProp2  : (NSString *)Val  __attribute__((unavailable));
 
 @property (nonatomic, copy) NSDictionary *undoAction;
-
 @end
 
 @implementation I
@@ -52,10 +48,6 @@ typedef char BOOL;
     NSArray *_names3;
     NSArray *_names4;
 }
-
-
-
-
 @property (nonatomic, retain) NSArray *names2;
 @property (nonatomic, retain) NSArray *names3;
 @property (nonatomic, retain) NSArray *names4;
@@ -67,26 +59,19 @@ typedef char BOOL;
 @interface NSInvocation 
 @property (nonatomic, assign) id target;
 
-
 @property (nonatomic, assign) id dataSource;
 
 @property (nonatomic, assign) id xxxdelegateYYY;
 
 
-
-
 @property (nonatomic, retain) id MYtarget;
 
-
 @property (nonatomic, retain) id targetX;
-
  
 @property (nonatomic) int value;
 
-
 @property (nonatomic, getter=isContinuous) BOOL continuous;
 
-
 - (id) isAnObject;
 - (void)setAnObject : (id) object;
 
@@ -102,7 +87,6 @@ typedef char BOOL;
 
 @property (nonatomic, getter=getStringValue, retain) NSString *stringValue;
 @property (nonatomic, getter=getCounterValue, readonly) BOOL counterValue;
-
 @property (nonatomic, getter=getns_dixtionary, readonly) NSDictionary *ns_dixtionary;
 
 - (BOOL)is3bar; // watch out
@@ -119,26 +103,19 @@ typedef char BOOL;
 @interface NSInvocation(CAT)
 @property (nonatomic, assign) id target;
 
-
 @property (nonatomic, assign) id dataSource;
 
 @property (nonatomic, assign) id xxxdelegateYYY;
 
 
-
-
 @property (nonatomic, retain) id MYtarget;
 
-
 @property (nonatomic, retain) id targetX;
 
-
 @property (nonatomic) int value;
 
-
 @property (nonatomic, getter=isContinuous) BOOL continuous;
 
-
 - (id) isAnObject;
 - (void)setAnObject : (id) object;
 
@@ -189,7 +166,6 @@ DEPRECATED
 
 @property (nonatomic, retain) NSURL *appStoreReceiptURLX NS_AVAILABLE;
 
-
 // Do not infer a property.
 - (NSURL *)appStoreReceiptURLY ;
 - (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE;
@@ -206,7 +182,6 @@ DEPRECATED
 
 @property (nonatomic, retain) id method1 ALIGNED NS_AVAILABLE;
 
-
 - (NSURL *)init;  // No Change
 + (id)alloc;      // No Change
 
@@ -222,10 +197,8 @@ DEPRECATED
 @interface NSArray
 @property (nonatomic, readonly) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *);
 @property (nonatomic, copy) id (^MyBlock)(id, NSArray *, NSMutableDictionary *);
-
 @property (nonatomic, readonly) id (*expressionFuncptr)(id, NSArray *, NSMutableDictionary *);
 @property (nonatomic) id (*MyFuncptr)(id, NSArray *, NSMutableDictionary *);
-
 @end
 
 // rdar://15231241





More information about the cfe-commits mailing list