forked from OSchip/llvm-project
[Concepts] Profile TypeConstraints in ProfileTemplateParameterList
Profile TypeConstraints in ProfileTemplateParameterList so we can distinguish between partial specializations which differ in their TemplateParameterList type constraints
This commit is contained in:
parent
1db1b8b8b3
commit
0e3ae353a4
|
@ -488,7 +488,15 @@ static void ProfileTemplateParameterList(ASTContext &C,
|
||||||
if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(D)) {
|
if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(D)) {
|
||||||
ID.AddInteger(1);
|
ID.AddInteger(1);
|
||||||
ID.AddBoolean(TTP->isParameterPack());
|
ID.AddBoolean(TTP->isParameterPack());
|
||||||
// TODO: Concepts: profile type-constraints.
|
ID.AddBoolean(TTP->hasTypeConstraint());
|
||||||
|
if (const TypeConstraint *TC = TTP->getTypeConstraint()) {
|
||||||
|
ID.AddPointer(TC->getNamedConcept()->getCanonicalDecl());
|
||||||
|
ID.AddBoolean(TC->hasExplicitTemplateArgs());
|
||||||
|
if (TC->hasExplicitTemplateArgs()) {
|
||||||
|
for (const auto &Arg : TC->getTemplateArgsAsWritten()->arguments())
|
||||||
|
Arg.getArgument().Profile(ID, C);
|
||||||
|
}
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto *TTP = cast<TemplateTemplateParmDecl>(D);
|
const auto *TTP = cast<TemplateTemplateParmDecl>(D);
|
||||||
|
|
|
@ -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@-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@-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}}
|
// 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
|
namespace variable_templates
|
||||||
|
|
Loading…
Reference in New Issue