summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaar Raz <saar@raz.email>2020-01-23 09:47:55 +0200
committerSaar Raz <saar@raz.email>2020-01-24 02:28:29 +0200
commitdd5820699b75849332c930d77beeb24417316b43 (patch)
tree9230a4ed0884c349ab9abf56927cfda37a3fc14a
parent51a0e9fd6ae58c1b61fbbea1adf7d97371b7fe1c (diff)
downloadbcm5719-llvm-dd5820699b75849332c930d77beeb24417316b43.tar.gz
bcm5719-llvm-dd5820699b75849332c930d77beeb24417316b43.zip
[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). (cherry picked from commit 62c221b5090c2e1d3ca408bcab6f69c4d9e175b7)
-rwxr-xr-xclang/lib/AST/DeclTemplate.cpp5
-rw-r--r--clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp17
2 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 95a2e26e0df..58ce49aab40 100755
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -483,7 +483,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);
diff --git a/clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp b/clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
index 1ea4da29ee9..9f3c21f9917 100644
--- a/clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
+++ b/clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
@@ -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
OpenPOWER on IntegriCloud