aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Type.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-07-15 18:40:39 +0000
committerSteve Naroff <snaroff@apple.com>2009-07-15 18:40:39 +0000
commitde2e22d33afec98324a66a358dfe0951b3c7259a (patch)
treed4bb699e42464c745d95b1d753e62a916d3415ed /lib/AST/Type.cpp
parent92db2841691b2f2a99294872ead8887854297ed7 (diff)
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
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r--lib/AST/Type.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 9edb9c046d..18fa76bf25 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 @@ const char *BuiltinType::getName(const LangOptions &LO) const {
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 @@ void TypenameType::getAsStringInternal(std::string &InnerString, const PrintingP
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 ObjCInterfaceType::getAsStringInternal(std::string &InnerString, const Prin
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 += '<';