================ @@ -16147,6 +16169,108 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, return Invalid; } +bool Sema::isTypeAwareOperatorNewOrDelete(const NamedDecl *ND) const { + const FunctionDecl *FnDecl = nullptr; + if (auto *FTD = dyn_cast<FunctionTemplateDecl>(ND)) + FnDecl = FTD->getTemplatedDecl(); + else if (auto *FD = dyn_cast<FunctionDecl>(ND)) + FnDecl = FD; + + return FnDecl->isTypeAwareOperatorNewOrDelete(); +} + +FunctionDecl * +Sema::instantiateTypeAwareUsualDelete(FunctionTemplateDecl *FnTemplateDecl, + QualType DeallocType) { + if (!getLangOpts().TypeAwareAllocators) + return nullptr; + + TemplateParameterList *TemplateParameters = + FnTemplateDecl->getTemplateParameters(); + if (TemplateParameters->hasParameterPack()) + return nullptr; + + FunctionDecl *FnDecl = FnTemplateDecl->getTemplatedDecl(); + if (!FnDecl->isTypeAwareOperatorNewOrDelete()) + return nullptr; + + if (FnDecl->isVariadic()) + return nullptr; + + unsigned NumParams = FnDecl->getNumParams(); + if (NumParams < 2) + return nullptr; + + for (size_t Idx = 1; Idx < NumParams; ++Idx) { + // A type aware allocation is only usual if the only dependent parameter is + // the first parameter. + const ParmVarDecl *ParamDecl = FnDecl->getParamDecl(Idx); + if (ParamDecl->getType()->isDependentType()) + return nullptr; + } ---------------- cor3ntin wrote:
oh, it's called `drop_front` 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