Tweak implementation for allowing ObjC builtin type redefinitions.

- Replace string comparisons with pre-defined idents.
- Avoid calling isBuiltinObjCType() to avoid two checks. 
- Remove isBuiltinObjCType(), since it was only used in Sema::MergeTypeDefDecl().
- Have Sema::MergeTypeDefDecl() set the new type.

This is a moidified version of an patch by David Chisnall.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55990 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 9092f83..2b8127b 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -21,12 +21,6 @@
 
 using namespace clang;
 
-bool Sema::isBuiltinObjCType(TypedefDecl *TD) {
-  const char *typeName = TD->getIdentifier()->getName();
-  return strcmp(typeName, "id") == 0 || strcmp(typeName, "Class") == 0 ||
-         strcmp(typeName, "SEL") == 0 || strcmp(typeName, "Protocol") == 0;
-}
-
 static inline RecordDecl *CreateStructDecl(ASTContext &C, const char *Name)
 {
   if (C.getLangOptions().CPlusPlus)
@@ -107,6 +101,12 @@
 
   SuperID = &IT.get("super");
 
+  // ObjC builtin typedef names.
+  Ident_id = &IT.get("id");
+  Ident_Class = &IT.get("Class");
+  Ident_SEL = &IT.get("SEL");
+  Ident_Protocol = &IT.get("Protocol");
+
   TUScope = 0;
   if (getLangOptions().CPlusPlus)
     FieldCollector.reset(new CXXFieldCollector());