@@ -2001,8 +2001,7 @@ bool ASTContext::isPromotableIntegerType(QualType T) const {
20012001
20022002 // Enumerated types are promotable to their compatible integer types
20032003 // (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()) {
20062005 if (T->isDependentType() || ED->getPromotionType().isNull() ||
20072006 ED->isScoped())
20082007 return false;
@@ -2712,11 +2711,8 @@ unsigned ASTContext::getPreferredTypeAlign(const Type *T) const {
27122711 // possible.
27132712 if (const auto *CT = T->getAs<ComplexType>())
27142713 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();
27202716 if (T->isSpecificBuiltinType(BuiltinType::Double) ||
27212717 T->isSpecificBuiltinType(BuiltinType::LongLong) ||
27222718 T->isSpecificBuiltinType(BuiltinType::ULongLong) ||
@@ -3412,10 +3408,7 @@ static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx,
34123408 // type, or an unsigned integer type.
34133409 //
34143410 // 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();
34193412 return encodeTypeForFunctionPointerAuth(
34203413 Ctx, OS, UnderlyingType.isNull() ? Ctx.IntTy : UnderlyingType);
34213414 }
@@ -8351,8 +8344,8 @@ QualType ASTContext::isPromotableBitField(Expr *E) const {
83518344QualType ASTContext::getPromotedIntegerType(QualType Promotable) const {
83528345 assert(!Promotable.isNull());
83538346 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();
83568349
83578350 if (const auto *BT = Promotable->getAs<BuiltinType>()) {
83588351 // C++ [conv.prom]: A prvalue of type char16_t, char32_t, or wchar_t
@@ -8571,10 +8564,9 @@ QualType ASTContext::getObjCSuperType() const {
85718564}
85728565
85738566void 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();
85788570}
85798571
85808572QualType ASTContext::getBlockDescriptorType() const {
@@ -11667,9 +11659,8 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs,
1166711659
1166811660 // Look at the converted type of enum types, since that is the type used
1166911661 // 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();
1167311664 if (paramTy.isNull())
1167411665 return {};
1167511666 }
@@ -12260,8 +12251,8 @@ QualType ASTContext::mergeObjCGCQualifiers(QualType LHS, QualType RHS) {
1226012251//===----------------------------------------------------------------------===//
1226112252
1226212253unsigned 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();
1226512256 if (T->isBooleanType())
1226612257 return 1;
1226712258 if (const auto *EIT = T->getAs<BitIntType>())
@@ -12286,8 +12277,8 @@ QualType ASTContext::getCorrespondingUnsignedType(QualType T) const {
1228612277
1228712278 // For enums, get the underlying integer type of the enum, and let the general
1228812279 // 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();
1229112282
1229212283 switch (T->castAs<BuiltinType>()->getKind()) {
1229312284 case BuiltinType::Char_U:
@@ -12360,8 +12351,8 @@ QualType ASTContext::getCorrespondingSignedType(QualType T) const {
1236012351
1236112352 // For enums, get the underlying integer type of the enum, and let the general
1236212353 // 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();
1236512356
1236612357 switch (T->castAs<BuiltinType>()->getKind()) {
1236712358 case BuiltinType::Char_S:
0 commit comments