diff options
author | Saar Raz <saar@raz.email> | 2020-02-12 15:58:51 +0200 |
---|---|---|
committer | Saar Raz <saar@raz.email> | 2020-02-12 16:03:13 +0200 |
commit | 9fbd4ab395f73209d09d821f6e5d49150c1e36ab (patch) | |
tree | 708507b39b19c7a3497afb6f44b7ced9d5d72289 /clang/lib/Sema/SemaTemplateDeduction.cpp | |
parent | 2804f355820ed5358694d6952db6650000086024 (diff) | |
download | bcm5719-llvm-9fbd4ab395f73209d09d821f6e5d49150c1e36ab.tar.gz bcm5719-llvm-9fbd4ab395f73209d09d821f6e5d49150c1e36ab.zip |
[Concepts] Do not check constraints if not all template arguments have been deduced
We previously checked the constraints of instantiated function templates even in cases where
PartialOverloading was true and not all template arguments have been deduced, which caused crashes
in clangd (bug 44714).
We now check if all arguments have been deduced before checking constraints in partial overloading
scenarios.
(cherry picked from commit 5fef14d932fe602bf998b8fb8a809ff85ca1e245)
Diffstat (limited to 'clang/lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateDeduction.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 1a71f270679..6b865a601f9 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -3439,13 +3439,16 @@ Sema::TemplateDeductionResult Sema::FinishTemplateArgumentDeduction( // ([temp.constr.decl]), those constraints are checked for satisfaction // ([temp.constr.constr]). If the constraints are not satisfied, type // deduction fails. - if (CheckInstantiatedFunctionTemplateConstraints(Info.getLocation(), - Specialization, Builder, Info.AssociatedConstraintsSatisfaction)) - return TDK_MiscellaneousDeductionFailure; + if (!PartialOverloading || + (Builder.size() == FunctionTemplate->getTemplateParameters()->size())) { + if (CheckInstantiatedFunctionTemplateConstraints(Info.getLocation(), + Specialization, Builder, Info.AssociatedConstraintsSatisfaction)) + return TDK_MiscellaneousDeductionFailure; - if (!Info.AssociatedConstraintsSatisfaction.IsSatisfied) { - Info.reset(TemplateArgumentList::CreateCopy(Context, Builder)); - return TDK_ConstraintsNotSatisfied; + if (!Info.AssociatedConstraintsSatisfaction.IsSatisfied) { + Info.reset(TemplateArgumentList::CreateCopy(Context, Builder)); + return TDK_ConstraintsNotSatisfied; + } } if (OriginalCallArgs) { |