@@ -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 (
@@ -2187,6 +2194,32 @@ void CIRGenItaniumCXXABI::emitVTableDefinitions(CIRGenVTables &CGVT,
2187
2194
llvm_unreachable (" NYI" );
2188
2195
}
2189
2196
2197
+ mlir::Value CIRGenItaniumCXXABI::emitVirtualDestructorCall (
2198
+ CIRGenFunction &CGF, const CXXDestructorDecl *dtor, CXXDtorType dtorType,
2199
+ Address thisAddr, DeleteOrMemberCallExpr expr) {
2200
+ auto *callExpr = dyn_cast<const CXXMemberCallExpr *>(expr);
2201
+ auto *delExpr = dyn_cast<const CXXDeleteExpr *>(expr);
2202
+ assert ((callExpr != nullptr ) ^ (delExpr != nullptr ));
2203
+ assert (callExpr == nullptr || callExpr->arg_begin () == callExpr->arg_end ());
2204
+ assert (dtorType == Dtor_Deleting || dtorType == Dtor_Complete);
2205
+
2206
+ GlobalDecl globalDecl (dtor, dtorType);
2207
+ const CIRGenFunctionInfo *fnInfo =
2208
+ &CGM.getTypes ().arrangeCXXStructorDeclaration (globalDecl);
2209
+ auto fnTy = CGF.CGM .getTypes ().GetFunctionType (*fnInfo);
2210
+ auto callee = CIRGenCallee::forVirtual (callExpr, globalDecl, thisAddr, fnTy);
2211
+
2212
+ QualType thisTy;
2213
+ if (callExpr)
2214
+ thisTy = callExpr->getObjectType ();
2215
+ else
2216
+ thisTy = delExpr->getDestroyedType ();
2217
+
2218
+ CGF.emitCXXDestructorCall (globalDecl, callee, thisAddr.emitRawPointer (),
2219
+ thisTy, nullptr , QualType (), nullptr );
2220
+ return nullptr ;
2221
+ }
2222
+
2190
2223
void CIRGenItaniumCXXABI::emitVirtualInheritanceTables (
2191
2224
const CXXRecordDecl *RD) {
2192
2225
CIRGenVTables &VTables = CGM.getVTables ();
@@ -2717,6 +2750,22 @@ bool CIRGenItaniumCXXABI::isZeroInitializable(const MemberPointerType *MPT) {
2717
2750
return MPT->isMemberFunctionPointer ();
2718
2751
}
2719
2752
2753
+ // / The Itanium ABI always places an offset to the complete object
2754
+ // / at entry -2 in the vtable.
2755
+ void CIRGenItaniumCXXABI::emitVirtualObjectDelete (
2756
+ CIRGenFunction &CGF, const CXXDeleteExpr *delExpr, Address ptr,
2757
+ QualType elementType, const CXXDestructorDecl *dtor) {
2758
+ bool useGlobalDelete = delExpr->isGlobalDelete ();
2759
+ if (useGlobalDelete)
2760
+ llvm_unreachable (" NYI" );
2761
+
2762
+ CXXDtorType dtorType = useGlobalDelete ? Dtor_Complete : Dtor_Deleting;
2763
+ emitVirtualDestructorCall (CGF, dtor, dtorType, ptr, delExpr);
2764
+
2765
+ if (useGlobalDelete)
2766
+ llvm_unreachable (" NYI" );
2767
+ }
2768
+
2720
2769
/* ************************* Array allocation cookies **************************/
2721
2770
2722
2771
CharUnits CIRGenItaniumCXXABI::getArrayCookieSizeImpl (QualType ElementType) {
0 commit comments