r231036 - [SDK modernizer] Patch to fix type of the typed enums when

Fariborz Jahanian fjahanian at apple.com
Mon Mar 2 15:58:02 PST 2015


Author: fjahanian
Date: Mon Mar  2 17:58:02 2015
New Revision: 231036

URL: http://llvm.org/viewvc/llvm-project?rev=231036&view=rev
Log:
[SDK modernizer] Patch to fix type of the typed enums when
migrating to NS_ENUM typedef. rdar://19994496

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=231036&r1=231035&r2=231036&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Mon Mar  2 17:58:02 2015
@@ -776,12 +776,12 @@ static void rewriteToNSMacroDecl(ASTCont
                                 const TypedefDecl *TypedefDcl,
                                 const NSAPI &NS, edit::Commit &commit,
                                  bool IsNSIntegerType) {
-  QualType EnumUnderlyingT = EnumDcl->getPromotionType();
-  assert(!EnumUnderlyingT.isNull()
+  QualType DesignatedEnumType = EnumDcl->getIntegerType();
+  assert(!DesignatedEnumType.isNull()
          && "rewriteToNSMacroDecl - underlying enum type is null");
   
   PrintingPolicy Policy(Ctx.getPrintingPolicy());
-  std::string TypeString = EnumUnderlyingT.getAsString(Policy);
+  std::string TypeString = DesignatedEnumType.getAsString(Policy);
   std::string ClassString = IsNSIntegerType ? "NS_ENUM(" : "NS_OPTIONS(";
   ClassString += TypeString;
   ClassString += ", ";

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=231036&r1=231035&r2=231036&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-ns-macros.m (original)
+++ cfe/trunk/test/ARCMT/objcmt-ns-macros.m Mon Mar  2 17:58:02 2015
@@ -379,3 +379,10 @@ typedef enum : unsigned long long {
   ll3,
   ll4
 } MyEnumunsignedlonglong;
+
+// rdar://19994496
+typedef enum : int8_t {int8_one} MyOneEnum;
+
+typedef enum : int16_t {
+          int16_t_one,
+          int16_t_two } Myint16_tEnum;

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=231036&r1=231035&r2=231036&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result Mon Mar  2 17:58:02 2015
@@ -358,3 +358,10 @@ typedef NS_ENUM(unsigned long long, MyEn
   ll3,
   ll4
 };
+
+// rdar://19994496
+typedef NS_ENUM(int8_t, MyOneEnum) {int8_one};
+
+typedef NS_ENUM(int16_t, Myint16_tEnum) {
+          int16_t_one,
+          int16_t_two };





More information about the cfe-commits mailing list