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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 1 07:07:44 PDT 2024


================
@@ -16110,6 +16128,127 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor,
   return Invalid;
 }
 
+bool Sema::IsTypeIdentitySpecialization(QualType Type) const {
+  auto *TypeIdentity = getStdTypeIdentity();
+  if (!TypeIdentity)
+    return false;
+  auto *SpecializedDecl = Type->getSpecializedTemplateDecl();
+  return TypeIdentity == SpecializedDecl;
+}
+
+bool Sema::IsTypeAwareOperatorNewOrDelete(const FunctionDecl *FnDecl) const {
+  // Type aware operators
+  if (FnDecl->getNumParams() < 2)
+    return false;
+  const auto *ParamDecl = FnDecl->getParamDecl(0);
+  return IsTypeIdentitySpecialization(ParamDecl->getType());
+}
+
+bool Sema::IsTypeAwareOperatorNewOrDelete(
+    const FunctionTemplateDecl *FTD) const {
+  return IsTypeAwareOperatorNewOrDelete(FTD->getTemplatedDecl());
+}
----------------
AaronBallman wrote:

Do we need these overloads? Both `FunctionDecl` and `FunctionTemplateDecl` inherit from `NamedDecl`, so it seems like the last overload should be all we'd need?

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


More information about the cfe-commits mailing list