diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-06-09 23:19:58 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-06-09 23:19:58 +0000 |
commit | 39ba4aeca296b1c9f04bde7d9d3cbbf129f1abd3 (patch) | |
tree | 0bd41bdbfdd41514deb4fbd92ddf3bade3030d8b /lib/AST/Type.cpp | |
parent | d3bb44f0f1a83cb208d3e61ee80afe6a4d20d2d8 (diff) |
-Changes to TagDecl:
Added TagKind enum.
Added getTagKind() method.
Added convenience methods: isEnum(), isStruct(), isUnion(), isClass().
-RecordDecl/CXXRecordDecl::Create() accept a TagKind enum instead of a DeclKind one.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52160 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r-- | lib/AST/Type.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index e561a1074c..7e09bb1ae3 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -63,8 +63,7 @@ bool Type::isDerivedType() const { return true; case Tagged: { const TagType *TT = cast<TagType>(CanonicalType); - const Decl::Kind Kind = TT->getDecl()->getKind(); - return Kind == Decl::Struct || Kind == Decl::Union; + return !TT->getDecl()->isEnum(); } default: return false; @@ -73,19 +72,19 @@ bool Type::isDerivedType() const { bool Type::isClassType() const { if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) - if (RT->getDecl()->getKind() == Decl::Class) + if (RT->getDecl()->isClass()) return true; return false; } bool Type::isStructureType() const { if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) - if (RT->getDecl()->getKind() == Decl::Struct) + if (RT->getDecl()->isStruct()) return true; return false; } bool Type::isUnionType() const { if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) - if (RT->getDecl()->getKind() == Decl::Union) + if (RT->getDecl()->isUnion()) return true; return false; } @@ -349,13 +348,13 @@ const RecordType *Type::getAsRecordType() const { const RecordType *Type::getAsStructureType() const { // If this is directly a structure type, return it. if (const RecordType *RT = dyn_cast<RecordType>(this)) { - if (RT->getDecl()->getKind() == Decl::Struct) + if (RT->getDecl()->isStruct()) return RT; } // If the canonical form of this type isn't the right kind, reject it. if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) { - if (RT->getDecl()->getKind() != Decl::Struct) + if (!RT->getDecl()->isStruct()) return 0; // If this is a typedef for a structure type, strip the typedef off without @@ -371,13 +370,13 @@ const RecordType *Type::getAsStructureType() const { const RecordType *Type::getAsUnionType() const { // If this is directly a union type, return it. if (const RecordType *RT = dyn_cast<RecordType>(this)) { - if (RT->getDecl()->getKind() == Decl::Union) + if (RT->getDecl()->isUnion()) return RT; } // If the canonical form of this type isn't the right kind, reject it. if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) { - if (RT->getDecl()->getKind() != Decl::Union) + if (!RT->getDecl()->isUnion()) return 0; // If this is a typedef for a union type, strip the typedef off without @@ -470,7 +469,7 @@ bool Type::isIntegerType() const { return BT->getKind() >= BuiltinType::Bool && BT->getKind() <= BuiltinType::LongLong; if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) - if (TT->getDecl()->getKind() == Decl::Enum) + if (TT->getDecl()->isEnum()) return true; if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType)) return VT->getElementType()->isIntegerType(); @@ -484,7 +483,7 @@ bool Type::isIntegralType() const { return BT->getKind() >= BuiltinType::Bool && BT->getKind() <= BuiltinType::LongLong; if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) - if (TT->getDecl()->getKind() == Decl::Enum) + if (TT->getDecl()->isEnum()) return true; if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType)) return ASQT->getBaseType()->isIntegralType(); @@ -493,7 +492,7 @@ bool Type::isIntegralType() const { bool Type::isEnumeralType() const { if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) - return TT->getDecl()->getKind() == Decl::Enum; + return TT->getDecl()->isEnum(); if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType)) return ASQT->getBaseType()->isEnumeralType(); return false; @@ -587,7 +586,7 @@ bool Type::isRealType() const { return BT->getKind() >= BuiltinType::Bool && BT->getKind() <= BuiltinType::LongDouble; if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) - return TT->getDecl()->getKind() == Decl::Enum; + return TT->getDecl()->isEnum(); if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType)) return VT->getElementType()->isRealType(); if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType)) @@ -611,7 +610,7 @@ bool Type::isScalarType() const { if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) return BT->getKind() != BuiltinType::Void; if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) { - if (TT->getDecl()->getKind() == Decl::Enum) + if (TT->getDecl()->isEnum()) return true; return false; } @@ -623,7 +622,7 @@ bool Type::isScalarType() const { bool Type::isAggregateType() const { if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) { - if (TT->getDecl()->getKind() == Decl::Struct) + if (TT->getDecl()->isStruct()) return true; return false; } |