[clang] [RFC] Initial implementation of P2719 (PR #113510)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 6 01:38:33 PST 2024
================
@@ -16106,6 +16127,128 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor,
return Invalid;
}
+bool Sema::isTypeIdentitySpecialization(QualType Type) const {
+ const ClassTemplateDecl *TypeIdentity = getStdTypeIdentity();
+ if (!TypeIdentity)
+ return false;
+ const TemplateDecl *SpecializedDecl = Type->getSpecializedTemplateDecl();
+ return TypeIdentity == SpecializedDecl;
+}
+
+bool Sema::isTypeAwareOperatorNewOrDelete(const FunctionDecl *FnDecl) const {
+ // Type aware operators
+ if (FnDecl->getNumParams() < 2)
+ return false;
+ const ParmVarDecl *ParamDecl = FnDecl->getParamDecl(0);
+ return isTypeIdentitySpecialization(ParamDecl->getType());
+}
+
+bool Sema::isTypeAwareOperatorNewOrDelete(
+ const FunctionTemplateDecl *FTD) const {
+ return isTypeAwareOperatorNewOrDelete(FTD->getTemplatedDecl());
+}
+
+bool Sema::isTypeAwareOperatorNewOrDelete(const NamedDecl *ND) const {
+ if (auto *FTD = dyn_cast<FunctionTemplateDecl>(ND))
+ return isTypeAwareOperatorNewOrDelete(FTD->getTemplatedDecl());
+ if (auto *FnDecl = dyn_cast<FunctionDecl>(ND))
+ return isTypeAwareOperatorNewOrDelete(FnDecl);
+ return false;
+}
+
+std::optional<FunctionDecl *>
----------------
cor3ntin wrote:
Just returning FunctionDecl * would be enough
https://github.com/llvm/llvm-project/pull/113510
More information about the cfe-commits
mailing list