[clang] [win][clang] Align scalar deleting destructors with MSABI (PR #139566)

Tom Honermann via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 13 21:18:13 PDT 2025


================
@@ -2886,6 +2887,16 @@ class CXXDestructorDecl : public CXXMethodDecl {
     return getCanonicalDecl()->OperatorDelete;
   }
 
+  const FunctionDecl *getOperatorGlobalDelete() const {
+    return getCanonicalDecl()->OperatorGlobalDelete;
+  }
+
+  void setOperatorGlobalDelete(FunctionDecl *OD) {
+    auto *First = cast<CXXDestructorDecl>(getCanonicalDecl());
+    if (OD && !First->OperatorGlobalDelete)
+      First->OperatorGlobalDelete = OD;
----------------
tahonermann wrote:

I think a call to `setOperatorGlobalDelete(nullptr)` should clear `OperatorGlobalDelete`.

Hmm, `setOperatorDelete()` silently ignores a call that passes `nullptr`. That seems wrong. Maybe there should be a non-null assertion?

`setOperatorDelete()` also registers the delete operator with `ASTMutationListener::ResolvedOperatorDelete()` and `ASTWriter` overrides that function. That seems important for PCH and module support. I think updates are needed to `clang/lib/Serialization/ASTReaderDecl.cpp` as well to restore `OperatorGlobalDelete` during AST deserialization; see `ASTDeclReader::VisitCXXDestructorDecl()` and `ASTDeclReader::UpdateDecl()` for assignments to `OperatorDelete`.

https://github.com/llvm/llvm-project/pull/139566


More information about the cfe-commits mailing list