From: Fariborz Jahanian Date: Fri, 23 Jan 2015 21:58:46 +0000 (+0000) Subject: Objective-C moderinzer [qoi], add space on rhs when needed when X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8e7cb7bdf2f00287e30e6520af256095a294274f;p=clang Objective-C moderinzer [qoi], add space on rhs when needed when converting to property-dot syntax for setters. rdar://19381786 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226944 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp index 48a4931c20..59feea11e1 100644 --- a/lib/ARCMigrate/ObjCMT.cpp +++ b/lib/ARCMigrate/ObjCMT.cpp @@ -309,6 +309,10 @@ namespace { BegLoc = PP.getLocForEndOfToken(BegLoc); SourceLocation EndLoc = RHS->getLocStart(); EndLoc = EndLoc.getLocWithOffset(-1); + const char *colon = PP.getSourceManager().getCharacterData(EndLoc); + // Add a space after '=' if there is no space between RHS and '=' + if (colon && colon[0] == ':') + PropertyDotString += " "; SourceRange Range(BegLoc, EndLoc); commit.replace(Range, PropertyDotString); // remove '[' ']' diff --git a/test/ARCMT/objcmt-property-dot-syntax.m b/test/ARCMT/objcmt-property-dot-syntax.m index f1038a844b..f1b9255550 100644 --- a/test/ARCMT/objcmt-property-dot-syntax.m +++ b/test/ARCMT/objcmt-property-dot-syntax.m @@ -90,3 +90,24 @@ id testRdar19038838(Rdar19038838 *obj) { } @end +// rdar://19140114 +int NSOnState; +int ArrNSOnState[4]; +@interface rdar19140114 : NSObject +{ + rdar19140114* menuItem; +} +@property int state; +@end + +@implementation rdar19140114 +- (void) Meth { + [menuItem setState:NSOnState]; + [menuItem setState :NSOnState]; + [menuItem setState :ArrNSOnState[NSOnState]]; + [menuItem setState : NSOnState]; + [menuItem setState: NSOnState]; + [menuItem setState: NSOnState]; + [menuItem setState : NSOnState]; +} +@end diff --git a/test/ARCMT/objcmt-property-dot-syntax.m.result b/test/ARCMT/objcmt-property-dot-syntax.m.result index b7561e526d..70c7e7ab54 100644 --- a/test/ARCMT/objcmt-property-dot-syntax.m.result +++ b/test/ARCMT/objcmt-property-dot-syntax.m.result @@ -90,3 +90,24 @@ id testRdar19038838(Rdar19038838 *obj) { } @end +// rdar://19140114 +int NSOnState; +int ArrNSOnState[4]; +@interface rdar19140114 : NSObject +{ + rdar19140114* menuItem; +} +@property int state; +@end + +@implementation rdar19140114 +- (void) Meth { + menuItem.state = NSOnState; + menuItem.state = NSOnState; + menuItem.state = ArrNSOnState[NSOnState]; + menuItem.state = NSOnState; + menuItem.state = NSOnState; + menuItem.state = NSOnState; + menuItem.state = NSOnState; +} +@end