aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Type.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-07 00:27:04 +0000
committerChris Lattner <sabre@nondot.org>2008-04-07 00:27:04 +0000
commit368eefa081d12f0a265ee90ee8ec61b54168d57d (patch)
tree3b927d26b2da3ed0640f6f722a935f2f70540404 /lib/AST/Type.cpp
parent1361b11066239ea15764a2a844405352d87296b3 (diff)
clean up some logic in objc type handling. Specifically, make it so that
there are QualType::getAsObjc* type methods, and make isa<ObjCInterfaceType> return true for ObjCQualifiedInterfaceType's. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49300 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r--lib/AST/Type.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 01f90ba961..16f54cae13 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -428,6 +428,46 @@ const OCUVectorType *Type::getAsOCUVectorType() const {
return getDesugaredType()->getAsOCUVectorType();
}
+const ObjCInterfaceType *Type::getAsObjCInterfaceType() const {
+ // Are we directly an ObjCInterface type?
+ if (const ObjCInterfaceType *VTy = dyn_cast<ObjCInterfaceType>(this))
+ return VTy;
+
+ // If the canonical form of this type isn't the right kind, reject it.
+ if (!isa<ObjCInterfaceType>(CanonicalType)) {
+ // Look through type qualifiers
+ if (isa<ObjCInterfaceType>(CanonicalType.getUnqualifiedType()))
+ return CanonicalType.getUnqualifiedType()->getAsObjCInterfaceType();
+ return 0;
+ }
+
+ // If this is a typedef for an objc interface type, strip the typedef off
+ // without losing all typedef information.
+ return getDesugaredType()->getAsObjCInterfaceType();
+}
+
+const ObjCQualifiedInterfaceType *
+Type::getAsObjCQualifiedInterfaceType() const {
+ // Are we directly an ObjCQualifiedInterfaceType?
+ if (const ObjCQualifiedInterfaceType *VTy =
+ dyn_cast<ObjCQualifiedInterfaceType>(this))
+ return VTy;
+
+ // If the canonical form of this type isn't the right kind, reject it.
+ if (!isa<ObjCQualifiedInterfaceType>(CanonicalType)) {
+ // Look through type qualifiers
+ if (isa<ObjCQualifiedInterfaceType>(CanonicalType.getUnqualifiedType()))
+ return CanonicalType.getUnqualifiedType()->
+ getAsObjCQualifiedInterfaceType();
+ return 0;
+ }
+
+ // If this is a typedef for an objc qual interface type, strip the typedef off
+ // without losing all typedef information.
+ return getDesugaredType()->getAsObjCQualifiedInterfaceType();
+}
+
+
bool Type::isIntegerType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() >= BuiltinType::Bool &&