[clang] [clang][win] MSVC-compat: Use `__global_delete` wrapper in deleting destructors instead of directly referencing `::operator delete` (PR #188372)
Daniel Paoliello via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 26 09:20:38 PDT 2026
================
@@ -1337,9 +1337,11 @@ static void EmitNewInitializer(CodeGenFunction &CGF, const CXXNewExpr *E,
static RValue EmitNewDeleteCall(CodeGenFunction &CGF,
const FunctionDecl *CalleeDecl,
const FunctionProtoType *CalleeType,
- const CallArgList &Args) {
+ const CallArgList &Args,
+ llvm::Constant *CalleeOverride = nullptr) {
llvm::CallBase *CallOrInvoke;
- llvm::Constant *CalleePtr = CGF.CGM.GetAddrOfFunction(CalleeDecl);
+ llvm::Constant *CalleePtr =
+ CalleeOverride ? CalleeOverride : CGF.CGM.GetAddrOfFunction(CalleeDecl);
----------------
dpaoliello wrote:
Yes, it's possible that there may end up being no calls to the global `operator delete`, however it's linkage type should prevent it from being optimized out. Once you get to the final binary, if there still are no calls (which there should be, since the CRT provides a `__global_delete` that forwards to it) then the linker may drop it.
https://github.com/llvm/llvm-project/pull/188372
More information about the cfe-commits
mailing list