summaryrefslogtreecommitdiff
path: root/lib/AST/NSAPI.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2014-10-06 23:50:37 +0000
committerFariborz Jahanian <fjahanian@apple.com>2014-10-06 23:50:37 +0000
commit6c85568f84494874b4a7a24fe94da19b94062964 (patch)
tree2242b512b41ba6499eb02390f0dc17c76db9be21 /lib/AST/NSAPI.cpp
parent34e9fc36ac5e1ccd3de053f8e99959a42ed7c47a (diff)
Objective-C SDK modernizer. Patch to support modernization
to NS_ENUM/NS_OPTION macros when typedef names are other than NSInteger/NSUInteger (int8_t, etc.). rdar://18532199 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219173 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/NSAPI.cpp')
-rw-r--r--lib/AST/NSAPI.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/AST/NSAPI.cpp b/lib/AST/NSAPI.cpp
index 579a92cacc..aac31e7f15 100644
--- a/lib/AST/NSAPI.cpp
+++ b/lib/AST/NSAPI.cpp
@@ -10,6 +10,7 @@
#include "clang/AST/NSAPI.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Expr.h"
+#include "llvm/ADT/StringSwitch.h"
using namespace clang;
@@ -400,6 +401,32 @@ bool NSAPI::isObjCNSUIntegerType(QualType T) const {
return isObjCTypedef(T, "NSUInteger", NSUIntegerId);
}
+StringRef NSAPI::GetNSIntegralKind(QualType T) const {
+ if (!Ctx.getLangOpts().ObjC1 || T.isNull())
+ return StringRef();
+
+ while (const TypedefType *TDT = T->getAs<TypedefType>()) {
+ StringRef NSIntegralResust =
+ llvm::StringSwitch<StringRef>(
+ TDT->getDecl()->getDeclName().getAsIdentifierInfo()->getName())
+ .Case("int8_t", "int8_t")
+ .Case("int16_t", "int16_t")
+ .Case("int32_t", "int32_t")
+ .Case("NSInteger", "NSInteger")
+ .Case("int64_t", "int64_t")
+ .Case("uint8_t", "uint8_t")
+ .Case("uint16_t", "uint16_t")
+ .Case("uint32_t", "uint32_t")
+ .Case("NSUInteger", "NSUInteger")
+ .Case("uint64_t", "uint64_t")
+ .Default(StringRef());
+ if (!NSIntegralResust.empty())
+ return NSIntegralResust;
+ T = TDT->desugar();
+ }
+ return StringRef();
+}
+
bool NSAPI::isObjCTypedef(QualType T,
StringRef name, IdentifierInfo *&II) const {
if (!Ctx.getLangOpts().ObjC1)