@@ -2001,8 +2001,7 @@ bool ASTContext::isPromotableIntegerType(QualType T) const {
2001
2001
2002
2002
// Enumerated types are promotable to their compatible integer types
2003
2003
// (C99 6.3.1.1) a.k.a. its underlying type (C++ [conv.prom]p2).
2004
- if (const auto *ET = T->getAs<EnumType>()) {
2005
- const EnumDecl *ED = ET->getOriginalDecl()->getDefinitionOrSelf();
2004
+ if (const auto *ED = T->getAsEnumDecl()) {
2006
2005
if (T->isDependentType() || ED->getPromotionType().isNull() ||
2007
2006
ED->isScoped())
2008
2007
return false;
@@ -2712,11 +2711,8 @@ unsigned ASTContext::getPreferredTypeAlign(const Type *T) const {
2712
2711
// possible.
2713
2712
if (const auto *CT = T->getAs<ComplexType>())
2714
2713
T = CT->getElementType().getTypePtr();
2715
- if (const auto *ET = T->getAs<EnumType>())
2716
- T = ET->getOriginalDecl()
2717
- ->getDefinitionOrSelf()
2718
- ->getIntegerType()
2719
- .getTypePtr();
2714
+ if (const auto *ED = T->getAsEnumDecl())
2715
+ T = ED->getIntegerType().getTypePtr();
2720
2716
if (T->isSpecificBuiltinType(BuiltinType::Double) ||
2721
2717
T->isSpecificBuiltinType(BuiltinType::LongLong) ||
2722
2718
T->isSpecificBuiltinType(BuiltinType::ULongLong) ||
@@ -3412,10 +3408,7 @@ static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx,
3412
3408
// type, or an unsigned integer type.
3413
3409
//
3414
3410
// So we have to treat enum types as integers.
3415
- QualType UnderlyingType = cast<EnumType>(T)
3416
- ->getOriginalDecl()
3417
- ->getDefinitionOrSelf()
3418
- ->getIntegerType();
3411
+ QualType UnderlyingType = T->castAsEnumDecl()->getIntegerType();
3419
3412
return encodeTypeForFunctionPointerAuth(
3420
3413
Ctx, OS, UnderlyingType.isNull() ? Ctx.IntTy : UnderlyingType);
3421
3414
}
@@ -8351,8 +8344,8 @@ QualType ASTContext::isPromotableBitField(Expr *E) const {
8351
8344
QualType ASTContext::getPromotedIntegerType(QualType Promotable) const {
8352
8345
assert(!Promotable.isNull());
8353
8346
assert(isPromotableIntegerType(Promotable));
8354
- if (const auto *ET = Promotable->getAs<EnumType> ())
8355
- return ET->getOriginalDecl()->getDefinitionOrSelf() ->getPromotionType();
8347
+ if (const auto *ED = Promotable->getAsEnumDecl ())
8348
+ return ED ->getPromotionType();
8356
8349
8357
8350
if (const auto *BT = Promotable->getAs<BuiltinType>()) {
8358
8351
// C++ [conv.prom]: A prvalue of type char16_t, char32_t, or wchar_t
@@ -8571,10 +8564,9 @@ QualType ASTContext::getObjCSuperType() const {
8571
8564
}
8572
8565
8573
8566
void ASTContext::setCFConstantStringType(QualType T) {
8574
- const auto *TD = T->castAs<TypedefType>();
8575
- CFConstantStringTypeDecl = cast<TypedefDecl>(TD->getDecl());
8576
- const auto *TagType = TD->castAs<RecordType>();
8577
- CFConstantStringTagDecl = TagType->getOriginalDecl()->getDefinitionOrSelf();
8567
+ const auto *TT = T->castAs<TypedefType>();
8568
+ CFConstantStringTypeDecl = cast<TypedefDecl>(TT->getDecl());
8569
+ CFConstantStringTagDecl = TT->castAsRecordDecl();
8578
8570
}
8579
8571
8580
8572
QualType ASTContext::getBlockDescriptorType() const {
@@ -11667,9 +11659,8 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs,
11667
11659
11668
11660
// Look at the converted type of enum types, since that is the type used
11669
11661
// to pass enum values.
11670
- if (const auto *Enum = paramTy->getAs<EnumType>()) {
11671
- paramTy =
11672
- Enum->getOriginalDecl()->getDefinitionOrSelf()->getIntegerType();
11662
+ if (const auto *ED = paramTy->getAsEnumDecl()) {
11663
+ paramTy = ED->getIntegerType();
11673
11664
if (paramTy.isNull())
11674
11665
return {};
11675
11666
}
@@ -12260,8 +12251,8 @@ QualType ASTContext::mergeObjCGCQualifiers(QualType LHS, QualType RHS) {
12260
12251
//===----------------------------------------------------------------------===//
12261
12252
12262
12253
unsigned ASTContext::getIntWidth(QualType T) const {
12263
- if (const auto *ET = T->getAs<EnumType> ())
12264
- T = ET->getOriginalDecl()->getDefinitionOrSelf() ->getIntegerType();
12254
+ if (const auto *ED = T->getAsEnumDecl ())
12255
+ T = ED ->getIntegerType();
12265
12256
if (T->isBooleanType())
12266
12257
return 1;
12267
12258
if (const auto *EIT = T->getAs<BitIntType>())
@@ -12286,8 +12277,8 @@ QualType ASTContext::getCorrespondingUnsignedType(QualType T) const {
12286
12277
12287
12278
// For enums, get the underlying integer type of the enum, and let the general
12288
12279
// integer type signchanging code handle it.
12289
- if (const auto *ETy = T->getAs<EnumType> ())
12290
- T = ETy->getOriginalDecl()->getDefinitionOrSelf() ->getIntegerType();
12280
+ if (const auto *ED = T->getAsEnumDecl ())
12281
+ T = ED ->getIntegerType();
12291
12282
12292
12283
switch (T->castAs<BuiltinType>()->getKind()) {
12293
12284
case BuiltinType::Char_U:
@@ -12360,8 +12351,8 @@ QualType ASTContext::getCorrespondingSignedType(QualType T) const {
12360
12351
12361
12352
// For enums, get the underlying integer type of the enum, and let the general
12362
12353
// integer type signchanging code handle it.
12363
- if (const auto *ETy = T->getAs<EnumType> ())
12364
- T = ETy->getOriginalDecl()->getDefinitionOrSelf() ->getIntegerType();
12354
+ if (const auto *ED = T->getAsEnumDecl ())
12355
+ T = ED ->getIntegerType();
12365
12356
12366
12357
switch (T->castAs<BuiltinType>()->getKind()) {
12367
12358
case BuiltinType::Char_S:
0 commit comments