r218809 - Objective-C Modernizer. Patch to remove dangling space

Fariborz Jahanian fjahanian at apple.com
Wed Oct 1 13:46:32 PDT 2014


Author: fjahanian
Date: Wed Oct  1 15:46:32 2014
New Revision: 218809

URL: http://llvm.org/viewvc/llvm-project?rev=218809&view=rev
Log:
Objective-C Modernizer. Patch to remove dangling space
before the semicolon wahen modernizing to use 
NS_ENUM/NS_OPTIONS macros. rdar://18498539

Modified:
    cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
    cfe/trunk/test/ARCMT/objcmt-ns-macros.m
    cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result

Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=218809&r1=218808&r2=218809&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Wed Oct  1 15:46:32 2014
@@ -644,8 +644,12 @@ static void rewriteToNSMacroDecl(const E
   ClassString += ')';
   SourceRange R(EnumDcl->getLocStart(), EnumDcl->getLocStart());
   commit.replace(R, ClassString);
-  SourceLocation TypedefLoc = TypedefDcl->getLocEnd();
-  commit.remove(SourceRange(TypedefLoc, TypedefLoc));
+  // This is to remove spaces between '}' and typedef name.
+  SourceLocation StartTypedefLoc = EnumDcl->getLocEnd();
+  StartTypedefLoc = StartTypedefLoc.getLocWithOffset(+1);
+  SourceLocation EndTypedefLoc = TypedefDcl->getLocEnd();
+  
+  commit.remove(SourceRange(StartTypedefLoc, EndTypedefLoc));
 }
 
 static bool UseNSOptionsMacro(Preprocessor &PP, ASTContext &Ctx,

Modified: cfe/trunk/test/ARCMT/objcmt-ns-macros.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-ns-macros.m?rev=218809&r1=218808&r2=218809&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-ns-macros.m (original)
+++ cfe/trunk/test/ARCMT/objcmt-ns-macros.m Wed Oct  1 15:46:32 2014
@@ -302,3 +302,23 @@ typedef enum : NSUInteger {
    ThingThree,
 } Thing;
 
+// rdar://18498539
+typedef enum {
+    one = 1
+} NumericEnum;
+
+typedef enum {
+    Two = 2
+}NumericEnum2;
+
+typedef enum {
+    Three = 3
+}
+NumericEnum3;
+
+typedef enum {
+    Four = 4
+}
+
+  NumericEnum4;
+

Modified: cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result?rev=218809&r1=218808&r2=218809&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result Wed Oct  1 15:46:32 2014
@@ -31,7 +31,7 @@ typedef NS_ENUM(NSInteger, UIViewAnimati
     UIViewAnimationTransitionFlipFromRight,
     UIViewAnimationTransitionCurlUp,
     UIViewAnimationTransitionCurlDown,
-} ;
+};
 
 typedef NS_OPTIONS(NSUInteger, UITableView) {
     UIViewOne   = 0,
@@ -41,7 +41,7 @@ typedef NS_OPTIONS(NSUInteger, UITableVi
     UIViewFive  = 1 << 3,
     UIViewSix   = 1 << 4,
     UIViewSeven = 1 << 5
-} ;
+};
 
 typedef NS_OPTIONS(NSUInteger, UI) {
   UIOne = 0,
@@ -55,7 +55,7 @@ typedef NS_OPTIONS(NSUInteger, UIPOWER2)
   UIP2Two = 0x1,
   UIP2three = 0x8,
   UIP2Four = 0x100
-} ;
+};
 
 enum {
   UNOne,
@@ -73,7 +73,7 @@ typedef NS_ENUM(NSInteger, NSTickMarkPos
     NSTickMarkAbove = 1,
     NSTickMarkLeft = NSTickMarkAbove,
     NSTickMarkRight = NSTickMarkBelow
-} ;
+};
 
 typedef NS_OPTIONS(NSUInteger, UITableStyle) {
     UIViewNone         = 0x0,
@@ -144,7 +144,7 @@ typedef NS_ENUM(NSInteger, UIP) {
   UIP0Three = 2,
   UIP0Four = 10,
   UIP0Last = 0x100
-} ;
+};
 
 typedef NS_OPTIONS(NSUInteger, UIP_3) {
   UIPZero = 0x0,
@@ -152,7 +152,7 @@ typedef NS_OPTIONS(NSUInteger, UIP_3) {
   UIPTwo = 0x2,
   UIP10 = 0x10,
   UIPHundred = 0x100
-} ;
+};
 
 typedef NS_ENUM(NSInteger, UIP4_3) {
   UIP4Zero = 0x0,
@@ -160,14 +160,14 @@ typedef NS_ENUM(NSInteger, UIP4_3) {
   UIP4Two = 0x2,
   UIP410 = 0x10,
   UIP4Hundred = 100
-} ;
+};
 
 typedef NS_OPTIONS(NSUInteger, UIP5_3) {
   UIP5Zero = 0x0,
   UIP5Two = 0x2,
   UIP510 = 0x3,
   UIP5Hundred = 0x4
-} ;
+};
 
 typedef NS_ENUM(NSInteger, UIP6_3) {
   UIP6Zero = 0x0,
@@ -175,7 +175,7 @@ typedef NS_ENUM(NSInteger, UIP6_3) {
   UIP6Two = 0x2,
   UIP610 = 10,
   UIP6Hundred = 0x100
-} ;
+};
 
 typedef NS_ENUM(NSInteger, UIP7_3) {
   UIP7Zero = 0x0,
@@ -183,7 +183,7 @@ typedef NS_ENUM(NSInteger, UIP7_3) {
   UIP7Two = 0x2,
   UIP710 = 10,
   UIP7Hundred = 100
-} ;
+};
 
 
 typedef NS_ENUM(NSInteger, UIP8_3) {
@@ -194,7 +194,7 @@ typedef NS_ENUM(NSInteger, UIP8_3) {
   Random4 = 0x3444444,
   Random5 = 0xbadbeef,
   Random6
-} ;
+};
 
 // rdar://15200602
 #define NS_AVAILABLE_MAC(X)  __attribute__((availability(macosx,introduced=X)))
@@ -285,3 +285,20 @@ typedef enum : NSUInteger {
    ThingThree,
 } Thing;
 
+// rdar://18498539
+typedef NS_ENUM(NSInteger, NumericEnum) {
+    one = 1
+};
+
+typedef NS_ENUM(NSInteger, NumericEnum2) {
+    Two = 2
+};
+
+typedef NS_ENUM(NSInteger, NumericEnum3) {
+    Three = 3
+};
+
+typedef NS_OPTIONS(NSUInteger, NumericEnum4) {
+    Four = 4
+};
+





More information about the cfe-commits mailing list