[flang] [compiler-rt] [lldb] [libc] [openmp] [libcxx] [llvm] [libcxxabi] [clang-tools-extra] [mlir] [lld] [clang] [libc++] Fix `take_view::__sentinel`'s `operator==` (PR #74655)

2023-12-08 Thread Hristo Hristov via cfe-commits


@@ -8,10 +8,7 @@
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17
 
-// sentinel() = default;
-// constexpr explicit sentinel(sentinel_t end);
-// constexpr sentinel(sentinel s)
-//   requires Const && convertible_to, sentinel_t>;
+// constexpr sentinel_t base() const;

Zingam wrote:

Maybe that's already encoded in the parent directory as all other tests use 
just "sentinel" and "iterator"

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


[llvm] [libcxx] [clang] [clang-tools-extra] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 1/2] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(tes

[llvm] [clang-tools-extra] [libcxx] [clang] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 1/3] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(tes

[clang] [llvm] [libcxx] [clang-tools-extra] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 1/4] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(tes

[libcxx] [llvm] [clang-tools-extra] [clang] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 1/5] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26c..b015d7cf1c15b 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 0..2a9ce2baeec1a
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(testCon

[libcxx] [llvm] [clang-tools-extra] [clang] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 1/6] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26c..b015d7cf1c15b 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 0..2a9ce2baeec1a
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(testCon

[libcxx] [llvm] [clang] [clang-tools-extra] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov ready_for_review 
https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang-tools-extra] [clang] [libcxx] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [libcxx] [clang-tools-extra] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits


@@ -41,7 +41,6 @@ void testRuntimeSpan(Span sp, std::size_t idx)
 assert(r1 == r2);
 }
 
-struct A{};

H-G-Hristov wrote:

Yes, I can restore that change. Initially I was looking into reusing op_idx 
tests and I noticed that this declaration is unused.

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


[llvm] [clang] [libcxx] [clang-tools-extra] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits


@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);

H-G-Hristov wrote:

I already renamed the arg as you suggested but in the synopsis both methods 
would be using `idx`
```c++
constexpr reference operator[](size_type idx) const;
constexpr reference at(size_type idx) const;
```
Would it make sense to also rename the arg of `operator[]` for consistency?

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


[clang] [clang-tools-extra] [llvm] [libcxx] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits


@@ -0,0 +1,136 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+constexpr void testSpanAt(auto span, int idx, int expectedValue) {
+  // non-const
+  {
+std::same_as decltype(auto) elem = 
span.at(idx);
+assert(elem == expectedValue);
+  }
+
+  // const
+  {
+std::same_as decltype(auto) elem = 
std::as_const(span).at(idx);
+assert(elem == expectedValue);
+  }
+}
+
+constexpr bool test() {
+  // With static extent
+  {
+std::array arr{0, 1, 2, 3, 4, 5, 9084};
+std::span arrSpan{arr};
+
+assert(std::dynamic_extent != arrSpan.extent);
+
+testSpanAt(arrSpan, 0, 0);
+testSpanAt(arrSpan, 1, 1);
+testSpanAt(arrSpan, 6, 9084);
+  }
+
+  // With dynamic extent
+  {
+std::vector vec{0, 1, 2, 3, 4, 5, 9084};
+std::span vecSpan{vec};
+
+assert(std::dynamic_extent == vecSpan.extent);
+
+testSpanAt(vecSpan, 0, 0);
+testSpanAt(vecSpan, 1, 1);
+testSpanAt(vecSpan, 6, 9084);
+  }
+
+  return true;
+}
+
+void test_exceptions() {
+#ifndef TEST_HAS_NO_EXCEPTIONS
+  // With static extent
+  {
+std::array arr{1, 2, 3, 4};
+const std::span arrSpan{arr};
+
+try {
+  TEST_IGNORE_NODISCARD arrSpan.at(arr.size() + 1);

H-G-Hristov wrote:

C++ Core Guidelines: [ES.48: Avoid 
casts](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es48-avoid-casts)

> Never cast to (void) to ignore a [[nodiscard]]return value. If you 
> deliberately want to discard such a result, first think hard about whether 
> that is really a good idea (there is usually a good reason the author of the 
> function or of the return type used [[nodiscard]] in the first place). If you 
> still think it's appropriate and your code reviewer agrees, use std::ignore = 
> to turn off the warning which is simple, portable, and easy to grep.
Alternatives
...
>- Use std::ignore = to ignore [[nodiscard]] values.

Maybe use `std::ignore` instead?

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


[llvm] [libcxx] [clang] [clang-tools-extra] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [libcxx] [clang] [clang-tools-extra] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [libcxx] [clang] [clang-tools-extra] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits


@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);

H-G-Hristov wrote:

For consistency I changed the implementation to how it is implemented in the 
other methods. Would that be a good compromise?

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


[llvm] [libcxx] [clang] [clang-tools-extra] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libc] [clang-tools-extra] [llvm] [mlir] [libcxx] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 1/7] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(tes

[clang] [libc] [clang-tools-extra] [llvm] [mlir] [libcxx] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-10 Thread Hristo Hristov via cfe-commits


@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {

H-G-Hristov wrote:

@mordante I am not sure what I need to do. My experience with modules is 
minuscule. I think we only need to export global namespace level names and this 
is a class member. Could you please show an example. I couldn't find any.

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


[mlir] [clang-tools-extra] [libc] [libcxx] [clang] [llvm] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-11 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 1/9] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(tes

[llvm] [clang] [clang-tools-extra] [mlir] [libcxx] [libc] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-11 Thread Hristo Hristov via cfe-commits


@@ -0,0 +1,136 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+constexpr void testSpanAt(auto span, int idx, int expectedValue) {
+  // non-const
+  {
+std::same_as decltype(auto) elem = 
span.at(idx);
+assert(elem == expectedValue);
+  }
+
+  // const
+  {
+std::same_as decltype(auto) elem = 
std::as_const(span).at(idx);
+assert(elem == expectedValue);
+  }
+}
+
+constexpr bool test() {
+  // With static extent
+  {
+std::array arr{0, 1, 2, 3, 4, 5, 9084};
+std::span arrSpan{arr};
+
+assert(std::dynamic_extent != arrSpan.extent);
+
+testSpanAt(arrSpan, 0, 0);
+testSpanAt(arrSpan, 1, 1);
+testSpanAt(arrSpan, 6, 9084);
+  }
+
+  // With dynamic extent
+  {
+std::vector vec{0, 1, 2, 3, 4, 5, 9084};
+std::span vecSpan{vec};
+
+assert(std::dynamic_extent == vecSpan.extent);
+
+testSpanAt(vecSpan, 0, 0);
+testSpanAt(vecSpan, 1, 1);
+testSpanAt(vecSpan, 6, 9084);
+  }
+
+  return true;
+}
+
+void test_exceptions() {

H-G-Hristov wrote:

I used `numeric_limits` I hope my change isn't too far off what you mean.

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


[llvm] [clang] [clang-tools-extra] [mlir] [libcxx] [libc] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-11 Thread Hristo Hristov via cfe-commits

H-G-Hristov wrote:

I don't know what is the accepted protocol, who should click  the "Resolve 
conversation" buttons (e.g. the author...), so I'll leave them unclicked.
Thank you for the review!

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


[mlir] [libc] [libcxx] [clang-tools-extra] [llvm] [clang] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-11 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 01/10] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(t

[libcxx] [libc] [clang] [mlir] [llvm] [clang-tools-extra] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-11 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 01/11] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(t

[lldb] [llvm] [libc] [libcxx] [flang] [compiler-rt] [mlir] [clang-tools-extra] [openmp] [clang] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-11 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 01/11] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(t

[compiler-rt] [flang] [clang-tools-extra] [llvm] [libcxx] [clang] [mlir] [lldb] [libc] [openmp] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-11 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 01/12] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(t

[lldb] [llvm] [libc] [libcxx] [flang] [compiler-rt] [mlir] [clang-tools-extra] [openmp] [clang] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-11 Thread Hristo Hristov via cfe-commits


@@ -343,6 +345,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __index) const {
+  if (__index >= size()) {

H-G-Hristov wrote:

Done! Sorry I missed that.

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


[llvm] [libcxx] [mlir] [flang] [clang] [libc] [libc++][memory] P1132R8: out_ptr - a scalable output pointer abstraction (PR #73618)

2023-12-14 Thread Hristo Hristov via cfe-commits


@@ -0,0 +1,97 @@
+// -*- 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___OUT_PTR_H
+#define _LIBCPP___OUT_PTR_H
+
+#include <__config>
+#include <__memory/addressof.h>
+#include <__memory/pointer_traits.h>
+#include <__memory/shared_ptr.h>
+#include <__memory/unique_ptr.h>
+#include <__type_traits/is_specialization.h>
+#include <__type_traits/is_void.h>
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 23
+
+template 
+concept __resettable_adapted_ptr = requires(_Tp __ptr) { __ptr().reset(); };
+
+template 
+class _LIBCPP_TEMPLATE_VIS out_ptr_t {
+  static_assert(!__is_specialization_v<_Smart, shared_ptr> || sizeof...(_Args) 
> 0,
+"Specialization of std::shared_ptr<> requires a deleter.");

H-G-Hristov wrote:

@ldionne After rereading the specs I found this requirements, did we miss them?

![Screenshot 2023-12-14 at 21 20 
25](https://github.com/llvm/llvm-project/assets/47526411/0965ebcc-0633-44a7-badc-5ac37eea97bc)
![Screenshot 2023-12-14 at 21 28 
04](https://github.com/llvm/llvm-project/assets/47526411/76ad1bfc-a4e7-4ed9-9deb-37913f3f0d1b)

My interpretation is that the standard mandates:

```c++
template 
class _LIBCPP_TEMPLATE_VIS out_ptr_t {
  static_assert(!__is_specialization_v<_Smart, shared_ptr> || sizeof...(_Args) 
> 0,
"Specialization of std::shared_ptr<> requires a deleter.");

template 
class _LIBCPP_TEMPLATE_VIS inout_ptr_t {
  static_assert(!__is_specialization_v<_Smart, shared_ptr>, "std::shared_ptr<> 
is not supported");
```
Also implemented similarly in libstdc++ with more clear message than mine: 
https://github.com/gcc-mirror/gcc/blob/95b70545331764c85079a1d0e1e19b605bda1456/libstdc%2B%2B-v3/include/bits/out_ptr.h#L57
https://github.com/gcc-mirror/gcc/blob/95b70545331764c85079a1d0e1e19b605bda1456/libstdc%2B%2B-v3/include/bits/out_ptr.h#L296


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


[llvm] [libcxx] [mlir] [flang] [clang] [libc] [libc++][memory] P1132R8: out_ptr - a scalable output pointer abstraction (PR #73618)

2023-12-14 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/73618
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[openmp] [libc] [compiler-rt] [flang] [mlir] [lldb] [clang-tools-extra] [llvm] [clang] [libcxx] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-16 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 01/14] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(t

[openmp] [libc] [compiler-rt] [flang] [mlir] [lldb] [clang-tools-extra] [llvm] [clang] [libcxx] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-16 Thread Hristo Hristov via cfe-commits




H-G-Hristov wrote:

Thank you for noticing. Somehow what should have been ignored snuck in back 
again.

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


[clang-tools-extra] [libc] [flang] [clang] [openmp] [llvm] [lldb] [mlir] [libcxx] [compiler-rt] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-17 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 01/15] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(t

[clang-tools-extra] [libc] [flang] [clang] [openmp] [llvm] [lldb] [mlir] [libcxx] [compiler-rt] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-17 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 01/15] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(t

[mlir] [lldb] [clang] [flang] [clang-tools-extra] [llvm] [compiler-rt] [openmp] [libc] [libcxx] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-17 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 01/16] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(t

[mlir] [openmp] [libcxx] [compiler-rt] [llvm] [lldb] [libc] [clang] [clang-tools-extra] [flang] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-17 Thread Hristo Hristov via cfe-commits

H-G-Hristov wrote:

> Thanks for the fixes, LGTM!

Thank you!

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


[openmp] [clang-tools-extra] [clang] [libcxx] [libc] [mlir] [llvm] [flang] [lldb] [compiler-rt] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-19 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 01/17] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(t

[flang] [libc] [clang] [mlir] [llvm] [libcxx] [libc++][memory] P1132R8: out_ptr - a scalable output pointer abstraction (PR #73618)

2023-11-30 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/73618

>From 84770c82152f027588dd744bbfb91ed55377e007 Mon Sep 17 00:00:00 2001
From: Hristo Hristov 
Date: Sun, 30 Apr 2023 13:17:20 +0300
Subject: [PATCH 1/4] [libc++][memory] P1132R8: out_ptr - a scalable output
 pointer abstraction

Differential Revision: https://reviews.llvm.org/D150525
---
 libcxx/docs/FeatureTestMacroTable.rst |   2 +-
 libcxx/docs/Status/Cxx23Issues.csv|   4 +-
 libcxx/docs/Status/Cxx23Papers.csv|   2 +-
 libcxx/include/CMakeLists.txt |   2 +
 libcxx/include/__memory/allocator_traits.h|   1 -
 libcxx/include/__memory/inout_ptr.h   | 100 +
 libcxx/include/__memory/out_ptr.h |  97 +
 libcxx/include/__memory/pointer_traits.h  |  67 +-
 libcxx/include/memory |  18 ++
 libcxx/include/module.modulemap.in|   2 +
 libcxx/include/version|   2 +-
 libcxx/modules/std/memory.inc |  10 +-
 .../memory.version.compile.pass.cpp   |  16 +-
 .../version.version.compile.pass.cpp  |  16 +-
 .../inout.ptr/inout.ptr.compile.pass.cpp  |  35 +++
 .../adapt/inout.ptr/inout.ptr.pass.cpp| 205 ++
 .../inout.ptr/inout.ptr.t.compile.pass.cpp|  32 +++
 .../adapt/inout.ptr/inout.ptr.t.verify.cpp|  29 +++
 .../adapt/inout.ptr/inout.ptr.verify.cpp  |  30 +++
 .../adapt/out.ptr/out.ptr.compile.pass.cpp|  34 +++
 .../smartptr/adapt/out.ptr/out.ptr.pass.cpp   | 163 ++
 .../adapt/out.ptr/out.ptr.t.compile.pass.cpp  |  32 +++
 .../adapt/out.ptr/out.ptr.t.verify.cpp|  29 +++
 .../smartptr/adapt/out.ptr/out.ptr.verify.cpp |  30 +++
 .../test/std/utilities/smartptr/adapt/types.h |  77 +++
 .../generate_feature_test_macro_components.py |   1 -
 26 files changed, 999 insertions(+), 37 deletions(-)
 create mode 100644 libcxx/include/__memory/inout_ptr.h
 create mode 100644 libcxx/include/__memory/out_ptr.h
 create mode 100644 
libcxx/test/std/utilities/smartptr/adapt/inout.ptr/inout.ptr.compile.pass.cpp
 create mode 100644 
libcxx/test/std/utilities/smartptr/adapt/inout.ptr/inout.ptr.pass.cpp
 create mode 100644 
libcxx/test/std/utilities/smartptr/adapt/inout.ptr/inout.ptr.t.compile.pass.cpp
 create mode 100644 
libcxx/test/std/utilities/smartptr/adapt/inout.ptr/inout.ptr.t.verify.cpp
 create mode 100644 
libcxx/test/std/utilities/smartptr/adapt/inout.ptr/inout.ptr.verify.cpp
 create mode 100644 
libcxx/test/std/utilities/smartptr/adapt/out.ptr/out.ptr.compile.pass.cpp
 create mode 100644 
libcxx/test/std/utilities/smartptr/adapt/out.ptr/out.ptr.pass.cpp
 create mode 100644 
libcxx/test/std/utilities/smartptr/adapt/out.ptr/out.ptr.t.compile.pass.cpp
 create mode 100644 
libcxx/test/std/utilities/smartptr/adapt/out.ptr/out.ptr.t.verify.cpp
 create mode 100644 
libcxx/test/std/utilities/smartptr/adapt/out.ptr/out.ptr.verify.cpp
 create mode 100644 libcxx/test/std/utilities/smartptr/adapt/types.h

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index d09f65b7cadc0e2..4b2adc70f51740c 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -342,7 +342,7 @@ Status
 --- -
 ``__cpp_lib_optional``  ``202110L``
 --- -
-``__cpp_lib_out_ptr``   *unimplemented*
+``__cpp_lib_out_ptr``   ``202106L``
 --- -
 ``__cpp_lib_print`` *unimplemented*
 --- -
diff --git a/libcxx/docs/Status/Cxx23Issues.csv 
b/libcxx/docs/Status/Cxx23Issues.csv
index b24ecc5525a1497..e5ad365f9ffb877 100644
--- a/libcxx/docs/Status/Cxx23Issues.csv
+++ b/libcxx/docs/Status/Cxx23Issues.csv
@@ -192,7 +192,7 @@
 "`3515 `__","§[stacktrace.basic.nonmem]: 
``operator<<`` should be less templatized", "November 2022","","",""
 "`3545 `__","``std::pointer_traits`` should be 
SFINAE-friendly", "November 2022","|Complete|","18.0",""
 "`3569 `__","``join_view`` fails to support ranges 
of ranges with non-default_initializable iterators", "November 
2022","","","|ranges|"
-"`3594 `__","``inout_ptr`` — inconsistent 
``release()`` in destructor", "November 2022","","",""
+"`3594 `__","``inout_ptr`` — inconsistent 
``release()`` in destructor", "November 2022","|Complete|","17.0",""
 "`3597 `__","Unsigned integer types don't model 
advanceable", "November 2022","","","|ranges|"
 "`3600 `_

[libc] [openmp] [llvm] [mlir] [clang-tools-extra] [lldb] [libcxx] [flang] [clang] [compiler-rt] [libc++][span] P2821R5: `span.at()` (PR #74994)

2023-12-25 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libc] [openmp] [llvm] [mlir] [clang-tools-extra] [lldb] [libcxx] [flang] [lld] [clang] [compiler-rt] [libc++][memory] P1132R8: `out_ptr` - a scalable output pointer abstraction (PR #73618)

2023-12-25 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/73618
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-12-27 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov 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


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

2023-12-28 Thread Hristo Hristov via cfe-commits

https://github.com/Zingam 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


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

2023-12-28 Thread Hristo Hristov via cfe-commits

https://github.com/Zingam 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


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

2023-12-28 Thread Hristo Hristov via cfe-commits

https://github.com/Zingam 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


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

2023-12-29 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov 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


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

2023-12-29 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov 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-tools-extra] [libc] [llvm] [flang] [lldb] [libcxx] [clang] [compiler-rt] [libc++][variant] P2637R3: Member `visit` (`std::variant`) (PR #76447)

2023-12-30 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov 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


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

2023-12-30 Thread Hristo Hristov via cfe-commits


@@ -26,7 +26,7 @@ template 
 void test_call_operator_forwarding() {
   using Fn = ForwardingCallObject;
   Fn obj{};
-  const Fn &cobj = obj;

Zingam wrote:

The reason for reformatting both files is that the CI format check failed for 
nearly every line in the previous commit:
https://github.com/llvm/llvm-project/actions/runs/7362740090/job/20041480045

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


[compiler-rt] [llvm] [libc] [clang] [clang-tools-extra] [flang] [libcxx] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2023-12-31 Thread Hristo Hristov via cfe-commits

H-G-Hristov wrote:

> Thanks for working on this.

Thank you for reviewing!

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


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

2023-12-31 Thread Hristo Hristov via cfe-commits


@@ -26,7 +26,7 @@ template 
 void test_call_operator_forwarding() {
   using Fn = ForwardingCallObject;
   Fn obj{};
-  const Fn &cobj = obj;

H-G-Hristov wrote:

Restored original file and name. But now the tests are not sorted.

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


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

2023-12-31 Thread Hristo Hristov via cfe-commits


@@ -17,27 +17,28 @@
 #include "test_macros.h"
 
 struct Incomplete;
-template struct Holder { T t; };

H-G-Hristov wrote:

Same as above.

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


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

2023-12-31 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov 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


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

2023-12-31 Thread Hristo Hristov via cfe-commits


@@ -0,0 +1,268 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// class variant;
+
+// template
+//   constexpr decltype(auto) visit(this Self&&, Visitor&&); // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+#include "variant_test_helpers.h"
+
+void test_call_operator_forwarding() {
+  using Fn = ForwardingCallObject;
+  Fn obj{};
+  const Fn& cobj = obj;
+
+  { // test call operator forwarding - no variant
+// non-member
+{
+  std::visit(obj);
+  assert(Fn::check_call<>(CT_NonConst | CT_LValue));
+  std::visit(cobj);
+  assert(Fn::check_call<>(CT_Const | CT_LValue));
+  std::visit(std::move(obj));
+  assert(Fn::check_call<>(CT_NonConst | CT_RValue));
+  std::visit(std::move(cobj));
+  assert(Fn::check_call<>(CT_Const | CT_RValue));
+}
+  }
+  { // test call operator forwarding - single variant, single arg
+using V = std::variant;
+V v(42);
+
+v.visit(obj);
+assert(Fn::check_call(CT_NonConst | CT_LValue));
+v.visit(cobj);
+assert(Fn::check_call(CT_Const | CT_LValue));
+v.visit(std::move(obj));
+assert(Fn::check_call(CT_NonConst | CT_RValue));
+v.visit(std::move(cobj));
+assert(Fn::check_call(CT_Const | CT_RValue));
+  }
+  { // test call operator forwarding - single variant, multi arg
+using V = std::variant;
+V v(42L);
+
+v.visit(obj);
+assert(Fn::check_call(CT_NonConst | CT_LValue));
+v.visit(cobj);
+assert(Fn::check_call(CT_Const | CT_LValue));
+v.visit(std::move(obj));
+assert(Fn::check_call(CT_NonConst | CT_RValue));
+v.visit(std::move(cobj));
+assert(Fn::check_call(CT_Const | CT_RValue));
+  }
+}
+
+// Applies to non-member `std::visit` only.
+void test_argument_forwarding() {
+  using Fn = ForwardingCallObject;
+  Fn obj{};
+  const auto val = CT_LValue | CT_NonConst;
+
+  { // single argument - value type
+using V = std::variant;
+V v(42);
+const V& cv = v;
+
+v.visit(obj);
+assert(Fn::check_call(val));
+cv.visit(obj);
+assert(Fn::check_call(val));
+std::move(v).visit(obj);
+assert(Fn::check_call(val));
+std::move(cv).visit(obj);
+assert(Fn::check_call(val));
+  }
+#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
+  { // single argument - lvalue reference
+using V = std::variant;
+int x   = 42;
+V v(x);
+const V& cv = v;
+
+v.visit(obj);
+assert(Fn::check_call(val));
+cv.visit(obj);
+assert(Fn::check_call(val));
+std::move(v).visit(obj);
+assert(Fn::check_call(val));
+std::move(cv).visit(obj);
+assert(Fn::check_call(val));
+assert(false);
+  }
+  { // single argument - rvalue reference
+using V = std::variant;
+int x   = 42;
+V v(std::move(x));
+const V& cv = v;
+
+v.visit(obj);
+assert(Fn::check_call(val));
+cvstd::visit(obj);
+assert(Fn::check_call(val));
+std::move(v).visit(obj);
+assert(Fn::check_call(val));
+std::move(cv).visit(obj);
+assert(Fn::check_call(val));
+  }
+#endif
+}
+
+void test_return_type() {
+  using Fn = ForwardingCallObject;
+  Fn obj{};
+  const Fn& cobj = obj;
+
+  { // test call operator forwarding - single variant, single arg
+using V = std::variant;
+V v(42);
+
+static_assert(std::is_same_v);
+static_assert(std::is_same_v);
+static_assert(std::is_same_v);
+static_assert(std::is_same_v);
+  }
+  { // test call operator forwarding - single variant, multi arg
+using V = std::variant;
+V v(42L);
+
+static_assert(std::is_same_v);
+static_assert(std::is_same_v);
+static_assert(std::is_same_v);
+static_assert(std::is_same_v);
+  }
+}
+
+void test_constexpr() {
+  constexpr ReturnFirst obj{};
+
+  {
+using V = std::variant;
+constexpr V v(42);
+
+static_assert(v.visit(obj) == 42);
+  }
+  {
+using V = std::variant;
+constexpr V v(42L);
+
+static_assert(v.visit(obj) == 42);
+  }
+}
+
+void test_exceptions() {
+#ifndef TEST_HAS_NO_EXCEPTIONS
+  ReturnArity obj{};
+
+  auto test = [&](auto&& v) {
+try {
+  v.visit(obj);
+} catch (const std::bad_variant_access&) {
+  return true;
+} catch (...) {
+}
+return false;
+  };
+
+  {
+using V = std::variant;
+V v;
+makeEmpty(v);
+
+assert(test(v));
+  }
+#endif
+}
+
+// See https://llvm.org/PR31916
+void test_caller_accepts_nonconst() {
+  struct A {};
+  struct Visitor {
+void operator()(A&) {}
+  };
+  std::variant v;
+
+  v.visit(Visitor{});
+}
+
+struct MyVariant : std::variant {};
+
+n

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

2023-12-31 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov 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


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

2023-12-31 Thread Hristo Hristov via cfe-commits

H-G-Hristov wrote:

> Thanks for working on this!

Thank you for reviewing!

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] [lld] [llvm] [flang] [libcxx] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2023-12-31 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/76632

>From 1165b11477ab59122a4db35221fcefe3c9505387 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 30 Dec 2023 17:34:56 +0200
Subject: [PATCH 1/7] [libc++][streams] P1759R6: Native handles and file
 streams

Implements: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1759r6.html

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 59 +++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 33 +++
 .../fstream.version.compile.pass.cpp  | 16 ++---
 .../version.version.compile.pass.cpp  | 16 ++---
 .../generate_feature_test_macro_components.py |  1 -
 10 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index ad12b109023154..0427615a9636fd 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fa60a581652d6a..e6f1adf4d5529b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -58,6 +58,7 @@ Implemented Papers
 - P2870R3 - Remove basic_string::reserve()
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index ff83648aa76830..1d7807a4291a99 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
 "`P1383R2 `__","LWG","More ``constexpr`` for 
 and ","Varna June 2023","","",""
 "`P2734R0 `__","LWG","Adding the new SI 
prefixes","Varna June 2023","|Complete|","17.0",""
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7a4e15b55d56fe..9609ff420220fa 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -73,6 +73,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ifstream();
 explicit basic_ifstream(const char* s, ios_base::openmode mode = 
ios_base::in);
@@ -85,6 +86,7 @@ public:
 void swap(basic_ifstream& rhs);
 
 basic_filebuf* rdbuf() const;
+native_handle_type native_handle() const noexcept; // Since C++26
 bool is_open() const;
 void open(const char* s, ios_base::openmode mode = ios_base::in);
 void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ofstream();
 explicit basic_ofstream(const char* s, ios_base::ope

[clang] [lld] [llvm] [flang] [libcxx] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2023-12-31 Thread Hristo Hristov via cfe-commits


@@ -208,8 +215,34 @@ _LIBCPP_PUSH_MACROS
 
 #if !defined(_LIBCPP_HAS_NO_FILESYSTEM)
 
+#  if defined(_LIBCPP_WIN32API)
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include 
+#include 
+#  endif
+
+// #  include 
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#  if _LIBCPP_STD_VER >= 26
+#if defined(_LIBCPP_WIN32API)
+using __filebuf_native_handle_type = HANDLE;
+_LIBCPP_EXPORTED_FROM_ABI __filebuf_native_handle_type 
__filebuf_windows_native_handle(FILE* __file);
+#else // POSIX
+using __filebuf_native_handle_type = int; // File descriptor
+#endif
+
+_LIBCPP_HIDE_FROM_ABI inline __filebuf_native_handle_type 
__filebuf_native_handle(FILE* __file) noexcept {
+#if defined(_LIBCPP_WIN32API)
+  return __filebuf_windows_native_handle(__file);
+#else
+  return ::fileno(__file);
+#endif
+}
+#  endif
+

H-G-Hristov wrote:

Great tip! Thank you!

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


[clang] [lld] [llvm] [flang] [libcxx] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2023-12-31 Thread Hristo Hristov via cfe-commits


@@ -0,0 +1,36 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+#include <__config>
+#include 
+#include 
+
+#if defined(_LIBCPP_WIN32API)
+#  define WIN32_LEAN_AND_MEAN
+#  define NOMINMAX
+#  include 
+#  include 
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+_LIBCPP_EXPORTED_FROM_ABI __filebuf_native_handle_type 
__filebuf_native_handle(FILE* __file) noexcept {

H-G-Hristov wrote:

Thank you for the tip! It helped me a lot!

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


[libcxx] [llvm] [lld] [flang] [clang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2023-12-31 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/76632

>From 1165b11477ab59122a4db35221fcefe3c9505387 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 30 Dec 2023 17:34:56 +0200
Subject: [PATCH 1/8] [libc++][streams] P1759R6: Native handles and file
 streams

Implements: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1759r6.html

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 59 +++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 33 +++
 .../fstream.version.compile.pass.cpp  | 16 ++---
 .../version.version.compile.pass.cpp  | 16 ++---
 .../generate_feature_test_macro_components.py |  1 -
 10 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index ad12b109023154..0427615a9636fd 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fa60a581652d6a..e6f1adf4d5529b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -58,6 +58,7 @@ Implemented Papers
 - P2870R3 - Remove basic_string::reserve()
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index ff83648aa76830..1d7807a4291a99 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
 "`P1383R2 `__","LWG","More ``constexpr`` for 
 and ","Varna June 2023","","",""
 "`P2734R0 `__","LWG","Adding the new SI 
prefixes","Varna June 2023","|Complete|","17.0",""
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7a4e15b55d56fe..9609ff420220fa 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -73,6 +73,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ifstream();
 explicit basic_ifstream(const char* s, ios_base::openmode mode = 
ios_base::in);
@@ -85,6 +86,7 @@ public:
 void swap(basic_ifstream& rhs);
 
 basic_filebuf* rdbuf() const;
+native_handle_type native_handle() const noexcept; // Since C++26
 bool is_open() const;
 void open(const char* s, ios_base::openmode mode = ios_base::in);
 void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ofstream();
 explicit basic_ofstream(const char* s, ios_base::ope

[libcxx] [flang] [llvm] [lld] [clang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/76632

>From 1165b11477ab59122a4db35221fcefe3c9505387 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 30 Dec 2023 17:34:56 +0200
Subject: [PATCH 1/9] [libc++][streams] P1759R6: Native handles and file
 streams

Implements: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1759r6.html

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 59 +++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 33 +++
 .../fstream.version.compile.pass.cpp  | 16 ++---
 .../version.version.compile.pass.cpp  | 16 ++---
 .../generate_feature_test_macro_components.py |  1 -
 10 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index ad12b109023154..0427615a9636fd 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fa60a581652d6a..e6f1adf4d5529b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -58,6 +58,7 @@ Implemented Papers
 - P2870R3 - Remove basic_string::reserve()
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index ff83648aa76830..1d7807a4291a99 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
 "`P1383R2 `__","LWG","More ``constexpr`` for 
 and ","Varna June 2023","","",""
 "`P2734R0 `__","LWG","Adding the new SI 
prefixes","Varna June 2023","|Complete|","17.0",""
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7a4e15b55d56fe..9609ff420220fa 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -73,6 +73,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ifstream();
 explicit basic_ifstream(const char* s, ios_base::openmode mode = 
ios_base::in);
@@ -85,6 +86,7 @@ public:
 void swap(basic_ifstream& rhs);
 
 basic_filebuf* rdbuf() const;
+native_handle_type native_handle() const noexcept; // Since C++26
 bool is_open() const;
 void open(const char* s, ios_base::openmode mode = ios_base::in);
 void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ofstream();
 explicit basic_ofstream(const char* s, ios_base::ope

[libcxx] [flang] [llvm] [lld] [clang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/76632

>From 1165b11477ab59122a4db35221fcefe3c9505387 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 30 Dec 2023 17:34:56 +0200
Subject: [PATCH 01/10] [libc++][streams] P1759R6: Native handles and file
 streams

Implements: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1759r6.html

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 59 +++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 33 +++
 .../fstream.version.compile.pass.cpp  | 16 ++---
 .../version.version.compile.pass.cpp  | 16 ++---
 .../generate_feature_test_macro_components.py |  1 -
 10 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index ad12b109023154..0427615a9636fd 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fa60a581652d6a..e6f1adf4d5529b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -58,6 +58,7 @@ Implemented Papers
 - P2870R3 - Remove basic_string::reserve()
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index ff83648aa76830..1d7807a4291a99 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
 "`P1383R2 `__","LWG","More ``constexpr`` for 
 and ","Varna June 2023","","",""
 "`P2734R0 `__","LWG","Adding the new SI 
prefixes","Varna June 2023","|Complete|","17.0",""
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7a4e15b55d56fe..9609ff420220fa 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -73,6 +73,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ifstream();
 explicit basic_ifstream(const char* s, ios_base::openmode mode = 
ios_base::in);
@@ -85,6 +86,7 @@ public:
 void swap(basic_ifstream& rhs);
 
 basic_filebuf* rdbuf() const;
+native_handle_type native_handle() const noexcept; // Since C++26
 bool is_open() const;
 void open(const char* s, ios_base::openmode mode = ios_base::in);
 void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ofstream();
 explicit basic_ofstream(const char* s, ios_base::o

[llvm] [libcxx] [flang] [clang] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov 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
+//
+//===--===//
+
+#ifndef TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+#define TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+
+#if _LIBCPP_STD_VER >= 26
+
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+
+#  if defined(_LIBCPP_WIN32API)
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include 
+#include 
+#  else
+#include 
+#  endif
+
+#  include "platform_support.h"
+
+#  if defined(_LIBCPP_WIN32API)
+using HandleT = void*; // HANDLE
+
+bool is_handle_valid([[HandleT handle) {
+  if (LPBY_HANDLE_FILE_INFORMATION & pFileInformation; 
!GetFileInformationByHandle(handle, &lpFileInformation))
+return false;
+  return true;
+};

Zingam wrote:

```suggestion
bool is_handle_valid(void* handle) {
if (BY_HANDLE_FILE_INFORMATION fileInformation; 
!GetFileInformationByHandle(handle, &fileInformation))
return false;
return true;
};
```

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


[llvm] [libcxx] [flang] [clang] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov via cfe-commits

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


[llvm] [libcxx] [flang] [clang] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/Zingam updated 
https://github.com/llvm/llvm-project/pull/76632

>From 1165b11477ab59122a4db35221fcefe3c9505387 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 30 Dec 2023 17:34:56 +0200
Subject: [PATCH 01/11] [libc++][streams] P1759R6: Native handles and file
 streams

Implements: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1759r6.html

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 59 +++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 33 +++
 .../fstream.version.compile.pass.cpp  | 16 ++---
 .../version.version.compile.pass.cpp  | 16 ++---
 .../generate_feature_test_macro_components.py |  1 -
 10 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index ad12b109023154..0427615a9636fd 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fa60a581652d6a..e6f1adf4d5529b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -58,6 +58,7 @@ Implemented Papers
 - P2870R3 - Remove basic_string::reserve()
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index ff83648aa76830..1d7807a4291a99 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
 "`P1383R2 `__","LWG","More ``constexpr`` for 
 and ","Varna June 2023","","",""
 "`P2734R0 `__","LWG","Adding the new SI 
prefixes","Varna June 2023","|Complete|","17.0",""
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7a4e15b55d56fe..9609ff420220fa 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -73,6 +73,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ifstream();
 explicit basic_ifstream(const char* s, ios_base::openmode mode = 
ios_base::in);
@@ -85,6 +86,7 @@ public:
 void swap(basic_ifstream& rhs);
 
 basic_filebuf* rdbuf() const;
+native_handle_type native_handle() const noexcept; // Since C++26
 bool is_open() const;
 void open(const char* s, ios_base::openmode mode = ios_base::in);
 void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ofstream();
 explicit basic_ofstream(const char* s, ios_base::openmo

[llvm] [clang] [lld] [libcxx] [flang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov via cfe-commits


@@ -245,6 +267,18 @@ public:
 #  endif
   _LIBCPP_HIDE_FROM_ABI basic_filebuf* __open(int __fd, ios_base::openmode 
__mode);
   basic_filebuf* close();
+#  if _LIBCPP_STD_VER >= 26
+  _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept {
+_LIBCPP_ASSERT_UNCATEGORIZED(this->is_open(), "File must be opened");

H-G-Hristov wrote:

Can runtime assertions be validated? I couldn't figure it out.

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


[libcxx] [flang] [llvm] [clang] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/76632

>From 1165b11477ab59122a4db35221fcefe3c9505387 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 30 Dec 2023 17:34:56 +0200
Subject: [PATCH 01/12] [libc++][streams] P1759R6: Native handles and file
 streams

Implements: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1759r6.html

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 59 +++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 33 +++
 .../fstream.version.compile.pass.cpp  | 16 ++---
 .../version.version.compile.pass.cpp  | 16 ++---
 .../generate_feature_test_macro_components.py |  1 -
 10 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index ad12b109023154..0427615a9636fd 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fa60a581652d6a..e6f1adf4d5529b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -58,6 +58,7 @@ Implemented Papers
 - P2870R3 - Remove basic_string::reserve()
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index ff83648aa76830..1d7807a4291a99 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
 "`P1383R2 `__","LWG","More ``constexpr`` for 
 and ","Varna June 2023","","",""
 "`P2734R0 `__","LWG","Adding the new SI 
prefixes","Varna June 2023","|Complete|","17.0",""
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7a4e15b55d56fe..9609ff420220fa 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -73,6 +73,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ifstream();
 explicit basic_ifstream(const char* s, ios_base::openmode mode = 
ios_base::in);
@@ -85,6 +86,7 @@ public:
 void swap(basic_ifstream& rhs);
 
 basic_filebuf* rdbuf() const;
+native_handle_type native_handle() const noexcept; // Since C++26
 bool is_open() const;
 void open(const char* s, ios_base::openmode mode = ios_base::in);
 void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ofstream();
 explicit basic_ofstream(const char* s, ios_base::o

[clang] [lld] [flang] [libcxx] [llvm] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/76632

>From 1165b11477ab59122a4db35221fcefe3c9505387 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 30 Dec 2023 17:34:56 +0200
Subject: [PATCH 01/13] [libc++][streams] P1759R6: Native handles and file
 streams

Implements: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1759r6.html

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 59 +++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 33 +++
 .../fstream.version.compile.pass.cpp  | 16 ++---
 .../version.version.compile.pass.cpp  | 16 ++---
 .../generate_feature_test_macro_components.py |  1 -
 10 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index ad12b109023154..0427615a9636fd 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fa60a581652d6a..e6f1adf4d5529b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -58,6 +58,7 @@ Implemented Papers
 - P2870R3 - Remove basic_string::reserve()
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index ff83648aa76830..1d7807a4291a99 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
 "`P1383R2 `__","LWG","More ``constexpr`` for 
 and ","Varna June 2023","","",""
 "`P2734R0 `__","LWG","Adding the new SI 
prefixes","Varna June 2023","|Complete|","17.0",""
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7a4e15b55d56fe..9609ff420220fa 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -73,6 +73,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ifstream();
 explicit basic_ifstream(const char* s, ios_base::openmode mode = 
ios_base::in);
@@ -85,6 +86,7 @@ public:
 void swap(basic_ifstream& rhs);
 
 basic_filebuf* rdbuf() const;
+native_handle_type native_handle() const noexcept; // Since C++26
 bool is_open() const;
 void open(const char* s, ios_base::openmode mode = ios_base::in);
 void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ofstream();
 explicit basic_ofstream(const char* s, ios_base::o

[libcxx] [flang] [clang] [lld] [llvm] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/76632

>From 1165b11477ab59122a4db35221fcefe3c9505387 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 30 Dec 2023 17:34:56 +0200
Subject: [PATCH 01/14] [libc++][streams] P1759R6: Native handles and file
 streams

Implements: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1759r6.html

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 59 +++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 33 +++
 .../fstream.version.compile.pass.cpp  | 16 ++---
 .../version.version.compile.pass.cpp  | 16 ++---
 .../generate_feature_test_macro_components.py |  1 -
 10 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index ad12b109023154..0427615a9636fd 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fa60a581652d6a..e6f1adf4d5529b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -58,6 +58,7 @@ Implemented Papers
 - P2870R3 - Remove basic_string::reserve()
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index ff83648aa76830..1d7807a4291a99 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
 "`P1383R2 `__","LWG","More ``constexpr`` for 
 and ","Varna June 2023","","",""
 "`P2734R0 `__","LWG","Adding the new SI 
prefixes","Varna June 2023","|Complete|","17.0",""
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7a4e15b55d56fe..9609ff420220fa 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -73,6 +73,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ifstream();
 explicit basic_ifstream(const char* s, ios_base::openmode mode = 
ios_base::in);
@@ -85,6 +86,7 @@ public:
 void swap(basic_ifstream& rhs);
 
 basic_filebuf* rdbuf() const;
+native_handle_type native_handle() const noexcept; // Since C++26
 bool is_open() const;
 void open(const char* s, ios_base::openmode mode = ios_base::in);
 void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ofstream();
 explicit basic_ofstream(const char* s, ios_base::o

[flang] [lldb] [libcxx] [clang-tools-extra] [clang] [compiler-rt] [mlir] [libc] [openmp] [llvm] [libc++][span] P2821R5: `span.at()` (PR #74994)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 01/17] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(t

[flang] [lldb] [libcxx] [clang-tools-extra] [clang] [compiler-rt] [mlir] [libc] [openmp] [llvm] [libc++][span] P2821R5: `span.at()` (PR #74994)

2024-01-01 Thread Hristo Hristov via cfe-commits

H-G-Hristov wrote:

@philnik777  a gentle ping 
...and Happy New Year!

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


[libcxx] [lld] [llvm] [clang] [flang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/76632

>From 1165b11477ab59122a4db35221fcefe3c9505387 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 30 Dec 2023 17:34:56 +0200
Subject: [PATCH 01/15] [libc++][streams] P1759R6: Native handles and file
 streams

Implements: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1759r6.html

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 59 +++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 33 +++
 .../fstream.version.compile.pass.cpp  | 16 ++---
 .../version.version.compile.pass.cpp  | 16 ++---
 .../generate_feature_test_macro_components.py |  1 -
 10 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index ad12b109023154..0427615a9636fd 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fa60a581652d6a..e6f1adf4d5529b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -58,6 +58,7 @@ Implemented Papers
 - P2870R3 - Remove basic_string::reserve()
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index ff83648aa76830..1d7807a4291a99 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
 "`P1383R2 `__","LWG","More ``constexpr`` for 
 and ","Varna June 2023","","",""
 "`P2734R0 `__","LWG","Adding the new SI 
prefixes","Varna June 2023","|Complete|","17.0",""
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7a4e15b55d56fe..9609ff420220fa 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -73,6 +73,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ifstream();
 explicit basic_ifstream(const char* s, ios_base::openmode mode = 
ios_base::in);
@@ -85,6 +86,7 @@ public:
 void swap(basic_ifstream& rhs);
 
 basic_filebuf* rdbuf() const;
+native_handle_type native_handle() const noexcept; // Since C++26
 bool is_open() const;
 void open(const char* s, ios_base::openmode mode = ios_base::in);
 void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ofstream();
 explicit basic_ofstream(const char* s, ios_base::o

[lld] [clang] [clang-tools-extra] [libcxx] [compiler-rt] [flang] [llvm] [libc++][ranges] P2116R9: Implements `views::enumerate` (PR #73617)

2024-01-01 Thread Hristo Hristov 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, c++20
+
+// 
+
+// class enumerate_view
+
+// class enumerate_view::sentinel
+
+// template
+//   requires sentinel_for, 
iterator_t>>
+// friend constexpr bool operator==(const iterator& x, const 
sentinel& y);
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_iterators.h"
+#include "../types.h"
+
+template >
+constexpr void test() {
+  using View = MinimalView;
+
+  std::array array{0, 1, 2, 3, 84};
+
+  View v(Iterator(array.begin()), Sentinel(Iterator(array.end(;
+  std::ranges::enumerate_view view(std::move(v));
+
+  auto const it = view.begin();
+  auto const s  = view.end();
+
+  std::same_as decltype(auto) eqItSResult = (it == s);
+  assert(!eqItSResult);
+  std::same_as decltype(auto) eqSItResult = (s == it);
+  assert(!eqSItResult);
+
+  std::same_as decltype(auto) neqItSResult = (it != s);
+  assert(neqItSResult);
+  std::same_as decltype(auto) neqSItResult = (s != it);
+  assert(neqSItResult);
+}
+
+constexpr bool tests() {
+  test>();

H-G-Hristov wrote:

I'll keep this as is for now. If we do the suggested changes, I'll prefer to do 
them after everything else is ironed out.

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


[lld] [clang] [clang-tools-extra] [libcxx] [compiler-rt] [flang] [llvm] [libc++][ranges] P2116R9: Implements `views::enumerate` (PR #73617)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/73617
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [libcxx] [flang] [clang] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov ready_for_review 
https://github.com/llvm/llvm-project/pull/76632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [libcxx] [flang] [clang] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov via cfe-commits

H-G-Hristov wrote:

This test is failing but I have no idea how to fix it:  
@github-actions
Build and Test libc++ / stage3 (generic-no-localization, libcxx-runners-8-set, 
OFF) (pull_request) Failing after 1m

https://github.com/llvm/llvm-project/actions/runs/7377144646/job/20072043476?pr=76632#step:3:1467

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


[llvm] [libcxx] [flang] [clang] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/76632

>From 1165b11477ab59122a4db35221fcefe3c9505387 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 30 Dec 2023 17:34:56 +0200
Subject: [PATCH 01/16] [libc++][streams] P1759R6: Native handles and file
 streams

Implements: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1759r6.html

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 59 +++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 33 +++
 .../fstream.version.compile.pass.cpp  | 16 ++---
 .../version.version.compile.pass.cpp  | 16 ++---
 .../generate_feature_test_macro_components.py |  1 -
 10 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index ad12b109023154..0427615a9636fd 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fa60a581652d6a..e6f1adf4d5529b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -58,6 +58,7 @@ Implemented Papers
 - P2870R3 - Remove basic_string::reserve()
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index ff83648aa76830..1d7807a4291a99 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
 "`P1383R2 `__","LWG","More ``constexpr`` for 
 and ","Varna June 2023","","",""
 "`P2734R0 `__","LWG","Adding the new SI 
prefixes","Varna June 2023","|Complete|","17.0",""
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7a4e15b55d56fe..9609ff420220fa 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -73,6 +73,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ifstream();
 explicit basic_ifstream(const char* s, ios_base::openmode mode = 
ios_base::in);
@@ -85,6 +86,7 @@ public:
 void swap(basic_ifstream& rhs);
 
 basic_filebuf* rdbuf() const;
+native_handle_type native_handle() const noexcept; // Since C++26
 bool is_open() const;
 void open(const char* s, ios_base::openmode mode = ios_base::in);
 void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ofstream();
 explicit basic_ofstream(const char* s, ios_base::o

[lldb] [llvm] [openmp] [libc] [libcxx] [clang-tools-extra] [mlir] [flang] [clang] [compiler-rt] [libc++][span] P2821R5: `span.at()` (PR #74994)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 01/18] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(t

[lldb] [llvm] [openmp] [libc] [libcxx] [clang-tools-extra] [mlir] [flang] [clang] [compiler-rt] [libc++][span] P2821R5: `span.at()` (PR #74994)

2024-01-01 Thread Hristo Hristov via cfe-commits


@@ -0,0 +1,136 @@
+//===--===//
+//
+// 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, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+constexpr void testSpanAt(auto span, int idx, int expectedValue) {
+  // non-const
+  {
+std::same_as decltype(auto) elem = 
span.at(idx);
+assert(elem == expectedValue);
+  }
+
+  // const
+  {
+std::same_as decltype(auto) elem = 
std::as_const(span).at(idx);
+assert(elem == expectedValue);
+  }
+}
+
+constexpr bool test() {
+  // With static extent
+  {
+std::array arr{0, 1, 2, 3, 4, 5, 9084};
+std::span arrSpan{arr};
+
+assert(std::dynamic_extent != arrSpan.extent);
+
+testSpanAt(arrSpan, 0, 0);
+testSpanAt(arrSpan, 1, 1);
+testSpanAt(arrSpan, 6, 9084);
+  }
+
+  // With dynamic extent
+  {
+std::vector vec{0, 1, 2, 3, 4, 5, 9084};
+std::span vecSpan{vec};
+
+assert(std::dynamic_extent == vecSpan.extent);
+
+testSpanAt(vecSpan, 0, 0);
+testSpanAt(vecSpan, 1, 1);
+testSpanAt(vecSpan, 6, 9084);
+  }
+
+  return true;
+}
+
+void test_exceptions() {

H-G-Hristov wrote:

Sorry, I missed your comment!

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


[clang] [llvm] [openmp] [mlir] [libcxx] [libc] [lldb] [compiler-rt] [clang-tools-extra] [flang] [libc++][span] P2821R5: `span.at()` (PR #74994)

2024-01-01 Thread Hristo Hristov via cfe-commits

Zingam wrote:

Thank you very much for the review. I'll wait a few days for addional feedback 
before I land this PR.

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


[flang] [llvm] [libcxx] [lld] [clang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-03 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/76632

>From 1165b11477ab59122a4db35221fcefe3c9505387 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 30 Dec 2023 17:34:56 +0200
Subject: [PATCH 01/17] [libc++][streams] P1759R6: Native handles and file
 streams

Implements: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1759r6.html

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 59 +++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 33 +++
 .../fstream.version.compile.pass.cpp  | 16 ++---
 .../version.version.compile.pass.cpp  | 16 ++---
 .../generate_feature_test_macro_components.py |  1 -
 10 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index ad12b109023154..0427615a9636fd 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fa60a581652d6a..e6f1adf4d5529b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -58,6 +58,7 @@ Implemented Papers
 - P2870R3 - Remove basic_string::reserve()
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index ff83648aa76830..1d7807a4291a99 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
 "`P1383R2 `__","LWG","More ``constexpr`` for 
 and ","Varna June 2023","","",""
 "`P2734R0 `__","LWG","Adding the new SI 
prefixes","Varna June 2023","|Complete|","17.0",""
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7a4e15b55d56fe..9609ff420220fa 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -73,6 +73,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ifstream();
 explicit basic_ifstream(const char* s, ios_base::openmode mode = 
ios_base::in);
@@ -85,6 +86,7 @@ public:
 void swap(basic_ifstream& rhs);
 
 basic_filebuf* rdbuf() const;
+native_handle_type native_handle() const noexcept; // Since C++26
 bool is_open() const;
 void open(const char* s, ios_base::openmode mode = ios_base::in);
 void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ofstream();
 explicit basic_ofstream(const char* s, ios_base::o

[libcxx] [flang] [openmp] [llvm] [lld] [clang] [mlir] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-03 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/76632

>From 1165b11477ab59122a4db35221fcefe3c9505387 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 30 Dec 2023 17:34:56 +0200
Subject: [PATCH 01/18] [libc++][streams] P1759R6: Native handles and file
 streams

Implements: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1759r6.html

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 59 +++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 33 +++
 .../fstream.version.compile.pass.cpp  | 16 ++---
 .../version.version.compile.pass.cpp  | 16 ++---
 .../generate_feature_test_macro_components.py |  1 -
 10 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index ad12b109023154..0427615a9636fd 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fa60a581652d6a..e6f1adf4d5529b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -58,6 +58,7 @@ Implemented Papers
 - P2870R3 - Remove basic_string::reserve()
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index ff83648aa76830..1d7807a4291a99 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
 "`P1383R2 `__","LWG","More ``constexpr`` for 
 and ","Varna June 2023","","",""
 "`P2734R0 `__","LWG","Adding the new SI 
prefixes","Varna June 2023","|Complete|","17.0",""
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7a4e15b55d56fe..9609ff420220fa 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -73,6 +73,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ifstream();
 explicit basic_ifstream(const char* s, ios_base::openmode mode = 
ios_base::in);
@@ -85,6 +86,7 @@ public:
 void swap(basic_ifstream& rhs);
 
 basic_filebuf* rdbuf() const;
+native_handle_type native_handle() const noexcept; // Since C++26
 bool is_open() const;
 void open(const char* s, ios_base::openmode mode = ios_base::in);
 void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ofstream();
 explicit basic_ofstream(const char* s, ios_base::o

[clang-tools-extra] [libc] [lldb] [mlir] [clang] [llvm] [lld] [libcxx] [compiler-rt] [flang] [openmp] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-03 Thread Hristo Hristov via cfe-commits

H-G-Hristov wrote:

> I did a full review. There are a number of comments, once these are addressed 
> the patch is ready.

Thank you for the detailed review and patience! 

I believe the failing tests are unrelated to this patch.

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


[compiler-rt] [libcxx] [openmp] [clang] [llvm] [libc] [flang] [mlir] [lldb] [clang-tools-extra] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-03 Thread Hristo Hristov via cfe-commits


@@ -0,0 +1,101 @@
+//===--===//
+//
+// 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 TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+#define TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 26
+
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+
+#  if defined(_WIN32)
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include 
+#include 
+#  else
+#include 
+#  endif
+
+#  include "check_assertion.h"
+#  include "platform_support.h"
+#  include "types.h"
+
+inline bool is_handle_valid(NativeHandleT handle) {

H-G-Hristov wrote:

I admit this looks ugly :)

Or I could move `if TEST_STD_VER >= 26` right before `#  include 
"check_assertion.h"`, where it is needed:}

```c++
#else
#include 
#endif

#include "test_macros.h"

#if TEST_STD_VER >= 26

#  include "check_assertion.h"
#  include "platform_support.h"
#  include "types.h"

inline bool is_handle_valid(NativeHandleT handle) {
```

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


[compiler-rt] [libcxx] [openmp] [clang] [llvm] [libc] [flang] [mlir] [lldb] [clang-tools-extra] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-03 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/76632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] [lld] [clang-tools-extra] [compiler-rt] [clang] [flang] [llvm] [libc++][ranges] P2116R9: Implements `views::enumerate` (PR #73617)

2024-01-03 Thread Hristo Hristov via cfe-commits


@@ -0,0 +1,333 @@
+// -*- 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_ENUMERATE_VIEW_H
+#define _LIBCPP___RANGES_ENUMERATE_VIEW_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 23
+
+namespace ranges {
+
+// [concept.object]
+
+template 
+concept __range_with_movable_references =
+ranges::input_range<_Rp> && 
std::move_constructible> &&
+std::move_constructible>;
+
+// [range.enumerate.view]
+
+template 
+  requires __range_with_movable_references<_View>
+class enumerate_view : public view_interface> {
+  _View __base_ = _View();
+
+  // [range.enumerate.iterator]
+  template 
+  class __iterator;
+
+  // [range.enumerate.sentinel]
+  template 
+  class __sentinel;
+
+  template 
+  _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto) __get_current(const 
__iterator<_AnyConst>& __iter) {
+return (__iter.__current_);
+  }
+
+public:
+  _LIBCPP_HIDE_FROM_ABI constexpr enumerate_view()
+requires(default_initializable<_View>)
+  = default;
+  _LIBCPP_HIDE_FROM_ABI constexpr explicit enumerate_view(_View __base) : 
__base_(std::move(__base)){};
+
+  _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
+requires(!__simple_view<_View>)
+  {
+return __iterator(ranges::begin(__base_), 0);
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
+requires __range_with_movable_references
+  {
+return __iterator(ranges::begin(__base_), 0);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI constexpr auto end()
+requires(!__simple_view<_View>)
+  {
+if constexpr (common_range<_View> && sized_range<_View>)
+  return __iterator(ranges::end(__base_), 
ranges::distance(__base_));
+else
+  return __sentinel(ranges::end(__base_));
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
+requires __range_with_movable_references
+  {
+if constexpr (common_range && sized_range)
+  return __iterator(ranges::end(__base_), ranges::distance(__base_));
+else
+  return __sentinel(ranges::end(__base_));
+  }
+
+  _LIBCPP_HIDE_FROM_ABI constexpr auto size()
+requires sized_range<_View>
+  {
+return ranges::size(__base_);
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
+requires sized_range
+  {
+return ranges::size(__base_);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
+requires copy_constructible<_View>
+  {
+return __base_;
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); 
}
+};
+
+template 
+enumerate_view(_Range&&) -> enumerate_view>;
+
+// [range.enumerate.iterator]
+
+template 
+  requires __range_with_movable_references<_View>
+template 
+class enumerate_view<_View>::__iterator {
+  using _Base = __maybe_const<_Const, _View>;
+
+  static consteval auto __get_iterator_concept() {
+if constexpr (random_access_range<_Base>) {
+  return random_access_iterator_tag{};
+} else if constexpr (bidirectional_range<_Base>) {
+  return bidirectional_iterator_tag{};
+} else if constexpr (forward_range<_Base>) {
+  return forward_iterator_tag{};
+} else {
+  return input_iterator_tag{};
+}
+  }
+
+  friend class enumerate_view<_View>;
+
+public:
+  using iterator_category = input_iterator_tag;
+  using iterator_concept  = decltype(__get_iterator_concept());
+  using difference_type   = range_difference_t<_Base>;
+  using value_type= tuple>;
+
+private:
+  using __reference_type   = tuple>;
+  iterator_t<_Base> __current_ = iterator_t<_Base>();
+  difference_type __pos_   = 0;
+
+  _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(iterator_t<_Base> 
__current, difference_type __pos)
+  : __current_(std::move(__current)), __pos_(__pos) {}
+
+public:
+  _LIBCPP_HIDE_FROM_ABI __iterator()
+requires(default_initializable>)
+  = default;
+  _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__iterator __i)
+requires _Const && convertible_to, iterator_t<_Base>>
+  : __current_(std::move(__i.__current_)), __pos_(__i.__pos_) {}
+
+  _L

[lldb] [clang] [llvm] [lld] [compiler-rt] [libcxx] [flang] [libc] [clang-tools-extra] [libc++][ranges] P2116R9: Implements `views::enumerate` (PR #73617)

2024-01-04 Thread Hristo Hristov via cfe-commits

H-G-Hristov wrote:

> Thanks for working on this! There's a fair bit that I've provided comments 
> for, but I think you're off to a great start, and I would like to see this 
> merged in January, if at all possible.
> 
> Some comments are short and repetitive: those are usually coupled with a 
> starter comment that explains my perspective, and then I just flag the others 
> as I see them in a (hopefully) non-intrusive way.

Thank you very much for the review!

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


[lld] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [clang] [flang] [libc] [libcxx] [libc++][ranges] P2116R9: Implements `views::enumerate` (PR #73617)

2024-01-04 Thread Hristo Hristov via cfe-commits


@@ -0,0 +1,333 @@
+// -*- 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_ENUMERATE_VIEW_H
+#define _LIBCPP___RANGES_ENUMERATE_VIEW_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 23
+
+namespace ranges {
+
+// [concept.object]
+
+template 
+concept __range_with_movable_references =
+ranges::input_range<_Rp> && 
std::move_constructible> &&
+std::move_constructible>;
+
+// [range.enumerate.view]
+
+template 
+  requires __range_with_movable_references<_View>
+class enumerate_view : public view_interface> {
+  _View __base_ = _View();
+
+  // [range.enumerate.iterator]
+  template 
+  class __iterator;
+
+  // [range.enumerate.sentinel]
+  template 
+  class __sentinel;
+
+  template 
+  _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto) __get_current(const 
__iterator<_AnyConst>& __iter) {
+return (__iter.__current_);
+  }
+
+public:
+  _LIBCPP_HIDE_FROM_ABI constexpr enumerate_view()
+requires(default_initializable<_View>)
+  = default;
+  _LIBCPP_HIDE_FROM_ABI constexpr explicit enumerate_view(_View __base) : 
__base_(std::move(__base)){};
+
+  _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
+requires(!__simple_view<_View>)
+  {
+return __iterator(ranges::begin(__base_), 0);
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
+requires __range_with_movable_references
+  {
+return __iterator(ranges::begin(__base_), 0);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI constexpr auto end()
+requires(!__simple_view<_View>)
+  {
+if constexpr (common_range<_View> && sized_range<_View>)
+  return __iterator(ranges::end(__base_), 
ranges::distance(__base_));
+else
+  return __sentinel(ranges::end(__base_));
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
+requires __range_with_movable_references
+  {
+if constexpr (common_range && sized_range)
+  return __iterator(ranges::end(__base_), ranges::distance(__base_));
+else
+  return __sentinel(ranges::end(__base_));
+  }
+
+  _LIBCPP_HIDE_FROM_ABI constexpr auto size()
+requires sized_range<_View>
+  {
+return ranges::size(__base_);
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
+requires sized_range
+  {
+return ranges::size(__base_);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
+requires copy_constructible<_View>
+  {
+return __base_;
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); 
}
+};
+
+template 
+enumerate_view(_Range&&) -> enumerate_view>;
+
+// [range.enumerate.iterator]
+
+template 
+  requires __range_with_movable_references<_View>
+template 
+class enumerate_view<_View>::__iterator {
+  using _Base = __maybe_const<_Const, _View>;
+
+  static consteval auto __get_iterator_concept() {
+if constexpr (random_access_range<_Base>) {
+  return random_access_iterator_tag{};
+} else if constexpr (bidirectional_range<_Base>) {
+  return bidirectional_iterator_tag{};
+} else if constexpr (forward_range<_Base>) {
+  return forward_iterator_tag{};
+} else {
+  return input_iterator_tag{};
+}
+  }
+
+  friend class enumerate_view<_View>;
+
+public:
+  using iterator_category = input_iterator_tag;
+  using iterator_concept  = decltype(__get_iterator_concept());
+  using difference_type   = range_difference_t<_Base>;
+  using value_type= tuple>;
+
+private:
+  using __reference_type   = tuple>;
+  iterator_t<_Base> __current_ = iterator_t<_Base>();
+  difference_type __pos_   = 0;
+
+  _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(iterator_t<_Base> 
__current, difference_type __pos)
+  : __current_(std::move(__current)), __pos_(__pos) {}
+
+public:
+  _LIBCPP_HIDE_FROM_ABI __iterator()
+requires(default_initializable>)
+  = default;
+  _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__iterator __i)
+requires _Const && convertible_to, iterator_t<_Base>>
+  : __current_(std::move(__i.__current_)), __pos_(__i.__pos_) {}
+
+  _L

[clang] [compiler-rt] [flang] [clang-tools-extra] [libc] [lld] [lldb] [llvm] [libcxx] [libc++][ranges] P2116R9: Implements `views::enumerate` (PR #73617)

2024-01-04 Thread Hristo Hristov via cfe-commits


@@ -0,0 +1,333 @@
+// -*- 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_ENUMERATE_VIEW_H
+#define _LIBCPP___RANGES_ENUMERATE_VIEW_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 23
+
+namespace ranges {
+
+// [concept.object]
+
+template 
+concept __range_with_movable_references =
+ranges::input_range<_Rp> && 
std::move_constructible> &&
+std::move_constructible>;
+
+// [range.enumerate.view]
+
+template 
+  requires __range_with_movable_references<_View>
+class enumerate_view : public view_interface> {
+  _View __base_ = _View();
+
+  // [range.enumerate.iterator]
+  template 
+  class __iterator;
+
+  // [range.enumerate.sentinel]
+  template 
+  class __sentinel;
+
+  template 
+  _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto) __get_current(const 
__iterator<_AnyConst>& __iter) {
+return (__iter.__current_);
+  }
+
+public:
+  _LIBCPP_HIDE_FROM_ABI constexpr enumerate_view()
+requires(default_initializable<_View>)
+  = default;
+  _LIBCPP_HIDE_FROM_ABI constexpr explicit enumerate_view(_View __base) : 
__base_(std::move(__base)){};
+
+  _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
+requires(!__simple_view<_View>)
+  {
+return __iterator(ranges::begin(__base_), 0);
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
+requires __range_with_movable_references
+  {
+return __iterator(ranges::begin(__base_), 0);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI constexpr auto end()
+requires(!__simple_view<_View>)
+  {
+if constexpr (common_range<_View> && sized_range<_View>)
+  return __iterator(ranges::end(__base_), 
ranges::distance(__base_));
+else
+  return __sentinel(ranges::end(__base_));
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
+requires __range_with_movable_references
+  {
+if constexpr (common_range && sized_range)
+  return __iterator(ranges::end(__base_), ranges::distance(__base_));
+else
+  return __sentinel(ranges::end(__base_));
+  }
+
+  _LIBCPP_HIDE_FROM_ABI constexpr auto size()
+requires sized_range<_View>
+  {
+return ranges::size(__base_);
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
+requires sized_range
+  {
+return ranges::size(__base_);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
+requires copy_constructible<_View>
+  {
+return __base_;
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); 
}
+};
+
+template 
+enumerate_view(_Range&&) -> enumerate_view>;
+
+// [range.enumerate.iterator]
+
+template 
+  requires __range_with_movable_references<_View>
+template 
+class enumerate_view<_View>::__iterator {
+  using _Base = __maybe_const<_Const, _View>;
+
+  static consteval auto __get_iterator_concept() {
+if constexpr (random_access_range<_Base>) {
+  return random_access_iterator_tag{};
+} else if constexpr (bidirectional_range<_Base>) {
+  return bidirectional_iterator_tag{};
+} else if constexpr (forward_range<_Base>) {
+  return forward_iterator_tag{};
+} else {
+  return input_iterator_tag{};
+}
+  }
+
+  friend class enumerate_view<_View>;
+
+public:
+  using iterator_category = input_iterator_tag;
+  using iterator_concept  = decltype(__get_iterator_concept());
+  using difference_type   = range_difference_t<_Base>;
+  using value_type= tuple>;
+
+private:
+  using __reference_type   = tuple>;
+  iterator_t<_Base> __current_ = iterator_t<_Base>();
+  difference_type __pos_   = 0;
+
+  _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(iterator_t<_Base> 
__current, difference_type __pos)
+  : __current_(std::move(__current)), __pos_(__pos) {}
+
+public:
+  _LIBCPP_HIDE_FROM_ABI __iterator()
+requires(default_initializable>)
+  = default;
+  _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__iterator __i)
+requires _Const && convertible_to, iterator_t<_Base>>
+  : __current_(std::move(__i.__current_)), __pos_(__i.__pos_) {}
+
+  _L

[flang] [lld] [lldb] [openmp] [compiler-rt] [libc] [mlir] [clang] [clang-tools-extra] [llvm] [libcxx] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-04 Thread Hristo Hristov via cfe-commits


@@ -0,0 +1,97 @@
+//===--===//
+//
+// 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 TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+#define TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#if defined(_WIN32)
+#  include 
+#  include 
+#else
+#  include 
+#endif
+
+#include "platform_support.h"
+#include "test_macros.h"
+#include "types.h"
+
+#if TEST_STD_VER >= 26
+
+#  include "check_assertion.h"
+
+inline bool is_handle_valid(NativeHandleT handle) {
+#  if defined(_WIN32)
+  BY_HANDLE_FILE_INFORMATION fileInformation;
+  return GetFileInformationByHandle(handle, &fileInformation));
+#  elif __has_include() // POSIX
+  return fcntl(handle, F_GETFL) != -1 || errno != EBADF;
+#  else
+#error "Provide a native file handle!"
+#  endif
+}
+
+template 
+inline void test_native_handle() {
+  static_assert(
+  std::is_same_v::native_handle_type, 
typename StreamT::native_handle_type>);
+
+  StreamT f;
+  std::filesystem::path p = get_temp_file_name();
+
+  // non-const
+  {
+f.open(p);
+std::same_as decltype(auto) handle = f.native_handle();
+assert(is_handle_valid(handle));
+assert(f.rdbuf()->native_handle() == handle);
+assert(std::as_const(f).rdbuf()->native_handle() == handle);
+f.close();
+assert(!is_handle_valid(handle));
+static_assert(noexcept(f.native_handle()));
+  }
+  // const
+  {
+f.open(p);
+std::same_as decltype(auto) const_handle = 
std::as_const(f).native_handle();
+assert(is_handle_valid(const_handle));
+assert(f.rdbuf()->native_handle() == const_handle);
+assert(std::as_const(f).rdbuf()->native_handle() == const_handle);
+f.close();
+assert(!is_handle_valid(const_handle));
+static_assert(noexcept(std::as_const(f).native_handle()));
+  }
+}
+
+template 
+inline void test_native_handle_assertion() {
+  StreamT f;
+
+  // non-const
+  { TEST_LIBCPP_ASSERT_FAILURE(f.native_handle(), "File must be opened"); }
+  // const
+  { TEST_LIBCPP_ASSERT_FAILURE(std::as_const(f).native_handle(), "File must be 
opened"); }

Zingam wrote:

```suggestion
  // non-const
  TEST_LIBCPP_ASSERT_FAILURE(f.native_handle(), "File must be opened");
  // const
  TEST_LIBCPP_ASSERT_FAILURE(std::as_const(f).native_handle(), "File must be 
opened");
```

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


[clang] [llvm] [libc] [mlir] [clang-tools-extra] [lldb] [compiler-rt] [openmp] [flang] [libcxx] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-04 Thread Hristo Hristov via cfe-commits

Zingam wrote:

> Thanks LGTM!

Thank you very much for the review!

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


[lldb] [openmp] [compiler-rt] [libcxx] [llvm] [libc] [flang] [clang-tools-extra] [mlir] [clang] [libc++][span] P2821R5: `span.at()` (PR #74994)

2024-01-05 Thread Hristo Hristov via cfe-commits

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


[lldb] [openmp] [compiler-rt] [libcxx] [llvm] [libc] [flang] [lld] [clang-tools-extra] [mlir] [clang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-05 Thread Hristo Hristov via cfe-commits

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


[libcxxabi] [lldb] [compiler-rt] [mlir] [flang] [libc] [clang-tools-extra] [llvm] [libcxx] [lld] [clang] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2024-01-05 Thread Hristo Hristov via cfe-commits

H-G-Hristov wrote:

Just a gentle reminder. You should probably also update the release notes, the 
status page and the feature test macro: `#define __cpp_lib_ranges_contains 
20L // also in `

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


[libc] [clang] [lld] [mlir] [lldb] [compiler-rt] [clang-tools-extra] [llvm] [openmp] [flang] [libcxx] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-06 Thread Hristo Hristov via cfe-commits

Zingam wrote:

> Hi, this change breaks libcxx test on Windows due to unable to find 
> "unistd.h" file (which doesn't exist on msvc based environment).
> 
> Failed test message and failed commandline:
> 
> ```
> 
> Failed Tests (8):
>   llvm-libc++-static-clangcl.cfg.in :: 
> std/input.output/file.streams/fstreams/filebuf.members/native_handle.pass.cpp
>   llvm-libc++-static-clangcl.cfg.in :: 
> std/input.output/file.streams/fstreams/filebuf/types.pass.cpp
>   llvm-libc++-static-clangcl.cfg.in :: 
> std/input.output/file.streams/fstreams/fstream.members/native_handle.pass.cpp
>   llvm-libc++-static-clangcl.cfg.in :: 
> std/input.output/file.streams/fstreams/fstream/types.pass.cpp
>   llvm-libc++-static-clangcl.cfg.in :: 
> std/input.output/file.streams/fstreams/ifstream.members/native_handle.pass.cpp
>   llvm-libc++-static-clangcl.cfg.in :: 
> std/input.output/file.streams/fstreams/ifstream/types.pass.cpp
>   llvm-libc++-static-clangcl.cfg.in :: 
> std/input.output/file.streams/fstreams/ofstream.members/native_handle.pass.cpp
>   llvm-libc++-static-clangcl.cfg.in :: 
> std/input.output/file.streams/fstreams/ofstream/types.pass.cpp
> ```
> 
> ```
> Exit Code: 1
> 
> Command Output (stdout):
> --
> # COMPILED WITH
> C:/b/s/w/ir/x/w/llvm_build/./bin/clang-cl.exe 
> C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\input.output\file.streams\fstreams\filebuf.members\native_handle.pass.cpp
>  --driver-mode=g++ --target=x86_64-pc-windows-msvc -fms-runtime-lib=static 
> -nostdinc++ -I C:/b/s/w/ir/x/w/llvm_build/include/c++/v1 -I 
> C:/b/s/w/ir/x/w/llvm_build/include/x86_64-pc-windows-msvc/c++/v1 -I 
> C:/b/s/w/ir/x/w/llvm-llvm-project/libcxx/test/support 
> -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS 
> -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -std=c++26 -Werror -Wall 
> -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template 
> -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move 
> -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier 
> -Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals 
> -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter 
> -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args 
> -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed 
> -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move 
> -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL 
> -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety 
> -Wuser-defined-warnings  -llibc++experimental -nostdlib -L 
> C:/b/s/w/ir/x/w/llvm_build/./lib/x86_64-pc-windows-msvc -llibc++ -llibcpmt -o 
> C:\b\s\w\ir\x\w\llvm_build\runtimes\runtimes-x86_64-pc-windows-msvc-bins\test\std\input.output\file.streams\fstreams\filebuf.members\Output\native_handle.pass.cpp.dir\t.tmp.exe
> # executed command: C:/b/s/w/ir/x/w/llvm_build/./bin/clang-cl.exe 
> 'C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\input.output\file.streams\fstreams\filebuf.members\native_handle.pass.cpp'
>  --driver-mode=g++ --target=x86_64-pc-windows-msvc -fms-runtime-lib=static 
> -nostdinc++ -I C:/b/s/w/ir/x/w/llvm_build/include/c++/v1 -I 
> C:/b/s/w/ir/x/w/llvm_build/include/x86_64-pc-windows-msvc/c++/v1 -I 
> C:/b/s/w/ir/x/w/llvm-llvm-project/libcxx/test/support 
> -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS 
> -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -std=c++26 -Werror -Wall 
> -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template 
> -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move 
> -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier 
> -Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals 
> -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter 
> -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args 
> -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed 
> -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move 
> -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL 
> -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety 
> -Wuser-defined-warnings -llibc++experimental -nostdlib -L 
> C:/b/s/w/ir/x/w/llvm_build/./lib/x86_64-pc-windows-msvc -llibc++ -llibcpmt -o 
> 'C:\b\s\w\ir\x\w\llvm_build\runtimes\runtimes-x86_64-pc-windows-msvc-bins\test\std\input.output\file.streams\fstreams\filebuf.members\Output\native_handle.pass.cpp.dir\t.tmp.exe'
> # .---command stderr
> # | In file included from 
> C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\input.output\file.streams\fstreams\filebuf.members\native_handle.pass.cpp:24:
> # | In file included from 
> C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\input.output\file.streams\fstreams\filebuf.members\../native_handle_test_helpers.h:33:
> # | 
> C:/b/s/w/ir/x/w/llvm-llvm-project/libcxx/test/support\check_assertion.h:22:10:
>  fatal error: 'unistd.h'

[llvm] [libcxx] [clang] Reapply "[libc++][streams] P1759R6: Native handles and file streams" (PR #77190)

2024-01-06 Thread Hristo Hristov via cfe-commits

https://github.com/Zingam updated 
https://github.com/llvm/llvm-project/pull/77190

>From 1d2c365efe493b4d62cb84a517d00a7d9dbd58b7 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 6 Jan 2024 12:47:23 +0200
Subject: [PATCH 1/2] Revert "Revert "[libc++][streams] P1759R6: Native handles
 and file streams (#76632)""

This reverts commit 40c07b559aa6ab4bac074c943967d3207bc07ae0.
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 50 ++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 37 +++
 .../native_handle.assert.pass.cpp | 32 ++
 .../filebuf.members/native_handle.pass.cpp| 58 +++
 .../fstreams/filebuf/types.pass.cpp   |  9 +-
 .../native_handle.assert.pass.cpp | 32 ++
 .../fstream.members/native_handle.pass.cpp| 27 ++
 .../fstreams/fstream/types.pass.cpp   |  9 +-
 .../native_handle.assert.pass.cpp | 32 ++
 .../ifstream.members/native_handle.pass.cpp   | 27 ++
 .../fstreams/ifstream/types.pass.cpp  |  9 +-
 .../fstreams/native_handle_test_helpers.h | 97 +++
 .../native_handle.assert.pass.cpp | 32 ++
 .../ofstream.members/native_handle.pass.cpp   | 27 ++
 .../fstreams/ofstream/types.pass.cpp  |  9 +-
 .../file.streams/fstreams/types.h | 10 ++
 .../fstream.version.compile.pass.cpp  | 16 +--
 .../version.version.compile.pass.cpp  | 16 +--
 .../generate_feature_test_macro_components.py |  1 -
 24 files changed, 508 insertions(+), 30 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp
 create mode 100644 
libcxx/test/std/input.output/file.streams/fstreams/filebuf.members/native_handle.assert.pass.cpp
 create mode 100644 
libcxx/test/std/input.output/file.streams/fstreams/filebuf.members/native_handle.pass.cpp
 create mode 100644 
libcxx/test/std/input.output/file.streams/fstreams/fstream.members/native_handle.assert.pass.cpp
 create mode 100644 
libcxx/test/std/input.output/file.streams/fstreams/fstream.members/native_handle.pass.cpp
 create mode 100644 
libcxx/test/std/input.output/file.streams/fstreams/ifstream.members/native_handle.assert.pass.cpp
 create mode 100644 
libcxx/test/std/input.output/file.streams/fstreams/ifstream.members/native_handle.pass.cpp
 create mode 100644 
libcxx/test/std/input.output/file.streams/fstreams/native_handle_test_helpers.h
 create mode 100644 
libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/native_handle.assert.pass.cpp
 create mode 100644 
libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/native_handle.pass.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index 8ce5ec9f64ef9a..893a3b13ca06e0 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index cae2347be5fd61..882f53b8d9f83f 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -59,6 +59,7 @@ Implemented Papers
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P2821R5 - span.at()
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index fa4a112d143673..5701717f39766c 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Var

[libcxx] [clang] [llvm] Reapply "[libc++][streams] P1759R6: Native handles and file streams" (PR #77190)

2024-01-06 Thread Hristo Hristov via cfe-commits

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


[clang] [libcxx] [llvm] Reapply "[libc++][streams] P1759R6: Native handles and file streams" (PR #77190)

2024-01-07 Thread Hristo Hristov via cfe-commits

Zingam wrote:

> I test run it with C++26 on Windows, it clears the test failures happened in 
> the original PR.

Thank you!

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


[clang] [libcxx] [llvm] Reapply "[libc++][streams] P1759R6: Native handles and file streams" (PR #77190)

2024-01-07 Thread Hristo Hristov via cfe-commits

Zingam wrote:

I'm relanding this and I'll keep eyes on it here: 
https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-windows-x64

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


[clang] [libcxx] [llvm] Reapply "[libc++][streams] P1759R6: Native handles and file streams" (PR #77190)

2024-01-07 Thread Hristo Hristov via cfe-commits

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


[flang] [llvm] [clang] [clang-tools-extra] [libcxx] [libc] [compiler-rt] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-11 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/76449
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [compiler-rt] [clang-tools-extra] [libc] [flang] [libcxx] [clang] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-11 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/76449
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-01-11 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov 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


[llvm] [flang] [libcxx] [mlir] [clang] [lld] [compiler-rt] [libc] [libc++][complex] P2819R2: Add `tuple` protocol to `complex` (PR #79744)

2024-01-30 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/79744
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >