summaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp40
1 files changed, 14 insertions, 26 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 2a8284209544..5a9279d92846 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -543,7 +543,7 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType,
QualType T
= Context.getUnqualifiedArrayType(Operand->getType().getNonReferenceType(),
Quals);
- if (T->getAs<RecordType>() &&
+ if (T->isRecordType() &&
RequireCompleteType(TypeidLoc, T, diag::err_incomplete_typeid))
return ExprError();
@@ -570,9 +570,7 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType,
}
QualType T = E->getType();
- if (const RecordType *RecordT = T->getAs<RecordType>()) {
- CXXRecordDecl *RecordD = cast<CXXRecordDecl>(RecordT->getOriginalDecl())
- ->getDefinitionOrSelf();
+ if (auto *RecordD = T->getAsCXXRecordDecl()) {
// C++ [expr.typeid]p3:
// [...] If the type of the expression is a class type, the class
// shall be completely-defined.
@@ -1975,8 +1973,8 @@ static UsualDeallocFnInfo resolveDeallocationOverload(
static bool doesUsualArrayDeleteWantSize(Sema &S, SourceLocation loc,
TypeAwareAllocationMode PassType,
QualType allocType) {
- const RecordType *record =
- allocType->getBaseElementTypeUnsafe()->getAs<RecordType>();
+ const auto *record =
+ allocType->getBaseElementTypeUnsafe()->getAsCanonical<RecordType>();
if (!record) return false;
// Try to find an operator delete[] in class scope.
@@ -2297,8 +2295,7 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
ConvertedSize = PerformImplicitConversion(
*ArraySize, Context.getSizeType(), AssignmentAction::Converting);
- if (!ConvertedSize.isInvalid() &&
- (*ArraySize)->getType()->getAs<RecordType>())
+ if (!ConvertedSize.isInvalid() && (*ArraySize)->getType()->isRecordType())
// Diagnose the compatibility of this conversion.
Diag(StartLoc, diag::warn_cxx98_compat_array_size_conversion)
<< (*ArraySize)->getType() << 0 << "'size_t'";
@@ -3055,9 +3052,7 @@ bool Sema::FindAllocationFunctions(
LookupResult FoundDelete(*this, DeleteName, StartLoc, LookupOrdinaryName);
if (AllocElemType->isRecordType() &&
DeleteScope != AllocationFunctionScope::Global) {
- auto *RD = cast<CXXRecordDecl>(
- AllocElemType->castAs<RecordType>()->getOriginalDecl())
- ->getDefinitionOrSelf();
+ auto *RD = AllocElemType->castAsCXXRecordDecl();
LookupQualifiedName(FoundDelete, RD);
}
if (FoundDelete.isAmbiguous())
@@ -4070,9 +4065,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
? diag::err_delete_incomplete
: diag::warn_delete_incomplete,
Ex.get())) {
- if (const RecordType *RT = PointeeElem->getAs<RecordType>())
- PointeeRD =
- cast<CXXRecordDecl>(RT->getOriginalDecl())->getDefinitionOrSelf();
+ PointeeRD = PointeeElem->getAsCXXRecordDecl();
}
}
@@ -4840,10 +4833,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
if (FromType->isVectorType() || ToType->isVectorType())
StepTy = adjustVectorType(Context, FromType, ToType, &ElTy);
if (ElTy->isBooleanType()) {
- assert(FromType->castAs<EnumType>()
- ->getOriginalDecl()
- ->getDefinitionOrSelf()
- ->isFixed() &&
+ assert(FromType->castAsEnumDecl()->isFixed() &&
SCS.Second == ICK_Integral_Promotion &&
"only enums with fixed underlying type can promote to bool");
From = ImpCastExprToType(From, StepTy, CK_IntegralToBoolean, VK_PRValue,
@@ -5529,8 +5519,8 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To,
// the same or one is a base class of the other:
QualType FTy = From->getType();
QualType TTy = To->getType();
- const RecordType *FRec = FTy->getAs<RecordType>();
- const RecordType *TRec = TTy->getAs<RecordType>();
+ const RecordType *FRec = FTy->getAsCanonical<RecordType>();
+ const RecordType *TRec = TTy->getAsCanonical<RecordType>();
bool FDerivedFromT = FRec && TRec && FRec != TRec &&
Self.IsDerivedFrom(QuestionLoc, FTy, TTy);
if (FRec && TRec && (FRec == TRec || FDerivedFromT ||
@@ -7528,12 +7518,10 @@ ExprResult Sema::IgnoredValueConversions(Expr *E) {
}
// GCC seems to also exclude expressions of incomplete enum type.
- if (const EnumType *T = E->getType()->getAs<EnumType>()) {
- if (!T->getOriginalDecl()->getDefinitionOrSelf()->isComplete()) {
- // FIXME: stupid workaround for a codegen bug!
- E = ImpCastExprToType(E, Context.VoidTy, CK_ToVoid).get();
- return E;
- }
+ if (const auto *ED = E->getType()->getAsEnumDecl(); ED && !ED->isComplete()) {
+ // FIXME: stupid workaround for a codegen bug!
+ E = ImpCastExprToType(E, Context.VoidTy, CK_ToVoid).get();
+ return E;
}
ExprResult Res = DefaultFunctionArrayLvalueConversion(E);