[clang] [clang][win] MSVC-compat: Use `__global_delete` wrapper in deleting destructors instead of directly referencing `::operator delete` (PR #188372)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 3 14:50:35 PDT 2026
================
@@ -2069,6 +2072,12 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) {
const Expr *Arg = E->getArgument();
Address Ptr = EmitPointerWithAlignment(Arg);
+ // If this delete expression uses global ::operator delete (not a
+ // class-specific one), note it so we emit __global_delete forwarding bodies.
+ if (!isa<CXXMethodDecl>(E->getOperatorDelete()) &&
+ CGM.getTarget().getCXXABI().isMicrosoft())
+ CGM.noteDirectGlobalDelete();
----------------
efriedma-quic wrote:
I think this is supposed to be specifically looking a `::delete` expression involving a class with a member delete, not just any delete which calls a global operator delete.
We also need to handle the case where the class is dllexport.
https://github.com/llvm/llvm-project/pull/188372
More information about the cfe-commits
mailing list