]> granicus.if.org Git - clang/commitdiff
ObjectiveC migrator. Remove blank lines
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 16 Oct 2013 22:35:19 +0000 (22:35 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 16 Oct 2013 22:35:19 +0000 (22:35 +0000)
when inferring property from setter/getter
methods. // rdar://15200949

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

lib/ARCMigrate/ObjCMT.cpp
test/ARCMT/objcmt-arc-cf-annotations.m.result
test/ARCMT/objcmt-atomic-property.m.result
test/ARCMT/objcmt-property.m.result

index 60ab4f271f32d075f4b2c453342ba441c830288c..deb391f967f4a32d7e2dbf2a5043fe98c97ca479 100644 (file)
@@ -273,7 +273,7 @@ void MigrateBlockOrFunctionPointerTypeVariable(std::string & PropertyString,
 }
 
 
-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 ObjCMethodDecl *Getter,
     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,
index 949016a8977807feb9441245f95e9cd94a8ccf60..7e0a9042f5e6f5cd88e9295df893074fe380f311 100644 (file)
@@ -2089,7 +2089,5 @@ CFAttributedStringRef CFAttributedCreate(void *CFObj CF_CONSUMED) CF_RETURNS_RET
 
 @interface Action
 @property (nonatomic) SEL action;
-
 @property (nonatomic, assign) id target;
-
 @end
index f764488bb6a0b452caad839b06f9259079a35066..668c8218d51434412fb6502590c1cc3277d7fba1 100644 (file)
@@ -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
index a3db9be1b69d32674f6d4aee023c51254b3713da..bdb135b42a538d39a635da6772b0e8f577cef662 100644 (file)
@@ -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