diff options
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp')
-rw-r--r-- | clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp | 64 |
1 files changed, 5 insertions, 59 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp b/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp index 83208bf..7989ad2 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp @@ -210,60 +210,6 @@ RValue CIRGenFunction::emitCXXMemberOrOperatorCall( return emitCall(fnInfo, callee, returnValue, args, nullptr, loc); } -namespace { -/// The parameters to pass to a usual operator delete. -struct UsualDeleteParams { - TypeAwareAllocationMode typeAwareDelete = TypeAwareAllocationMode::No; - bool destroyingDelete = false; - bool size = false; - AlignedAllocationMode alignment = AlignedAllocationMode::No; -}; -} // namespace - -// FIXME(cir): this should be shared with LLVM codegen -static UsualDeleteParams getUsualDeleteParams(const FunctionDecl *fd) { - UsualDeleteParams params; - - const FunctionProtoType *fpt = fd->getType()->castAs<FunctionProtoType>(); - auto ai = fpt->param_type_begin(), ae = fpt->param_type_end(); - - if (fd->isTypeAwareOperatorNewOrDelete()) { - params.typeAwareDelete = TypeAwareAllocationMode::Yes; - assert(ai != ae); - ++ai; - } - - // The first argument after the type-identity parameter (if any) is - // always a void* (or C* for a destroying operator delete for class - // type C). - ++ai; - - // The next parameter may be a std::destroying_delete_t. - if (fd->isDestroyingOperatorDelete()) { - params.destroyingDelete = true; - assert(ai != ae); - ++ai; - } - - // Figure out what other parameters we should be implicitly passing. - if (ai != ae && (*ai)->isIntegerType()) { - params.size = true; - ++ai; - } else { - assert(!isTypeAwareAllocation(params.typeAwareDelete)); - } - - if (ai != ae && (*ai)->isAlignValT()) { - params.alignment = AlignedAllocationMode::Yes; - ++ai; - } else { - assert(!isTypeAwareAllocation(params.typeAwareDelete)); - } - - assert(ai == ae && "unexpected usual deallocation function parameter"); - return params; -} - static mlir::Value emitCXXNewAllocSize(CIRGenFunction &cgf, const CXXNewExpr *e, unsigned minElements, mlir::Value &numElements, @@ -616,11 +562,11 @@ void CIRGenFunction::emitDeleteCall(const FunctionDecl *deleteFD, const auto *deleteFTy = deleteFD->getType()->castAs<FunctionProtoType>(); CallArgList deleteArgs; - UsualDeleteParams params = getUsualDeleteParams(deleteFD); + UsualDeleteParams params = deleteFD->getUsualDeleteParams(); auto paramTypeIt = deleteFTy->param_type_begin(); // Pass std::type_identity tag if present - if (isTypeAwareAllocation(params.typeAwareDelete)) + if (isTypeAwareAllocation(params.TypeAwareDelete)) cgm.errorNYI(deleteFD->getSourceRange(), "emitDeleteCall: type aware delete"); @@ -631,12 +577,12 @@ void CIRGenFunction::emitDeleteCall(const FunctionDecl *deleteFD, deleteArgs.add(RValue::get(deletePtr), argTy); // Pass the std::destroying_delete tag if present. - if (params.destroyingDelete) + if (params.DestroyingDelete) cgm.errorNYI(deleteFD->getSourceRange(), "emitDeleteCall: destroying delete"); // Pass the size if the delete function has a size_t parameter. - if (params.size) { + if (params.Size) { QualType sizeType = *paramTypeIt++; CharUnits deleteTypeSize = getContext().getTypeSizeInChars(deleteTy); assert(mlir::isa<cir::IntType>(convertType(sizeType)) && @@ -648,7 +594,7 @@ void CIRGenFunction::emitDeleteCall(const FunctionDecl *deleteFD, } // Pass the alignment if the delete function has an align_val_t parameter. - if (isAlignedAllocation(params.alignment)) + if (isAlignedAllocation(params.Alignment)) cgm.errorNYI(deleteFD->getSourceRange(), "emitDeleteCall: aligned allocation"); |