diff options
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r-- | lib/AST/Type.cpp | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 6114dba148..2f66454aad 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -192,23 +192,23 @@ bool Type::isDerivedType() const { } bool Type::isClassType() const { - if (const RecordType *RT = getAs<RecordType>()) + if (const RecordType *RT = getAsRecordType()) return RT->getDecl()->isClass(); return false; } bool Type::isStructureType() const { - if (const RecordType *RT = getAs<RecordType>()) + if (const RecordType *RT = getAsRecordType()) return RT->getDecl()->isStruct(); return false; } bool Type::isVoidPointerType() const { - if (const PointerType *PT = getAs<PointerType>()) + if (const PointerType *PT = getAsPointerType()) return PT->getPointeeType()->isVoidType(); return false; } bool Type::isUnionType() const { - if (const RecordType *RT = getAs<RecordType>()) + if (const RecordType *RT = getAsRecordType()) return RT->getDecl()->isUnion(); return false; } @@ -296,11 +296,11 @@ const FunctionProtoType *Type::getAsFunctionProtoType() const { } QualType Type::getPointeeType() const { - if (const PointerType *PT = getAs<PointerType>()) + if (const PointerType *PT = getAsPointerType()) return PT->getPointeeType(); if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType()) return OPT->getPointeeType(); - if (const BlockPointerType *BPT = getAs<BlockPointerType>()) + if (const BlockPointerType *BPT = getAsBlockPointerType()) return BPT->getPointeeType(); return QualType(); } @@ -321,11 +321,11 @@ bool Type::isVariablyModifiedType() const { // Also, C++ references and member pointers can point to a variably modified // type, where VLAs appear as an extension to C++, and should be treated // correctly. - if (const PointerType *PT = getAs<PointerType>()) + if (const PointerType *PT = getAsPointerType()) return PT->getPointeeType()->isVariablyModifiedType(); - if (const ReferenceType *RT = getAs<ReferenceType>()) + if (const ReferenceType *RT = getAsReferenceType()) return RT->getPointeeType()->isVariablyModifiedType(); - if (const MemberPointerType *PT = getAs<MemberPointerType>()) + if (const MemberPointerType *PT = getAsMemberPointerType()) return PT->getPointeeType()->isVariablyModifiedType(); // A function can return a variably modified type @@ -338,6 +338,30 @@ bool Type::isVariablyModifiedType() const { return false; } +const PointerType *Type::getAsPointerType() const { + return getAs<PointerType>(); +} +const BlockPointerType *Type::getAsBlockPointerType() const { + return getAs<BlockPointerType>(); +} +const ReferenceType *Type::getAsReferenceType() const { + return getAs<ReferenceType>(); +} +const LValueReferenceType *Type::getAsLValueReferenceType() const { + return getAs<LValueReferenceType>(); +} +const RValueReferenceType *Type::getAsRValueReferenceType() const { + return getAs<RValueReferenceType>(); +} +const MemberPointerType *Type::getAsMemberPointerType() const { + return getAs<MemberPointerType>(); +} +const TagType *Type::getAsTagType() const { + return getAs<TagType>(); +} +const RecordType *Type::getAsRecordType() const { + return getAs<RecordType>(); +} const RecordType *Type::getAsStructureType() const { // If this is directly a structure type, return it. if (const RecordType *RT = dyn_cast<RecordType>(this)) { |