@@ -2108,8 +2108,7 @@ bool Type::hasIntegerRepresentation() const {
21082108// / \returns true if the type is considered an integral type, false otherwise.
21092109bool Type::isIntegralType (const ASTContext &Ctx) const {
21102110 if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2111- return BT->getKind () >= BuiltinType::Bool &&
2112- BT->getKind () <= BuiltinType::Int128;
2111+ return BT->isInteger ();
21132112
21142113 // Complete enum types are integral in C.
21152114 if (!Ctx.getLangOpts ().CPlusPlus )
@@ -2121,8 +2120,7 @@ bool Type::isIntegralType(const ASTContext &Ctx) const {
21212120
21222121bool Type::isIntegralOrUnscopedEnumerationType () const {
21232122 if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2124- return BT->getKind () >= BuiltinType::Bool &&
2125- BT->getKind () <= BuiltinType::Int128;
2123+ return BT->isInteger ();
21262124
21272125 if (isBitIntType ())
21282126 return true ;
@@ -2211,10 +2209,8 @@ bool Type::isUnicodeCharacterType() const {
22112209// / signed, according to C99 6.2.5p4 [char, signed char, short, int, long..],
22122210// / an enum decl which has a signed representation
22132211bool Type::isSignedIntegerType () const {
2214- if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2215- return BT->getKind () >= BuiltinType::Char_S &&
2216- BT->getKind () <= BuiltinType::Int128;
2217- }
2212+ if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2213+ return BT->isSignedInteger ();
22182214
22192215 if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
22202216 // Incomplete enum types are not treated as integer types.
@@ -2232,15 +2228,12 @@ bool Type::isSignedIntegerType() const {
22322228}
22332229
22342230bool Type::isSignedIntegerOrEnumerationType () const {
2235- if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2236- return BT->getKind () >= BuiltinType::Char_S &&
2237- BT->getKind () <= BuiltinType::Int128;
2238- }
2231+ if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2232+ return BT->isSignedInteger ();
22392233
2240- if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2241- if (ET->getDecl ()->isComplete ())
2242- return ET->getDecl ()->getIntegerType ()->isSignedIntegerType ();
2243- }
2234+ if (const auto *ET = dyn_cast<EnumType>(CanonicalType);
2235+ ET && ET->getDecl ()->isComplete ())
2236+ return ET->getDecl ()->getIntegerType ()->isSignedIntegerType ();
22442237
22452238 if (const auto *IT = dyn_cast<BitIntType>(CanonicalType))
22462239 return IT->isSigned ();
@@ -2261,10 +2254,8 @@ bool Type::hasSignedIntegerRepresentation() const {
22612254// / unsigned, according to C99 6.2.5p6 [which returns true for _Bool], an enum
22622255// / decl which has an unsigned representation
22632256bool Type::isUnsignedIntegerType () const {
2264- if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2265- return BT->getKind () >= BuiltinType::Bool &&
2266- BT->getKind () <= BuiltinType::UInt128;
2267- }
2257+ if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2258+ return BT->isUnsignedInteger ();
22682259
22692260 if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
22702261 // Incomplete enum types are not treated as integer types.
@@ -2282,15 +2273,12 @@ bool Type::isUnsignedIntegerType() const {
22822273}
22832274
22842275bool Type::isUnsignedIntegerOrEnumerationType () const {
2285- if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2286- return BT->getKind () >= BuiltinType::Bool &&
2287- BT->getKind () <= BuiltinType::UInt128;
2288- }
2276+ if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2277+ return BT->isUnsignedInteger ();
22892278
2290- if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2291- if (ET->getDecl ()->isComplete ())
2292- return ET->getDecl ()->getIntegerType ()->isUnsignedIntegerType ();
2293- }
2279+ if (const auto *ET = dyn_cast<EnumType>(CanonicalType);
2280+ ET && ET->getDecl ()->isComplete ())
2281+ return ET->getDecl ()->getIntegerType ()->isUnsignedIntegerType ();
22942282
22952283 if (const auto *IT = dyn_cast<BitIntType>(CanonicalType))
22962284 return IT->isUnsigned ();
0 commit comments