Author: Saar Raz
Date: 2020-01-23T09:59:51+02:00
New Revision: 62c221b5090c2e1d3ca408bcab6f69c4d9e175b7

URL: 
https://github.com/llvm/llvm-project/commit/62c221b5090c2e1d3ca408bcab6f69c4d9e175b7
DIFF: 
https://github.com/llvm/llvm-project/commit/62c221b5090c2e1d3ca408bcab6f69c4d9e175b7.diff

LOG: [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).

Added: 
    

Modified: 
    clang/lib/AST/DeclTemplate.cpp
    
clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index e750bb8b6af7..9bd3b64feb4e 100755
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -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);

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 1ea4da29ee9f..9f3c21f99174 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


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to