[clang] c9447c6 - [Clang] fold expression is considered atomic during constraints normalization

Yuanfang Chen via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 22 20:49:34 PDT 2022


Author: Yuanfang Chen
Date: 2022-10-22T20:48:57-07:00
New Revision: c9447c62966e5ec60ec277e4a7d75420224f53f6

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

LOG: [Clang] fold expression is considered atomic during constraints normalization

`|| fold` is not disjunction; `&& fold` is not conjunction. Both are atomic per
current wording. See http://cplusplus.github.io/concepts-ts/ts-active.html#28.

D128750 accidentally tried to partially addresss this which is not desirable.
This patch reverts that part and associated test cases.

Added: 
    

Modified: 
    clang/lib/Sema/SemaConcept.cpp
    clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 9809ccb2ccc00..484c02498f20b 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -1110,14 +1110,8 @@ NormalizedConstraint::fromConstraintExpr(Sema &S, NamedDecl *D, const Expr *E) {
 
   // C++2a [temp.param]p4:
   //     [...] If T is not a pack, then E is E', otherwise E is (E' && ...).
-  //
-  // Using the pattern suffices because the partial ordering rules guarantee
-  // the template paramaters are equivalent.
-  if (auto *FoldE = dyn_cast<const CXXFoldExpr>(E)) {
-    assert(FoldE->isRightFold() && FoldE->getOperator() == BO_LAnd);
-    assert(E->IgnoreParenImpCasts() == E);
-    E = FoldE->getPattern();
-  }
+  // Fold expression is considered atomic constraints per current wording.
+  // See http://cplusplus.github.io/concepts-ts/ts-active.html#28
 
   if (LogicalBinOp BO = E) {
     auto LHS = fromConstraintExpr(S, D, BO.getLHS());

diff  --git a/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
index bdd1c376243bb..d6e6d73d05ed5 100644
--- a/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
+++ b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
@@ -44,23 +44,8 @@ template<C T, E auto M, int W, A S,
          typename... Z>
 void foo(T, U<T, M, W, S, Z...>);
 
-// check auto template parameter pack.
-template<C T, auto M, int W, A S,
-         template<typename, auto, int, A, auto...> class U,
-         C auto... Z>
-void foo2(T, U<T, M, W, S, Z...>) = delete;
-template<C T, auto M, int W, A S,
-         template<typename, auto, int, A, auto...> class U,
-         D auto... Z>
-void foo2(T, U<T, M, W, S, Z...>) = delete;
-template<C T, auto M, int W, A S,
-         template<typename, auto, int, A, auto...> class U,
-         E auto... Z>
-void foo2(T, U<T, M, W, S, Z...>);
-
 void bar(S<int, 1, 1, A{}, int> s, S2<int, 1, 1, A{}, 0, 0u> s2) {
   foo(0, s);
-  foo2(0, s2);
 }
 
 template<C auto... T> void bar2();
@@ -110,8 +95,9 @@ template<D T, C V> struct Y4<V, T>; // expected-error {{class template partial s
 template<C auto T> struct W1;
 template<D auto T> struct W1<T> {};
 
-template<C auto... T> struct W2;
-template<D auto... T> struct W2<T...> {};
+// See http://cplusplus.github.io/concepts-ts/ts-active.html#28
+// template<C auto... T> struct W2;
+// template<D auto... T> struct W2<T...> {};
 
 template<class T, class U>
 concept C1 = C<T> && C<U>;
@@ -121,8 +107,9 @@ concept D1 = D<T> && C<U>;
 template<C1<A> auto T> struct W3;
 template<D1<A> auto T> struct W3<T> {};
 
-template<C1<A> auto... T> struct W4;
-template<D1<A> auto... T> struct W4<T...> {};
+// See http://cplusplus.github.io/concepts-ts/ts-active.html#28
+// template<C1<A> auto... T> struct W4;
+// template<D1<A> auto... T> struct W4<T...> {};
 
 // FIXME: enable once Clang support non-trivial auto on NTTP.
 // template<C auto* T> struct W5;
@@ -133,9 +120,9 @@ template<D1<A> auto... T> struct W4<T...> {};
 // template<D auto& T> struct W6<T> {};
 
 struct W1<0> w1;
-struct W2<0> w2;
+// struct W2<0> w2;
 struct W3<0> w3;
-struct W4<0> w4;
+// struct W4<0> w4;
 // FIXME: enable once Clang support non-trivial auto on NTTP.
 // struct W5<(int*)nullptr> w5;
 // struct W6<w5> w6;


        


More information about the cfe-commits mailing list