From 7b012d37287cd0b6afcea445d51faa64ba8007c6 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Mon, 2 Mar 2015 23:58:02 +0000 Subject: [PATCH] [SDK modernizer] Patch to fix type of the typed enums when migrating to NS_ENUM typedef. rdar://19994496 llvm-svn: 231036 --- clang/lib/ARCMigrate/ObjCMT.cpp | 6 +++--- clang/test/ARCMT/objcmt-ns-macros.m | 7 +++++++ clang/test/ARCMT/objcmt-ns-macros.m.result | 7 +++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp index ddb802e..98b3955 100644 --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -776,12 +776,12 @@ static void rewriteToNSMacroDecl(ASTContext &Ctx, 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 += ", "; diff --git a/clang/test/ARCMT/objcmt-ns-macros.m b/clang/test/ARCMT/objcmt-ns-macros.m index 795b94a..5bc390b 100644 --- a/clang/test/ARCMT/objcmt-ns-macros.m +++ b/clang/test/ARCMT/objcmt-ns-macros.m @@ -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; diff --git a/clang/test/ARCMT/objcmt-ns-macros.m.result b/clang/test/ARCMT/objcmt-ns-macros.m.result index 094c444..bcc865c 100644 --- a/clang/test/ARCMT/objcmt-ns-macros.m.result +++ b/clang/test/ARCMT/objcmt-ns-macros.m.result @@ -358,3 +358,10 @@ typedef NS_ENUM(unsigned long long, MyEnumunsignedlonglong) { 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 }; -- 2.7.4