[clang] [win][clang] Align scalar deleting destructors with MSABI (PR #139566)
Mariya Podchishchaeva via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 26 06:06:53 PDT 2025
================
@@ -1587,28 +1587,82 @@ namespace {
}
};
+ // This function implements generation of scalar deleting destructor body for
+ // the case when the destructor also accepts an implicit flag. Right now only
+ // Microsoft ABI requires deleting destructors to accept implicit flags.
+ // The flag indicates whether an operator delete should be called and whether
+ // it should be a class-specific operator delete or a global one.
void EmitConditionalDtorDeleteCall(CodeGenFunction &CGF,
llvm::Value *ShouldDeleteCondition,
bool ReturnAfterDelete) {
+ const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CGF.CurCodeDecl);
+ const CXXRecordDecl *ClassDecl = Dtor->getParent();
+ const FunctionDecl *OD = Dtor->getOperatorDelete();
+ assert(OD->isDestroyingOperatorDelete() == ReturnAfterDelete &&
+ "unexpected value for ReturnAfterDelete");
+ auto *CondTy = cast<llvm::IntegerType>(ShouldDeleteCondition->getType());
+ // Clang 20 calls global operator delete after dtor call. Clang 21 and newer
+ // call global operator delete inside of dtor body, as MSVC does.
+ bool Clang21AndNewer = CGF.getContext().getLangOpts().getClangABICompat() >
+ LangOptions::ClangABI::Ver20;
----------------
Fznamznon wrote:
Ok, I added a member to `TargetInfo` which seems to be easily available in both Sema and CodeGen. Thanks.
https://github.com/llvm/llvm-project/pull/139566
More information about the cfe-commits
mailing list