summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-06 22:29:16 +0000
committerChris Lattner <sabre@nondot.org>2008-04-06 22:29:16 +0000
commit7d9b6a9d50d8dee3287ed6217cad09221a225ab2 (patch)
tree63c8c10523fd61652e62f4c988a55c96582a85dd /clang/lib
parent8b23c25b21d406d8f83c537b0528f5d94c73ca82 (diff)
downloadbcm5719-llvm-7d9b6a9d50d8dee3287ed6217cad09221a225ab2.tar.gz
bcm5719-llvm-7d9b6a9d50d8dee3287ed6217cad09221a225ab2.zip
Use EnumType to simplify some code.
llvm-svn: 49289
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/Type.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index c8fb3868046..01f90ba961f 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -491,9 +491,8 @@ bool Type::isSignedIntegerType() const {
BT->getKind() <= BuiltinType::LongLong;
}
- if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
- if (const EnumDecl *ED = dyn_cast<EnumDecl>(TT->getDecl()))
- return ED->getIntegerType()->isSignedIntegerType();
+ if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
+ return ET->getDecl()->getIntegerType()->isSignedIntegerType();
if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
return VT->getElementType()->isSignedIntegerType();
@@ -512,9 +511,8 @@ bool Type::isUnsignedIntegerType() const {
BT->getKind() <= BuiltinType::ULongLong;
}
- if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
- if (const EnumDecl *ED = dyn_cast<EnumDecl>(TT->getDecl()))
- return ED->getIntegerType()->isUnsignedIntegerType();
+ if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
+ return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
return VT->getElementType()->isUnsignedIntegerType();
@@ -563,11 +561,10 @@ bool Type::isRealType() const {
bool Type::isArithmeticType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() != BuiltinType::Void;
- if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
- if (const EnumDecl *ED = dyn_cast<EnumDecl>(TT->getDecl()))
- // GCC allows forward declaration of enum types (forbid by C99 6.7.2.3p2).
- // If a body isn't seen by the time we get here, return false.
- return ED->isDefinition();
+ if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
+ // GCC allows forward declaration of enum types (forbid by C99 6.7.2.3p2).
+ // If a body isn't seen by the time we get here, return false.
+ return ET->getDecl()->isDefinition();
if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType))
return ASQT->getBaseType()->isArithmeticType();
return isa<ComplexType>(CanonicalType) || isa<VectorType>(CanonicalType);
OpenPOWER on IntegriCloud