[clang] [CIR] Add support for virtual destructor calls (PR #162725)
Amr Hesham via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 9 13:31:27 PDT 2025
================
@@ -465,6 +468,32 @@ void CIRGenItaniumCXXABI::emitVTableDefinitions(CIRGenVTables &cgvt,
}
}
+mlir::Value CIRGenItaniumCXXABI::emitVirtualDestructorCall(
+ CIRGenFunction &cgf, const CXXDestructorDecl *dtor, CXXDtorType dtorType,
+ Address thisAddr, DeleteOrMemberCallExpr expr) {
+ auto *callExpr = dyn_cast<const CXXMemberCallExpr *>(expr);
+ auto *delExpr = dyn_cast<const CXXDeleteExpr *>(expr);
+ assert((callExpr != nullptr) ^ (delExpr != nullptr));
+ assert(callExpr == nullptr || callExpr->arg_begin() == callExpr->arg_end());
+ assert(dtorType == Dtor_Deleting || dtorType == Dtor_Complete);
+
+ GlobalDecl globalDecl(dtor, dtorType);
+ const CIRGenFunctionInfo *fnInfo =
+ &cgm.getTypes().arrangeCXXStructorDeclaration(globalDecl);
+ const cir::FuncType &fnTy = cgm.getTypes().getFunctionType(*fnInfo);
+ auto callee = CIRGenCallee::forVirtual(callExpr, globalDecl, thisAddr, fnTy);
+
+ QualType thisTy;
+ if (callExpr)
+ thisTy = callExpr->getObjectType();
+ else
+ thisTy = delExpr->getDestroyedType();
----------------
AmrDeveloper wrote:
```suggestion
QualType thisTy = callExpr ? callExpr->getObjectType() : delExpr->getDestroyedType();
```
https://github.com/llvm/llvm-project/pull/162725
More information about the cfe-commits
mailing list