@@ -2108,8 +2108,7 @@ bool Type::hasIntegerRepresentation() const {
2108
2108
// / \returns true if the type is considered an integral type, false otherwise.
2109
2109
bool Type::isIntegralType (const ASTContext &Ctx) const {
2110
2110
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2111
- return BT->getKind () >= BuiltinType::Bool &&
2112
- BT->getKind () <= BuiltinType::Int128;
2111
+ return BT->isInteger ();
2113
2112
2114
2113
// Complete enum types are integral in C.
2115
2114
if (!Ctx.getLangOpts ().CPlusPlus )
@@ -2121,8 +2120,7 @@ bool Type::isIntegralType(const ASTContext &Ctx) const {
2121
2120
2122
2121
bool Type::isIntegralOrUnscopedEnumerationType () const {
2123
2122
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2124
- return BT->getKind () >= BuiltinType::Bool &&
2125
- BT->getKind () <= BuiltinType::Int128;
2123
+ return BT->isInteger ();
2126
2124
2127
2125
if (isBitIntType ())
2128
2126
return true ;
@@ -2211,10 +2209,8 @@ bool Type::isUnicodeCharacterType() const {
2211
2209
// / signed, according to C99 6.2.5p4 [char, signed char, short, int, long..],
2212
2210
// / an enum decl which has a signed representation
2213
2211
bool 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 ();
2218
2214
2219
2215
if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
2220
2216
// Incomplete enum types are not treated as integer types.
@@ -2232,15 +2228,12 @@ bool Type::isSignedIntegerType() const {
2232
2228
}
2233
2229
2234
2230
bool 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 ();
2239
2233
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 ();
2244
2237
2245
2238
if (const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2246
2239
return IT->isSigned ();
@@ -2261,10 +2254,8 @@ bool Type::hasSignedIntegerRepresentation() const {
2261
2254
// / unsigned, according to C99 6.2.5p6 [which returns true for _Bool], an enum
2262
2255
// / decl which has an unsigned representation
2263
2256
bool 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 ();
2268
2259
2269
2260
if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2270
2261
// Incomplete enum types are not treated as integer types.
@@ -2282,15 +2273,12 @@ bool Type::isUnsignedIntegerType() const {
2282
2273
}
2283
2274
2284
2275
bool 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 ();
2289
2278
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 ();
2294
2282
2295
2283
if (const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2296
2284
return IT->isUnsigned ();
0 commit comments