@@ -162,8 +162,8 @@ class FieldMemcpyizer {
162162
163163 CharUnits memcpySize = getMemcpySize (firstByteOffset);
164164 QualType recordTy = CGF.getContext ().getTagType (
165- ElaboratedTypeKeyword::None, /* Qualifier=*/ std::nullopt ,
166- ClassDecl, /* OwnsTag=*/ false );
165+ ElaboratedTypeKeyword::None, /* Qualifier=*/ std::nullopt , ClassDecl,
166+ /* OwnsTag=*/ false );
167167 Address thisPtr = CGF.LoadCXXThisAddress ();
168168 LValue destLv = CGF.makeAddrLValue (thisPtr, recordTy);
169169 LValue dest = CGF.emitLValueForFieldInitialization (destLv, FirstField,
@@ -521,8 +521,7 @@ class AssignmentMemcpyizer : public FieldMemcpyizer {
521521
522522static bool isInitializerOfDynamicClass (const CXXCtorInitializer *BaseInit) {
523523 const Type *BaseType = BaseInit->getBaseClass ();
524- const auto *BaseClassDecl =
525- cast<CXXRecordDecl>(BaseType->castAs <RecordType>()->getOriginalDecl ());
524+ const auto *BaseClassDecl = BaseType->castAsCXXRecordDecl ();
526525 return BaseClassDecl->isDynamicClass ();
527526}
528527
@@ -608,8 +607,7 @@ static void emitBaseInitializer(mlir::Location loc, CIRGenFunction &CGF,
608607 Address ThisPtr = CGF.LoadCXXThisAddress ();
609608
610609 const Type *BaseType = BaseInit->getBaseClass ();
611- const auto *BaseClassDecl =
612- cast<CXXRecordDecl>(BaseType->castAs <RecordType>()->getOriginalDecl ());
610+ const auto *BaseClassDecl = BaseType->getAsCXXRecordDecl ();
613611
614612 bool isBaseVirtual = BaseInit->isBaseVirtual ();
615613
@@ -871,8 +869,7 @@ void CIRGenFunction::getVTablePointers(BaseSubobject Base,
871869
872870 // Traverse bases.
873871 for (const auto &I : RD->bases ()) {
874- auto *BaseDecl =
875- cast<CXXRecordDecl>(I.getType ()->castAs <RecordType>()->getOriginalDecl ());
872+ auto *BaseDecl = I.getType ()->getAsCXXRecordDecl ();
876873
877874 // Ignore classes without a vtable.
878875 if (!BaseDecl->isDynamicClass ())
@@ -1088,7 +1085,7 @@ void CIRGenFunction::emitLambdaStaticInvokeBody(const CXXMethodDecl *MD) {
10881085void CIRGenFunction::destroyCXXObject (CIRGenFunction &CGF, Address addr,
10891086 QualType type) {
10901087 const RecordType *rtype = type->castAs <RecordType>();
1091- const CXXRecordDecl *record = cast<CXXRecordDecl>( rtype->getOriginalDecl () );
1088+ const CXXRecordDecl *record = rtype->getAsCXXRecordDecl ( );
10921089 const CXXDestructorDecl *dtor = record->getDestructor ();
10931090 // TODO(cir): Unlike traditional codegen, CIRGen should actually emit trivial
10941091 // dtors which shall be removed on later CIR passes. However, only remove this
@@ -1123,8 +1120,7 @@ HasTrivialDestructorBody(ASTContext &astContext,
11231120 if (I.isVirtual ())
11241121 continue ;
11251122
1126- const CXXRecordDecl *NonVirtualBase =
1127- cast<CXXRecordDecl>(I.getType ()->castAs <RecordType>()->getOriginalDecl ());
1123+ const CXXRecordDecl *NonVirtualBase = I.getType ()->getAsCXXRecordDecl ();
11281124 if (!HasTrivialDestructorBody (astContext, NonVirtualBase,
11291125 MostDerivedClassDecl))
11301126 return false ;
@@ -1133,8 +1129,7 @@ HasTrivialDestructorBody(ASTContext &astContext,
11331129 if (BaseClassDecl == MostDerivedClassDecl) {
11341130 // Check virtual bases.
11351131 for (const auto &I : BaseClassDecl->vbases ()) {
1136- const CXXRecordDecl *VirtualBase =
1137- cast<CXXRecordDecl>(I.getType ()->castAs <RecordType>()->getOriginalDecl ());
1132+ const CXXRecordDecl *VirtualBase = I.getType ()->getAsCXXRecordDecl ();
11381133 if (!HasTrivialDestructorBody (astContext, VirtualBase,
11391134 MostDerivedClassDecl))
11401135 return false ;
@@ -1154,7 +1149,7 @@ static bool FieldHasTrivialDestructorBody(ASTContext &astContext,
11541149 if (!RT)
11551150 return true ;
11561151
1157- CXXRecordDecl *FieldClassDecl = cast<CXXRecordDecl>( RT->getOriginalDecl () );
1152+ CXXRecordDecl *FieldClassDecl = RT->getAsCXXRecordDecl ( );
11581153
11591154 // The destructor for an implicit anonymous union member is never invoked.
11601155 if (FieldClassDecl->isUnion () && FieldClassDecl->isAnonymousStructOrUnion ())
@@ -1247,6 +1242,8 @@ void CIRGenFunction::emitDestructorBody(FunctionArgList &Args) {
12471242 // we'd introduce *two* handler blocks. In the Microsoft ABI, we
12481243 // always delegate because we might not have a definition in this TU.
12491244 switch (DtorType) {
1245+ case Dtor_Unified:
1246+ llvm_unreachable (" not expecting a unified dtor" );
12501247 case Dtor_Comdat:
12511248 llvm_unreachable (" not expecting a COMDAT" );
12521249 case Dtor_Deleting:
@@ -1405,8 +1402,7 @@ void CIRGenFunction::EnterDtorCleanups(const CXXDestructorDecl *DD,
14051402 // We push them in the forward order so that they'll be popped in
14061403 // the reverse order.
14071404 for (const auto &Base : ClassDecl->vbases ()) {
1408- auto *BaseClassDecl =
1409- cast<CXXRecordDecl>(Base.getType ()->castAs <RecordType>()->getOriginalDecl ());
1405+ auto *BaseClassDecl = Base.getType ()->getAsCXXRecordDecl ();
14101406
14111407 if (BaseClassDecl->hasTrivialDestructor ()) {
14121408 // Under SanitizeMemoryUseAfterDtor, poison the trivial base class
@@ -1466,7 +1462,7 @@ void CIRGenFunction::EnterDtorCleanups(const CXXDestructorDecl *DD,
14661462
14671463 // Anonymous union members do not have their destructors called.
14681464 const RecordType *RT = type->getAsUnionType ();
1469- if (RT && RT->getOriginalDecl ()->isAnonymousStructOrUnion ())
1465+ if (RT && RT->getDecl ()->isAnonymousStructOrUnion ())
14701466 continue ;
14711467
14721468 CleanupKind cleanupKind = getCleanupKind (dtorKind);
@@ -1593,8 +1589,7 @@ Address CIRGenFunction::getAddressOfDerivedClass(
15931589 CastExpr::path_const_iterator pathEnd, bool nullCheckValue) {
15941590 assert (pathBegin != pathEnd && " Base path should not be empty!" );
15951591
1596- QualType derivedTy =
1597- getContext ().getCanonicalTagType (derived);
1592+ QualType derivedTy = getContext ().getCanonicalTagType (derived);
15981593 mlir::Type derivedValueTy = convertType (derivedTy);
15991594 CharUnits nonVirtualOffset =
16001595 CGM.getNonVirtualBaseClassOffset (derived, pathBegin, pathEnd);
@@ -1624,8 +1619,7 @@ CIRGenFunction::getAddressOfBaseClass(Address Value,
16241619 // *start* with a step down to the correct virtual base subobject,
16251620 // and hence will not require any further steps.
16261621 if ((*Start)->isVirtual ()) {
1627- VBase = cast<CXXRecordDecl>(
1628- (*Start)->getType ()->castAs <RecordType>()->getOriginalDecl ());
1622+ VBase = (*Start)->getType ()->getAsCXXRecordDecl ();
16291623 ++Start;
16301624 }
16311625
@@ -1873,8 +1867,8 @@ void CIRGenFunction::emitCXXAggrConstructorCall(
18731867 // Note that these are complete objects and so we don't need to
18741868 // use the non-virtual size or alignment.
18751869 QualType type = getContext ().getTypeDeclType (ElaboratedTypeKeyword::None,
1876- /* Qualifier=*/ std::nullopt ,
1877- ctor->getParent ());
1870+ /* Qualifier=*/ std::nullopt ,
1871+ ctor->getParent ());
18781872 CharUnits eltAlignment = arrayBase.getAlignment ().alignmentOfArrayElement (
18791873 getContext ().getTypeSizeInChars (type));
18801874
@@ -1992,7 +1986,8 @@ void CIRGenFunction::emitCXXConstructorCall(
19921986
19931987 if (!NewPointerIsChecked)
19941988 emitTypeCheck (CIRGenFunction::TCK_ConstructorCall, Loc, This.getPointer (),
1995- getContext ().getCanonicalTagType (ClassDecl), CharUnits::Zero ());
1989+ getContext ().getCanonicalTagType (ClassDecl),
1990+ CharUnits::Zero ());
19961991
19971992 // If this is a call to a trivial default constructor:
19981993 // In LLVM: do nothing.
0 commit comments