[cfe-commits] r49289 - /cfe/trunk/lib/AST/Type.cpp

Chris Lattner sabre at nondot.org
Sun Apr 6 15:29:16 PDT 2008


Author: lattner
Date: Sun Apr  6 17:29:16 2008
New Revision: 49289

URL: http://llvm.org/viewvc/llvm-project?rev=49289&view=rev
Log:
Use EnumType to simplify some code.

Modified:
    cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=49289&r1=49288&r2=49289&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Sun Apr  6 17:29:16 2008
@@ -491,9 +491,8 @@
            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 @@
            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::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);





More information about the cfe-commits mailing list