@@ -187,6 +187,9 @@ class CIRGenItaniumCXXABI : public CIRGenCXXABI {
187187                          QualType ThisTy) override ;
188188  void  registerGlobalDtor (CIRGenFunction &CGF, const  VarDecl *D,
189189                          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 ;
190193  virtual  void  emitRethrow (CIRGenFunction &CGF, bool  isNoReturn) override ;
191194  virtual  void  emitThrow (CIRGenFunction &CGF, const  CXXThrowExpr *E) override ;
192195  CatchTypeInfo
@@ -205,6 +208,10 @@ class CIRGenItaniumCXXABI : public CIRGenCXXABI {
205208  CIRGenCallee getVirtualFunctionPointer (CIRGenFunction &CGF, GlobalDecl GD,
206209                                         Address This, mlir::Type Ty,
207210                                         SourceLocation Loc) override ;
211+   mlir::Value emitVirtualDestructorCall (CIRGenFunction &CGF,
212+                                         const  CXXDestructorDecl *Dtor,
213+                                         CXXDtorType DtorType, Address This,
214+                                         DeleteOrMemberCallExpr E) override ;
208215  mlir::Value getVTableAddressPoint (BaseSubobject Base,
209216                                    const  CXXRecordDecl *VTableClass) override ;
210217  mlir::Value getVTableAddressPointInStructorWithVTT (
@@ -2186,6 +2193,32 @@ void CIRGenItaniumCXXABI::emitVTableDefinitions(CIRGenVTables &CGVT,
21862193    llvm_unreachable (" NYI" 
21872194}
21882195
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+ 
21892222void  CIRGenItaniumCXXABI::emitVirtualInheritanceTables (
21902223    const  CXXRecordDecl *RD) {
21912224  CIRGenVTables &VTables = CGM.getVTables ();
@@ -2716,6 +2749,22 @@ bool CIRGenItaniumCXXABI::isZeroInitializable(const MemberPointerType *MPT) {
27162749  return  MPT->isMemberFunctionPointer ();
27172750}
27182751
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+ 
27192768/* ************************* Array allocation cookies **************************/ 
27202769
27212770CharUnits CIRGenItaniumCXXABI::getArrayCookieSizeImpl (QualType ElementType) {
0 commit comments