r226944 - Objective-C moderinzer [qoi], add space on rhs when needed when

Fariborz Jahanian fjahanian at apple.com
Fri Jan 23 13:58:46 PST 2015


Author: fjahanian
Date: Fri Jan 23 15:58:46 2015
New Revision: 226944

URL: http://llvm.org/viewvc/llvm-project?rev=226944&view=rev
Log:
Objective-C moderinzer [qoi], add space on rhs when needed when
converting to property-dot syntax for setters.
rdar://19381786

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

Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=226944&r1=226943&r2=226944&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Fri Jan 23 15:58:46 2015
@@ -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 '[' ']'

Modified: cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m?rev=226944&r1=226943&r2=226944&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m (original)
+++ cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m Fri Jan 23 15:58:46 2015
@@ -90,3 +90,24 @@ id testRdar19038838(Rdar19038838 *obj) {
 }
 @end
 
+// rdar://19140114
+int NSOnState;
+int ArrNSOnState[4];
+ at interface rdar19140114 : NSObject
+{
+  rdar19140114* menuItem;
+}
+ at property int state;
+ at end
+
+ at 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];
+}
+ at end

Modified: cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m.result?rev=226944&r1=226943&r2=226944&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-property-dot-syntax.m.result Fri Jan 23 15:58:46 2015
@@ -90,3 +90,24 @@ id testRdar19038838(Rdar19038838 *obj) {
 }
 @end
 
+// rdar://19140114
+int NSOnState;
+int ArrNSOnState[4];
+ at interface rdar19140114 : NSObject
+{
+  rdar19140114* menuItem;
+}
+ at property int state;
+ at end
+
+ at 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;
+}
+ at end





More information about the cfe-commits mailing list