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/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 9b58e47..3966251 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -149,35 +149,23 @@
     Context.setObjCProtoType(Context.getObjCInterfaceType(ProtocolDecl));
     PushOnScopeChains(ProtocolDecl, TUScope);
   }
-  // Create the built-in decls/typedefs for 'id' and 'Class'.
+  // Create the built-in typedef for 'id'.
   if (Context.getObjCIdType().isNull()) {
-    ObjCInterfaceDecl *IdIDecl =
-      ObjCInterfaceDecl::Create(Context, CurContext, SourceLocation(),
-                                &Context.Idents.get("id"), 
-                                SourceLocation(), true);
-    QualType IdIType = Context.getObjCInterfaceType(IdIDecl);
-    QualType ObjCIdType = Context.getObjCObjectPointerType(IdIType);
-
-    TypedefDecl *IdTypedef = TypedefDecl::Create(Context, CurContext,
-                                                 SourceLocation(),
-                                                 &Context.Idents.get("id"),
-                                                 ObjCIdType);
+    TypedefDecl *IdTypedef = 
+      TypedefDecl::Create( 
+        Context, CurContext, SourceLocation(), &Context.Idents.get("id"),
+        Context.getObjCObjectPointerType(Context.ObjCBuiltinIdTy)
+      );
     PushOnScopeChains(IdTypedef, TUScope);
     Context.setObjCIdType(Context.getTypeDeclType(IdTypedef));
   }
-  // Create the built-in decls/typedefs and type for "Class".
+  // Create the built-in typedef for 'Class'.
   if (Context.getObjCClassType().isNull()) {
-    ObjCInterfaceDecl *ClassIDecl =
-      ObjCInterfaceDecl::Create(Context, CurContext, SourceLocation(),
-                                &Context.Idents.get("Class"), 
-                                SourceLocation(), true);
-    QualType ClassIType = Context.getObjCInterfaceType(ClassIDecl);
-    QualType ObjCClassType = Context.getObjCObjectPointerType(ClassIType);
-    
-    TypedefDecl *ClassTypedef = TypedefDecl::Create(Context, CurContext,
-                                                    SourceLocation(),
-                                                    &Context.Idents.get("Class"),
-                                                    ObjCClassType);
+    TypedefDecl *ClassTypedef = 
+      TypedefDecl::Create( 
+        Context, CurContext, SourceLocation(), &Context.Idents.get("Class"),
+        Context.getObjCObjectPointerType(Context.ObjCBuiltinClassTy)
+      );
     PushOnScopeChains(ClassTypedef, TUScope);
     Context.setObjCClassType(Context.getTypeDeclType(ClassTypedef));
   }