@@ -187,6 +187,9 @@ class CIRGenItaniumCXXABI : public CIRGenCXXABI {
187
187
QualType ThisTy) override ;
188
188
void registerGlobalDtor (CIRGenFunction &CGF, const VarDecl *D,
189
189
cir::FuncOp dtor, mlir::Value Addr) override ;
190
+ void emitVirtualObjectDelete (CIRGenFunction &CGF, const CXXDeleteExpr *DE,
191
+ Address Ptr, QualType ElementType,
192
+ const CXXDestructorDecl *Dtor) override ;
190
193
virtual void emitRethrow (CIRGenFunction &CGF, bool isNoReturn) override ;
191
194
virtual void emitThrow (CIRGenFunction &CGF, const CXXThrowExpr *E) override ;
192
195
CatchTypeInfo
@@ -205,6 +208,10 @@ class CIRGenItaniumCXXABI : public CIRGenCXXABI {
205
208
CIRGenCallee getVirtualFunctionPointer (CIRGenFunction &CGF, GlobalDecl GD,
206
209
Address This, mlir::Type Ty,
207
210
SourceLocation Loc) override ;
211
+ mlir::Value emitVirtualDestructorCall (CIRGenFunction &CGF,
212
+ const CXXDestructorDecl *Dtor,
213
+ CXXDtorType DtorType, Address This,
214
+ DeleteOrMemberCallExpr E) override ;
208
215
mlir::Value getVTableAddressPoint (BaseSubobject Base,
209
216
const CXXRecordDecl *VTableClass) override ;
210
217
mlir::Value getVTableAddressPointInStructorWithVTT (
@@ -2186,6 +2193,32 @@ void CIRGenItaniumCXXABI::emitVTableDefinitions(CIRGenVTables &CGVT,
2186
2193
llvm_unreachable (" NYI" );
2187
2194
}
2188
2195
2196
+ mlir::Value CIRGenItaniumCXXABI::emitVirtualDestructorCall (
2197
+ CIRGenFunction &CGF, const CXXDestructorDecl *dtor, CXXDtorType dtorType,
2198
+ Address thisAddr, DeleteOrMemberCallExpr expr) {
2199
+ auto *callExpr = dyn_cast<const CXXMemberCallExpr *>(expr);
2200
+ auto *delExpr = dyn_cast<const CXXDeleteExpr *>(expr);
2201
+ assert ((callExpr != nullptr ) ^ (delExpr != nullptr ));
2202
+ assert (callExpr == nullptr || callExpr->arg_begin () == callExpr->arg_end ());
2203
+ assert (dtorType == Dtor_Deleting || dtorType == Dtor_Complete);
2204
+
2205
+ GlobalDecl globalDecl (dtor, dtorType);
2206
+ const CIRGenFunctionInfo *fnInfo =
2207
+ &CGM.getTypes ().arrangeCXXStructorDeclaration (globalDecl);
2208
+ auto fnTy = CGF.CGM .getTypes ().GetFunctionType (*fnInfo);
2209
+ auto callee = CIRGenCallee::forVirtual (callExpr, globalDecl, thisAddr, fnTy);
2210
+
2211
+ QualType thisTy;
2212
+ if (callExpr)
2213
+ thisTy = callExpr->getObjectType ();
2214
+ else
2215
+ thisTy = delExpr->getDestroyedType ();
2216
+
2217
+ CGF.emitCXXDestructorCall (globalDecl, callee, thisAddr.emitRawPointer (),
2218
+ thisTy, nullptr , QualType (), nullptr );
2219
+ return nullptr ;
2220
+ }
2221
+
2189
2222
void CIRGenItaniumCXXABI::emitVirtualInheritanceTables (
2190
2223
const CXXRecordDecl *RD) {
2191
2224
CIRGenVTables &VTables = CGM.getVTables ();
@@ -2716,6 +2749,22 @@ bool CIRGenItaniumCXXABI::isZeroInitializable(const MemberPointerType *MPT) {
2716
2749
return MPT->isMemberFunctionPointer ();
2717
2750
}
2718
2751
2752
+ // / The Itanium ABI always places an offset to the complete object
2753
+ // / at entry -2 in the vtable.
2754
+ void CIRGenItaniumCXXABI::emitVirtualObjectDelete (
2755
+ CIRGenFunction &CGF, const CXXDeleteExpr *delExpr, Address ptr,
2756
+ QualType elementType, const CXXDestructorDecl *dtor) {
2757
+ bool useGlobalDelete = delExpr->isGlobalDelete ();
2758
+ if (useGlobalDelete)
2759
+ llvm_unreachable (" NYI" );
2760
+
2761
+ CXXDtorType dtorType = useGlobalDelete ? Dtor_Complete : Dtor_Deleting;
2762
+ emitVirtualDestructorCall (CGF, dtor, dtorType, ptr, delExpr);
2763
+
2764
+ if (useGlobalDelete)
2765
+ llvm_unreachable (" NYI" );
2766
+ }
2767
+
2719
2768
/* ************************* Array allocation cookies **************************/
2720
2769
2721
2770
CharUnits CIRGenItaniumCXXABI::getArrayCookieSizeImpl (QualType ElementType) {
0 commit comments