================ @@ -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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits