From: Chris Lattner Date: Mon, 12 Jan 2009 00:10:42 +0000 (+0000) Subject: improve some more is*Type predicates to look through asqualtypes. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4bbce9901f7296ab030c58f0877be0b042bd70d3;p=clang improve some more is*Type predicates to look through asqualtypes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62063 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index b9db41e95e..9c6e036b0d 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -20,7 +20,7 @@ using namespace clang; -bool QualType::isConstant(ASTContext& Ctx) const { +bool QualType::isConstant(ASTContext &Ctx) const { if (isConstQualified()) return true; @@ -90,20 +90,23 @@ QualType Type::getDesugaredType() const { bool Type::isVoidType() const { if (const BuiltinType *BT = dyn_cast(CanonicalType)) return BT->getKind() == BuiltinType::Void; + if (const ASQualType *AS = dyn_cast(CanonicalType)) + return AS->getBaseType()->isVoidType(); return false; } bool Type::isObjectType() const { if (isa(CanonicalType)) return false; - else if (CanonicalType->isIncompleteType()) - return false; - else - return true; + if (const ASQualType *AS = dyn_cast(CanonicalType)) + return AS->getBaseType()->isObjectType(); + return !CanonicalType->isIncompleteType(); } bool Type::isDerivedType() const { switch (CanonicalType->getTypeClass()) { + case ASQual: + return cast(CanonicalType)->getBaseType()->isDerivedType(); case Pointer: case VariableArray: case ConstantArray: @@ -112,10 +115,8 @@ bool Type::isDerivedType() const { case FunctionNoProto: case Reference: return true; - case Tagged: { - const TagType *TT = cast(CanonicalType); - return !TT->getDecl()->isEnum(); - } + case Tagged: + return !cast(CanonicalType)->getDecl()->isEnum(); default: return false; } @@ -140,6 +141,8 @@ bool Type::isUnionType() const { bool Type::isComplexType() const { if (const ComplexType *CT = dyn_cast(CanonicalType)) return CT->getElementType()->isFloatingType(); + if (const ASQualType *AS = dyn_cast(CanonicalType)) + return AS->getBaseType()->isComplexType(); return false; } @@ -147,6 +150,8 @@ bool Type::isComplexIntegerType() const { // Check for GCC complex integer extension. if (const ComplexType *CT = dyn_cast(CanonicalType)) return CT->getElementType()->isIntegerType(); + if (const ASQualType *AS = dyn_cast(CanonicalType)) + return AS->getBaseType()->isComplexIntegerType(); return false; } @@ -155,7 +160,9 @@ const ComplexType *Type::getAsComplexIntegerType() const { if (const ComplexType *CTy = dyn_cast(this)) { if (CTy->getElementType()->isIntegerType()) return CTy; + return 0; } + // If the canonical form of this type isn't the right kind, reject it. const ComplexType *CTy = dyn_cast(CanonicalType); if (!CTy || !CTy->getElementType()->isIntegerType())