[clang] [Docs][Clang] Missing DR status for C++23-era papers in cxx_status.html (PR #68846)

2023-11-07 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/68846

>From 40dca93d3e1f339f3e756e54687ea5506b3d6f2e Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Tue, 17 Oct 2023 10:41:18 +0800
Subject: [PATCH] [Docs][Clang] DR status in cxx_status.html

---
 clang/www/cxx_status.html | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index e2cf9ab25465214..8e2869d3fdf8ac6 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -190,7 +190,7 @@ C++23 implementation status
 
 
   Allow duplicate attributes
-  https://wg21.link/P2156R1";>P2156R1
+  https://wg21.link/P2156R1";>P2156R1 (DR)
   Clang 13
 
 
@@ -210,7 +210,7 @@ C++23 implementation status
 
 
   C++ identifier syntax using UAX 31
-  https://wg21.link/P1949R7";>P1949R7
+  https://wg21.link/P1949R7";>P1949R7 (DR)
   Clang 14
 
 
@@ -230,11 +230,11 @@ C++23 implementation status
 
 
   Change scope of lambda trailing-return-type
-  https://wg21.link/P2036R3";>P2036R3
+  https://wg21.link/P2036R3";>P2036R3 (DR)
   Clang 17
 
 
-  https://wg21.link/P2579R0";>P2579R0
+  https://wg21.link/P2579R0";>P2579R0 (DR)
 
 
   Multidimensional subscript operator
@@ -303,12 +303,12 @@ C++23 implementation status
 
 
   The Equality Operator You Are Looking For
-  https://wg21.link/P2468R2";>P2468R2
+  https://wg21.link/P2468R2";>P2468R2 (DR)
   Clang 16
 
 
   De-deprecating volatile compound operations
-  https://wg21.link/P2327R1";>P2327R1
+  https://wg21.link/P2327R1";>P2327R1 (DR)
   Clang 15
 
 
@@ -380,7 +380,7 @@ C++23 implementation status
 
 
   char8_t Compatibility and Portability Fix
-  https://wg21.link/P2513R3";>P2513R3
+  https://wg21.link/P2513R3";>P2513R3 (DR)
   Clang 16
 
 
@@ -522,7 +522,7 @@ C++20 implementation status
 https://wg21.link/p2103r0";>P2103R0
   

-https://wg21.link/p2493r0";>P2493R0
+https://wg21.link/p2493r0";>P2493R0 (DR)
   
   
 https://wg21.link/p2092r0";>P2092R0

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


[clang] [Docs][Clang] Missing DR status for C++23-era papers in cxx_status.html (PR #68846)

2023-11-14 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/68846

>From b2ec5be2a9eb80a4aeaf329ea4aed727b36501a1 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Tue, 17 Oct 2023 10:41:18 +0800
Subject: [PATCH] [Docs][Clang] DR status in cxx_status.html

---
 clang/www/cxx_status.html | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 621439d0bae9666..a1e9b51c25905b9 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -207,7 +207,7 @@ C++23 implementation status
 
 
   Allow duplicate attributes
-  https://wg21.link/P2156R1";>P2156R1
+  https://wg21.link/P2156R1";>P2156R1 (DR)
   Clang 13
 
 
@@ -227,7 +227,7 @@ C++23 implementation status
 
 
   C++ identifier syntax using UAX 31
-  https://wg21.link/P1949R7";>P1949R7
+  https://wg21.link/P1949R7";>P1949R7 (DR)
   Clang 14
 
 
@@ -247,11 +247,11 @@ C++23 implementation status
 
 
   Change scope of lambda trailing-return-type
-  https://wg21.link/P2036R3";>P2036R3
+  https://wg21.link/P2036R3";>P2036R3 (DR)
   Clang 17
 
 
-  https://wg21.link/P2579R0";>P2579R0
+  https://wg21.link/P2579R0";>P2579R0 (DR)
 
 
   Multidimensional subscript operator
@@ -320,12 +320,12 @@ C++23 implementation status
 
 
   The Equality Operator You Are Looking For
-  https://wg21.link/P2468R2";>P2468R2
+  https://wg21.link/P2468R2";>P2468R2 (DR)
   Clang 16
 
 
   De-deprecating volatile compound operations
-  https://wg21.link/P2327R1";>P2327R1
+  https://wg21.link/P2327R1";>P2327R1 (DR)
   Clang 15
 
 
@@ -397,7 +397,7 @@ C++23 implementation status
 
 
   char8_t Compatibility and Portability Fix
-  https://wg21.link/P2513R3";>P2513R3
+  https://wg21.link/P2513R3";>P2513R3 (DR)
   Clang 16
 
 
@@ -539,7 +539,7 @@ C++20 implementation status
 https://wg21.link/p2103r0";>P2103R0
   

-https://wg21.link/p2493r0";>P2493R0
+https://wg21.link/p2493r0";>P2493R0 (DR)
   
   
 https://wg21.link/p2092r0";>P2092R0

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


[clang] [Docs][Clang] Missing DR status for C++23-era papers in cxx_status.html (PR #68846)

2023-11-26 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/68846

>From 9ef23f11f52735976a05080227bb880af3b9cbb6 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Tue, 17 Oct 2023 10:41:18 +0800
Subject: [PATCH] [Docs][Clang] DR status in cxx_status.html

---
 clang/www/cxx_status.html | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 621439d0bae9666..a1e9b51c25905b9 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -207,7 +207,7 @@ C++23 implementation status
 
 
   Allow duplicate attributes
-  https://wg21.link/P2156R1";>P2156R1
+  https://wg21.link/P2156R1";>P2156R1 (DR)
   Clang 13
 
 
@@ -227,7 +227,7 @@ C++23 implementation status
 
 
   C++ identifier syntax using UAX 31
-  https://wg21.link/P1949R7";>P1949R7
+  https://wg21.link/P1949R7";>P1949R7 (DR)
   Clang 14
 
 
@@ -247,11 +247,11 @@ C++23 implementation status
 
 
   Change scope of lambda trailing-return-type
-  https://wg21.link/P2036R3";>P2036R3
+  https://wg21.link/P2036R3";>P2036R3 (DR)
   Clang 17
 
 
-  https://wg21.link/P2579R0";>P2579R0
+  https://wg21.link/P2579R0";>P2579R0 (DR)
 
 
   Multidimensional subscript operator
@@ -320,12 +320,12 @@ C++23 implementation status
 
 
   The Equality Operator You Are Looking For
-  https://wg21.link/P2468R2";>P2468R2
+  https://wg21.link/P2468R2";>P2468R2 (DR)
   Clang 16
 
 
   De-deprecating volatile compound operations
-  https://wg21.link/P2327R1";>P2327R1
+  https://wg21.link/P2327R1";>P2327R1 (DR)
   Clang 15
 
 
@@ -397,7 +397,7 @@ C++23 implementation status
 
 
   char8_t Compatibility and Portability Fix
-  https://wg21.link/P2513R3";>P2513R3
+  https://wg21.link/P2513R3";>P2513R3 (DR)
   Clang 16
 
 
@@ -539,7 +539,7 @@ C++20 implementation status
 https://wg21.link/p2103r0";>P2103R0
   

-https://wg21.link/p2493r0";>P2493R0
+https://wg21.link/p2493r0";>P2493R0 (DR)
   
   
 https://wg21.link/p2092r0";>P2092R0

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


[libcxx] [flang] [clang] [compiler-rt] [llvm] [lldb] [clang-tools-extra] [libc] [lld] [libc++][variant] P2637R3: Member `visit` (`std::variant`) (PR #76447)

2024-01-02 Thread A. Jiang via cfe-commits


@@ -1273,6 +1293,22 @@ public:
 __impl_.__swap(__that.__impl_);
   }
 
+#  if _LIBCPP_STD_VER >= 26
+  // [variant.visit], visitation
+
+  template 

frederick-vs-ja wrote:

Would it be better to use a special tag type like this
```C++
struct __variant_visit_barrier_tag { // unnamable when using standard library 
modules
  explicit __variant_visit_barrier_tag() = default;
};
// ...
template <__variant_visit_barrier_tag = __variant_visit_barrier_tag{}, class 
_Self, class _Visitor>
// ...
```
to avoid accepting `v.visit<0, T, F>(f)`?

https://github.com/llvm/llvm-project/pull/76447
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] [flang] [clang] [compiler-rt] [llvm] [lldb] [clang-tools-extra] [libc] [lld] [libc++][variant] P2637R3: Member `visit` (`std::variant`) (PR #76447)

2024-01-02 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/76447
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [libc++] Implement LWG3528 (`make_from_tuple` can perform (the equivalent of) a C-style cast) (PR #85263)

2024-03-20 Thread A. Jiang via cfe-commits


@@ -1386,9 +1386,19 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) 
apply(_Fn&& __f, _Tuple&&
 std::forward<_Tuple>(__t),
 typename 
__make_tuple_indices>>::type{}))
 
+#if _LIBCPP_STD_VER >= 20
 template 
 inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& 
__t, __tuple_indices<_Idx...>)
+  noexcept(noexcept(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...)))
+  requires is_constructible_v<_Tp, 
decltype(std::get<_Idx>(std::forward<_Tuple>(__t)))...> {
+  return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...);
+}
+#else
+template 
+inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& 
__t, __tuple_indices<_Idx...>, 
+enable_if_t(std::forward<_Tuple>(__t)))...>> * = nullptr)
 _LIBCPP_NOEXCEPT_RETURN(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...))
+#endif // _LIBCPP_STD_VER >= 20
 
 template 

frederick-vs-ja wrote:

Just making `__make_from_tuple_impl` SFINAE-friendly is insufficient and leads 
to worse diagnostic messages.

I guess we can write the following to make `make_from_tuple` SFINAE-friendly. 
`(requires` can be used since C++20 to make the implemenation clearer.)

```C++
template >>::type, class = 
void>
inline constexpr bool __can_make_from_tuple = false;
template 
inline constexpr bool __can_make_from_tuple<
_Tp, _Tuple, index_sequence<_Idx...>,
enable_if_t(std::declval<_Tuple>()))...>>> = true;

template , int> = 0>
inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp make_from_tuple(_Tuple&& __t)
_LIBCPP_NOEXCEPT_RETURN(std::__make_from_tuple_impl<_Tp>(
std::forward<_Tuple>(__t), typename 
__make_tuple_indices>>::type{}))
```

And perhaps we shouldn't touch `__make_from_tuple_impl` if it's OK to constrain 
`make_from_tuple`.

https://github.com/llvm/llvm-project/pull/85263
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add __builtin_start_object_lifetime builtin. (PR #82776)

2024-03-27 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

> This does something both useful and correct with `-fno-strict-aliasing`.

I'm not sure whether an instrinsic is even needed with `-fno-strict-aliasing`. 
IIUC `std::start_lifetime_as` mainly tells the compiler that the types of data 
in the storage can be changed (indeterminately) with the object representations 
unchanged. This behaves like some fence for TBAA.

> we can now observe them and use them to validate e.g. the `llvm.tbaa.fence` 
> proposal.

Yeah. I guess we need to implement `std::start_lifetime_as(_array)` with 
`llvm.tbaa.fence`.

https://github.com/llvm/llvm-project/pull/82776
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] [Sema] Improve support for `__restrict`-qualified member functions (PR #83855)

2024-03-06 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

Reported 2 bugs for MSVC. (The first also affects standard cv-qualifiers.)
- 
https://developercommunity.visualstudio.com/t/cv-qualifiers-and-__restrict-in-the-temp/10609457
- 
https://developercommunity.visualstudio.com/t/__restrict-on-non-static-member-function/10609449

https://github.com/llvm/llvm-project/pull/83855
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Update value for __cpp_implicit_move (#84216) (PR #84228)

2024-03-06 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

[This page](https://clang.llvm.org/cxx_status.html) still refers to 
[P2266R1](https://wg21.link/p2266r1) but the approved revision is 
[P2266R3](https://wg21.link/p2266r3). Should we fix the citation in this PR or 
another?

https://github.com/llvm/llvm-project/pull/84228
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add __builtin_start_object_lifetime builtin. (PR #82776)

2024-02-23 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

> * with `-fstrict-vtable-pointers` flag, we update the vtpr assumption 
> correctly (mark the load/store vptr with appropriate invariant group 
> intrinsics) to prevent incorrect vptr load folding;

I _guess_ we want a variant of this intrinsic which doesn't affect analyzation 
for devirtualization. Such an intrinsic should be sufficient for **C++23** 
`std::start_lifetime_as(_array)`.

> * for now, it is non-constant, thus cannot be executed in constant evaluation;

It seems intended that `std::start_lifetime_as(_array)` is not usable in 
constant evaluation, as the indeterminism of implicit object creation doesn't 
seem compatible with constant evaluation.


https://github.com/llvm/llvm-project/pull/82776
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add __builtin_start_object_lifetime builtin. (PR #82776)

2024-02-25 Thread A. Jiang via cfe-commits


@@ -896,6 +896,12 @@ def Launder : Builtin {
   let Prototype = "void*(void*)";
 }
 
+def StartObjectLifeTime : Builtin {
+  let Spellings = ["__builtin_start_object_lifetime"];

frederick-vs-ja wrote:

IMO if the intent of this intrinsic is to handle polymorphic classes (which is 
not covered by `std::start_lifetime_as`), its name should diverge from "plain" 
`start_lifetime`.

https://github.com/llvm/llvm-project/pull/82776
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] [SemaCXX] Implement CWG2627 Bit-fields and narrowing conversions (PR #78112)

2024-01-14 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

> Should this be a SFINAE-able error before C++23? (It isn't currently)

I believe this should (in C++11 and later modes).

https://github.com/llvm/llvm-project/pull/78112
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] fix static operator()/[] call not evaluating object (PR #78356)

2024-01-16 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja commented:

It seems that more things are being done #68485. Have you double checked that 
PR?

https://github.com/llvm/llvm-project/pull/78356
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] fix static operator()/[] call not evaluating object (PR #78356)

2024-01-16 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/78356
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] fix static operator()/[] call not evaluating object (PR #78356)

2024-01-16 Thread A. Jiang via cfe-commits


@@ -598,3 +600,27 @@ namespace B {
 }
 void g(B::X x) { A::f(x); }
 }
+
+namespace static_operator {
+#if __cplusplus >= 201703L

frederick-vs-ja wrote:

Why C++17?

https://github.com/llvm/llvm-project/pull/78356
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Docs][Clang] Missing DR status for C++23-era papers in cxx_status.html (PR #68846)

2024-01-19 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

@Endilll Oh, I'm sorry for late replying. I wasn't wating for anybody and think 
this can be merged.

https://github.com/llvm/llvm-project/pull/68846
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] fix static operator()/[] call not evaluating object (PR #78356)

2024-01-19 Thread A. Jiang via cfe-commits


@@ -598,3 +600,27 @@ namespace B {
 }
 void g(B::X x) { A::f(x); }
 }
+
+namespace static_operator {
+#if __cplusplus >= 201703L

frederick-vs-ja wrote:

> No way to modify things in a C++11/14 constexpr function (`++x` is not a 
> constant expression), so no way to make a positive test that the expression 
> was evaluated. Though I guess I should have done `(non_constexpr_fn(), 
> X())()` and see if that failed.

Oh I see. It's inconvenient that runtime results can't be easily asserted in 
this test file.

I think the related changes of constexpr were made in C++14 
([N3652](https://wg21.link/n3652)).

https://github.com/llvm/llvm-project/pull/78356
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Docs][Clang] Missing DR status for C++23-era papers in cxx_status.html (PR #68846)

2023-10-25 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/68846

>From 07007c384ee57a20ad1dd1b0422c93152bb7f18e Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Tue, 17 Oct 2023 10:41:18 +0800
Subject: [PATCH] [Docs][Clang] DR status in cxx_status.html

---
 clang/www/cxx_status.html | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index e2cf9ab25465214..8e2869d3fdf8ac6 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -190,7 +190,7 @@ C++23 implementation status
 
 
   Allow duplicate attributes
-  https://wg21.link/P2156R1";>P2156R1
+  https://wg21.link/P2156R1";>P2156R1 (DR)
   Clang 13
 
 
@@ -210,7 +210,7 @@ C++23 implementation status
 
 
   C++ identifier syntax using UAX 31
-  https://wg21.link/P1949R7";>P1949R7
+  https://wg21.link/P1949R7";>P1949R7 (DR)
   Clang 14
 
 
@@ -230,11 +230,11 @@ C++23 implementation status
 
 
   Change scope of lambda trailing-return-type
-  https://wg21.link/P2036R3";>P2036R3
+  https://wg21.link/P2036R3";>P2036R3 (DR)
   Clang 17
 
 
-  https://wg21.link/P2579R0";>P2579R0
+  https://wg21.link/P2579R0";>P2579R0 (DR)
 
 
   Multidimensional subscript operator
@@ -303,12 +303,12 @@ C++23 implementation status
 
 
   The Equality Operator You Are Looking For
-  https://wg21.link/P2468R2";>P2468R2
+  https://wg21.link/P2468R2";>P2468R2 (DR)
   Clang 16
 
 
   De-deprecating volatile compound operations
-  https://wg21.link/P2327R1";>P2327R1
+  https://wg21.link/P2327R1";>P2327R1 (DR)
   Clang 15
 
 
@@ -380,7 +380,7 @@ C++23 implementation status
 
 
   char8_t Compatibility and Portability Fix
-  https://wg21.link/P2513R3";>P2513R3
+  https://wg21.link/P2513R3";>P2513R3 (DR)
   Clang 16
 
 
@@ -522,7 +522,7 @@ C++20 implementation status
 https://wg21.link/p2103r0";>P2103R0
   

-https://wg21.link/p2493r0";>P2493R0
+https://wg21.link/p2493r0";>P2493R0 (DR)
   
   
 https://wg21.link/p2092r0";>P2092R0

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


[clang-tools-extra] [libc++] Prevent calling the projection more than three times (PR #66315)

2023-09-24 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

It seems that we should remove this block because it turns out that 
`ranges::clamp` needs double moves under some circumstances.
https://github.com/llvm/llvm-project/blob/4c1c96e6fc0f704e9e032f87b2cd1e04bb4240dd/libcxx/test/std/algorithms/alg.sorting/alg.clamp/ranges.clamp.pass.cpp#L89-L110

https://github.com/llvm/llvm-project/pull/66315
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Docs][Clang] Missing DR status for C++23-era papers in cxx_status.html (PR #68846)

2023-10-11 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja created 
https://github.com/llvm/llvm-project/pull/68846

I'm unsure whether [P2460R2](https://wg21.link/p2460r2) should be listed in the 
page. The paper seemingly requires no changes.

### References
- [N4891](https://wg21.link/n4891)
  - [P1949R7](https://wg21.link/p1949r7) (C++ Identifier Syntax using Unicode 
Standard Annex 31)
- [N4898](https://wg21.link/n4898)
  - [P2036R3](https://wg21.link/p2036r3) (Change scope of lambda 
_trailing-return-type_)
- [N4916](https://wg21.link/n4916)
  - [P2468R2](https://wg21.link/p2468r2) (The Equality Operator You Are Looking 
For)
  - [P2327R1](https://wg21.link/p2327r1) (De-deprecating `volatile` compound 
operations)
  - [P2493R0](https://wg21.link/p2493r0) (Missing feature test macros for C++20 
core papers)
  - [P2513R3](https://wg21.link/p2513r3) (`char8_t` Compatibility and 
Portability Fix)
  - [P2460R2](https://wg21.link/p2460r2) (Relax requirements on `wchar_t` to 
match existing practices)
  - [P2579R0](https://wg21.link/p2579r0) (Mitigation strategies for 
[P2036](https://wg21.link/p2036) ”Changing scope for lambda 
_trailing-return-type_”)

### Unchanged
- [N4884](https://wg21.link/n4884) effectively specifies 
[P1787R6](https://wg21.link/p1787r6) (Declarations and where to find them) to 
be a DR, but it seems that we're tracking the DR(s) in [another 
page](https://clang.llvm.org/cxx_dr_status.html).
- [N4940](https://wg21.link/n4940) says [P2706R0](https://wg21.link/p2706r0) 
(Redundant specification for defaulted functions) is a DR, but it seems that 
the paper requires no changes.
- [P2647R1](https://wg21.link/p2647r1) (Permitting `static` `constexpr` 
variables in `constexpr` functions) was once specified to be a DR, but it 
turned out that the DR status was a mistake and then reverted 
([N4943](https://wg21.link/n4943)).

>From c8013dbdf6acdd0ca29ee871f9fef608c986916a Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Thu, 12 Oct 2023 11:29:08 +0800
Subject: [PATCH] [Docs][Clang] DR status in cxx_status.html

---
 clang/www/cxx_status.html | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index e2cf9ab25465214..5244c7f666ad363 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -210,7 +210,7 @@ C++23 implementation status
 
 
   C++ identifier syntax using UAX 31
-  https://wg21.link/P1949R7";>P1949R7
+  https://wg21.link/P1949R7";>P1949R7 (DR)
   Clang 14
 
 
@@ -230,11 +230,11 @@ C++23 implementation status
 
 
   Change scope of lambda trailing-return-type
-  https://wg21.link/P2036R3";>P2036R3
+  https://wg21.link/P2036R3";>P2036R3 (DR)
   Clang 17
 
 
-  https://wg21.link/P2579R0";>P2579R0
+  https://wg21.link/P2579R0";>P2579R0 (DR)
 
 
   Multidimensional subscript operator
@@ -303,12 +303,12 @@ C++23 implementation status
 
 
   The Equality Operator You Are Looking For
-  https://wg21.link/P2468R2";>P2468R2
+  https://wg21.link/P2468R2";>P2468R2 (DR)
   Clang 16
 
 
   De-deprecating volatile compound operations
-  https://wg21.link/P2327R1";>P2327R1
+  https://wg21.link/P2327R1";>P2327R1 (DR)
   Clang 15
 
 
@@ -380,7 +380,7 @@ C++23 implementation status
 
 
   char8_t Compatibility and Portability Fix
-  https://wg21.link/P2513R3";>P2513R3
+  https://wg21.link/P2513R3";>P2513R3 (DR)
   Clang 16
 
 
@@ -522,7 +522,7 @@ C++20 implementation status
 https://wg21.link/p2103r0";>P2103R0
   

-https://wg21.link/p2493r0";>P2493R0
+https://wg21.link/p2493r0";>P2493R0 (DR)
   
   
 https://wg21.link/p2092r0";>P2092R0

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


[clang] [Docs][Clang] Missing DR status for C++23-era papers in cxx_status.html (PR #68846)

2023-10-16 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/68846

>From 00dec85aabcbd2e93fa80aed7b21f7ce02aab589 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Tue, 17 Oct 2023 10:41:18 +0800
Subject: [PATCH] [Docs][Clang] DR status in cxx_status.html

---
 clang/www/cxx_status.html | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index e2cf9ab25465214..8e2869d3fdf8ac6 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -190,7 +190,7 @@ C++23 implementation status
 
 
   Allow duplicate attributes
-  https://wg21.link/P2156R1";>P2156R1
+  https://wg21.link/P2156R1";>P2156R1 (DR)
   Clang 13
 
 
@@ -210,7 +210,7 @@ C++23 implementation status
 
 
   C++ identifier syntax using UAX 31
-  https://wg21.link/P1949R7";>P1949R7
+  https://wg21.link/P1949R7";>P1949R7 (DR)
   Clang 14
 
 
@@ -230,11 +230,11 @@ C++23 implementation status
 
 
   Change scope of lambda trailing-return-type
-  https://wg21.link/P2036R3";>P2036R3
+  https://wg21.link/P2036R3";>P2036R3 (DR)
   Clang 17
 
 
-  https://wg21.link/P2579R0";>P2579R0
+  https://wg21.link/P2579R0";>P2579R0 (DR)
 
 
   Multidimensional subscript operator
@@ -303,12 +303,12 @@ C++23 implementation status
 
 
   The Equality Operator You Are Looking For
-  https://wg21.link/P2468R2";>P2468R2
+  https://wg21.link/P2468R2";>P2468R2 (DR)
   Clang 16
 
 
   De-deprecating volatile compound operations
-  https://wg21.link/P2327R1";>P2327R1
+  https://wg21.link/P2327R1";>P2327R1 (DR)
   Clang 15
 
 
@@ -380,7 +380,7 @@ C++23 implementation status
 
 
   char8_t Compatibility and Portability Fix
-  https://wg21.link/P2513R3";>P2513R3
+  https://wg21.link/P2513R3";>P2513R3 (DR)
   Clang 16
 
 
@@ -522,7 +522,7 @@ C++20 implementation status
 https://wg21.link/p2103r0";>P2103R0
   

-https://wg21.link/p2493r0";>P2493R0
+https://wg21.link/p2493r0";>P2493R0 (DR)
   
   
 https://wg21.link/p2092r0";>P2092R0

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


[clang] [Docs][Clang] Missing DR status for C++23-era papers in cxx_status.html (PR #68846)

2023-10-16 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

@Endilll Thanks for notification! P2280 was already handled, while P2156 was 
previously missed.
@cor3ntin I've add the DR status to P2156R1 and force-pushed.

https://github.com/llvm/llvm-project/pull/68846
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Docs][Clang] Missing DR status for C++23-era papers in cxx_status.html (PR #68846)

2023-10-16 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/68846
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Implement `__is_layout_compatible` (PR #81506)

2024-02-19 Thread A. Jiang via cfe-commits


@@ -1558,6 +1558,89 @@ void is_standard_layout()
   int t71[F(__is_standard_layout(HasEmptyIndirectBaseAsSecondUnionMember))];
 }
 
+struct CStruct2 {
+  int one;
+  int two;
+};
+
+struct CEmptyStruct2 {};
+
+struct CppEmptyStruct2 : CStruct2 {};
+struct CppStructStandard2 : CEmptyStruct2 {
+  int three;
+  int four;
+};
+struct CppStructNonStandardByBase2 : CStruct2 {
+  int three;
+  int four;
+};
+struct CppStructNonStandardByVirt2 : CStruct2 {
+  virtual void method() {}
+};
+struct CppStructNonStandardByMemb2 : CStruct2 {
+  CppStructNonStandardByVirt member;
+};
+struct CppStructNonStandardByProt2 : CStruct2 {
+  int five;
+protected:
+  int six;
+};
+struct CppStructNonStandardByVirtBase2 : virtual CStruct2 {
+};
+struct CppStructNonStandardBySameBase2 : CEmptyStruct2 {
+  CEmptyStruct member;
+};
+struct CppStructNonStandardBy2ndVirtBase2 : CEmptyStruct2 {
+  CEmptyStruct member;
+};
+
+struct CStructWithQualifiers {
+  const int one;
+  volatile int two;
+};
+
+struct CStructNoUniqueAddress {
+  int one;
+  [[no_unique_address]] int two;
+};
+
+struct CStructNoUniqueAddress2 {
+  int one;
+  [[no_unique_address]] int two;
+};
+
+struct CStructAlignment {
+  int one;
+  alignas(16) int two;
+};
+
+struct CStructIncomplete;
+
+void is_layout_compatible()
+{
+  static_assert(__is_layout_compatible(void, void), "");
+  static_assert(__is_layout_compatible(int, int), "");
+  static_assert(__is_layout_compatible(int[], int[]), "");
+  static_assert(__is_layout_compatible(int[2], int[2]), "");
+  static_assert(__is_layout_compatible(CStruct, CStruct2), "");
+  static_assert(__is_layout_compatible(CEmptyStruct, CEmptyStruct2), "");
+  static_assert(__is_layout_compatible(CppEmptyStruct, CppEmptyStruct2), "");
+  static_assert(__is_layout_compatible(CppStructStandard, CppStructStandard2), 
"");
+  static_assert(!__is_layout_compatible(CppStructNonStandardByBase, 
CppStructNonStandardByBase2), "");
+  static_assert(!__is_layout_compatible(CppStructNonStandardByVirt, 
CppStructNonStandardByVirt2), "");
+  static_assert(!__is_layout_compatible(CppStructNonStandardByMemb, 
CppStructNonStandardByMemb2), "");
+  static_assert(!__is_layout_compatible(CppStructNonStandardByProt, 
CppStructNonStandardByProt2), "");
+  static_assert(!__is_layout_compatible(CppStructNonStandardByVirtBase, 
CppStructNonStandardByVirtBase2), "");
+  static_assert(!__is_layout_compatible(CppStructNonStandardBySameBase, 
CppStructNonStandardBySameBase2), "");
+  static_assert(!__is_layout_compatible(CppStructNonStandardBy2ndVirtBase, 
CppStructNonStandardBy2ndVirtBase2), "");
+  static_assert(!__is_layout_compatible(CStruct, CStructWithQualifiers), ""); 
// FIXME: this is CWG1719
+  static_assert(__is_layout_compatible(CStruct, CStructNoUniqueAddress) == 
bool(__has_cpp_attribute(no_unique_address)), ""); // FIXME: this is CWG2759
+  static_assert(__is_layout_compatible(CStructNoUniqueAddress, 
CStructNoUniqueAddress2) == bool(__has_cpp_attribute(no_unique_address)), ""); 
// FIXME: this is CWG2759
+  static_assert(__is_layout_compatible(CStruct, CStructAlignment), "");
+  static_assert(__is_layout_compatible(CStructIncomplete, CStructIncomplete), 
"");
+  static_assert(!__is_layout_compatible(CStruct, CStructIncomplete), "");
+}

frederick-vs-ja wrote:

> * That an enumeration type and its underlying type are not layout compatible

This is possibly a defect 
(https://github.com/cplusplus/CWG/issues/39#issuecomment-1184791364, 
https://github.com/cplusplus/CWG/issues/95#issuecomment-1185260854), but no CWG 
issue is filed yet.

https://github.com/llvm/llvm-project/pull/81506
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C99] Claim conformance for _Complex support (PR #88161)

2024-04-09 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

> But fails on Windows.

This seems because of that MS UCRT's complex math functions are non-conforming.

I _guess_ they could work if we write the following before including UCRT's 
``.
```C
#define _C_COMPLEX_T
typedef double _Complex _C_double_complex;
typedef float _Complex _C_float_complex;
typedef long double _Complex _C_ldouble_complex;
```

https://github.com/llvm/llvm-project/pull/88161
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-06-05 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

IIUC this intrinsic is unrelated to assignment operators. Do you have any plan 
for `__is_bitwise_assignable`, which should determine whether the assignment 
operator equivalently copies the value representation, possibly modulo the 
vptrs?

```C++
struct Cat {}; // bitwise copy assignable
struct Leopard : Cat { // is_trivially_assignable_v returns true but not 
bitwise copy assignable
int spots_;
Leopard& operator=(Leopard&) = delete;
using Cat::operator=; // We can detect this by metaprogramming as operator= 
overloads have wrong types.
};
struct LeopardHouse { // is_trivially_assignable_v returns true but not bitwise 
copy assignable
Leopard _;
// Non-bitwise-assignability *can't* be detected by metaprogramming since 
operator= overloads have right types.
};
```

https://github.com/llvm/llvm-project/pull/86512
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

2024-06-13 Thread A. Jiang via cfe-commits


@@ -1961,7 +1961,8 @@ namespace ConstexprConstructorRecovery {
 
 namespace Lifetime {
   void f() {
-constexpr int &n = n; // expected-error {{constant expression}} 
expected-note {{use of reference outside its lifetime}} expected-warning {{not 
yet bound to a value}}
+constexpr int &n = n; // expected-error {{constant expression}} cxx23-note 
{{reference to 'n' is not a constant expression}} cxx23-note {{address of 
non-static constexpr variable 'n' may differ}} expected-warning {{not yet bound 
to a value}}
+  // cxx11_20-note@-1 {{use of reference outside its 
lifetime is not allowed in a constant expression}}

frederick-vs-ja wrote:

This looks strange. The old message looks better (see also 
[CWG453](https://cplusplus.github.io/CWG/issues/453.html)) and the new one is 
possibly misleading as we perhaps shoudn't say the address of a reference 
variable.

https://github.com/llvm/llvm-project/pull/95474
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

2024-06-13 Thread A. Jiang via cfe-commits


@@ -3300,6 +3308,11 @@ static bool HandleLValueComplexElement(EvalInfo &Info, 
const Expr *E,
 static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
 const VarDecl *VD, CallStackFrame *Frame,
 unsigned Version, APValue *&Result) {
+  // P2280R4 If we have a reference type and we are in C++23 allow unknown
+  // references and pointers.
+  bool AllowConstexprUnknown =
+  Info.getLangOpts().CPlusPlus23 && VD->getType()->isReferenceType();

frederick-vs-ja wrote:

This is a DR per [N4916](https://wg21.link/n4916) (ditto below).
```suggestion
  // P2280R4 allow unknown references and pointers.
  bool AllowConstexprUnknown = VD->getType()->isReferenceType();
```

https://github.com/llvm/llvm-project/pull/95474
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

2024-06-13 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/95474
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [Clang] Add __common_type builtin (PR #99473)

2024-07-25 Thread A. Jiang via cfe-commits


@@ -1511,6 +1511,43 @@ Attributes (N2335)   
 C2
 ``#embed`` (N3017)
C23   C89, C++
   
= =
 
+Builtin type aliases
+
+
+Clang provides a few builtin aliases to improve the throughput of certain 
metaprogramming facilities.
+
+__common_type
+-
+
+.. code-block:: c++
+  template  class BaseTemplate,
+template  class HasTypeMember,
+class HasNoTypeMember,
+class... Ts>
+  using __common_type = ...;
+
+This alias is used for implementing ``std::common_type``. If 
``std::common_type`` should contain a ``type`` member,
+it is an alias to ``HasTypeMember``. Otherwise it is an alias 
to ``HasNoTypeMember``. The
+``BaseTemplate`` is usually ``std::common_type``. ``Ts`` are the arguments to 
``std::common_type``.
+
+__type_pack_element
+---
+
+.. code-block:: c++
+  template 
+  using __type_pack_element = ...;
+
+This alias returns the type at ``Index`` in the parameter pack ``Ts``.
+
+__make_integer_seq
+--
+
+.. code-block:: c++
+  template  class IntSeq, class T, 
class N>

frederick-vs-ja wrote:

```suggestion
  template  class IntSeq, class T, T 
N>
```
Typo?

https://github.com/llvm/llvm-project/pull/99473
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin and frexp. (PR #88978)

2024-04-23 Thread A. Jiang via cfe-commits


@@ -2922,7 +2922,7 @@ static bool handleFloatFloatBinOp(EvalInfo &Info, const 
BinaryOperator *E,
   //   If during the evaluation of an expression, the result is not
   //   mathematically defined [...], the behavior is undefined.
   // FIXME: C++ rules require us to not conform to IEEE 754 here.
-  if (LHS.isNaN()) {
+  if (!Info.getLangOpts().CPlusPlus23 && LHS.isNaN()) {

frederick-vs-ja wrote:

There's an open CWG issue 
([CWG2168](https://cplusplus.github.io/CWG/issues/2168.html)) about this.

https://github.com/llvm/llvm-project/pull/88978
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-24 Thread A. Jiang via cfe-commits


@@ -8340,8 +8340,17 @@ void Sema::checkInitializerLifetime(const 
InitializedEntity &Entity,
 << Entity.getType()->isReferenceType() << CLE->getInitializer() << 
2
 << DiagRange;
   } else {
-Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
- << Entity.getType()->isReferenceType() << DiagRange;
+// P2748R5: Disallow Binding a Returned Glvalue to a Temporary.
+// [stmt.return]/p6: In a function whose return type is a reference,
+// other than an invented function for std::is_convertible 
([meta.rel]),
+// a return statement that binds the returned reference to a temporary
+// expression ([class.temporary]) is ill-formed.

frederick-vs-ja wrote:

> I wanted to implement LWG4028 as well

I don't know which part of LWG4028 is "not yet implemented". As the submitter, 
my intent was just to reflect what implementations actually did and to avoid 
crux in the core wording.

https://github.com/llvm/llvm-project/pull/89942
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-24 Thread A. Jiang via cfe-commits


@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++26 -fsyntax-only -verify %s
+
+auto&& f1() {
+  return 42; // expected-error{{returning reference to local temporary object}}
+}
+const double& f2() {
+  static int x = 42;
+  return x; // expected-error{{returning reference to local temporary object}}
+}
+auto&& id(auto&& r) {
+  return static_cast(r);
+}
+auto&& f3() {
+  return id(42);// OK, but probably a bug
+}
+
+static_assert(__is_convertible(int, const int &));
+static_assert(__is_nothrow_convertible(int, const int &));

frederick-vs-ja wrote:

I think these should go to `clang/test/SemaCXX/type-traits.cpp` (and be 
unconditionally tested). Note that test coverage for `__is_convertible` is 
already present.
https://github.com/llvm/llvm-project/blob/4b10ade1a6afa1fcff5752aaebd86a1611d499d7/clang/test/SemaCXX/type-traits.cpp#L2556-L2560

But test coverage for `__is_nothrow_convertible` where destination types are 
references seems missing. Perhaps we should add it in another PR.

https://github.com/llvm/llvm-project/pull/89942
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-24 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/89942
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-24 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/89942
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-25 Thread A. Jiang via cfe-commits


@@ -8340,8 +8340,17 @@ void Sema::checkInitializerLifetime(const 
InitializedEntity &Entity,
 << Entity.getType()->isReferenceType() << CLE->getInitializer() << 
2
 << DiagRange;
   } else {
-Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
- << Entity.getType()->isReferenceType() << DiagRange;
+// P2748R5: Disallow Binding a Returned Glvalue to a Temporary.
+// [stmt.return]/p6: In a function whose return type is a reference,
+// other than an invented function for std::is_convertible 
([meta.rel]),
+// a return statement that binds the returned reference to a temporary
+// expression ([class.temporary]) is ill-formed.

frederick-vs-ja wrote:

> should we makes `std::is_nothrow_convertible_v` evaluated as 
> `true`?

I don't see any proper motivation for doing so. Implementations consistently 
match the design in [P0758R1](https://wg21.link/p0758r1). It's the standard 
wording that failed to reflect the intent, which is perhaps a defect. 
(Additionally, the pasted sample implementation would exactly reflect the bug 
in the `noexcept` operator, if any.)

And IMO `std::is_nothrow_convertible(_v)` should be implementable without 
intrinsic (and the implementation strategy would be [quite 
simple](https://en.cppreference.com/w/cpp/types/is_convertible#Possible_implementation)).
 The `__is_nothrow_convertible` instrinsic should only be meaningful for 
acceleration of compilation.

https://github.com/llvm/llvm-project/pull/89942
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin and frexp. (PR #88978)

2024-04-29 Thread A. Jiang via cfe-commits


@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -DWIN -verify -std=c++23 -fsyntax-only  %s
+// RUN: %clang_cc1 -verify -std=c++23 -fsyntax-only  %s
+
+// expected-no-diagnostics
+
+
+#ifdef WIN
+#define INFINITY ((float)(1e+300 * 1e+300))
+#define NAN  (-(float)(INFINITY * 0.0F))
+#else
+#define NAN (__builtin_nanf(""))
+#define INFINITY (__builtin_inff())
+#endif
+
+extern "C" void abort() noexcept;
+extern "C" int write(int, const void*, unsigned long);
+
+#define assert(condition) \
+  do { \
+if (!(condition)) {\
+  write(2, "Assertion failed: ", 18);  \
+  write(2, #condition, sizeof(#condition) - 1);\
+  write(2, "\n", 1);   \
+  abort(); \
+}  \
+  } while (false)
+
+int main() {
+int i;
+
+// fmin
+static_assert(__builtin_fmin(15.24, 1.3) == 1.3, "");
+static_assert(__builtin_fmin(-0.0, +0.0) == -0.0, "");
+static_assert(__builtin_fmin(+0.0, -0.0) == -0.0, "");
+assert(__builtin_isnan(__builtin_fminf(NAN,NAN)));
+assert(__builtin_isnan(__builtin_fminf(NAN, -1)));
+assert(__builtin_isnan(__builtin_fminf(-INFINITY, 0)));
+assert(__builtin_iszero(__builtin_fminf(+INFINITY, 0)));
+
+// frexp
+static_assert(__builtin_frexp(123.45, &i) == 0.9644531250002);

frederick-vs-ja wrote:

It seems that we should write something like
```C++
struct { double num_; int expo_; } result;
result.num_ = frexp(x, &result.expo_);
return result;
```

https://github.com/llvm/llvm-project/pull/88978
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][C++20] Implement constexpr std::bit_cast for bit-fields (PR #74775)

2024-05-21 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

This PR should fix #54018.

https://github.com/llvm/llvm-project/pull/74775
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Nameof operator (PR #104777)

2024-08-19 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

BTW, the PR description perfectly ignored what will be got if the enum value 
matches no enumerator or more than one enumerators.

https://github.com/llvm/llvm-project/pull/104777
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Docs][Clang] Missing DR status for C++23-era papers in cxx_status.html (PR #68846)

2024-06-22 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/68846
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Docs][Clang] Missing DR status for C++23-era papers in cxx_status.html (PR #68846)

2024-06-22 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/68846

>From c38259bd70993a96a35ce4f94790e420847786e2 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Sun, 23 Jun 2024 01:39:42 +0800
Subject: [PATCH] [Docs][Clang] DR status for C++23-era papers in
 cxx_status.html
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

List the following C++23-era WG21 papers as Defect Reports in cxx_status.html 
as per WG21 meeting minutes.

- P1949R7 (C++ Identifier Syntax using Unicode Standard Annex 31)
- P2156R1 (Allow Duplicate Attributes)
- P2036R3 (Change scope of lambda trailing-return-type)
- P2468R2 (The Equality Operator You Are Looking For)
- P2327R1 (De-deprecating volatile compound operations)
- P2493R0 (Missing feature test macros for C++20 core papers)
- P2513R3 (char8_t Compatibility and Portability Fix)
- P2460R2 (Relax requirements on wchar_t to match existing practices)
- P2579R0 (Mitigation strategies for P2036 ”Changing scope for lambda 
trailing-return-type”)
---
 clang/www/cxx_status.html | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 65dd31a0fb802..3ae9f5cb65ba8 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -247,7 +247,7 @@ C++23 implementation status
 
 
   Allow duplicate attributes
-  https://wg21.link/P2156R1";>P2156R1
+  https://wg21.link/P2156R1";>P2156R1 (DR)
   Clang 13
 
 
@@ -267,7 +267,7 @@ C++23 implementation status
 
 
   C++ identifier syntax using UAX 31
-  https://wg21.link/P1949R7";>P1949R7
+  https://wg21.link/P1949R7";>P1949R7 (DR)
   Clang 14
 
 
@@ -287,11 +287,11 @@ C++23 implementation status
 
 
   Change scope of lambda trailing-return-type
-  https://wg21.link/P2036R3";>P2036R3
+  https://wg21.link/P2036R3";>P2036R3 (DR)
   Clang 17
 
 
-  https://wg21.link/P2579R0";>P2579R0
+  https://wg21.link/P2579R0";>P2579R0 (DR)
 
 
   Multidimensional subscript operator
@@ -352,12 +352,12 @@ C++23 implementation status
 
 
   The Equality Operator You Are Looking For
-  https://wg21.link/P2468R2";>P2468R2
+  https://wg21.link/P2468R2";>P2468R2 (DR)
   Clang 16
 
 
   De-deprecating volatile compound operations
-  https://wg21.link/P2327R1";>P2327R1
+  https://wg21.link/P2327R1";>P2327R1 (DR)
   Clang 15
 
 
@@ -422,12 +422,12 @@ C++23 implementation status
 
 
   char8_t Compatibility and Portability Fix
-  https://wg21.link/P2513R3";>P2513R3
+  https://wg21.link/P2513R3";>P2513R3 (DR)
   Clang 16
 
 
   Relax requirements on wchar_t to match existing 
practices
-  https://wg21.link/P2460R2";>P2460R2
+  https://wg21.link/P2460R2";>P2460R2 (DR)
   Yes
 
 
@@ -563,7 +563,7 @@ C++20 implementation status
 https://wg21.link/p2103r0";>P2103R0
   

-https://wg21.link/p2493r0";>P2493R0
+https://wg21.link/p2493r0";>P2493R0 (DR)
   
   
 https://wg21.link/p2092r0";>P2092R0

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


[clang] [Docs][Clang] Missing DR status for C++23-era papers in cxx_status.html (PR #68846)

2024-06-22 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

@Endilll I think it's ready now. Sorry for late replying again.

https://github.com/llvm/llvm-project/pull/68846
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [libc++][modules] Rewrite the modulemap to have fewer top-level modules (PR #110501)

2024-09-30 Thread A. Jiang via cfe-commits


@@ -1,2125 +1,2235 @@
-// Main C++ standard library interfaces
-module std_algorithm [system] {
-  header "algorithm"
-  export *
-}
-module std_any [system] {
-  header "any"
-  export *
-}
-module std_array [system] {
-  header "array"
-  export *
-}
-module std_atomic [system] {
-  header "atomic"
-  export *
-}
-module std_barrier [system] {
-  header "barrier"
-  export *
-}
-module std_bit [system] {
-  header "bit"
-  export *
-}
-module std_bitset [system] {
-  header "bitset"
-  export *
-}
-module std_charconv [system] {
-  header "charconv"
-  module chars_format{ header "__charconv/chars_format.h" }
-  module from_chars_integral { header "__charconv/from_chars_integral.h" }
-  module from_chars_result   { header "__charconv/from_chars_result.h" }
-  module tables  { header "__charconv/tables.h" }
-  module to_chars{ header "__charconv/to_chars.h" }
-  module to_chars_base_10{ header "__charconv/to_chars_base_10.h" }
-  module to_chars_floating_point { header 
"__charconv/to_chars_floating_point.h" }
-  module to_chars_integral   { header "__charconv/to_chars_integral.h" }
-  module to_chars_result { header "__charconv/to_chars_result.h" }
-  module traits  { header "__charconv/traits.h" }
-  export *
-}
-module std_chrono [system] {
-  header "chrono"
-  export *
-}
-module std_codecvt [system] {
-  header "codecvt"
-  export *
-}
-module std_compare [system] {
-  header "compare"
-  export *
-}
-module std_complex [system] {
-  header "complex"
-  export *
-}
-module std_concepts [system] {
-  header "concepts"
-  export *
-}
-module std_condition_variable [system] {
-  header "condition_variable"
-  module condition_variable { header 
"__condition_variable/condition_variable.h" }
-  export *
-}
-module std_coroutine [system] {
-  header "coroutine"
-  module coroutine_handle  { header "__coroutine/coroutine_handle.h" }
-  module coroutine_traits  { header "__coroutine/coroutine_traits.h" }
-  module noop_coroutine_handle { header "__coroutine/noop_coroutine_handle.h" }
-  module trivial_awaitables{ header "__coroutine/trivial_awaitables.h" }
-  export *
-}
-module std_deque [system] {
-  header "deque"
-  export *
-}
-module std_exception [system] {
-  header "exception"
-  export *
-}
-module std_execution [system] {
-  header "execution"
-  export *
-}
-module std_expected [system] {
-  header "expected"
-  export *
-}
-module std_filesystem [system] {
-  header "filesystem"
-  module copy_options { header "__filesystem/copy_options.h" }
-  module directory_entry  { header 
"__filesystem/directory_entry.h" }
-  module directory_iterator   { header 
"__filesystem/directory_iterator.h" }
-  module directory_options{ header 
"__filesystem/directory_options.h" }
-  module file_status  { header "__filesystem/file_status.h" }
-  module file_time_type   { header "__filesystem/file_time_type.h" 
}
-  module file_type{ header "__filesystem/file_type.h" }
-  module filesystem_error {
-header "__filesystem/filesystem_error.h"
-export std_private_memory_shared_ptr
-  }
-  module operations   { header "__filesystem/operations.h" }
-  module path {
-header "__filesystem/path.h"
-export std_string // returned by various methods
-  }
-  module path_iterator{ header "__filesystem/path_iterator.h" }
-  module perm_options { header "__filesystem/perm_options.h" }
-  module perms{ header "__filesystem/perms.h" }
-  module recursive_directory_iterator { header 
"__filesystem/recursive_directory_iterator.h" }
-  module space_info   { header "__filesystem/space_info.h" }
-  module u8path   { header "__filesystem/u8path.h" }
-  export *
-}
-module std_format [system] {
-  header "format"
-  export *
-}
-module std_forward_list [system] {
-  header "forward_list"
-  export *
-}
-module std_fstream [system] {
-  header "fstream"
-  export *
-}
-module std_functional [system] {
-  header "functional"
-  export *
-}
-module std_future [system] {
-  header "future"
-  export *
-}
-module std_initializer_list [system] {
-  header "initializer_list"
-  export *
-}
-module std_iomanip [system] {
-  header "iomanip"
-  export *
-}
-module std_ios [system] {
-  header "ios"
-  export *
-}
-module std_iosfwd [system] {
-  header "iosfwd"
-  export *
-}
-module std_iostream [system] {
-  header "iostream"
-  export *
-}
-module std_istream [system] {
-  header "istream"
-  export *
-}
-module std_iterator [system] {
-  header "iterator"
-  export *
-}
-module std_latch [system] {
-  header "latch"
-  export *
-}
-module std_limits [system] {
-  header "limits"
-  export *
-}
-module std_list [system] {
-  header "list"
-  export *
-}
-module std_locale [syste

[clang] [Clang] Fix constexpr-ness on implicitly deleted destructors (PR #116359)

2024-11-27 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/116359

>From c950170822a58ca98e3f50e95b160c83ec1c63f1 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Fri, 15 Nov 2024 21:49:23 +0800
Subject: [PATCH 1/5] [Clang] Fix constexpr-ness on implicitly deleted
 destructors

In C++20, a defaulted but implicitly deleted destructor is constexpr if
and only if the class has no virtual base class. This hasn't been
changed in C++23 by P2448R2.

Constexpr-ness on a deleted destructor affects almost nothing. The
`__is_literal` intrinsic is related, while the corresponding
`std::is_literal_type(_v)` utility has been removed in C++20.
A recently added example in `test/AST/ByteCode/cxx23.cpp` will become
valid, and the example is already accepted by GCC.

Clang currently behaves correctly in C++23 mode, because the
constexpr-ness on defaulted destructor is relaxed by P2448R2. But we
should make similar relaxation for an implicitly deleted destructor.
---
 .../clang/AST/CXXRecordDeclDefinitionBits.def |  3 +
 clang/include/clang/AST/DeclCXX.h |  7 ++
 clang/lib/AST/DeclCXX.cpp | 24 ---
 clang/test/AST/ByteCode/cxx23.cpp |  4 +-
 clang/test/SemaCXX/literal-type.cpp   | 68 +++
 5 files changed, 96 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def 
b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
index 6620840df0ced2..7f47fb0890f50e 100644
--- a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
+++ b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
@@ -81,6 +81,9 @@ FIELD(IsStandardLayout, 1, NO_MERGE)
 ///   member.
 FIELD(IsCXX11StandardLayout, 1, NO_MERGE)
 
+/// True when the class has a virtual base class.
+FIELD(HasVBases, 1, NO_MERGE)
+
 /// True when any base class has any declared non-static data
 /// members or bit-fields.
 /// This is a helper bit of state used to implement IsStandardLayout more
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 2693cc0e95b4b2..6aadb9794328ae 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -890,6 +890,13 @@ class CXXRecordDecl : public RecordDecl {
 needsOverloadResolutionForDestructor()) &&
"destructor should not be deleted");
 data().DefaultedDestructorIsDeleted = true;
+// C++23 [dcl.constexpr]p3.2:
+//  if the function is a constructor or destructor, its class does not have
+//  any virtual base classes.
+// C++20 [dcl.constexpr]p5:
+//   The definition of a constexpr destructor whose function-body is
+//   [not = delete] shall additionally satisfy...
+data().DefaultedDestructorIsConstexpr = !data().HasVBases;
   }
 
   /// Determine whether this class should get an implicit move
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 4394a0724b3c17..f094482eec6165 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -77,10 +77,11 @@ CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl 
*D)
 : UserDeclaredConstructor(false), UserDeclaredSpecialMembers(0),
   Aggregate(true), PlainOldData(true), Empty(true), Polymorphic(false),
   Abstract(false), IsStandardLayout(true), IsCXX11StandardLayout(true),
-  HasBasesWithFields(false), HasBasesWithNonStaticDataMembers(false),
-  HasPrivateFields(false), HasProtectedFields(false),
-  HasPublicFields(false), HasMutableFields(false), 
HasVariantMembers(false),
-  HasOnlyCMembers(true), HasInitMethod(false), 
HasInClassInitializer(false),
+  HasVBases(false), HasBasesWithFields(false),
+  HasBasesWithNonStaticDataMembers(false), HasPrivateFields(false),
+  HasProtectedFields(false), HasPublicFields(false),
+  HasMutableFields(false), HasVariantMembers(false), HasOnlyCMembers(true),
+  HasInitMethod(false), HasInClassInitializer(false),
   HasUninitializedReferenceMember(false), HasUninitializedFields(false),
   HasInheritedConstructor(false), HasInheritedDefaultConstructor(false),
   HasInheritedAssignment(false),
@@ -316,6 +317,8 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const 
*Bases,
 }
 
 if (Base->isVirtual()) {
+  data().HasVBases = true;
+
   // Add this base if it's not already in the list.
   if (SeenVBaseTypes.insert(C.getCanonicalType(BaseType)).second)
 VBases.push_back(Base);
@@ -547,9 +550,9 @@ void CXXRecordDecl::addedClassSubobject(CXXRecordDecl 
*Subobj) {
 data().NeedOverloadResolutionForDestructor = true;
   }
 
-  // C++2a [dcl.constexpr]p4:
-  //   The definition of a constexpr destructor [shall] satisfy the
-  //   following requirement:
+  // C++20 [dcl.constexpr]p5:
+  //  The definition of a constexpr destructor whose function-body is not
+  //  = delete [shall] additionally satisfy the following requirement:
   //   -- for every subobject of class type or (

[clang] [Clang] Fix constexpr-ness on implicitly deleted destructors (PR #116359)

2024-11-27 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja closed 
https://github.com/llvm/llvm-project/pull/116359
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix constexpr-ness on implicitly deleted destructors (PR #116359)

2024-11-20 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/116359

>From c950170822a58ca98e3f50e95b160c83ec1c63f1 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Fri, 15 Nov 2024 21:49:23 +0800
Subject: [PATCH 1/3] [Clang] Fix constexpr-ness on implicitly deleted
 destructors

In C++20, a defaulted but implicitly deleted destructor is constexpr if
and only if the class has no virtual base class. This hasn't been
changed in C++23 by P2448R2.

Constexpr-ness on a deleted destructor affects almost nothing. The
`__is_literal` intrinsic is related, while the corresponding
`std::is_literal_type(_v)` utility has been removed in C++20.
A recently added example in `test/AST/ByteCode/cxx23.cpp` will become
valid, and the example is already accepted by GCC.

Clang currently behaves correctly in C++23 mode, because the
constexpr-ness on defaulted destructor is relaxed by P2448R2. But we
should make similar relaxation for an implicitly deleted destructor.
---
 .../clang/AST/CXXRecordDeclDefinitionBits.def |  3 +
 clang/include/clang/AST/DeclCXX.h |  7 ++
 clang/lib/AST/DeclCXX.cpp | 24 ---
 clang/test/AST/ByteCode/cxx23.cpp |  4 +-
 clang/test/SemaCXX/literal-type.cpp   | 68 +++
 5 files changed, 96 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def 
b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
index 6620840df0ced2..7f47fb0890f50e 100644
--- a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
+++ b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
@@ -81,6 +81,9 @@ FIELD(IsStandardLayout, 1, NO_MERGE)
 ///   member.
 FIELD(IsCXX11StandardLayout, 1, NO_MERGE)
 
+/// True when the class has a virtual base class.
+FIELD(HasVBases, 1, NO_MERGE)
+
 /// True when any base class has any declared non-static data
 /// members or bit-fields.
 /// This is a helper bit of state used to implement IsStandardLayout more
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 2693cc0e95b4b2..6aadb9794328ae 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -890,6 +890,13 @@ class CXXRecordDecl : public RecordDecl {
 needsOverloadResolutionForDestructor()) &&
"destructor should not be deleted");
 data().DefaultedDestructorIsDeleted = true;
+// C++23 [dcl.constexpr]p3.2:
+//  if the function is a constructor or destructor, its class does not have
+//  any virtual base classes.
+// C++20 [dcl.constexpr]p5:
+//   The definition of a constexpr destructor whose function-body is
+//   [not = delete] shall additionally satisfy...
+data().DefaultedDestructorIsConstexpr = !data().HasVBases;
   }
 
   /// Determine whether this class should get an implicit move
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 4394a0724b3c17..f094482eec6165 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -77,10 +77,11 @@ CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl 
*D)
 : UserDeclaredConstructor(false), UserDeclaredSpecialMembers(0),
   Aggregate(true), PlainOldData(true), Empty(true), Polymorphic(false),
   Abstract(false), IsStandardLayout(true), IsCXX11StandardLayout(true),
-  HasBasesWithFields(false), HasBasesWithNonStaticDataMembers(false),
-  HasPrivateFields(false), HasProtectedFields(false),
-  HasPublicFields(false), HasMutableFields(false), 
HasVariantMembers(false),
-  HasOnlyCMembers(true), HasInitMethod(false), 
HasInClassInitializer(false),
+  HasVBases(false), HasBasesWithFields(false),
+  HasBasesWithNonStaticDataMembers(false), HasPrivateFields(false),
+  HasProtectedFields(false), HasPublicFields(false),
+  HasMutableFields(false), HasVariantMembers(false), HasOnlyCMembers(true),
+  HasInitMethod(false), HasInClassInitializer(false),
   HasUninitializedReferenceMember(false), HasUninitializedFields(false),
   HasInheritedConstructor(false), HasInheritedDefaultConstructor(false),
   HasInheritedAssignment(false),
@@ -316,6 +317,8 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const 
*Bases,
 }
 
 if (Base->isVirtual()) {
+  data().HasVBases = true;
+
   // Add this base if it's not already in the list.
   if (SeenVBaseTypes.insert(C.getCanonicalType(BaseType)).second)
 VBases.push_back(Base);
@@ -547,9 +550,9 @@ void CXXRecordDecl::addedClassSubobject(CXXRecordDecl 
*Subobj) {
 data().NeedOverloadResolutionForDestructor = true;
   }
 
-  // C++2a [dcl.constexpr]p4:
-  //   The definition of a constexpr destructor [shall] satisfy the
-  //   following requirement:
+  // C++20 [dcl.constexpr]p5:
+  //  The definition of a constexpr destructor whose function-body is not
+  //  = delete [shall] additionally satisfy the following requirement:
   //   -- for every subobject of class type or (

[clang] [Clang] Fix constexpr-ness on implicitly deleted destructors (PR #116359)

2024-11-20 Thread A. Jiang via cfe-commits


@@ -81,6 +81,9 @@ FIELD(IsStandardLayout, 1, NO_MERGE)
 ///   member.
 FIELD(IsCXX11StandardLayout, 1, NO_MERGE)
 
+/// True when the class has a virtual base class.
+FIELD(HasVBases, 1, NO_MERGE)

frederick-vs-ja wrote:

Thanks for pointing this out!

https://github.com/llvm/llvm-project/pull/116359
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix constexpr-ness on implicitly deleted destructors (PR #116359)

2024-11-20 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/116359

>From c950170822a58ca98e3f50e95b160c83ec1c63f1 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Fri, 15 Nov 2024 21:49:23 +0800
Subject: [PATCH 1/2] [Clang] Fix constexpr-ness on implicitly deleted
 destructors

In C++20, a defaulted but implicitly deleted destructor is constexpr if
and only if the class has no virtual base class. This hasn't been
changed in C++23 by P2448R2.

Constexpr-ness on a deleted destructor affects almost nothing. The
`__is_literal` intrinsic is related, while the corresponding
`std::is_literal_type(_v)` utility has been removed in C++20.
A recently added example in `test/AST/ByteCode/cxx23.cpp` will become
valid, and the example is already accepted by GCC.

Clang currently behaves correctly in C++23 mode, because the
constexpr-ness on defaulted destructor is relaxed by P2448R2. But we
should make similar relaxation for an implicitly deleted destructor.
---
 .../clang/AST/CXXRecordDeclDefinitionBits.def |  3 +
 clang/include/clang/AST/DeclCXX.h |  7 ++
 clang/lib/AST/DeclCXX.cpp | 24 ---
 clang/test/AST/ByteCode/cxx23.cpp |  4 +-
 clang/test/SemaCXX/literal-type.cpp   | 68 +++
 5 files changed, 96 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def 
b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
index 6620840df0ced2..7f47fb0890f50e 100644
--- a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
+++ b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
@@ -81,6 +81,9 @@ FIELD(IsStandardLayout, 1, NO_MERGE)
 ///   member.
 FIELD(IsCXX11StandardLayout, 1, NO_MERGE)
 
+/// True when the class has a virtual base class.
+FIELD(HasVBases, 1, NO_MERGE)
+
 /// True when any base class has any declared non-static data
 /// members or bit-fields.
 /// This is a helper bit of state used to implement IsStandardLayout more
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 2693cc0e95b4b2..6aadb9794328ae 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -890,6 +890,13 @@ class CXXRecordDecl : public RecordDecl {
 needsOverloadResolutionForDestructor()) &&
"destructor should not be deleted");
 data().DefaultedDestructorIsDeleted = true;
+// C++23 [dcl.constexpr]p3.2:
+//  if the function is a constructor or destructor, its class does not have
+//  any virtual base classes.
+// C++20 [dcl.constexpr]p5:
+//   The definition of a constexpr destructor whose function-body is
+//   [not = delete] shall additionally satisfy...
+data().DefaultedDestructorIsConstexpr = !data().HasVBases;
   }
 
   /// Determine whether this class should get an implicit move
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 4394a0724b3c17..f094482eec6165 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -77,10 +77,11 @@ CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl 
*D)
 : UserDeclaredConstructor(false), UserDeclaredSpecialMembers(0),
   Aggregate(true), PlainOldData(true), Empty(true), Polymorphic(false),
   Abstract(false), IsStandardLayout(true), IsCXX11StandardLayout(true),
-  HasBasesWithFields(false), HasBasesWithNonStaticDataMembers(false),
-  HasPrivateFields(false), HasProtectedFields(false),
-  HasPublicFields(false), HasMutableFields(false), 
HasVariantMembers(false),
-  HasOnlyCMembers(true), HasInitMethod(false), 
HasInClassInitializer(false),
+  HasVBases(false), HasBasesWithFields(false),
+  HasBasesWithNonStaticDataMembers(false), HasPrivateFields(false),
+  HasProtectedFields(false), HasPublicFields(false),
+  HasMutableFields(false), HasVariantMembers(false), HasOnlyCMembers(true),
+  HasInitMethod(false), HasInClassInitializer(false),
   HasUninitializedReferenceMember(false), HasUninitializedFields(false),
   HasInheritedConstructor(false), HasInheritedDefaultConstructor(false),
   HasInheritedAssignment(false),
@@ -316,6 +317,8 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const 
*Bases,
 }
 
 if (Base->isVirtual()) {
+  data().HasVBases = true;
+
   // Add this base if it's not already in the list.
   if (SeenVBaseTypes.insert(C.getCanonicalType(BaseType)).second)
 VBases.push_back(Base);
@@ -547,9 +550,9 @@ void CXXRecordDecl::addedClassSubobject(CXXRecordDecl 
*Subobj) {
 data().NeedOverloadResolutionForDestructor = true;
   }
 
-  // C++2a [dcl.constexpr]p4:
-  //   The definition of a constexpr destructor [shall] satisfy the
-  //   following requirement:
+  // C++20 [dcl.constexpr]p5:
+  //  The definition of a constexpr destructor whose function-body is not
+  //  = delete [shall] additionally satisfy the following requirement:
   //   -- for every subobject of class type or (

[clang] [Clang] Fix constexpr-ness on implicitly deleted destructors (PR #116359)

2024-11-15 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja created 
https://github.com/llvm/llvm-project/pull/116359

In C++20, a defaulted but implicitly deleted destructor is constexpr if and 
only if the class has no virtual base class. This hasn't been changed in C++23 
by P2448R2.

Constexpr-ness on a deleted destructor affects almost nothing. It seems that 
only the `__is_literal` intrinsic is related, while the corresponding 
`std::is_literal_type(_v)` has been removed in C++20.

Clang currently behaves correctly in C++23 mode, because the constexpr-ness on 
defaulted destructor is relaxed by P2448R2. But we should make similar 
relaxation for an implicitly deleted destructor.

Fixes #85550.

>From 8a3cb70e3bc4bbb3a8862a1dbf22322b4b7decc2 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Fri, 15 Nov 2024 17:06:08 +0800
Subject: [PATCH] [Clang] Fix constexpr-ness on implicitly deleted destructors

In C++20, a defaulted but implicitly deleted destructor is constexpr if
and only if the class has no virtual base class. This hasn't been
changed in C++23 by P2448R2.

Constexpr-ness on a deleted destructor affects almost nothing. It seems
that only the `__is_literal` intrinsic is related, while the
corresponding `std::is_literal_type(_v)` has been removed in C++20.

Clang currently behaves correctly in C++23 mode, because the
constexpr-ness on defaulted destructor is relaxed by P2448R2. But we
should make similar relaxation for an implicitly deleted destructor.
---
 .../clang/AST/CXXRecordDeclDefinitionBits.def |  3 ++
 clang/include/clang/AST/DeclCXX.h |  7 +++
 clang/lib/AST/DeclCXX.cpp | 24 ++---
 clang/test/SemaCXX/literal-type.cpp   | 53 +++
 4 files changed, 79 insertions(+), 8 deletions(-)

diff --git a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def 
b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
index 6620840df0ced2..7f47fb0890f50e 100644
--- a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
+++ b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
@@ -81,6 +81,9 @@ FIELD(IsStandardLayout, 1, NO_MERGE)
 ///   member.
 FIELD(IsCXX11StandardLayout, 1, NO_MERGE)
 
+/// True when the class has a virtual base class.
+FIELD(HasVBases, 1, NO_MERGE)
+
 /// True when any base class has any declared non-static data
 /// members or bit-fields.
 /// This is a helper bit of state used to implement IsStandardLayout more
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 2693cc0e95b4b2..6aadb9794328ae 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -890,6 +890,13 @@ class CXXRecordDecl : public RecordDecl {
 needsOverloadResolutionForDestructor()) &&
"destructor should not be deleted");
 data().DefaultedDestructorIsDeleted = true;
+// C++23 [dcl.constexpr]p3.2:
+//  if the function is a constructor or destructor, its class does not have
+//  any virtual base classes.
+// C++20 [dcl.constexpr]p5:
+//   The definition of a constexpr destructor whose function-body is
+//   [not = delete] shall additionally satisfy...
+data().DefaultedDestructorIsConstexpr = !data().HasVBases;
   }
 
   /// Determine whether this class should get an implicit move
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 4394a0724b3c17..f094482eec6165 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -77,10 +77,11 @@ CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl 
*D)
 : UserDeclaredConstructor(false), UserDeclaredSpecialMembers(0),
   Aggregate(true), PlainOldData(true), Empty(true), Polymorphic(false),
   Abstract(false), IsStandardLayout(true), IsCXX11StandardLayout(true),
-  HasBasesWithFields(false), HasBasesWithNonStaticDataMembers(false),
-  HasPrivateFields(false), HasProtectedFields(false),
-  HasPublicFields(false), HasMutableFields(false), 
HasVariantMembers(false),
-  HasOnlyCMembers(true), HasInitMethod(false), 
HasInClassInitializer(false),
+  HasVBases(false), HasBasesWithFields(false),
+  HasBasesWithNonStaticDataMembers(false), HasPrivateFields(false),
+  HasProtectedFields(false), HasPublicFields(false),
+  HasMutableFields(false), HasVariantMembers(false), HasOnlyCMembers(true),
+  HasInitMethod(false), HasInClassInitializer(false),
   HasUninitializedReferenceMember(false), HasUninitializedFields(false),
   HasInheritedConstructor(false), HasInheritedDefaultConstructor(false),
   HasInheritedAssignment(false),
@@ -316,6 +317,8 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const 
*Bases,
 }
 
 if (Base->isVirtual()) {
+  data().HasVBases = true;
+
   // Add this base if it's not already in the list.
   if (SeenVBaseTypes.insert(C.getCanonicalType(BaseType)).second)
 VBases.push_back(Base);
@@ -547,9 +550,9 @@ void CXXRecordDecl::addedClassSubobject(CXXRecordDecl 
*Subobj)

[clang] [Clang] Fix constexpr-ness on implicitly deleted destructors (PR #116359)

2024-11-15 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/116359

>From c950170822a58ca98e3f50e95b160c83ec1c63f1 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Fri, 15 Nov 2024 21:49:23 +0800
Subject: [PATCH] [Clang] Fix constexpr-ness on implicitly deleted destructors

In C++20, a defaulted but implicitly deleted destructor is constexpr if
and only if the class has no virtual base class. This hasn't been
changed in C++23 by P2448R2.

Constexpr-ness on a deleted destructor affects almost nothing. The
`__is_literal` intrinsic is related, while the corresponding
`std::is_literal_type(_v)` utility has been removed in C++20.
A recently added example in `test/AST/ByteCode/cxx23.cpp` will become
valid, and the example is already accepted by GCC.

Clang currently behaves correctly in C++23 mode, because the
constexpr-ness on defaulted destructor is relaxed by P2448R2. But we
should make similar relaxation for an implicitly deleted destructor.
---
 .../clang/AST/CXXRecordDeclDefinitionBits.def |  3 +
 clang/include/clang/AST/DeclCXX.h |  7 ++
 clang/lib/AST/DeclCXX.cpp | 24 ---
 clang/test/AST/ByteCode/cxx23.cpp |  4 +-
 clang/test/SemaCXX/literal-type.cpp   | 68 +++
 5 files changed, 96 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def 
b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
index 6620840df0ced2..7f47fb0890f50e 100644
--- a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
+++ b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
@@ -81,6 +81,9 @@ FIELD(IsStandardLayout, 1, NO_MERGE)
 ///   member.
 FIELD(IsCXX11StandardLayout, 1, NO_MERGE)
 
+/// True when the class has a virtual base class.
+FIELD(HasVBases, 1, NO_MERGE)
+
 /// True when any base class has any declared non-static data
 /// members or bit-fields.
 /// This is a helper bit of state used to implement IsStandardLayout more
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 2693cc0e95b4b2..6aadb9794328ae 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -890,6 +890,13 @@ class CXXRecordDecl : public RecordDecl {
 needsOverloadResolutionForDestructor()) &&
"destructor should not be deleted");
 data().DefaultedDestructorIsDeleted = true;
+// C++23 [dcl.constexpr]p3.2:
+//  if the function is a constructor or destructor, its class does not have
+//  any virtual base classes.
+// C++20 [dcl.constexpr]p5:
+//   The definition of a constexpr destructor whose function-body is
+//   [not = delete] shall additionally satisfy...
+data().DefaultedDestructorIsConstexpr = !data().HasVBases;
   }
 
   /// Determine whether this class should get an implicit move
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 4394a0724b3c17..f094482eec6165 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -77,10 +77,11 @@ CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl 
*D)
 : UserDeclaredConstructor(false), UserDeclaredSpecialMembers(0),
   Aggregate(true), PlainOldData(true), Empty(true), Polymorphic(false),
   Abstract(false), IsStandardLayout(true), IsCXX11StandardLayout(true),
-  HasBasesWithFields(false), HasBasesWithNonStaticDataMembers(false),
-  HasPrivateFields(false), HasProtectedFields(false),
-  HasPublicFields(false), HasMutableFields(false), 
HasVariantMembers(false),
-  HasOnlyCMembers(true), HasInitMethod(false), 
HasInClassInitializer(false),
+  HasVBases(false), HasBasesWithFields(false),
+  HasBasesWithNonStaticDataMembers(false), HasPrivateFields(false),
+  HasProtectedFields(false), HasPublicFields(false),
+  HasMutableFields(false), HasVariantMembers(false), HasOnlyCMembers(true),
+  HasInitMethod(false), HasInClassInitializer(false),
   HasUninitializedReferenceMember(false), HasUninitializedFields(false),
   HasInheritedConstructor(false), HasInheritedDefaultConstructor(false),
   HasInheritedAssignment(false),
@@ -316,6 +317,8 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const 
*Bases,
 }
 
 if (Base->isVirtual()) {
+  data().HasVBases = true;
+
   // Add this base if it's not already in the list.
   if (SeenVBaseTypes.insert(C.getCanonicalType(BaseType)).second)
 VBases.push_back(Base);
@@ -547,9 +550,9 @@ void CXXRecordDecl::addedClassSubobject(CXXRecordDecl 
*Subobj) {
 data().NeedOverloadResolutionForDestructor = true;
   }
 
-  // C++2a [dcl.constexpr]p4:
-  //   The definition of a constexpr destructor [shall] satisfy the
-  //   following requirement:
+  // C++20 [dcl.constexpr]p5:
+  //  The definition of a constexpr destructor whose function-body is not
+  //  = delete [shall] additionally satisfy the following requirement:
   //   -- for every subobject of class type or (possi

[clang] [Clang] Fix constexpr-ness on implicitly deleted destructors (PR #116359)

2024-11-15 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/116359
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix constexpr-ness on implicitly deleted destructors (PR #116359)

2024-11-15 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/116359

>From b93d63fff0b5a3b7e77c2ecfffe69830c0802e76 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Fri, 15 Nov 2024 18:20:26 +0800
Subject: [PATCH] [Clang] Fix constexpr-ness on implicitly deleted destructors

In C++20, a defaulted but implicitly deleted destructor is constexpr if
and only if the class has no virtual base class. This hasn't been
changed in C++23 by P2448R2.

Constexpr-ness on a deleted destructor affects almost nothing. It seems
that only the `__is_literal` intrinsic is related, while the
corresponding `std::is_literal_type(_v)` has been removed in C++20.

Clang currently behaves correctly in C++23 mode, because the
constexpr-ness on defaulted destructor is relaxed by P2448R2. But we
should make similar relaxation for an implicitly deleted destructor.
---
 .../clang/AST/CXXRecordDeclDefinitionBits.def |  3 +
 clang/include/clang/AST/DeclCXX.h |  7 +++
 clang/lib/AST/DeclCXX.cpp | 24 +---
 clang/test/AST/ByteCode/cxx23.cpp |  4 +-
 clang/test/SemaCXX/literal-type.cpp   | 59 +++
 5 files changed, 87 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def 
b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
index 6620840df0ced2..7f47fb0890f50e 100644
--- a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
+++ b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
@@ -81,6 +81,9 @@ FIELD(IsStandardLayout, 1, NO_MERGE)
 ///   member.
 FIELD(IsCXX11StandardLayout, 1, NO_MERGE)
 
+/// True when the class has a virtual base class.
+FIELD(HasVBases, 1, NO_MERGE)
+
 /// True when any base class has any declared non-static data
 /// members or bit-fields.
 /// This is a helper bit of state used to implement IsStandardLayout more
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 2693cc0e95b4b2..6aadb9794328ae 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -890,6 +890,13 @@ class CXXRecordDecl : public RecordDecl {
 needsOverloadResolutionForDestructor()) &&
"destructor should not be deleted");
 data().DefaultedDestructorIsDeleted = true;
+// C++23 [dcl.constexpr]p3.2:
+//  if the function is a constructor or destructor, its class does not have
+//  any virtual base classes.
+// C++20 [dcl.constexpr]p5:
+//   The definition of a constexpr destructor whose function-body is
+//   [not = delete] shall additionally satisfy...
+data().DefaultedDestructorIsConstexpr = !data().HasVBases;
   }
 
   /// Determine whether this class should get an implicit move
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 4394a0724b3c17..f094482eec6165 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -77,10 +77,11 @@ CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl 
*D)
 : UserDeclaredConstructor(false), UserDeclaredSpecialMembers(0),
   Aggregate(true), PlainOldData(true), Empty(true), Polymorphic(false),
   Abstract(false), IsStandardLayout(true), IsCXX11StandardLayout(true),
-  HasBasesWithFields(false), HasBasesWithNonStaticDataMembers(false),
-  HasPrivateFields(false), HasProtectedFields(false),
-  HasPublicFields(false), HasMutableFields(false), 
HasVariantMembers(false),
-  HasOnlyCMembers(true), HasInitMethod(false), 
HasInClassInitializer(false),
+  HasVBases(false), HasBasesWithFields(false),
+  HasBasesWithNonStaticDataMembers(false), HasPrivateFields(false),
+  HasProtectedFields(false), HasPublicFields(false),
+  HasMutableFields(false), HasVariantMembers(false), HasOnlyCMembers(true),
+  HasInitMethod(false), HasInClassInitializer(false),
   HasUninitializedReferenceMember(false), HasUninitializedFields(false),
   HasInheritedConstructor(false), HasInheritedDefaultConstructor(false),
   HasInheritedAssignment(false),
@@ -316,6 +317,8 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const 
*Bases,
 }
 
 if (Base->isVirtual()) {
+  data().HasVBases = true;
+
   // Add this base if it's not already in the list.
   if (SeenVBaseTypes.insert(C.getCanonicalType(BaseType)).second)
 VBases.push_back(Base);
@@ -547,9 +550,9 @@ void CXXRecordDecl::addedClassSubobject(CXXRecordDecl 
*Subobj) {
 data().NeedOverloadResolutionForDestructor = true;
   }
 
-  // C++2a [dcl.constexpr]p4:
-  //   The definition of a constexpr destructor [shall] satisfy the
-  //   following requirement:
+  // C++20 [dcl.constexpr]p5:
+  //  The definition of a constexpr destructor whose function-body is not
+  //  = delete [shall] additionally satisfy the following requirement:
   //   -- for every subobject of class type or (possibly multi-dimensional)
   //  array thereof, that class type shall have a constexpr destructor
   if (!S

[clang] [Clang] Fix constexpr-ness on implicitly deleted destructors (PR #116359)

2024-11-15 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/116359

>From f39b5a01c0c98ff9270a1c47c1c3915688d8b359 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Fri, 15 Nov 2024 19:35:11 +0800
Subject: [PATCH] [Clang] Fix constexpr-ness on implicitly deleted destructors

In C++20, a defaulted but implicitly deleted destructor is constexpr if
and only if the class has no virtual base class. This hasn't been
changed in C++23 by P2448R2.

Constexpr-ness on a deleted destructor affects almost nothing. It seems
that only the `__is_literal` intrinsic is related, while the
corresponding `std::is_literal_type(_v)` has been removed in C++20.

Clang currently behaves correctly in C++23 mode, because the
constexpr-ness on defaulted destructor is relaxed by P2448R2. But we
should make similar relaxation for an implicitly deleted destructor.
---
 .../clang/AST/CXXRecordDeclDefinitionBits.def |  3 +
 clang/include/clang/AST/DeclCXX.h |  7 +++
 clang/lib/AST/DeclCXX.cpp | 24 ---
 clang/test/AST/ByteCode/cxx23.cpp |  4 +-
 clang/test/SemaCXX/literal-type.cpp   | 63 +++
 5 files changed, 91 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def 
b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
index 6620840df0ced2..7f47fb0890f50e 100644
--- a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
+++ b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
@@ -81,6 +81,9 @@ FIELD(IsStandardLayout, 1, NO_MERGE)
 ///   member.
 FIELD(IsCXX11StandardLayout, 1, NO_MERGE)
 
+/// True when the class has a virtual base class.
+FIELD(HasVBases, 1, NO_MERGE)
+
 /// True when any base class has any declared non-static data
 /// members or bit-fields.
 /// This is a helper bit of state used to implement IsStandardLayout more
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 2693cc0e95b4b2..6aadb9794328ae 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -890,6 +890,13 @@ class CXXRecordDecl : public RecordDecl {
 needsOverloadResolutionForDestructor()) &&
"destructor should not be deleted");
 data().DefaultedDestructorIsDeleted = true;
+// C++23 [dcl.constexpr]p3.2:
+//  if the function is a constructor or destructor, its class does not have
+//  any virtual base classes.
+// C++20 [dcl.constexpr]p5:
+//   The definition of a constexpr destructor whose function-body is
+//   [not = delete] shall additionally satisfy...
+data().DefaultedDestructorIsConstexpr = !data().HasVBases;
   }
 
   /// Determine whether this class should get an implicit move
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 4394a0724b3c17..f094482eec6165 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -77,10 +77,11 @@ CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl 
*D)
 : UserDeclaredConstructor(false), UserDeclaredSpecialMembers(0),
   Aggregate(true), PlainOldData(true), Empty(true), Polymorphic(false),
   Abstract(false), IsStandardLayout(true), IsCXX11StandardLayout(true),
-  HasBasesWithFields(false), HasBasesWithNonStaticDataMembers(false),
-  HasPrivateFields(false), HasProtectedFields(false),
-  HasPublicFields(false), HasMutableFields(false), 
HasVariantMembers(false),
-  HasOnlyCMembers(true), HasInitMethod(false), 
HasInClassInitializer(false),
+  HasVBases(false), HasBasesWithFields(false),
+  HasBasesWithNonStaticDataMembers(false), HasPrivateFields(false),
+  HasProtectedFields(false), HasPublicFields(false),
+  HasMutableFields(false), HasVariantMembers(false), HasOnlyCMembers(true),
+  HasInitMethod(false), HasInClassInitializer(false),
   HasUninitializedReferenceMember(false), HasUninitializedFields(false),
   HasInheritedConstructor(false), HasInheritedDefaultConstructor(false),
   HasInheritedAssignment(false),
@@ -316,6 +317,8 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const 
*Bases,
 }
 
 if (Base->isVirtual()) {
+  data().HasVBases = true;
+
   // Add this base if it's not already in the list.
   if (SeenVBaseTypes.insert(C.getCanonicalType(BaseType)).second)
 VBases.push_back(Base);
@@ -547,9 +550,9 @@ void CXXRecordDecl::addedClassSubobject(CXXRecordDecl 
*Subobj) {
 data().NeedOverloadResolutionForDestructor = true;
   }
 
-  // C++2a [dcl.constexpr]p4:
-  //   The definition of a constexpr destructor [shall] satisfy the
-  //   following requirement:
+  // C++20 [dcl.constexpr]p5:
+  //  The definition of a constexpr destructor whose function-body is not
+  //  = delete [shall] additionally satisfy the following requirement:
   //   -- for every subobject of class type or (possibly multi-dimensional)
   //  array thereof, that class type shall have a constexpr destructor
   if (!Su

[clang] [Clang] Fix constexpr-ness on implicitly deleted destructors (PR #116359)

2024-11-27 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/116359

>From c950170822a58ca98e3f50e95b160c83ec1c63f1 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Fri, 15 Nov 2024 21:49:23 +0800
Subject: [PATCH 1/3] [Clang] Fix constexpr-ness on implicitly deleted
 destructors

In C++20, a defaulted but implicitly deleted destructor is constexpr if
and only if the class has no virtual base class. This hasn't been
changed in C++23 by P2448R2.

Constexpr-ness on a deleted destructor affects almost nothing. The
`__is_literal` intrinsic is related, while the corresponding
`std::is_literal_type(_v)` utility has been removed in C++20.
A recently added example in `test/AST/ByteCode/cxx23.cpp` will become
valid, and the example is already accepted by GCC.

Clang currently behaves correctly in C++23 mode, because the
constexpr-ness on defaulted destructor is relaxed by P2448R2. But we
should make similar relaxation for an implicitly deleted destructor.
---
 .../clang/AST/CXXRecordDeclDefinitionBits.def |  3 +
 clang/include/clang/AST/DeclCXX.h |  7 ++
 clang/lib/AST/DeclCXX.cpp | 24 ---
 clang/test/AST/ByteCode/cxx23.cpp |  4 +-
 clang/test/SemaCXX/literal-type.cpp   | 68 +++
 5 files changed, 96 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def 
b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
index 6620840df0ced2..7f47fb0890f50e 100644
--- a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
+++ b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
@@ -81,6 +81,9 @@ FIELD(IsStandardLayout, 1, NO_MERGE)
 ///   member.
 FIELD(IsCXX11StandardLayout, 1, NO_MERGE)
 
+/// True when the class has a virtual base class.
+FIELD(HasVBases, 1, NO_MERGE)
+
 /// True when any base class has any declared non-static data
 /// members or bit-fields.
 /// This is a helper bit of state used to implement IsStandardLayout more
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 2693cc0e95b4b2..6aadb9794328ae 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -890,6 +890,13 @@ class CXXRecordDecl : public RecordDecl {
 needsOverloadResolutionForDestructor()) &&
"destructor should not be deleted");
 data().DefaultedDestructorIsDeleted = true;
+// C++23 [dcl.constexpr]p3.2:
+//  if the function is a constructor or destructor, its class does not have
+//  any virtual base classes.
+// C++20 [dcl.constexpr]p5:
+//   The definition of a constexpr destructor whose function-body is
+//   [not = delete] shall additionally satisfy...
+data().DefaultedDestructorIsConstexpr = !data().HasVBases;
   }
 
   /// Determine whether this class should get an implicit move
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 4394a0724b3c17..f094482eec6165 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -77,10 +77,11 @@ CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl 
*D)
 : UserDeclaredConstructor(false), UserDeclaredSpecialMembers(0),
   Aggregate(true), PlainOldData(true), Empty(true), Polymorphic(false),
   Abstract(false), IsStandardLayout(true), IsCXX11StandardLayout(true),
-  HasBasesWithFields(false), HasBasesWithNonStaticDataMembers(false),
-  HasPrivateFields(false), HasProtectedFields(false),
-  HasPublicFields(false), HasMutableFields(false), 
HasVariantMembers(false),
-  HasOnlyCMembers(true), HasInitMethod(false), 
HasInClassInitializer(false),
+  HasVBases(false), HasBasesWithFields(false),
+  HasBasesWithNonStaticDataMembers(false), HasPrivateFields(false),
+  HasProtectedFields(false), HasPublicFields(false),
+  HasMutableFields(false), HasVariantMembers(false), HasOnlyCMembers(true),
+  HasInitMethod(false), HasInClassInitializer(false),
   HasUninitializedReferenceMember(false), HasUninitializedFields(false),
   HasInheritedConstructor(false), HasInheritedDefaultConstructor(false),
   HasInheritedAssignment(false),
@@ -316,6 +317,8 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const 
*Bases,
 }
 
 if (Base->isVirtual()) {
+  data().HasVBases = true;
+
   // Add this base if it's not already in the list.
   if (SeenVBaseTypes.insert(C.getCanonicalType(BaseType)).second)
 VBases.push_back(Base);
@@ -547,9 +550,9 @@ void CXXRecordDecl::addedClassSubobject(CXXRecordDecl 
*Subobj) {
 data().NeedOverloadResolutionForDestructor = true;
   }
 
-  // C++2a [dcl.constexpr]p4:
-  //   The definition of a constexpr destructor [shall] satisfy the
-  //   following requirement:
+  // C++20 [dcl.constexpr]p5:
+  //  The definition of a constexpr destructor whose function-body is not
+  //  = delete [shall] additionally satisfy the following requirement:
   //   -- for every subobject of class type or (

[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2025-01-06 Thread A. Jiang via cfe-commits


@@ -0,0 +1,623 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__ranges/zip_view.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+template 
+struct __extract_last : __extract_last<_Tail...> {};

frederick-vs-ja wrote:

We can use conditional compilation like this:

```C++
#ifdef __cpp_pack_indexing
template 
using __extract_last = _Tp...[sizeof...(_Tp) - 1];
#else
template 
struct __extract_last_impl : __extract_last<_Tail...> {};
template 
struct __extract_last_impl<_Tp> {
  using type = _Tp;
};

template 
using __extract_last = __extract_last_impl<_Tp...>::type;
#endif
```

But I'm not sure whether this is wanted.

https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement CWG2351 `void{}` (PR #78060)

2024-12-30 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/78060
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2024-12-24 Thread A. Jiang via cfe-commits


@@ -0,0 +1,623 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/constructible.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+template 
+struct extract_last : extract_last {};
+
+template 
+struct extract_last {
+  using type = T;
+};

frederick-vs-ja wrote:

Please use __ugly names for non-standard internal names (except for member 
`type`/`value`). Ditto below.
```suggestion
template 
struct __extract_last : __extract_last <_Tail...> {};

template 
struct __extract_last<_Tp> {
  using type = _Tp;
};
```

https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2024-12-24 Thread A. Jiang via cfe-commits


@@ -0,0 +1,623 @@
+// -*- C++ -*-

frederick-vs-ja wrote:

Do we need to add anything to `__cxx03` subdirectory for implementing a C++26 
feature?

https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2024-12-30 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2024-12-30 Thread A. Jiang via cfe-commits


@@ -0,0 +1,626 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+template 
+struct __extract_last : __extract_last<_Tp...> {};
+
+template 
+struct __extract_last<_T> {
+  using type = _T;
+};
+
+template 
+struct __derived_from_pack {
+  constexpr static bool value =
+  __derived_from_pack<_T, typename __extract_last<_Tp...>::type>::value && 
__derived_from_pack<_Tp...>::value;
+};
+
+template 
+struct __derived_from_pack<_T, _IterCategory> {
+  constexpr static bool value = derived_from<_T, _IterCategory>;
+};
+
+template 
+struct __last_view : __last_view<_Views...> {};
+
+template 
+struct __last_view<_View> {
+  using type = _View;
+};
+
+template 
+concept __concat_indirectly_readable_impl = requires(const _It it) {
+  { *it } -> convertible_to<_Ref>;
+  { ranges::iter_move(it) } -> convertible_to<_RRef>;
+};
+
+template 
+using __concat_reference_t = common_reference_t...>;
+
+template 
+using __concat_value_t = common_type_t...>;
+
+template 
+using __concat_rvalue_reference_t = 
common_reference_t...>;
+
+template 
+concept __concat_indirectly_readable =
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...>&> &&
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_rvalue_reference_t<_Rs...>&&> &&
+common_reference_with<__concat_rvalue_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...> const&> &&
+(__concat_indirectly_readable_impl<__concat_reference_t<_Rs...>,
+   __concat_rvalue_reference_t<_Rs...>,
+   iterator_t<_Rs>> &&
+ ...);
+
+template 
+concept __concatable = requires {
+  typename __concat_reference_t<_Rs...>;
+  typename __concat_value_t<_Rs...>;
+  typename __concat_rvalue_reference_t<_Rs...>;
+} && __concat_indirectly_readable<_Rs...>;
+
+template 
+concept __concat_is_random_access =
+(random_access_range<__maybe_const<_Const, _Rs>> && ...) && 
(sized_range<__maybe_const<_Const, _Rs>> && ...);
+
+template 
+concept __concat_is_bidirectional =
+((bidirectional_range<__maybe_const<_Const, _Rs>> && ...) && 
(common_range<__maybe_const<_Const, _Rs>> && ...));
+
+template 
+concept __all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...);
+
+template 
+struct __apply_drop_first;
+
+template 
+struct __apply_drop_first<_Const, Head, Tail...> {
+  static constexpr bool value = (sized_range<__maybe_const<_Const, Tail>> && 
...);
+};
+
+template 
+  requires(view<_Views> && ...) && (sizeof...(_Views) > 0) && 
__concatable<_Views...>
+class concat_view : public view_interface> {
+  tuple<_Views...> views_;
+
+  template 
+  class iterator;
+  class sentinel;
+
+public:
+  _LIBCPP_HIDE_FROM_ABI constexpr concat_view() = default;
+
+  _LIBCPP_HIDE_FROM_ABI constexpr explicit concat_view(_Views... views) : 
views_(std::move(views)...) {}
+
+  _LIBCPP_HIDE_FROM_ABI conste

[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2024-12-30 Thread A. Jiang via cfe-commits


@@ -0,0 +1,626 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+template 
+struct __extract_last : __extract_last<_Tp...> {};
+
+template 
+struct __extract_last<_T> {
+  using type = _T;
+};
+
+template 
+struct __derived_from_pack {
+  constexpr static bool value =
+  __derived_from_pack<_T, typename __extract_last<_Tp...>::type>::value && 
__derived_from_pack<_Tp...>::value;
+};
+
+template 
+struct __derived_from_pack<_T, _IterCategory> {
+  constexpr static bool value = derived_from<_T, _IterCategory>;
+};
+
+template 
+struct __last_view : __last_view<_Views...> {};
+
+template 
+struct __last_view<_View> {
+  using type = _View;
+};
+
+template 
+concept __concat_indirectly_readable_impl = requires(const _It it) {
+  { *it } -> convertible_to<_Ref>;
+  { ranges::iter_move(it) } -> convertible_to<_RRef>;
+};
+
+template 
+using __concat_reference_t = common_reference_t...>;
+
+template 
+using __concat_value_t = common_type_t...>;
+
+template 
+using __concat_rvalue_reference_t = 
common_reference_t...>;
+
+template 
+concept __concat_indirectly_readable =
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...>&> &&
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_rvalue_reference_t<_Rs...>&&> &&
+common_reference_with<__concat_rvalue_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...> const&> &&
+(__concat_indirectly_readable_impl<__concat_reference_t<_Rs...>,
+   __concat_rvalue_reference_t<_Rs...>,
+   iterator_t<_Rs>> &&
+ ...);
+
+template 
+concept __concatable = requires {
+  typename __concat_reference_t<_Rs...>;
+  typename __concat_value_t<_Rs...>;
+  typename __concat_rvalue_reference_t<_Rs...>;
+} && __concat_indirectly_readable<_Rs...>;
+
+template 
+concept __concat_is_random_access =
+(random_access_range<__maybe_const<_Const, _Rs>> && ...) && 
(sized_range<__maybe_const<_Const, _Rs>> && ...);
+
+template 
+concept __concat_is_bidirectional =
+((bidirectional_range<__maybe_const<_Const, _Rs>> && ...) && 
(common_range<__maybe_const<_Const, _Rs>> && ...));
+
+template 
+concept __all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...);
+
+template 
+struct __apply_drop_first;
+
+template 
+struct __apply_drop_first<_Const, Head, Tail...> {
+  static constexpr bool value = (sized_range<__maybe_const<_Const, Tail>> && 
...);
+};
+
+template 
+  requires(view<_Views> && ...) && (sizeof...(_Views) > 0) && 
__concatable<_Views...>
+class concat_view : public view_interface> {
+  tuple<_Views...> views_;
+
+  template 
+  class iterator;
+  class sentinel;

frederick-vs-ja wrote:

Exposition-only names are not standard, and thus should be __ugly (ditto below).

```suggestion
  template 
  class __iterator;
  class __sentinel;
```

https://github.com/

[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2024-12-30 Thread A. Jiang via cfe-commits


@@ -0,0 +1,626 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+template 
+struct __extract_last : __extract_last<_Tp...> {};
+
+template 
+struct __extract_last<_T> {
+  using type = _T;
+};
+
+template 
+struct __derived_from_pack {
+  constexpr static bool value =
+  __derived_from_pack<_T, typename __extract_last<_Tp...>::type>::value && 
__derived_from_pack<_Tp...>::value;
+};
+
+template 
+struct __derived_from_pack<_T, _IterCategory> {
+  constexpr static bool value = derived_from<_T, _IterCategory>;
+};
+
+template 
+struct __last_view : __last_view<_Views...> {};
+
+template 
+struct __last_view<_View> {
+  using type = _View;
+};
+
+template 
+concept __concat_indirectly_readable_impl = requires(const _It it) {
+  { *it } -> convertible_to<_Ref>;
+  { ranges::iter_move(it) } -> convertible_to<_RRef>;
+};
+
+template 
+using __concat_reference_t = common_reference_t...>;
+
+template 
+using __concat_value_t = common_type_t...>;
+
+template 
+using __concat_rvalue_reference_t = 
common_reference_t...>;
+
+template 
+concept __concat_indirectly_readable =
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...>&> &&
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_rvalue_reference_t<_Rs...>&&> &&
+common_reference_with<__concat_rvalue_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...> const&> &&
+(__concat_indirectly_readable_impl<__concat_reference_t<_Rs...>,
+   __concat_rvalue_reference_t<_Rs...>,
+   iterator_t<_Rs>> &&
+ ...);
+
+template 
+concept __concatable = requires {
+  typename __concat_reference_t<_Rs...>;
+  typename __concat_value_t<_Rs...>;
+  typename __concat_rvalue_reference_t<_Rs...>;
+} && __concat_indirectly_readable<_Rs...>;
+
+template 
+concept __concat_is_random_access =
+(random_access_range<__maybe_const<_Const, _Rs>> && ...) && 
(sized_range<__maybe_const<_Const, _Rs>> && ...);
+
+template 
+concept __concat_is_bidirectional =
+((bidirectional_range<__maybe_const<_Const, _Rs>> && ...) && 
(common_range<__maybe_const<_Const, _Rs>> && ...));
+
+template 
+concept __all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...);
+
+template 
+struct __apply_drop_first;
+
+template 
+struct __apply_drop_first<_Const, Head, Tail...> {
+  static constexpr bool value = (sized_range<__maybe_const<_Const, Tail>> && 
...);
+};
+
+template 
+  requires(view<_Views> && ...) && (sizeof...(_Views) > 0) && 
__concatable<_Views...>
+class concat_view : public view_interface> {
+  tuple<_Views...> views_;

frederick-vs-ja wrote:

Member names should be __ugly unless specified by the standard (ditto below).
```suggestion
  tuple<_Views...> __views_;
```

https://github.com/llvm/llvm-project/pull/120920
___
cf

[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2024-12-30 Thread A. Jiang via cfe-commits


@@ -0,0 +1,626 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+template 
+struct __extract_last : __extract_last<_Tp...> {};
+
+template 
+struct __extract_last<_T> {
+  using type = _T;
+};
+
+template 
+struct __derived_from_pack {
+  constexpr static bool value =
+  __derived_from_pack<_T, typename __extract_last<_Tp...>::type>::value && 
__derived_from_pack<_Tp...>::value;
+};
+
+template 
+struct __derived_from_pack<_T, _IterCategory> {
+  constexpr static bool value = derived_from<_T, _IterCategory>;
+};

frederick-vs-ja wrote:

It's better to define `__derived_from_pack` as a variable template.

https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2024-12-30 Thread A. Jiang via cfe-commits


@@ -0,0 +1,626 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+template 
+struct __extract_last : __extract_last<_Tp...> {};
+
+template 
+struct __extract_last<_T> {
+  using type = _T;
+};

frederick-vs-ja wrote:

Please avoid using `_T` (or another underscore-followed-by-singled-letter 
identifier) as it would conflict with implementation-specific macros (e.g. MS 
uses `_T` for ANSI/Unicode literals).
```suggestion
template 
struct __extract_last : __extract_last<_Tail..> {};

template 
struct __extract_last<_Tp> {
  using type = _Tp;
};
```

https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2024-12-30 Thread A. Jiang via cfe-commits


@@ -0,0 +1,626 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+template 
+struct __extract_last : __extract_last<_Tp...> {};
+
+template 
+struct __extract_last<_T> {
+  using type = _T;
+};
+
+template 
+struct __derived_from_pack {
+  constexpr static bool value =
+  __derived_from_pack<_T, typename __extract_last<_Tp...>::type>::value && 
__derived_from_pack<_Tp...>::value;
+};
+
+template 
+struct __derived_from_pack<_T, _IterCategory> {
+  constexpr static bool value = derived_from<_T, _IterCategory>;
+};
+
+template 
+struct __last_view : __last_view<_Views...> {};
+
+template 
+struct __last_view<_View> {
+  using type = _View;
+};
+
+template 
+concept __concat_indirectly_readable_impl = requires(const _It it) {
+  { *it } -> convertible_to<_Ref>;
+  { ranges::iter_move(it) } -> convertible_to<_RRef>;
+};
+
+template 
+using __concat_reference_t = common_reference_t...>;
+
+template 
+using __concat_value_t = common_type_t...>;
+
+template 
+using __concat_rvalue_reference_t = 
common_reference_t...>;
+
+template 
+concept __concat_indirectly_readable =
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...>&> &&
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_rvalue_reference_t<_Rs...>&&> &&
+common_reference_with<__concat_rvalue_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...> const&> &&
+(__concat_indirectly_readable_impl<__concat_reference_t<_Rs...>,
+   __concat_rvalue_reference_t<_Rs...>,
+   iterator_t<_Rs>> &&
+ ...);
+
+template 
+concept __concatable = requires {
+  typename __concat_reference_t<_Rs...>;
+  typename __concat_value_t<_Rs...>;
+  typename __concat_rvalue_reference_t<_Rs...>;
+} && __concat_indirectly_readable<_Rs...>;
+
+template 
+concept __concat_is_random_access =
+(random_access_range<__maybe_const<_Const, _Rs>> && ...) && 
(sized_range<__maybe_const<_Const, _Rs>> && ...);
+
+template 
+concept __concat_is_bidirectional =
+((bidirectional_range<__maybe_const<_Const, _Rs>> && ...) && 
(common_range<__maybe_const<_Const, _Rs>> && ...));
+
+template 
+concept __all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...);
+
+template 
+struct __apply_drop_first;
+
+template 
+struct __apply_drop_first<_Const, Head, Tail...> {
+  static constexpr bool value = (sized_range<__maybe_const<_Const, Tail>> && 
...);
+};
+
+template 
+  requires(view<_Views> && ...) && (sizeof...(_Views) > 0) && 
__concatable<_Views...>
+class concat_view : public view_interface> {
+  tuple<_Views...> views_;
+
+  template 
+  class iterator;
+  class sentinel;
+
+public:
+  _LIBCPP_HIDE_FROM_ABI constexpr concat_view() = default;
+
+  _LIBCPP_HIDE_FROM_ABI constexpr explicit concat_view(_Views... views) : 
views_(std::move(views)...) {}
+
+  _LIBCPP_HIDE_FROM_ABI conste

[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2024-12-30 Thread A. Jiang via cfe-commits


@@ -0,0 +1,626 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+template 
+struct __extract_last : __extract_last<_Tp...> {};
+
+template 
+struct __extract_last<_T> {
+  using type = _T;
+};
+
+template 
+struct __derived_from_pack {
+  constexpr static bool value =
+  __derived_from_pack<_T, typename __extract_last<_Tp...>::type>::value && 
__derived_from_pack<_Tp...>::value;
+};
+
+template 
+struct __derived_from_pack<_T, _IterCategory> {
+  constexpr static bool value = derived_from<_T, _IterCategory>;
+};
+
+template 
+struct __last_view : __last_view<_Views...> {};
+
+template 
+struct __last_view<_View> {
+  using type = _View;
+};
+
+template 
+concept __concat_indirectly_readable_impl = requires(const _It it) {
+  { *it } -> convertible_to<_Ref>;
+  { ranges::iter_move(it) } -> convertible_to<_RRef>;
+};

frederick-vs-ja wrote:

Missed __uglification (ditto below)
```suggestion
template 
concept __concat_indirectly_readable_impl = requires(const _It __it) {
  { *__it } -> convertible_to<_Ref>;
  { ranges::iter_move(__it) } -> convertible_to<_RRef>;
};
```

https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Update __cpp_concepts macro (PR #87998)

2025-02-06 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/87998
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][docs] Clarify the tail padding considered by `__datasizeof` (PR #125981)

2025-02-05 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja created 
https://github.com/llvm/llvm-project/pull/125981

Some tail padding are not reusable due to the ABI specification, and 
`__datasizeof` intentionally doesn't consider them.

Closes #125863.

>From 0577594d4ecbbae6e61e087ce16609469d5f459c Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Thu, 6 Feb 2025 10:20:49 +0800
Subject: [PATCH] [clang][docs] Clarify the tail padding considered by
 `__datasizeof`

---
 clang/docs/LanguageExtensions.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index dd7513ceaa4e4bf..a779064e84cb404 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -432,7 +432,7 @@ __datasizeof
 
 
 ``__datasizeof`` behaves like ``sizeof``, except that it returns the size of 
the
-type ignoring tail padding.
+type ignoring reusable tail padding according to the ABI.
 
 _BitInt, _ExtInt
 

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


[clang] [Clang] Deleting an incomplete enum type is not an error (PR #118455)

2024-12-12 Thread A. Jiang via cfe-commits


@@ -540,6 +540,14 @@ namespace PR10504 {
   void f(A *x) { delete x; } // expected-warning {{delete called on 
'PR10504::A' that is abstract but has non-virtual destructor}}
 }
 
+#if __cplusplus >= 201103L
+enum GH99278_1 { // expected-note {{definition of 'GH99278_1' is not complete 
until the closing '}'}}
+zero = decltype(delete static_cast(nullptr), 0){}

frederick-vs-ja wrote:

If one attempts to evaluate such a weird delete-expression, there would be 
initially UB because it's impossible to `new` an object of an incomplete enum 
type. However, the UB would be definitely transformed into constant evaluation 
failure, becaue such an enum type only incomplete in the enum body, where every 
evaluation must be within the constant evaluation of some enumerator.

https://github.com/llvm/llvm-project/pull/118455
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Deleting an incomplete enum type is not an error (PR #118455)

2024-12-12 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/118455
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++][ranges] P2542R8: Implement `views::concat` (PR #120920)

2025-01-11 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Add predefined macros for integer constants to implement section 7.18.4 of ISO/IEC 9899:1999 in `` in a safe way (PR #123514)

2025-01-19 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

> > This seems related to #85995. Do you plan to fix that issue together?
> 
> I wasn't planning on fixing Clang's ``, I thought it would be 
> better handled by the maintainers of the standard library, but I can do it if 
> you want.
> 
> Do you want me to do it?

Oh, I didn't mean that. It might be better to do that in a separated PR.

https://github.com/llvm/llvm-project/pull/123514
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Add predefined macros for integer constants to implement section 7.18.4 of ISO/IEC 9899:1999 in `` in a safe way (PR #123514)

2025-01-19 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

This seems related to #85995. Do you plan to fix that issue together?

https://github.com/llvm/llvm-project/pull/123514
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] use constant evaluation context for constexpr if conditions (PR #123667)

2025-01-20 Thread A. Jiang via cfe-commits


@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++26 -verify %s

frederick-vs-ja wrote:

I think it would be better to verify that this is OK since C++20.

https://github.com/llvm/llvm-project/pull/123667
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] fix deducing auto& from const int in template parameters is impossible in partial specializations (PR #79733)

2025-01-03 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/79733
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Headers] Workaround for UCRT's `` in `` (PR #121650)

2025-01-04 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja created 
https://github.com/llvm/llvm-project/pull/121650

This patch uses `__builtin_bit_cast` as workaround to make MS UCRT's 
non-conforming functions `` usable for ``.

Fixes #45552.

>From 0366072ca42ec9773897daabf7946eb37c631623 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Sat, 4 Jan 2025 23:53:05 +0800
Subject: [PATCH] [Clang][Headers] Workaround for UCRT's `` in
 ``

This patch uses `__builtin_bit_cast` as workaround to make MS UCRT's
non-conforming functions `` usable for ``.
---
 clang/lib/Headers/tgmath.h | 453 -
 1 file changed, 245 insertions(+), 208 deletions(-)

diff --git a/clang/lib/Headers/tgmath.h b/clang/lib/Headers/tgmath.h
index 7acf18b9dd3578..e236be92f35c6c 100644
--- a/clang/lib/Headers/tgmath.h
+++ b/clang/lib/Headers/tgmath.h
@@ -28,6 +28,30 @@
 #define _TG_ATTRSp __attribute__((__overloadable__))
 #define _TG_ATTRS __attribute__((__overloadable__, __always_inline__))
 
+// https://github.com/llvm/llvm-project/issues/45552
+// workaround for MS UCRT's 
+#if defined(_VCRUNTIME_H) && defined(_C_COMPLEX_T)
+#define __CLANG_TGMATH_H_USES_UCRT_COMPLEX_H 1
+#else
+#define __CLANG_TGMATH_H_USES_UCRT_COMPLEX_H 0
+#endif
+
+#if __CLANG_TGMATH_H_USES_UCRT_COMPLEX_H
+#define _TG_FROM_FCOMPLEX(__z) __builtin_bit_cast(float _Complex, (__z))
+#define _TG_FROM_DCOMPLEX(__z) __builtin_bit_cast(double _Complex, (__z))
+#define _TG_FROM_LCOMPLEX(__z) __builtin_bit_cast(long double _Complex, (__z))
+#define _TG_TO_FCOMPLEX(__z) __builtin_bit_cast(_Fcomplex, (__z))
+#define _TG_TO_DCOMPLEX(__z) __builtin_bit_cast(_Dcomplex, (__z))
+#define _TG_TO_LCOMPLEX(__z) __builtin_bit_cast(_Lcomplex, (__z))
+#else
+#define _TG_FROM_FCOMPLEX(__z) (__z)
+#define _TG_FROM_DCOMPLEX(__z) (__z)
+#define _TG_FROM_LCOMPLEX(__z) (__z)
+#define _TG_TO_FCOMPLEX(__z) (__z)
+#define _TG_TO_DCOMPLEX(__z) (__z)
+#define _TG_TO_LCOMPLEX(__z) (__z)
+#endif
+
 // promotion
 
 typedef void _Argument_type_is_not_arithmetic;
@@ -67,17 +91,17 @@ static long double
 _TG_ATTRS
 __tg_acos(long double __x) {return acosl(__x);}
 
-static float _Complex
-_TG_ATTRS
-__tg_acos(float _Complex __x) {return cacosf(__x);}
+static float _Complex _TG_ATTRS __tg_acos(float _Complex __x) {
+  return _TG_FROM_FCOMPLEX(cacosf(_TG_TO_FCOMPLEX(__x)));
+}
 
-static double _Complex
-_TG_ATTRS
-__tg_acos(double _Complex __x) {return cacos(__x);}
+static double _Complex _TG_ATTRS __tg_acos(double _Complex __x) {
+  return _TG_FROM_DCOMPLEX(cacos(_TG_TO_DCOMPLEX(__x)));
+}
 
-static long double _Complex
-_TG_ATTRS
-__tg_acos(long double _Complex __x) {return cacosl(__x);}
+static long double _Complex _TG_ATTRS __tg_acos(long double _Complex __x) {
+  return _TG_FROM_LCOMPLEX(cacosl(_TG_TO_LCOMPLEX(__x)));
+}
 
 #undef acos
 #define acos(__x) __tg_acos(__tg_promote1((__x))(__x))
@@ -96,17 +120,17 @@ static long double
 _TG_ATTRS
 __tg_asin(long double __x) {return asinl(__x);}
 
-static float _Complex
-_TG_ATTRS
-__tg_asin(float _Complex __x) {return casinf(__x);}
+static float _Complex _TG_ATTRS __tg_asin(float _Complex __x) {
+  return _TG_FROM_FCOMPLEX(casinf(_TG_TO_FCOMPLEX(__x)));
+}
 
-static double _Complex
-_TG_ATTRS
-__tg_asin(double _Complex __x) {return casin(__x);}
+static double _Complex _TG_ATTRS __tg_asin(double _Complex __x) {
+  return _TG_FROM_DCOMPLEX(casin(_TG_TO_DCOMPLEX(__x)));
+}
 
-static long double _Complex
-_TG_ATTRS
-__tg_asin(long double _Complex __x) {return casinl(__x);}
+static long double _Complex _TG_ATTRS __tg_asin(long double _Complex __x) {
+  return _TG_FROM_LCOMPLEX(casinl(_TG_TO_LCOMPLEX(__x)));
+}
 
 #undef asin
 #define asin(__x) __tg_asin(__tg_promote1((__x))(__x))
@@ -125,17 +149,17 @@ static long double
 _TG_ATTRS
 __tg_atan(long double __x) {return atanl(__x);}
 
-static float _Complex
-_TG_ATTRS
-__tg_atan(float _Complex __x) {return catanf(__x);}
+static float _Complex _TG_ATTRS __tg_atan(float _Complex __x) {
+  return _TG_FROM_FCOMPLEX(catanf(_TG_TO_FCOMPLEX(__x)));
+}
 
-static double _Complex
-_TG_ATTRS
-__tg_atan(double _Complex __x) {return catan(__x);}
+static double _Complex _TG_ATTRS __tg_atan(double _Complex __x) {
+  return _TG_FROM_DCOMPLEX(catan(_TG_TO_DCOMPLEX(__x)));
+}
 
-static long double _Complex
-_TG_ATTRS
-__tg_atan(long double _Complex __x) {return catanl(__x);}
+static long double _Complex _TG_ATTRS __tg_atan(long double _Complex __x) {
+  return _TG_FROM_LCOMPLEX(catanl(_TG_TO_LCOMPLEX(__x)));
+}
 
 #undef atan
 #define atan(__x) __tg_atan(__tg_promote1((__x))(__x))
@@ -154,17 +178,17 @@ static long double
 _TG_ATTRS
 __tg_acosh(long double __x) {return acoshl(__x);}
 
-static float _Complex
-_TG_ATTRS
-__tg_acosh(float _Complex __x) {return cacoshf(__x);}
+static float _Complex _TG_ATTRS __tg_acosh(float _Complex __x) {
+  return _TG_FROM_FCOMPLEX(cacoshf(_TG_TO_FCOMPLEX(__x)));
+}
 
-static double _C

[clang] [Clang][Headers] Workaround for UCRT's `` in `` (PR #121650)

2025-01-04 Thread A. Jiang via cfe-commits


@@ -28,6 +28,30 @@
 #define _TG_ATTRSp __attribute__((__overloadable__))
 #define _TG_ATTRS __attribute__((__overloadable__, __always_inline__))
 
+// https://github.com/llvm/llvm-project/issues/45552
+// workaround for MS UCRT's 
+#if defined(_VCRUNTIME_H) && defined(_C_COMPLEX_T)

frederick-vs-ja wrote:

This doesn't seem to be a favorite approach for detecting whether MS UCRT's 
`` is used. But I'm not aware of any conventional way (the 
`_COMPLEX` guard looks possible).

Also, I've verified the changes with Clang 18 installed with VS 2022, but 
perhaps a test in the LLVM repo is desired.

https://github.com/llvm/llvm-project/pull/121650
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Headers] Workaround for UCRT's `` in `` (PR #121650)

2025-01-04 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/121650
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2025-01-05 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

We also need to export `std::ranges::concat_view` and 
`std::ranges::views::concat` in `main/libcxx/modules/std/ranges.inc`.

https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2025-01-05 Thread A. Jiang via cfe-commits


@@ -0,0 +1,623 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__ranges/zip_view.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+template 
+struct __extract_last : __extract_last<_Tail...> {};

frederick-vs-ja wrote:

Perhaps we should add workaround for GCC 14 which hadn't implemented pack 
indexing.

https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2025-01-05 Thread A. Jiang via cfe-commits


@@ -0,0 +1,623 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__ranges/zip_view.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+

frederick-vs-ja wrote:

I _guess_ some OS header is defining `move` as a macro, but I'm not sure.

https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] CWG722: nullptr to ellipses (PR #104704)

2024-12-30 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/104704
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2024-12-31 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2024-12-31 Thread A. Jiang via cfe-commits


@@ -0,0 +1,623 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__ranges/zip_view.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+

frederick-vs-ja wrote:

As `std::move` is used in the header, we need to add `_LIBCPP_PUSH_MACROS`, 
`#include <__undef_macros>`, and `_LIBCPP_POP_MACROS` to correct places, see 
another headers.

Also, CI failure messages indicated that there're still a large number of 
non-__uglified identifiers being used.

https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-08 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

Do we want to add some workaround to libc++'s ``?

https://github.com/llvm/llvm-project/pull/102857
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2025-01-07 Thread A. Jiang via cfe-commits


@@ -0,0 +1,79 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include "test_iterators.h"
+#include "test_macros.h"
+#include "../types.h"
+
+template 
+concept has_iter_swap = requires(It it) { std::ranges::iter_swap(it, it); };
+
+template 
+constexpr void test() {
+  using Sentinel   = sentinel_wrapper;
+  using View   = minimal_view;
+  using ConcatView = std::ranges::concat_view;
+  using ConcatIterator = std::ranges::iterator_t;

frederick-vs-ja wrote:

Ditto unused typedef-names.
```suggestion
  using Sentinel   = sentinel_wrapper;
  using View   = minimal_view;
  using ConcatView = std::ranges::concat_view;
```

https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2025-01-07 Thread A. Jiang via cfe-commits


@@ -0,0 +1,637 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__ranges/zip_view.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+#  ifdef __cpp_pack_indexing
+template 
+using __extract_last = _Tp...[sizeof...(_Tp) - 1];
+#  else
+template 
+struct __extract_last_impl : __extract_last_impl<_Tail...> {};
+template 
+struct __extract_last_impl<_Tp> {
+  using type = _Tp;
+};
+
+template 
+using __extract_last = __extract_last_impl<_Tp...>::type;
+#  endif
+
+template 
+constexpr bool __derived_from_pack =
+__derived_from_pack<_Tp, __extract_last<_Tail...>> && 
__derived_from_pack<_Tail...>;
+
+template 
+constexpr bool __derived_from_pack<_Tp, _IterCategory> = derived_from<_Tp, 
_IterCategory>;
+
+template 
+struct __last_view : __last_view<_Views...> {};
+
+template 
+struct __last_view<_View> {
+  using type = _View;
+};
+
+template 
+concept __concat_indirectly_readable_impl = requires(const _It __it) {
+  { *__it } -> convertible_to<_Ref>;
+  { ranges::iter_move(__it) } -> convertible_to<_RRef>;
+};
+
+template 
+using __concat_reference_t = common_reference_t...>;
+
+template 
+using __concat_value_t = common_type_t...>;
+
+template 
+using __concat_rvalue_reference_t = 
common_reference_t...>;
+
+template 
+concept __concat_indirectly_readable =
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...>&> &&
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_rvalue_reference_t<_Rs...>&&> &&
+common_reference_with<__concat_rvalue_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...> const&> &&
+(__concat_indirectly_readable_impl<__concat_reference_t<_Rs...>,
+   __concat_rvalue_reference_t<_Rs...>,
+   iterator_t<_Rs>> &&
+ ...);
+
+template 
+concept __concatable = requires {
+  typename __concat_reference_t<_Rs...>;
+  typename __concat_value_t<_Rs...>;
+  typename __concat_rvalue_reference_t<_Rs...>;
+} && __concat_indirectly_readable<_Rs...>;
+
+template 
+concept __concat_is_random_access =
+(random_access_range<__maybe_const<_Const, _Rs>> && ...) && 
(sized_range<__maybe_const<_Const, _Rs>> && ...);
+
+template 
+concept __concat_is_bidirectional =
+((bidirectional_range<__maybe_const<_Const, _Rs>> && ...) && 
(common_range<__maybe_const<_Const, _Rs>> && ...));
+
+template 
+concept __all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...);
+
+template 
+struct __apply_drop_first;
+
+template 
+struct __apply_drop_first<_Const, _Head, _Tail...> {
+  static constexpr bool value = (sized_range<__maybe_const<_Const, _Tail>> && 
...);
+};
+
+template 
+  requires(view<_Views> && ...) && (sizeof...(_Views) > 0) && 
__concatable<_Views...>
+class concat_view : public view_interface> {
+  tuple<_Views...> __views_;
+
+  template 
+  class __iterator;
+
+public:
+  _LI

[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2025-01-07 Thread A. Jiang via cfe-commits


@@ -0,0 +1,38 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+#include 
+#include 
+
+#include 
+#include "test_iterators.h"
+
+constexpr void general_tests() {
+  std::vector v1 = {1, 2, 3, 4, 5, 6, 7, 8};
+  std::vector v2 = {1, 2, 3, 4, 5, 6, 7, 8};
+  using type  = std::vector;

frederick-vs-ja wrote:

Ditto unused typedef-names.
```suggestion
```

https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2025-01-07 Thread A. Jiang via cfe-commits


@@ -0,0 +1,71 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// std::views::filter
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_iterators.h"
+#include "test_range.h"
+
+struct Range : std::ranges::view_base {
+  using Iterator = forward_iterator;
+  using Sentinel = sentinel_wrapper;
+  constexpr explicit Range(int* b, int* e) : begin_(b), end_(e) {}
+  constexpr Iterator begin() const { return Iterator(begin_); }
+  constexpr Sentinel end() const { return Sentinel(Iterator(end_)); }
+
+private:
+  int* begin_;
+  int* end_;
+};
+
+template 
+constexpr void compareViews(View v, std::initializer_list list) {
+  auto b1 = v.begin();
+  auto e1 = v.end();
+  auto b2 = list.begin();
+  auto e2 = list.end();
+  for (; b1 != e1 && b2 != e2; ++b1, ++b2) {
+assert(*b1 == *b2);
+  }
+  assert(b1 == e1);
+  assert(b2 == e2);
+}
+
+constexpr bool test() {
+  int buff[] = {0, 1, 2, 3, 4, 5, 6, 7};
+
+  {
+using Result = std::ranges::concat_view;

frederick-vs-ja wrote:

GCC compains about unused typedef names.
```suggestion
```

https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2025-01-07 Thread A. Jiang via cfe-commits


@@ -0,0 +1,637 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__ranges/zip_view.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+#  ifdef __cpp_pack_indexing
+template 
+using __extract_last = _Tp...[sizeof...(_Tp) - 1];
+#  else
+template 
+struct __extract_last_impl : __extract_last_impl<_Tail...> {};
+template 
+struct __extract_last_impl<_Tp> {
+  using type = _Tp;
+};
+
+template 
+using __extract_last = __extract_last_impl<_Tp...>::type;
+#  endif
+
+template 
+constexpr bool __derived_from_pack =
+__derived_from_pack<_Tp, __extract_last<_Tail...>> && 
__derived_from_pack<_Tail...>;
+
+template 
+constexpr bool __derived_from_pack<_Tp, _IterCategory> = derived_from<_Tp, 
_IterCategory>;
+
+template 
+struct __last_view : __last_view<_Views...> {};
+
+template 
+struct __last_view<_View> {
+  using type = _View;
+};
+
+template 
+concept __concat_indirectly_readable_impl = requires(const _It __it) {
+  { *__it } -> convertible_to<_Ref>;
+  { ranges::iter_move(__it) } -> convertible_to<_RRef>;
+};
+
+template 
+using __concat_reference_t = common_reference_t...>;
+
+template 
+using __concat_value_t = common_type_t...>;
+
+template 
+using __concat_rvalue_reference_t = 
common_reference_t...>;
+
+template 
+concept __concat_indirectly_readable =
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...>&> &&
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_rvalue_reference_t<_Rs...>&&> &&
+common_reference_with<__concat_rvalue_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...> const&> &&
+(__concat_indirectly_readable_impl<__concat_reference_t<_Rs...>,
+   __concat_rvalue_reference_t<_Rs...>,
+   iterator_t<_Rs>> &&
+ ...);
+
+template 
+concept __concatable = requires {
+  typename __concat_reference_t<_Rs...>;
+  typename __concat_value_t<_Rs...>;
+  typename __concat_rvalue_reference_t<_Rs...>;
+} && __concat_indirectly_readable<_Rs...>;
+
+template 
+concept __concat_is_random_access =
+(random_access_range<__maybe_const<_Const, _Rs>> && ...) && 
(sized_range<__maybe_const<_Const, _Rs>> && ...);
+
+template 
+concept __concat_is_bidirectional =
+((bidirectional_range<__maybe_const<_Const, _Rs>> && ...) && 
(common_range<__maybe_const<_Const, _Rs>> && ...));
+
+template 
+concept __all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...);
+
+template 
+struct __apply_drop_first;
+
+template 
+struct __apply_drop_first<_Const, _Head, _Tail...> {
+  static constexpr bool value = (sized_range<__maybe_const<_Const, _Tail>> && 
...);
+};
+
+template 
+  requires(view<_Views> && ...) && (sizeof...(_Views) > 0) && 
__concatable<_Views...>
+class concat_view : public view_interface> {
+  tuple<_Views...> __views_;
+
+  template 
+  class __iterator;
+
+public:
+  _LI

[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2025-01-07 Thread A. Jiang via cfe-commits


@@ -0,0 +1,637 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__ranges/zip_view.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+#  ifdef __cpp_pack_indexing
+template 
+using __extract_last = _Tp...[sizeof...(_Tp) - 1];
+#  else
+template 
+struct __extract_last_impl : __extract_last_impl<_Tail...> {};
+template 
+struct __extract_last_impl<_Tp> {
+  using type = _Tp;
+};
+
+template 
+using __extract_last = __extract_last_impl<_Tp...>::type;
+#  endif
+
+template 
+constexpr bool __derived_from_pack =
+__derived_from_pack<_Tp, __extract_last<_Tail...>> && 
__derived_from_pack<_Tail...>;
+
+template 
+constexpr bool __derived_from_pack<_Tp, _IterCategory> = derived_from<_Tp, 
_IterCategory>;
+
+template 
+struct __last_view : __last_view<_Views...> {};
+
+template 
+struct __last_view<_View> {
+  using type = _View;
+};
+
+template 
+concept __concat_indirectly_readable_impl = requires(const _It __it) {
+  { *__it } -> convertible_to<_Ref>;
+  { ranges::iter_move(__it) } -> convertible_to<_RRef>;
+};
+
+template 
+using __concat_reference_t = common_reference_t...>;
+
+template 
+using __concat_value_t = common_type_t...>;
+
+template 
+using __concat_rvalue_reference_t = 
common_reference_t...>;
+
+template 
+concept __concat_indirectly_readable =
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...>&> &&
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_rvalue_reference_t<_Rs...>&&> &&
+common_reference_with<__concat_rvalue_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...> const&> &&
+(__concat_indirectly_readable_impl<__concat_reference_t<_Rs...>,
+   __concat_rvalue_reference_t<_Rs...>,
+   iterator_t<_Rs>> &&
+ ...);
+
+template 
+concept __concatable = requires {
+  typename __concat_reference_t<_Rs...>;
+  typename __concat_value_t<_Rs...>;
+  typename __concat_rvalue_reference_t<_Rs...>;
+} && __concat_indirectly_readable<_Rs...>;
+
+template 
+concept __concat_is_random_access =
+(random_access_range<__maybe_const<_Const, _Rs>> && ...) && 
(sized_range<__maybe_const<_Const, _Rs>> && ...);
+
+template 
+concept __concat_is_bidirectional =
+((bidirectional_range<__maybe_const<_Const, _Rs>> && ...) && 
(common_range<__maybe_const<_Const, _Rs>> && ...));
+
+template 
+concept __all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...);
+
+template 
+struct __apply_drop_first;
+
+template 
+struct __apply_drop_first<_Const, _Head, _Tail...> {
+  static constexpr bool value = (sized_range<__maybe_const<_Const, _Tail>> && 
...);
+};
+
+template 
+  requires(view<_Views> && ...) && (sizeof...(_Views) > 0) && 
__concatable<_Views...>
+class concat_view : public view_interface> {
+  tuple<_Views...> __views_;
+
+  template 
+  class __iterator;
+
+public:
+  _LI

[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2025-01-07 Thread A. Jiang via cfe-commits


@@ -0,0 +1,637 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__ranges/zip_view.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+#  ifdef __cpp_pack_indexing
+template 
+using __extract_last = _Tp...[sizeof...(_Tp) - 1];
+#  else
+template 
+struct __extract_last_impl : __extract_last_impl<_Tail...> {};
+template 
+struct __extract_last_impl<_Tp> {
+  using type = _Tp;
+};
+
+template 
+using __extract_last = __extract_last_impl<_Tp...>::type;
+#  endif
+
+template 
+constexpr bool __derived_from_pack =
+__derived_from_pack<_Tp, __extract_last<_Tail...>> && 
__derived_from_pack<_Tail...>;
+
+template 
+constexpr bool __derived_from_pack<_Tp, _IterCategory> = derived_from<_Tp, 
_IterCategory>;
+
+template 
+struct __last_view : __last_view<_Views...> {};
+
+template 
+struct __last_view<_View> {
+  using type = _View;
+};
+
+template 
+concept __concat_indirectly_readable_impl = requires(const _It __it) {
+  { *__it } -> convertible_to<_Ref>;
+  { ranges::iter_move(__it) } -> convertible_to<_RRef>;
+};
+
+template 
+using __concat_reference_t = common_reference_t...>;
+
+template 
+using __concat_value_t = common_type_t...>;
+
+template 
+using __concat_rvalue_reference_t = 
common_reference_t...>;
+
+template 
+concept __concat_indirectly_readable =
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...>&> &&
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_rvalue_reference_t<_Rs...>&&> &&
+common_reference_with<__concat_rvalue_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...> const&> &&
+(__concat_indirectly_readable_impl<__concat_reference_t<_Rs...>,
+   __concat_rvalue_reference_t<_Rs...>,
+   iterator_t<_Rs>> &&
+ ...);
+
+template 
+concept __concatable = requires {
+  typename __concat_reference_t<_Rs...>;
+  typename __concat_value_t<_Rs...>;
+  typename __concat_rvalue_reference_t<_Rs...>;
+} && __concat_indirectly_readable<_Rs...>;
+
+template 
+concept __concat_is_random_access =
+(random_access_range<__maybe_const<_Const, _Rs>> && ...) && 
(sized_range<__maybe_const<_Const, _Rs>> && ...);
+
+template 
+concept __concat_is_bidirectional =
+((bidirectional_range<__maybe_const<_Const, _Rs>> && ...) && 
(common_range<__maybe_const<_Const, _Rs>> && ...));
+
+template 
+concept __all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...);
+
+template 
+struct __apply_drop_first;
+
+template 
+struct __apply_drop_first<_Const, _Head, _Tail...> {
+  static constexpr bool value = (sized_range<__maybe_const<_Const, _Tail>> && 
...);
+};
+
+template 
+  requires(view<_Views> && ...) && (sizeof...(_Views) > 0) && 
__concatable<_Views...>
+class concat_view : public view_interface> {
+  tuple<_Views...> __views_;
+
+  template 
+  class __iterator;
+
+public:
+  _LI

[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2025-01-07 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2025-01-07 Thread A. Jiang via cfe-commits


@@ -0,0 +1,637 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__ranges/zip_view.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+#  ifdef __cpp_pack_indexing
+template 
+using __extract_last = _Tp...[sizeof...(_Tp) - 1];
+#  else
+template 
+struct __extract_last_impl : __extract_last_impl<_Tail...> {};
+template 
+struct __extract_last_impl<_Tp> {
+  using type = _Tp;
+};
+
+template 
+using __extract_last = __extract_last_impl<_Tp...>::type;
+#  endif
+
+template 
+constexpr bool __derived_from_pack =
+__derived_from_pack<_Tp, __extract_last<_Tail...>> && 
__derived_from_pack<_Tail...>;
+
+template 
+constexpr bool __derived_from_pack<_Tp, _IterCategory> = derived_from<_Tp, 
_IterCategory>;
+
+template 
+struct __last_view : __last_view<_Views...> {};
+
+template 
+struct __last_view<_View> {
+  using type = _View;
+};
+
+template 
+concept __concat_indirectly_readable_impl = requires(const _It __it) {
+  { *__it } -> convertible_to<_Ref>;
+  { ranges::iter_move(__it) } -> convertible_to<_RRef>;
+};
+
+template 
+using __concat_reference_t = common_reference_t...>;
+
+template 
+using __concat_value_t = common_type_t...>;
+
+template 
+using __concat_rvalue_reference_t = 
common_reference_t...>;
+
+template 
+concept __concat_indirectly_readable =
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...>&> &&
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_rvalue_reference_t<_Rs...>&&> &&
+common_reference_with<__concat_rvalue_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...> const&> &&
+(__concat_indirectly_readable_impl<__concat_reference_t<_Rs...>,
+   __concat_rvalue_reference_t<_Rs...>,
+   iterator_t<_Rs>> &&
+ ...);
+
+template 
+concept __concatable = requires {
+  typename __concat_reference_t<_Rs...>;
+  typename __concat_value_t<_Rs...>;
+  typename __concat_rvalue_reference_t<_Rs...>;
+} && __concat_indirectly_readable<_Rs...>;
+
+template 
+concept __concat_is_random_access =
+(random_access_range<__maybe_const<_Const, _Rs>> && ...) && 
(sized_range<__maybe_const<_Const, _Rs>> && ...);
+
+template 
+concept __concat_is_bidirectional =
+((bidirectional_range<__maybe_const<_Const, _Rs>> && ...) && 
(common_range<__maybe_const<_Const, _Rs>> && ...));
+
+template 
+concept __all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...);
+
+template 
+struct __apply_drop_first;
+
+template 
+struct __apply_drop_first<_Const, _Head, _Tail...> {
+  static constexpr bool value = (sized_range<__maybe_const<_Const, _Tail>> && 
...);
+};
+
+template 
+  requires(view<_Views> && ...) && (sizeof...(_Views) > 0) && 
__concatable<_Views...>
+class concat_view : public view_interface> {
+  tuple<_Views...> __views_;
+
+  template 
+  class __iterator;
+
+public:
+  _LI

[clang] [clang-tools-extra] [libcxx] [llvm] [libc++][ranges] P2542R8: Implement `views::concat` (PR #120920)

2025-01-09 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++][ranges] P2542R8: Implement `views::concat` (PR #120920)

2025-01-09 Thread A. Jiang via cfe-commits


@@ -0,0 +1,637 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__ranges/zip_view.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+#  ifdef __cpp_pack_indexing
+template 
+using __extract_last = _Tp...[sizeof...(_Tp) - 1];
+#  else
+template 
+struct __extract_last_impl : __extract_last_impl<_Tail...> {};
+template 
+struct __extract_last_impl<_Tp> {
+  using type = _Tp;
+};
+
+template 
+using __extract_last = __extract_last_impl<_Tp...>::type;
+#  endif
+
+template 
+constexpr bool __derived_from_pack =
+__derived_from_pack<_Tp, __extract_last<_Tail...>> && 
__derived_from_pack<_Tail...>;
+
+template 
+constexpr bool __derived_from_pack<_Tp, _IterCategory> = derived_from<_Tp, 
_IterCategory>;
+
+template 
+struct __last_view : __last_view<_Views...> {};
+
+template 
+struct __last_view<_View> {
+  using type = _View;
+};
+
+template 
+concept __concat_indirectly_readable_impl = requires(const _It __it) {
+  { *__it } -> convertible_to<_Ref>;
+  { ranges::iter_move(__it) } -> convertible_to<_RRef>;
+};
+
+template 
+using __concat_reference_t = common_reference_t...>;
+
+template 
+using __concat_value_t = common_type_t...>;
+
+template 
+using __concat_rvalue_reference_t = 
common_reference_t...>;
+
+template 
+concept __concat_indirectly_readable =
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...>&> &&
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_rvalue_reference_t<_Rs...>&&> &&
+common_reference_with<__concat_rvalue_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...> const&> &&
+(__concat_indirectly_readable_impl<__concat_reference_t<_Rs...>,
+   __concat_rvalue_reference_t<_Rs...>,
+   iterator_t<_Rs>> &&
+ ...);
+
+template 
+concept __concatable = requires {
+  typename __concat_reference_t<_Rs...>;
+  typename __concat_value_t<_Rs...>;
+  typename __concat_rvalue_reference_t<_Rs...>;
+} && __concat_indirectly_readable<_Rs...>;
+
+template 
+concept __concat_is_random_access =
+(random_access_range<__maybe_const<_Const, _Rs>> && ...) && 
(sized_range<__maybe_const<_Const, _Rs>> && ...);
+
+template 
+concept __concat_is_bidirectional =
+((bidirectional_range<__maybe_const<_Const, _Rs>> && ...) && 
(common_range<__maybe_const<_Const, _Rs>> && ...));
+
+template 
+concept __all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...);
+
+template 
+struct __apply_drop_first;
+
+template 
+struct __apply_drop_first<_Const, _Head, _Tail...> {
+  static constexpr bool value = (sized_range<__maybe_const<_Const, _Tail>> && 
...);
+};
+
+template 
+  requires(view<_Views> && ...) && (sizeof...(_Views) > 0) && 
__concatable<_Views...>
+class concat_view : public view_interface> {
+  tuple<_Views...> __views_;
+
+  template 
+  class __iterator;
+
+public:
+  _LI

[clang] [clang][docs] Fix DR status for P2280R4 (PR #127166)

2025-02-14 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/127166
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][docs] Fix DR staus for P2280R4 (PR #127166)

2025-02-13 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja created 
https://github.com/llvm/llvm-project/pull/127166

P2280R4 is officially a defect report. Although Clang 20 only implementated it 
for C++23 and later, and #95474 accidently removed the DR status in 
`cxx_status.html`. I think we should mention that it is a DR but not backported 
yet.

>From a2fc3d0550ab22e1a4273dc2debfda23df7cad6f Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Fri, 14 Feb 2025 14:03:23 +0800
Subject: [PATCH] [clang][docs] Fix DR staus for P2280R4

P2280R4 is officially a defect report. Although Clang 20 only implementated it
for C++23 and later. I think we should mention that it is a DR but not 
backported yet.
---
 clang/www/cxx_status.html | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 0fc3b1d314698..70490b2e4331f 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -439,8 +439,8 @@ C++23 implementation status
 
 
   Using unknown pointers and references in constant expressions
-  https://wg21.link/P2280R4";>P2280R4
-  Clang 20
+  https://wg21.link/P2280R4";>P2280R4 (DR)
+  Clang 20 (12)
 
 
   static operator()
@@ -510,6 +510,12 @@ C++23 implementation status
   Yes
 
 
+
+
+(12): In Clang 20, this change is not yet retroactively
+applied to pre-C++23 modes.
+
+
 
 
 

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


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++][ranges] P2542R8: Implement `views::concat` (PR #120920)

2025-02-16 Thread A. Jiang via cfe-commits


@@ -0,0 +1,644 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__ranges/zip_view.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+#  ifdef __cpp_pack_indexing
+template 
+using __extract_last _LIBCPP_NODEBUG = _Tp...[sizeof...(_Tp) - 1];
+#  else
+template 
+struct __extract_last_impl : __extract_last_impl<_Tail...> {};
+template 
+struct __extract_last_impl<_Tp> {
+  using type _LIBCPP_NODEBUG = _Tp;
+};
+
+template 
+using __extract_last _LIBCPP_NODEBUG = __extract_last_impl<_Tp...>::type;
+#  endif
+
+template 
+constexpr bool __derived_from_pack =
+__derived_from_pack<_Tp, __extract_last<_Tail...>> && 
__derived_from_pack<_Tail...>;
+
+template 
+constexpr bool __derived_from_pack<_Tp, _IterCategory> = derived_from<_Tp, 
_IterCategory>;
+
+template 
+struct __last_view : __last_view<_Views...> {};
+
+template 
+struct __last_view<_View> {
+  using type = _View;
+};
+
+template 
+concept __concat_indirectly_readable_impl = requires(const _It __it) {
+  { *__it } -> convertible_to<_Ref>;
+  { ranges::iter_move(__it) } -> convertible_to<_RRef>;
+};
+
+template 
+using __concat_reference_t _LIBCPP_NODEBUG = 
common_reference_t...>;
+
+template 
+using __concat_value_t _LIBCPP_NODEBUG = common_type_t...>;
+
+template 
+using __concat_rvalue_reference_t _LIBCPP_NODEBUG = 
common_reference_t...>;
+
+template 
+concept __concat_indirectly_readable =
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...>&> &&
+common_reference_with<__concat_reference_t<_Rs...>&&, 
__concat_rvalue_reference_t<_Rs...>&&> &&
+common_reference_with<__concat_rvalue_reference_t<_Rs...>&&, 
__concat_value_t<_Rs...> const&> &&
+(__concat_indirectly_readable_impl<__concat_reference_t<_Rs...>,
+   __concat_rvalue_reference_t<_Rs...>,
+   iterator_t<_Rs>> &&
+ ...);
+
+template 
+concept __concatable = requires {
+  typename __concat_reference_t<_Rs...>;
+  typename __concat_value_t<_Rs...>;
+  typename __concat_rvalue_reference_t<_Rs...>;
+} && __concat_indirectly_readable<_Rs...>;
+
+template 
+concept __concat_is_random_access =
+(random_access_range<__maybe_const<_Const, _Rs>> && ...) && 
(sized_range<__maybe_const<_Const, _Rs>> && ...);
+
+template 
+concept __concat_is_bidirectional =
+((bidirectional_range<__maybe_const<_Const, _Rs>> && ...) && 
(common_range<__maybe_const<_Const, _Rs>> && ...));
+
+template 
+concept __all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...);
+
+template 
+struct __apply_drop_first;
+
+template 
+struct __apply_drop_first<_Const, _Head, _Tail...> {
+  static constexpr bool value = (sized_range<__maybe_const<_Const, _Tail>> && 
...);
+};
+
+template 
+  requires(view<_Views> && ...) && (sizeof...(_Views) > 0) && 
__concatable<_Views...>
+class concat_view : public view

[clang] [clang-tools-extra] [libcxx] [llvm] [libc++][ranges] P2542R8: Implement `views::concat` (PR #120920)

2025-02-16 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/120920
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >