@@ -210,60 +210,6 @@ RValue CIRGenFunction::emitCXXMemberOrOperatorCall(
210210 return emitCall (fnInfo, callee, returnValue, args, nullptr , loc);
211211}
212212
213- namespace {
214- // / The parameters to pass to a usual operator delete.
215- struct UsualDeleteParams {
216- TypeAwareAllocationMode typeAwareDelete = TypeAwareAllocationMode::No;
217- bool destroyingDelete = false ;
218- bool size = false ;
219- AlignedAllocationMode alignment = AlignedAllocationMode::No;
220- };
221- } // namespace
222-
223- // FIXME(cir): this should be shared with LLVM codegen
224- static UsualDeleteParams getUsualDeleteParams (const FunctionDecl *fd) {
225- UsualDeleteParams params;
226-
227- const FunctionProtoType *fpt = fd->getType ()->castAs <FunctionProtoType>();
228- auto ai = fpt->param_type_begin (), ae = fpt->param_type_end ();
229-
230- if (fd->isTypeAwareOperatorNewOrDelete ()) {
231- params.typeAwareDelete = TypeAwareAllocationMode::Yes;
232- assert (ai != ae);
233- ++ai;
234- }
235-
236- // The first argument after the type-identity parameter (if any) is
237- // always a void* (or C* for a destroying operator delete for class
238- // type C).
239- ++ai;
240-
241- // The next parameter may be a std::destroying_delete_t.
242- if (fd->isDestroyingOperatorDelete ()) {
243- params.destroyingDelete = true ;
244- assert (ai != ae);
245- ++ai;
246- }
247-
248- // Figure out what other parameters we should be implicitly passing.
249- if (ai != ae && (*ai)->isIntegerType ()) {
250- params.size = true ;
251- ++ai;
252- } else {
253- assert (!isTypeAwareAllocation (params.typeAwareDelete ));
254- }
255-
256- if (ai != ae && (*ai)->isAlignValT ()) {
257- params.alignment = AlignedAllocationMode::Yes;
258- ++ai;
259- } else {
260- assert (!isTypeAwareAllocation (params.typeAwareDelete ));
261- }
262-
263- assert (ai == ae && " unexpected usual deallocation function parameter" );
264- return params;
265- }
266-
267213static mlir::Value emitCXXNewAllocSize (CIRGenFunction &cgf, const CXXNewExpr *e,
268214 unsigned minElements,
269215 mlir::Value &numElements,
@@ -616,11 +562,11 @@ void CIRGenFunction::emitDeleteCall(const FunctionDecl *deleteFD,
616562 const auto *deleteFTy = deleteFD->getType ()->castAs <FunctionProtoType>();
617563 CallArgList deleteArgs;
618564
619- UsualDeleteParams params = getUsualDeleteParams (deleteFD );
565+ UsualDeleteParams params = deleteFD-> getUsualDeleteParams ();
620566 auto paramTypeIt = deleteFTy->param_type_begin ();
621567
622568 // Pass std::type_identity tag if present
623- if (isTypeAwareAllocation (params.typeAwareDelete ))
569+ if (isTypeAwareAllocation (params.TypeAwareDelete ))
624570 cgm.errorNYI (deleteFD->getSourceRange (),
625571 " emitDeleteCall: type aware delete" );
626572
@@ -631,12 +577,12 @@ void CIRGenFunction::emitDeleteCall(const FunctionDecl *deleteFD,
631577 deleteArgs.add (RValue::get (deletePtr), argTy);
632578
633579 // Pass the std::destroying_delete tag if present.
634- if (params.destroyingDelete )
580+ if (params.DestroyingDelete )
635581 cgm.errorNYI (deleteFD->getSourceRange (),
636582 " emitDeleteCall: destroying delete" );
637583
638584 // Pass the size if the delete function has a size_t parameter.
639- if (params.size ) {
585+ if (params.Size ) {
640586 QualType sizeType = *paramTypeIt++;
641587 CharUnits deleteTypeSize = getContext ().getTypeSizeInChars (deleteTy);
642588 assert (mlir::isa<cir::IntType>(convertType (sizeType)) &&
@@ -648,7 +594,7 @@ void CIRGenFunction::emitDeleteCall(const FunctionDecl *deleteFD,
648594 }
649595
650596 // Pass the alignment if the delete function has an align_val_t parameter.
651- if (isAlignedAllocation (params.alignment ))
597+ if (isAlignedAllocation (params.Alignment ))
652598 cgm.errorNYI (deleteFD->getSourceRange (),
653599 " emitDeleteCall: aligned allocation" );
654600
0 commit comments