Implement the ObjC pseudo built-in types as clang "BuiltinType's". I say pseudo built-in types, since Sema still injects a typedef for recognition (i.e. they aren't truly built-ins from a parser perspective).

This removes the static data/methods on ObjCObjectPointerType while preserving the nice API (no need to fiddle with ASTContext:-).

This patch also adds Type::isObjCBuiltinType().

This should be the last fairly large patch related to recrafting the ObjC type system. The follow-on patches should be fairly small.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75808 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 9edb9c0..18fa76b 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -22,9 +22,6 @@
 #include "llvm/Support/raw_ostream.h"
 using namespace clang;
 
-ObjCInterfaceType *ObjCObjectPointerType::IdInterfaceT;
-ObjCInterfaceType *ObjCObjectPointerType::ClassInterfaceT;
-
 bool QualType::isConstant(ASTContext &Ctx) const {
   if (isConstQualified())
     return true;
@@ -1009,6 +1006,8 @@
   case Overload:          return "<overloaded function type>";
   case Dependent:         return "<dependent type>";
   case UndeducedAuto:     return "auto";
+  case ObjCId:            return "id";
+  case ObjCClass:         return "Class";
   }
 }
 
@@ -1687,14 +1686,6 @@
     InnerString = MyString + ' ' + InnerString;
 }
 
-bool ObjCInterfaceType::isObjCIdInterface() const {
-  return this == ObjCObjectPointerType::getIdInterface();
-}
-
-bool ObjCInterfaceType::isObjCClassInterface() const {
-  return this == ObjCObjectPointerType::getClassInterface();
-}  
-
 void ObjCInterfaceType::getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const {
   if (!InnerString.empty())    // Prefix the basic type, e.g. 'typedefname X'.
     InnerString = ' ' + InnerString;
@@ -1703,7 +1694,14 @@
 
 void ObjCObjectPointerType::getAsStringInternal(std::string &InnerString, 
                                                 const PrintingPolicy &Policy) const {
-  std::string ObjCQIString = getInterfaceType()->getDecl()->getNameAsString();
+  std::string ObjCQIString;
+  
+  if (isObjCIdType() || isObjCQualifiedIdType())
+    ObjCQIString = "id";
+  else if (isObjCClassType())
+    ObjCQIString = "Class";
+  else
+    ObjCQIString = getInterfaceDecl()->getNameAsString();
 
   if (!qual_empty()) {
     ObjCQIString += '<';