diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-12 00:21:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-12 00:21:19 +0000 |
commit | 2a18dfe292cf3c406a769c3672080970ac586345 (patch) | |
tree | f0a1b8188c6307610688090c9a6e6d094e629c1d | |
parent | 4bbce9901f7296ab030c58f0877be0b042bd70d3 (diff) |
some more minor asqualtype bugs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62064 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/Type.cpp | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 9c6e036b0d..d7c821fbb5 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -163,11 +163,14 @@ const ComplexType *Type::getAsComplexIntegerType() const { return 0; } - // If the canonical form of this type isn't the right kind, reject it. - const ComplexType *CTy = dyn_cast<ComplexType>(CanonicalType); - if (!CTy || !CTy->getElementType()->isIntegerType()) + // If the canonical form of this type isn't what we want, reject it. + if (!isa<ComplexType>(CanonicalType)) { + // Look through type qualifiers (e.g. ASQualType's). + if (isa<ComplexType>(CanonicalType.getUnqualifiedType())) + return CanonicalType.getUnqualifiedType()->getAsComplexIntegerType(); return 0; - + } + // If this is a typedef for a complex type, strip the typedef off without // losing all typedef information. return getDesugaredType()->getAsComplexIntegerType(); @@ -180,7 +183,7 @@ const BuiltinType *Type::getAsBuiltinType() const { // If the canonical form of this type isn't a builtin type, reject it. if (!isa<BuiltinType>(CanonicalType)) { - // Look through type qualifiers + // Look through type qualifiers (e.g. ASQualType's). if (isa<BuiltinType>(CanonicalType.getUnqualifiedType())) return CanonicalType.getUnqualifiedType()->getAsBuiltinType(); return 0; @@ -256,8 +259,12 @@ const BlockPointerType *Type::getAsBlockPointerType() const { return PTy; // If the canonical form of this type isn't the right kind, reject it. - if (!isa<BlockPointerType>(CanonicalType)) + if (!isa<BlockPointerType>(CanonicalType)) { + // Look through type qualifiers + if (isa<BlockPointerType>(CanonicalType.getUnqualifiedType())) + return CanonicalType.getUnqualifiedType()->getAsBlockPointerType(); return 0; + } // If this is a typedef for a block pointer type, strip the typedef off // without losing all typedef information. @@ -295,14 +302,14 @@ bool Type::isVariablyModifiedType() const { return T->isVariablyModifiedType(); // A pointer can point to a variably modified type - if (const PointerType* PT = getAsPointerType()) + if (const PointerType *PT = getAsPointerType()) return PT->getPointeeType()->isVariablyModifiedType(); // A function can return a variably modified type // This one isn't completely obvious, but it follows from the // definition in C99 6.7.5p3. Because of this rule, it's // illegal to declare a function returning a variably modified type. - if (const FunctionType* FT = getAsFunctionType()) + if (const FunctionType *FT = getAsFunctionType()) return FT->getResultType()->isVariablyModifiedType(); return false; @@ -434,14 +441,15 @@ const ExtVectorType *Type::getAsExtVectorType() const { const ObjCInterfaceType *Type::getAsObjCInterfaceType() const { // There is no sugar for ObjCInterfaceType's, just return the canonical - // type pointer if it is the right class. + // type pointer if it is the right class. There is no typedef information to + // return and these cannot be Address-space qualified. return dyn_cast<ObjCInterfaceType>(CanonicalType); } const ObjCQualifiedInterfaceType * Type::getAsObjCQualifiedInterfaceType() const { - // There is no sugar for ObjCQualifiedInterfaceType's, just return the canonical - // type pointer if it is the right class. + // There is no sugar for ObjCQualifiedInterfaceType's, just return the + // canonical type pointer if it is the right class. return dyn_cast<ObjCQualifiedInterfaceType>(CanonicalType); } @@ -454,6 +462,7 @@ const ObjCQualifiedIdType *Type::getAsObjCQualifiedIdType() const { const TemplateTypeParmType *Type::getAsTemplateTypeParmType() const { // There is no sugar for template type parameters, so just return // the canonical type pointer if it is the right class. + // FIXME: can these be address-space qualified? return dyn_cast<TemplateTypeParmType>(CanonicalType); } @@ -711,22 +720,20 @@ bool Type::isPODType() const { } bool Type::isPromotableIntegerType() const { - if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType)) - return ASQT->getBaseType()->isPromotableIntegerType(); - const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType); - if (!BT) return false; - switch (BT->getKind()) { - case BuiltinType::Bool: - case BuiltinType::Char_S: - case BuiltinType::Char_U: - case BuiltinType::SChar: - case BuiltinType::UChar: - case BuiltinType::Short: - case BuiltinType::UShort: - return true; - default: - return false; - } + if (const BuiltinType *BT = getAsBuiltinType()) + switch (BT->getKind()) { + case BuiltinType::Bool: + case BuiltinType::Char_S: + case BuiltinType::Char_U: + case BuiltinType::SChar: + case BuiltinType::UChar: + case BuiltinType::Short: + case BuiltinType::UShort: + return true; + default: + return false; + } + return false; } const char *BuiltinType::getName() const { |