Skip to content

Commit 848112c

Browse files
YannicAaronBallman
authored andcommitted
Simplify implementation of Type::isXXXType(); NFC
1 parent 0915825 commit 848112c

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

clang/include/clang/AST/Type.h

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6679,9 +6679,9 @@ inline bool Type::isTemplateTypeParmType() const {
66796679
}
66806680

66816681
inline bool Type::isSpecificBuiltinType(unsigned K) const {
6682-
if (const BuiltinType *BT = getAs<BuiltinType>())
6683-
if (BT->getKind() == (BuiltinType::Kind) K)
6684-
return true;
6682+
if (const BuiltinType *BT = getAs<BuiltinType>()) {
6683+
return BT->getKind() == static_cast<BuiltinType::Kind>(K);
6684+
}
66856685
return false;
66866686
}
66876687

@@ -6700,9 +6700,7 @@ inline const BuiltinType *Type::getAsPlaceholderType() const {
67006700

67016701
inline bool Type::isSpecificPlaceholderType(unsigned K) const {
67026702
assert(BuiltinType::isPlaceholderTypeKind((BuiltinType::Kind) K));
6703-
if (const auto *BT = dyn_cast<BuiltinType>(this))
6704-
return (BT->getKind() == (BuiltinType::Kind) K);
6705-
return false;
6703+
return isSpecificBuiltinType(K);
67066704
}
67076705

67086706
inline bool Type::isNonOverloadPlaceholderType() const {
@@ -6712,34 +6710,24 @@ inline bool Type::isNonOverloadPlaceholderType() const {
67126710
}
67136711

67146712
inline bool Type::isVoidType() const {
6715-
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
6716-
return BT->getKind() == BuiltinType::Void;
6717-
return false;
6713+
return isSpecificBuiltinType(BuiltinType::Void);
67186714
}
67196715

67206716
inline bool Type::isHalfType() const {
6721-
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
6722-
return BT->getKind() == BuiltinType::Half;
67236717
// FIXME: Should we allow complex __fp16? Probably not.
6724-
return false;
6718+
return isSpecificBuiltinType(BuiltinType::Half);
67256719
}
67266720

67276721
inline bool Type::isFloat16Type() const {
6728-
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
6729-
return BT->getKind() == BuiltinType::Float16;
6730-
return false;
6722+
return isSpecificBuiltinType(BuiltinType::Float16);
67316723
}
67326724

67336725
inline bool Type::isFloat128Type() const {
6734-
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
6735-
return BT->getKind() == BuiltinType::Float128;
6736-
return false;
6726+
return isSpecificBuiltinType(BuiltinType::Float128);
67376727
}
67386728

67396729
inline bool Type::isNullPtrType() const {
6740-
if (const auto *BT = getAs<BuiltinType>())
6741-
return BT->getKind() == BuiltinType::NullPtr;
6742-
return false;
6730+
return isSpecificBuiltinType(BuiltinType::NullPtr);
67436731
}
67446732

67456733
bool IsEnumDeclComplete(EnumDecl *);

0 commit comments

Comments
 (0)