diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-07 05:30:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-07 05:30:13 +0000 |
commit | eca7be6b7ebd93682eeaab2c71d59f2995dacdcc (patch) | |
tree | 146cdf9150eb701dade31b5987d174a86d632040 /lib/AST/Type.cpp | |
parent | 821a01baa2968dd27720c631a6722ec60686ce27 (diff) |
move ObjCQualifiedIdTypesAreCompatible out of ASTContext into Sema.
While it is similar to the other compatibility predicates in ASTContext,
it is not used by them and is different.
In addition, greatly simplify ObjCQualifiedIdTypesAreCompatible and
fix some canonical type bugs. Also, simplify my Type::getAsObjC* methods.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49313 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r-- | lib/AST/Type.cpp | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 16f54cae13..f80f3641da 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -429,42 +429,22 @@ const OCUVectorType *Type::getAsOCUVectorType() const { } 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(); + // There is no sugar for ObjCInterfaceType's, just return the canonical + // type pointer if it is the right class. + return dyn_cast<ObjCInterfaceType>(CanonicalType); } 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(); + // There is no sugar for ObjCQualifiedInterfaceType's, just return the canonical + // type pointer if it is the right class. + return dyn_cast<ObjCQualifiedInterfaceType>(CanonicalType); +} + +const ObjCQualifiedIdType *Type::getAsObjCQualifiedIdType() const { + // There is no sugar for ObjCQualifiedIdType's, just return the canonical + // type pointer if it is the right class. + return dyn_cast<ObjCQualifiedIdType>(CanonicalType); } |