[cfe-commits] r64946 - in /cfe/trunk: include/clang/AST/Type.h lib/AST/ASTContext.cpp

Daniel Dunbar daniel at zuster.org
Wed Feb 18 11:59:32 PST 2009


Author: ddunbar
Date: Wed Feb 18 13:59:32 2009
New Revision: 64946

URL: http://llvm.org/viewvc/llvm-project?rev=64946&view=rev
Log:
Add Type::isSpecificBuiltinType as a shortcut.

Modified:
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=64946&r1=64945&r2=64946&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Feb 18 13:59:32 2009
@@ -321,6 +321,9 @@
   
   /// Helper methods to distinguish type categories. All type predicates
   /// operate on the canonical type, ignoring typedefs and qualifiers.
+
+  /// isSpecificBuiltinType - Test for a particular builtin type.
+  bool isSpecificBuiltinType(unsigned K) const;
   
   /// isIntegerType() does *not* include complex integers (a GCC extension).
   /// isComplexIntegerType() can be used to test for complex integers.
@@ -1876,11 +1879,15 @@
   return isa<TemplateTypeParmType>(CanonicalType.getUnqualifiedType());
 }
 
-inline bool Type::isOverloadType() const {
+inline bool Type::isSpecificBuiltinType(unsigned K) const {
   if (const BuiltinType *BT = getAsBuiltinType())
-    return BT->getKind() == BuiltinType::Overload;
-  else
-    return false;
+    if (BT->getKind() == (BuiltinType::Kind) K)
+      return true;
+  return false;
+}
+
+inline bool Type::isOverloadType() const {
+  return isSpecificBuiltinType(BuiltinType::Overload);
 }
 
 /// Insertion operator for diagnostics.  This allows sending QualType's into a

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

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Feb 18 13:59:32 2009
@@ -468,9 +468,8 @@
   unsigned ABIAlign = getTypeAlign(T);
   
   // Doubles should be naturally aligned if possible.
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(getCanonicalType(T)))
-    if (BT->getKind() == BuiltinType::Double)
-      return std::max(ABIAlign, 64U);
+  if (T->isSpecificBuiltinType(BuiltinType::Double))
+    return std::max(ABIAlign, 64U);
   
   return ABIAlign;
 }





More information about the cfe-commits mailing list