From: Chris Lattner Date: Sun, 6 Apr 2008 22:29:16 +0000 (+0000) Subject: Use EnumType to simplify some code. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=37c1b78a20a09b0456aa5caa15e159027010ca22;p=clang Use EnumType to simplify some code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49289 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index c8fb386804..01f90ba961 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -491,9 +491,8 @@ bool Type::isSignedIntegerType() const { BT->getKind() <= BuiltinType::LongLong; } - if (const TagType *TT = dyn_cast(CanonicalType)) - if (const EnumDecl *ED = dyn_cast(TT->getDecl())) - return ED->getIntegerType()->isSignedIntegerType(); + if (const EnumType *ET = dyn_cast(CanonicalType)) + return ET->getDecl()->getIntegerType()->isSignedIntegerType(); if (const VectorType *VT = dyn_cast(CanonicalType)) return VT->getElementType()->isSignedIntegerType(); @@ -512,9 +511,8 @@ bool Type::isUnsignedIntegerType() const { BT->getKind() <= BuiltinType::ULongLong; } - if (const TagType *TT = dyn_cast(CanonicalType)) - if (const EnumDecl *ED = dyn_cast(TT->getDecl())) - return ED->getIntegerType()->isUnsignedIntegerType(); + if (const EnumType *ET = dyn_cast(CanonicalType)) + return ET->getDecl()->getIntegerType()->isUnsignedIntegerType(); if (const VectorType *VT = dyn_cast(CanonicalType)) return VT->getElementType()->isUnsignedIntegerType(); @@ -563,11 +561,10 @@ bool Type::isRealType() const { bool Type::isArithmeticType() const { if (const BuiltinType *BT = dyn_cast(CanonicalType)) return BT->getKind() != BuiltinType::Void; - if (const TagType *TT = dyn_cast(CanonicalType)) - if (const EnumDecl *ED = dyn_cast(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(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(CanonicalType)) return ASQT->getBaseType()->isArithmeticType(); return isa(CanonicalType) || isa(CanonicalType);