[clang] [clang] check deduction consistency when partial ordering function templates (PR #100692)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 23 06:34:15 PDT 2024
================
@@ -5421,34 +5635,139 @@ static bool isAtLeastAsSpecializedAs(Sema &S, SourceLocation Loc,
// the partial ordering is done:
TemplateDeductionInfo Info(Loc);
switch (TPOC) {
- case TPOC_Call:
- if (DeduceTemplateArguments(S, TemplateParams, Args2.data(), Args2.size(),
- Args1.data(), Args1.size(), Info, Deduced,
- TDF_None, /*PartialOrdering=*/true) !=
- TemplateDeductionResult::Success)
+ case TPOC_Call: {
+ llvm::SmallBitVector HasDeducedParam(Args2.size());
+ if (DeduceTemplateArguments(
+ S, TemplateParams, Args2.data(), Args2.size(), Args1.data(),
+ Args1.size(), Info, Deduced, TDF_None, /*PartialOrdering=*/true,
+ /*HasDeducedAnyParam=*/nullptr,
+ &HasDeducedParam) != TemplateDeductionResult::Success)
return false;
- break;
+ SmallVector<TemplateArgument, 4> DeducedArgs(Deduced.begin(),
+ Deduced.end());
+ Sema::InstantiatingTemplate Inst(
+ S, Info.getLocation(), FT2, DeducedArgs,
+ Sema::CodeSynthesisContext::DeducedTemplateArgumentSubstitution, Info);
+ if (Inst.isInvalid())
+ return false;
- case TPOC_Conversion:
+ bool AtLeastAsSpecialized = true;
+ S.runWithSufficientStackSpace(Info.getLocation(), [&] {
+ AtLeastAsSpecialized =
+ ::FinishTemplateArgumentDeduction(
+ S, FT2, Deduced, Info,
+ [&](Sema &S, FunctionTemplateDecl *FTD,
+ ArrayRef<TemplateArgument> DeducedArgs) {
+ return ::DeduceForEachType(
+ S, TemplateParams, Args2.data(), Args2.size(), Args1.data(),
+ Args1.size(), Info, Deduced,
+ /*PartialOrdering=*/true, /*FinishingDeduction=*/true,
+ [&](Sema &S, TemplateParameterList *, int ParamIdx,
+ int ArgIdx, QualType P, QualType A,
+ TemplateDeductionInfo &Info,
+ SmallVectorImpl<DeducedTemplateArgument> &Deduced,
+ bool) {
+ // As a provisional fix for a core issue that does not
+ // exist yet, only check the consistency of parameters
+ // which participated in deduction. We still try to
+ // substitute them though.
----------------
cor3ntin wrote:
Did you submit it?
https://github.com/llvm/llvm-project/pull/100692
More information about the cfe-commits
mailing list