diff options
| author | Saar Raz <saar@raz.email> | 2020-01-31 15:55:06 +0200 |
|---|---|---|
| committer | Saar Raz <saar@raz.email> | 2020-01-31 16:00:41 +0200 |
| commit | 3b32963252bc8580ad8237ded3814e2a6a2ba9b6 (patch) | |
| tree | ad3048a40aba5f5b1e1bdb8af02af201e9896bcc /clang/include | |
| parent | 3573526c0286c9461f0459be1a4592b2214594e7 (diff) | |
| download | bcm5719-llvm-3b32963252bc8580ad8237ded3814e2a6a2ba9b6.tar.gz bcm5719-llvm-3b32963252bc8580ad8237ded3814e2a6a2ba9b6.zip | |
[Concepts] Correctly form initial parameter mapping for parameter packs, support substitution into SubstNonTypeTemplateParmExpr
We previously would not correctly for the initial parameter mapping for variadic template parameters in Concepts.
Testing this lead to the discovery that with the normalization process we would need to substitute into already-substituted-into
template arguments, which means we need to add NonTypeTemplateParmExpr support to TemplateInstantiator.
We do that by substituting into the replacement and the type separately, and then re-checking the expression against the NTTP
with the new type, in order to form any new required implicit casts (for cases where the type of the NTTP was dependent).
(cherry picked from commit ba1f3db4b0729ad932aa4f091e9578132d98a0c8)
Diffstat (limited to 'clang/include')
| -rw-r--r-- | clang/include/clang/Sema/Sema.h | 2 | ||||
| -rw-r--r-- | clang/include/clang/Sema/SemaConcept.h | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 72d49c119e8..697d1911be8 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -6997,7 +6997,7 @@ public: /// Get a template argument mapping the given template parameter to itself, /// e.g. for X in \c template<int X>, this would return an expression template /// argument referencing X. - TemplateArgumentLoc getIdentityTemplateArgumentLoc(Decl *Param, + TemplateArgumentLoc getIdentityTemplateArgumentLoc(NamedDecl *Param, SourceLocation Location); void translateTemplateArguments(const ASTTemplateArgsPtr &In, diff --git a/clang/include/clang/Sema/SemaConcept.h b/clang/include/clang/Sema/SemaConcept.h index 7fc42a4816e..c5f9fc45612 100644 --- a/clang/include/clang/Sema/SemaConcept.h +++ b/clang/include/clang/Sema/SemaConcept.h @@ -43,11 +43,15 @@ struct AtomicConstraint { if (ParameterMapping->size() != Other.ParameterMapping->size()) return false; - for (unsigned I = 0, S = ParameterMapping->size(); I < S; ++I) - if (!C.getCanonicalTemplateArgument((*ParameterMapping)[I].getArgument()) - .structurallyEquals(C.getCanonicalTemplateArgument( - (*Other.ParameterMapping)[I].getArgument()))) + for (unsigned I = 0, S = ParameterMapping->size(); I < S; ++I) { + llvm::FoldingSetNodeID IDA, IDB; + C.getCanonicalTemplateArgument((*ParameterMapping)[I].getArgument()) + .Profile(IDA, C); + C.getCanonicalTemplateArgument((*Other.ParameterMapping)[I].getArgument()) + .Profile(IDB, C); + if (IDA != IDB) return false; + } return true; } |

