ObjectiveC migrator. Remove blank lines
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
diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp
index 60ab4f2..deb391f9 100644
--- a/lib/ARCMigrate/ObjCMT.cpp
+++ b/lib/ARCMigrate/ObjCMT.cpp
@@ -273,7 +273,7 @@
}
-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 @@
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,
diff --git a/test/ARCMT/objcmt-arc-cf-annotations.m.result b/test/ARCMT/objcmt-arc-cf-annotations.m.result
index 949016a..7e0a904 100644
--- a/test/ARCMT/objcmt-arc-cf-annotations.m.result
+++ b/test/ARCMT/objcmt-arc-cf-annotations.m.result
@@ -2089,7 +2089,5 @@
@interface Action
@property (nonatomic) SEL action;
-
@property (nonatomic, assign) id target;
-
@end
diff --git a/test/ARCMT/objcmt-atomic-property.m.result b/test/ARCMT/objcmt-atomic-property.m.result
index f764488..668c821 100644
--- a/test/ARCMT/objcmt-atomic-property.m.result
+++ b/test/ARCMT/objcmt-atomic-property.m.result
@@ -21,23 +21,19 @@
@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 @@
NSArray *_names3;
NSArray *_names4;
}
-
-
-
-
@property (retain) NSArray *names2;
@property (retain) NSArray *names3;
@property (retain) NSArray *names4;
@@ -67,26 +59,19 @@
@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 @@
@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 @@
@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 @@
@property (retain) NSURL *appStoreReceiptURLX NS_AVAILABLE;
-
// Do not infer a property.
- (NSURL *)appStoreReceiptURLY ;
- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE;
@@ -206,7 +182,6 @@
@property (retain) id method1 ALIGNED NS_AVAILABLE;
-
- (NSURL *)init; // No Change
+ (id)alloc; // No Change
@@ -222,8 +197,6 @@
@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
diff --git a/test/ARCMT/objcmt-property.m.result b/test/ARCMT/objcmt-property.m.result
index a3db9be..bdb135b 100644
--- a/test/ARCMT/objcmt-property.m.result
+++ b/test/ARCMT/objcmt-property.m.result
@@ -21,23 +21,19 @@
@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 @@
NSArray *_names3;
NSArray *_names4;
}
-
-
-
-
@property (nonatomic, retain) NSArray *names2;
@property (nonatomic, retain) NSArray *names3;
@property (nonatomic, retain) NSArray *names4;
@@ -67,26 +59,19 @@
@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 @@
@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 @@
@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 @@
@property (nonatomic, retain) NSURL *appStoreReceiptURLX NS_AVAILABLE;
-
// Do not infer a property.
- (NSURL *)appStoreReceiptURLY ;
- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE;
@@ -206,7 +182,6 @@
@property (nonatomic, retain) id method1 ALIGNED NS_AVAILABLE;
-
- (NSURL *)init; // No Change
+ (id)alloc; // No Change
@@ -222,10 +197,8 @@
@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