aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/Type.h15
-rw-r--r--lib/AST/ASTContext.cpp5
2 files changed, 13 insertions, 7 deletions
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index fdf79dbd37..9db22fc836 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -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
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 6b49b85c24..9198bf71cd 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -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;
}