]> granicus.if.org Git - clang/commitdiff
Add Type::isSpecificBuiltinType as a shortcut.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 18 Feb 2009 19:59:32 +0000 (19:59 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 18 Feb 2009 19:59:32 +0000 (19:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64946 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Type.h
lib/AST/ASTContext.cpp

index fdf79dbd37583d2e5e85befabf904922066ab19a..9db22fc836c81739c8091b1e2011db75e5937415 100644 (file)
@@ -321,6 +321,9 @@ public:
   
   /// 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 @@ inline bool Type::isTemplateTypeParmType() const {
   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
index 6b49b85c243c5bdd99600bae149d7883eabfe0d7..9198bf71cda20198a08a724a5f55498c2d9f95aa 100644 (file)
@@ -468,9 +468,8 @@ unsigned ASTContext::getPreferredTypeAlign(const Type *T) {
   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;
 }