[Concepts] Profile TypeConstraints in ProfileTemplateParameterList

Profile TypeConstraints in ProfileTemplateParameterList so we can distinguish
between partial specializations which differ in their TemplateParameterList
type constraints.

Recommit, now profiling the IDC so that we can deal with situations where the
TemplateArgsAsWritten are nullptr (happens when canonicalizing type constraints).
This commit is contained in:
Saar Raz 2020-01-23 09:47:55 +02:00
parent c985e7b07d
commit 62c221b509
2 changed files with 21 additions and 1 deletions

View File

@ -488,7 +488,10 @@ static void ProfileTemplateParameterList(ASTContext &C,
if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(D)) {
ID.AddInteger(1);
ID.AddBoolean(TTP->isParameterPack());
// TODO: Concepts: profile type-constraints.
ID.AddBoolean(TTP->hasTypeConstraint());
if (const TypeConstraint *TC = TTP->getTypeConstraint())
TC->getImmediatelyDeclaredConstraint()->Profile(ID, C,
/*Canonical=*/true);
continue;
}
const auto *TTP = cast<TemplateTemplateParmDecl>(D);

View File

@ -31,6 +31,23 @@ namespace class_templates
// expected-note@-2{{during template argument deduction for class template partial specialization 'B<T *>' [with T = int *]}}
// expected-note@-3{{during template argument deduction for class template partial specialization 'B<T **>' [with T = int]}}
// expected-note@-4 2{{in instantiation of template class 'class_templates::B<int **>' requested here}}
template<typename T, typename U = double>
concept same_as = is_same<T, U>::value;
template<same_as<bool> T> requires A<T>::type
struct B<T*> {};
// expected-note@-1{{previous}}
template<same_as<bool> T> requires A<T>::type
struct B<T*> {};
// expected-error@-1{{redefinition}}
template<same_as T> requires A<T>::type
struct B<T*> {};
template<same_as<int> T> requires A<T>::type
struct B<T*> {};
}
namespace variable_templates