[clang] 2904f80 - Revert "[Clang][Sema] Use the correct injected template arguments for partial specializations when collecting multi-level template argument lists (#112381)" (#115157)

via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 6 05:43:42 PST 2024


Author: Krystian Stasiowski
Date: 2024-11-06T08:43:37-05:00
New Revision: 2904f809cd1bf2651d6eceb2ad86553f407bf530

URL: https://github.com/llvm/llvm-project/commit/2904f809cd1bf2651d6eceb2ad86553f407bf530
DIFF: https://github.com/llvm/llvm-project/commit/2904f809cd1bf2651d6eceb2ad86553f407bf530.diff

LOG: Revert "[Clang][Sema] Use the correct injected template arguments for partial specializations when collecting multi-level template argument lists (#112381)" (#115157)

This reverts commit 9381c6fd04cc16a7606633f57c96c11e58181ddb.

Added: 
    

Modified: 
    clang/lib/Sema/SemaTemplateInstantiate.cpp
    clang/test/CXX/temp/temp.constr/temp.constr.decl/p4.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index b63063813f1b56..c5921287a3afb2 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -237,8 +237,7 @@ struct TemplateInstantiationArgumentCollecter
     if (Innermost)
       AddInnermostTemplateArguments(VTPSD);
     else if (ForConstraintInstantiation)
-      AddOuterTemplateArguments(VTPSD,
-                                VTPSD->getInjectedTemplateArgs(S.Context),
+      AddOuterTemplateArguments(VTPSD, VTPSD->getTemplateArgs().asArray(),
                                 /*Final=*/false);
 
     if (VTPSD->isMemberSpecialization())
@@ -275,8 +274,7 @@ struct TemplateInstantiationArgumentCollecter
     if (Innermost)
       AddInnermostTemplateArguments(CTPSD);
     else if (ForConstraintInstantiation)
-      AddOuterTemplateArguments(CTPSD,
-                                CTPSD->getInjectedTemplateArgs(S.Context),
+      AddOuterTemplateArguments(CTPSD, CTPSD->getTemplateArgs().asArray(),
                                 /*Final=*/false);
 
     if (CTPSD->isMemberSpecialization())

diff  --git a/clang/test/CXX/temp/temp.constr/temp.constr.decl/p4.cpp b/clang/test/CXX/temp/temp.constr/temp.constr.decl/p4.cpp
index f144e14cd122f9..70064f867e18e3 100644
--- a/clang/test/CXX/temp/temp.constr/temp.constr.decl/p4.cpp
+++ b/clang/test/CXX/temp/temp.constr/temp.constr.decl/p4.cpp
@@ -1,219 +1,175 @@
 // RUN: %clang_cc1 -std=c++20 -verify %s
 // expected-no-diagnostics
 
-namespace Primary {
-  template<typename T>
-  concept D = true;
+template<typename T>
+concept D = true;
 
-  template<typename T>
-  struct A {
-    template<typename U, bool V>
-    void f() requires V;
-
-    template<>
-    void f<short, true>();
-
-    template<D U>
-    void g();
-
-    template<typename U, bool V> requires V
-    struct B;
-
-    template<typename U, bool V> requires V
-    struct B<U*, V>;
-
-    template<>
-    struct B<short, true>;
-
-    template<D U>
-    struct C;
-
-    template<D U>
-    struct C<U*>;
-
-    template<typename U, bool V> requires V
-    static int x;
-
-    template<typename U, bool V> requires V
-    static int x<U*, V>;
-
-    template<>
-    int x<short, true>;
-
-    template<D U>
-    static int y;
-
-    template<D U>
-    static int y<U*>;
-  };
-
-  template<typename T>
+template<typename T>
+struct A {
   template<typename U, bool V>
-  void A<T>::f() requires V { }
+  void f() requires V;
+
+  template<>
+  void f<short, true>();
 
-  template<typename T>
   template<D U>
-  void A<T>::g() { }
+  void g();
 
-  template<typename T>
   template<typename U, bool V> requires V
-  struct A<T>::B { };
+  struct B;
 
-  template<typename T>
   template<typename U, bool V> requires V
-  struct A<T>::B<U*, V> { };
+  struct B<U*, V>;
 
-  template<typename T>
-  template<typename U, bool V> requires V
-  struct A<T>::B<U&, V> { };
+  template<>
+  struct B<short, true>;
 
-  template<typename T>
   template<D U>
-  struct A<T>::C { };
+  struct C;
 
-  template<typename T>
   template<D U>
-  struct A<T>::C<U*> { };
+  struct C<U*>;
 
-  template<typename T>
   template<typename U, bool V> requires V
-  int A<T>::x = 0;
+  static int x;
 
-  template<typename T>
   template<typename U, bool V> requires V
-  int A<T>::x<U*, V> = 0;
+  static int x<U*, V>;
 
-  template<typename T>
-  template<typename U, bool V> requires V
-  int A<T>::x<U&, V> = 0;
+  template<>
+  int x<short, true>;
 
-  template<typename T>
   template<D U>
-  int A<T>::y = 0;
+  static int y;
 
-  template<typename T>
   template<D U>
-  int A<T>::y<U*> = 0;
+  static int y<U*>;
+};
 
-  template<>
-  template<typename U, bool V>
-  void A<short>::f() requires V;
+template<typename T>
+template<typename U, bool V>
+void A<T>::f() requires V { }
 
-  template<>
-  template<>
-  void A<short>::f<int, true>();
+template<typename T>
+template<D U>
+void A<T>::g() { }
 
-  template<>
-  template<>
-  void A<void>::f<int, true>();
+template<typename T>
+template<typename U, bool V> requires V
+struct A<T>::B { };
 
-  template<>
-  template<D U>
-  void A<short>::g();
+template<typename T>
+template<typename U, bool V> requires V
+struct A<T>::B<U*, V> { };
 
-  template<>
-  template<typename U, bool V> requires V
-  struct A<int>::B;
+template<typename T>
+template<typename U, bool V> requires V
+struct A<T>::B<U&, V> { };
 
-  template<>
-  template<>
-  struct A<int>::B<int, true>;
+template<typename T>
+template<D U>
+struct A<T>::C { };
 
-  template<>
-  template<>
-  struct A<void>::B<int, true>;
+template<typename T>
+template<D U>
+struct A<T>::C<U*> { };
 
-  template<>
-  template<typename U, bool V> requires V
-  struct A<int>::B<U*, V>;
+template<typename T>
+template<typename U, bool V> requires V
+int A<T>::x = 0;
 
-  template<>
-  template<typename U, bool V> requires V
-  struct A<int>::B<U&, V>;
+template<typename T>
+template<typename U, bool V> requires V
+int A<T>::x<U*, V> = 0;
 
-  template<>
-  template<D U>
-  struct A<int>::C;
+template<typename T>
+template<typename U, bool V> requires V
+int A<T>::x<U&, V> = 0;
 
-  template<>
-  template<D U>
-  struct A<int>::C<U*>;
+template<typename T>
+template<D U>
+int A<T>::y = 0;
 
-  template<>
-  template<D U>
-  struct A<int>::C<U&>;
+template<typename T>
+template<D U>
+int A<T>::y<U*> = 0;
 
-  template<>
-  template<typename U, bool V> requires V
-  int A<long>::x;
+template<>
+template<typename U, bool V>
+void A<short>::f() requires V;
 
-  template<>
-  template<>
-  int A<long>::x<int, true>;
+template<>
+template<>
+void A<short>::f<int, true>();
 
-  template<>
-  template<>
-  int A<void>::x<int, true>;
+template<>
+template<>
+void A<void>::f<int, true>();
 
-  template<>
-  template<typename U, bool V> requires V
-  int A<long>::x<U*, V>;
+template<>
+template<D U>
+void A<short>::g();
 
-  template<>
-  template<typename U, bool V> requires V
-  int A<long>::x<U&, V>;
+template<>
+template<typename U, bool V> requires V
+struct A<int>::B;
 
-  template<>
-  template<D U>
-  int A<long>::y;
+template<>
+template<>
+struct A<int>::B<int, true>;
 
-  template<>
-  template<D U>
-  int A<long>::y<U*>;
+template<>
+template<>
+struct A<void>::B<int, true>;
 
-  template<>
-  template<D U>
-  int A<long>::y<U&>;
-} // namespace Primary
+template<>
+template<typename U, bool V> requires V
+struct A<int>::B<U*, V>;
 
-namespace Partial {
-  template<typename T, bool B>
-  struct A;
+template<>
+template<typename U, bool V> requires V
+struct A<int>::B<U&, V>;
 
-  template<bool U>
-  struct A<int, U>
-  {
-      template<typename V> requires U
-      void f();
+template<>
+template<D U>
+struct A<int>::C;
 
-      template<typename V> requires U
-      static const int x;
+template<>
+template<D U>
+struct A<int>::C<U*>;
 
-      template<typename V> requires U
-      struct B;
-  };
+template<>
+template<D U>
+struct A<int>::C<U&>;
 
-  template<bool U>
-  template<typename V> requires U
-  void A<int, U>::f() { }
+template<>
+template<typename U, bool V> requires V
+int A<long>::x;
 
-  template<bool U>
-  template<typename V> requires U
-  constexpr int A<int, U>::x = 0;
+template<>
+template<>
+int A<long>::x<int, true>;
 
-  template<bool U>
-  template<typename V> requires U
-  struct A<int, U>::B { };
+template<>
+template<>
+int A<void>::x<int, true>;
 
-  template<>
-  template<typename V> requires true
-  void A<int, true>::f() { }
+template<>
+template<typename U, bool V> requires V
+int A<long>::x<U*, V>;
 
-  template<>
-  template<typename V> requires true
-  constexpr int A<int, true>::x = 1;
+template<>
+template<typename U, bool V> requires V
+int A<long>::x<U&, V>;
 
-  template<>
-  template<typename V> requires true
-  struct A<int, true>::B { };
-} // namespace Partial
+template<>
+template<D U>
+int A<long>::y;
+
+template<>
+template<D U>
+int A<long>::y<U*>;
+
+template<>
+template<D U>
+int A<long>::y<U&>;


        


More information about the cfe-commits mailing list