[clang] [RFC] Initial implementation of P2719 (PR #113510)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 25 13:19:50 PDT 2025


================
@@ -3503,9 +3518,23 @@ bool FunctionDecl::isDestroyingOperatorDelete() const {
       getNumParams() < 2)
     return false;
 
-  auto *RD = getParamDecl(1)->getType()->getAsCXXRecordDecl();
-  return RD && RD->isInStdNamespace() && RD->getIdentifier() &&
-         RD->getIdentifier()->isStr("destroying_delete_t");
+  if (isTypeAwareOperatorNewOrDelete())
+    return false;
+
+  return getParamDecl(1)->getType()->isDestroyingDeleteT();
----------------
ojhunt wrote:

@cor3ntin @AaronBallman So part of my reason for this approach for `isTypeAwareOperatorNewOrDelete()` is to avoid the more expensive type checks in the common case of them not being type aware.

But to resolve the problems with `isDestroyingDeleteT` and `isTypeIdentity` needing a Sema reference in contexts where a Sema is not available is generally for queries on Function/CXXMethodDecl to determine if they're destroying or type aware delete, which could be resolved by spending a couple of bits on FunctionDecl to just record that directly - which would also help perf in a bunch of places.

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


More information about the cfe-commits mailing list