[libcxx-commits] [libcxx] [libc++] Implement LWG3430 disallow implicit conversion of the source arguments to `std::filesystem::path` when constructing `std::basic_*fstream` (PR #85079)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Apr 5 19:44:47 PDT 2024
https://github.com/yronglin updated https://github.com/llvm/llvm-project/pull/85079
>From 50656d0781b4e516c5475ee0c37d98e85209c54d Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Wed, 13 Mar 2024 21:51:17 +0800
Subject: [PATCH 01/15] [libc++] Implement LWG3430 std::fstream & co. should be
constructible from string_view
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
libcxx/docs/Status/Cxx23Issues.csv | 2 +-
libcxx/include/fstream | 19 ++++++++++---------
.../fstreams/fstream.cons/path.pass.cpp | 7 +++++++
.../fstreams/ifstream.cons/path.pass.cpp | 5 +++++
.../fstreams/ofstream.cons/path.pass.cpp | 5 +++++
5 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/libcxx/docs/Status/Cxx23Issues.csv b/libcxx/docs/Status/Cxx23Issues.csv
index e00345533b865d..87f60fa5278e70 100644
--- a/libcxx/docs/Status/Cxx23Issues.csv
+++ b/libcxx/docs/Status/Cxx23Issues.csv
@@ -64,7 +64,7 @@
`2818 <https://wg21.link/LWG2818>`__,"``::std::`` everywhere rule needs tweaking","June 2021","|Nothing To Do|",""
`2997 <https://wg21.link/LWG2997>`__,"LWG 491 and the specification of ``{forward_,}list::unique``","June 2021","",""
`3410 <https://wg21.link/LWG3410>`__,"``lexicographical_compare_three_way`` is overspecified","June 2021","|Complete|","17.0","|spaceship|"
-`3430 <https://wg21.link/LWG3430>`__,"``std::fstream`` & co. should be constructible from string_view","June 2021","",""
+`3430 <https://wg21.link/LWG3430>`__,"``std::fstream`` & co. should be constructible from string_view","June 2021","|Complete|","19.0",""
`3462 <https://wg21.link/LWG3462>`__,"ยง[formatter.requirements]: Formatter requirements forbid use of ``fc.arg()``","June 2021","|Nothing To Do|","","|format|"
`3481 <https://wg21.link/LWG3481>`__,"``viewable_range`` mishandles lvalue move-only views","June 2021","Superseded by `P2415R2 <https://wg21.link/P2415R2>`__","","|ranges|"
`3506 <https://wg21.link/LWG3506>`__,"Missing allocator-extended constructors for ``priority_queue``","June 2021","|Complete|","14.0"
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 776641b347e6c1..5932a42e1b5392 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -78,8 +78,7 @@ public:
basic_ifstream();
explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in);
explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in);
- explicit basic_ifstream(const filesystem::path& p,
- ios_base::openmode mode = ios_base::in); // C++17
+ template<class T> explicit basic_ifstream(const T& s, ios_base::openmode mode = ios_base::in); // Since C++17
basic_ifstream(basic_ifstream&& rhs);
basic_ifstream& operator=(basic_ifstream&& rhs);
@@ -117,8 +116,7 @@ public:
basic_ofstream();
explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out);
- explicit basic_ofstream(const filesystem::path& p,
- ios_base::openmode mode = ios_base::out); // C++17
+ template<class T> explicit basic_ofstream(const T& s, ios_base::openmode mode = ios_base::out); // Since C++17
basic_ofstream(basic_ofstream&& rhs);
basic_ofstream& operator=(basic_ofstream&& rhs);
@@ -158,8 +156,8 @@ public:
basic_fstream();
explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
- explicit basic_fstream(const filesystem::path& p,
- ios_base::openmode mode = ios_base::in|ios_base::out); C++17
+ template<class T>
+ explicit basic_fstream(const T& s, ios_base::openmode mode = ios_base::in | ios_base::out); // Since C++17
basic_fstream(basic_fstream&& rhs);
basic_fstream& operator=(basic_fstream&& rhs);
@@ -1043,8 +1041,9 @@ public:
# endif
_LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
# if _LIBCPP_STD_VER >= 17
+ template <class _Tp, std::enable_if_t<std::is_same_v<_Tp, std::filesystem::path>>* = nullptr>
_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(
- const filesystem::path& __p, ios_base::openmode __mode = ios_base::in)
+ const _Tp& __p, ios_base::openmode __mode = ios_base::in)
: basic_ifstream(__p.c_str(), __mode) {}
# endif // _LIBCPP_STD_VER >= 17
_LIBCPP_HIDE_FROM_ABI basic_ifstream(basic_ifstream&& __rhs);
@@ -1197,8 +1196,9 @@ public:
_LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
# if _LIBCPP_STD_VER >= 17
+ template <class _Tp, std::enable_if_t<std::is_same_v<_Tp, std::filesystem::path>>* = nullptr>
_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(
- const filesystem::path& __p, ios_base::openmode __mode = ios_base::out)
+ const _Tp& __p, ios_base::openmode __mode = ios_base::out)
: basic_ofstream(__p.c_str(), __mode) {}
# endif // _LIBCPP_STD_VER >= 17
@@ -1356,8 +1356,9 @@ public:
ios_base::openmode __mode = ios_base::in | ios_base::out);
# if _LIBCPP_STD_VER >= 17
+ template <class _Tp, std::enable_if_t<std::is_same_v<_Tp, std::filesystem::path>>* = nullptr>
_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(
- const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out)
+ const _Tp& __p, ios_base::openmode __mode = ios_base::in | ios_base::out)
: basic_fstream(__p.c_str(), __mode) {}
# endif // _LIBCPP_STD_VER >= 17
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
index bc75d04740da02..e0e211b4478a7d 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
@@ -21,11 +21,18 @@
#include <fstream>
#include <filesystem>
#include <cassert>
+#include <type_traits>
+
#include "test_macros.h"
#include "platform_support.h"
namespace fs = std::filesystem;
+struct fake_path {};
+
+static_assert(std::is_constructible_v<std::fstream, fs::path>);
+static_assert(!std::is_constructible_v<std::fstream, fake_path>);
+
int main(int, char**) {
fs::path p = get_temp_file_name();
{
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
index cfbb8419fe1c5b..72030c2983e4b3 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
@@ -29,6 +29,11 @@
namespace fs = std::filesystem;
+struct fake_path {};
+
+static_assert(std::is_constructible_v<std::ifstream, fs::path>);
+static_assert(!std::is_constructible_v<std::ifstream, fake_path>);
+
int main(int, char**) {
{
fs::path p;
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
index 316ed776a48b54..01c90f326a130b 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
@@ -27,6 +27,11 @@
namespace fs = std::filesystem;
+struct fake_path {};
+
+static_assert(std::is_constructible_v<std::ofstream, fs::path>);
+static_assert(!std::is_constructible_v<std::ofstream, fake_path>);
+
int main(int, char**) {
fs::path p = get_temp_file_name();
{
>From 5e995e9bd13a9cace6df3c519c0041c584763af4 Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Thu, 14 Mar 2024 21:18:58 +0800
Subject: [PATCH 02/15] [libc++] Refine test cases
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
.../fstreams/fstream.cons/path.pass.cpp | 32 ++++++++++++++++--
.../fstreams/ifstream.cons/path.pass.cpp | 33 +++++++++++++++++--
.../fstreams/ofstream.cons/path.pass.cpp | 32 ++++++++++++++++--
3 files changed, 88 insertions(+), 9 deletions(-)
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
index e0e211b4478a7d..bc2d85ec1b0bfd 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
@@ -24,14 +24,40 @@
#include <type_traits>
#include "test_macros.h"
+#include "test_iterators.h"
#include "platform_support.h"
namespace fs = std::filesystem;
-struct fake_path {};
+template <class CharT>
+constexpr bool test_non_convert_to_path() {
-static_assert(std::is_constructible_v<std::fstream, fs::path>);
-static_assert(!std::is_constructible_v<std::fstream, fake_path>);
+ // String types
+ static_assert(!std::is_constructible_v<std::fstream, std::basic_string_view<CharT>>);
+ static_assert(!std::is_constructible_v<std::fstream, const std::basic_string_view<CharT>>);
+
+ // Char* pointers
+ if constexpr (!std::is_same_v<CharT, char>)
+ static_assert(!std::is_constructible_v<std::fstream, const CharT *>);
+
+ // Iterators
+ static_assert(!std::is_convertible_v<std::fstream, cpp17_input_iterator<const CharT *>>);
+
+ return true;
+}
+
+static_assert(test_non_convert_to_path<char>());
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(test_non_convert_to_path<wchar_t>());
+#endif // TEST_HAS_NO_WIDE_CHARACTERS
+
+#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
+static_assert(test_non_convert_to_path<char8_t>());
+#endif // TEST_STD_VER > 17 && defined(__cpp_char8_t)
+
+static_assert(test_non_convert_to_path<char16_t>());
+static_assert(test_non_convert_to_path<char32_t>());
int main(int, char**) {
fs::path p = get_temp_file_name();
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
index 72030c2983e4b3..41a0e4a1ada9fc 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
@@ -26,13 +26,40 @@
#include <type_traits>
#include "test_macros.h"
+#include "test_iterators.h"
namespace fs = std::filesystem;
-struct fake_path {};
+template <class CharT>
+constexpr bool test_non_convert_to_path() {
+
+ // String types
+ static_assert(!std::is_constructible_v<std::ifstream, std::basic_string_view<CharT>>);
+ static_assert(!std::is_constructible_v<std::ifstream, const std::basic_string_view<CharT>>);
+
+ // Char* pointers
+ if constexpr (!std::is_same_v<CharT, char>)
+ static_assert(!std::is_constructible_v<std::ifstream, const CharT *>);
+
+ // Iterators
+ static_assert(!std::is_convertible_v<std::ifstream, cpp17_input_iterator<const CharT *>>);
+
+ return true;
+}
+
+static_assert(test_non_convert_to_path<char>());
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(test_non_convert_to_path<wchar_t>());
+#endif // TEST_HAS_NO_WIDE_CHARACTERS
+
+#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
+static_assert(test_non_convert_to_path<char8_t>());
+#endif // TEST_STD_VER > 17 && defined(__cpp_char8_t)
+
+static_assert(test_non_convert_to_path<char16_t>());
+static_assert(test_non_convert_to_path<char32_t>());
-static_assert(std::is_constructible_v<std::ifstream, fs::path>);
-static_assert(!std::is_constructible_v<std::ifstream, fake_path>);
int main(int, char**) {
{
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
index 01c90f326a130b..a07e10721be8f4 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
@@ -24,13 +24,39 @@
#include "platform_support.h"
#include "test_macros.h"
+#include "test_iterators.h"
namespace fs = std::filesystem;
-struct fake_path {};
+template <class CharT>
+constexpr bool test_non_convert_to_path() {
-static_assert(std::is_constructible_v<std::ofstream, fs::path>);
-static_assert(!std::is_constructible_v<std::ofstream, fake_path>);
+ // String types
+ static_assert(!std::is_constructible_v<std::ofstream, std::basic_string_view<CharT>>);
+ static_assert(!std::is_constructible_v<std::ofstream, const std::basic_string_view<CharT>>);
+
+ // Char* pointers
+ if constexpr (!std::is_same_v<CharT, char>)
+ static_assert(!std::is_constructible_v<std::ofstream, const CharT *>);
+
+ // Iterators
+ static_assert(!std::is_convertible_v<std::ofstream, cpp17_input_iterator<const CharT *>>);
+
+ return true;
+}
+
+static_assert(test_non_convert_to_path<char>());
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(test_non_convert_to_path<wchar_t>());
+#endif // TEST_HAS_NO_WIDE_CHARACTERS
+
+#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
+static_assert(test_non_convert_to_path<char8_t>());
+#endif // TEST_STD_VER > 17 && defined(__cpp_char8_t)
+
+static_assert(test_non_convert_to_path<char16_t>());
+static_assert(test_non_convert_to_path<char32_t>());
int main(int, char**) {
fs::path p = get_temp_file_name();
>From 3090674b463dcc5e3ae31e9fcccdb5ac361781c2 Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Thu, 14 Mar 2024 21:26:16 +0800
Subject: [PATCH 03/15] format
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
.../file.streams/fstreams/fstream.cons/path.pass.cpp | 5 ++---
.../file.streams/fstreams/ifstream.cons/path.pass.cpp | 6 ++----
.../file.streams/fstreams/ofstream.cons/path.pass.cpp | 5 ++---
3 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
index bc2d85ec1b0bfd..a787b921a4bf4e 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
@@ -31,17 +31,16 @@ namespace fs = std::filesystem;
template <class CharT>
constexpr bool test_non_convert_to_path() {
-
// String types
static_assert(!std::is_constructible_v<std::fstream, std::basic_string_view<CharT>>);
static_assert(!std::is_constructible_v<std::fstream, const std::basic_string_view<CharT>>);
// Char* pointers
if constexpr (!std::is_same_v<CharT, char>)
- static_assert(!std::is_constructible_v<std::fstream, const CharT *>);
+ static_assert(!std::is_constructible_v<std::fstream, const CharT*>);
// Iterators
- static_assert(!std::is_convertible_v<std::fstream, cpp17_input_iterator<const CharT *>>);
+ static_assert(!std::is_convertible_v<std::fstream, cpp17_input_iterator<const CharT*>>);
return true;
}
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
index 41a0e4a1ada9fc..8d81ec3191dd64 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
@@ -32,17 +32,16 @@ namespace fs = std::filesystem;
template <class CharT>
constexpr bool test_non_convert_to_path() {
-
// String types
static_assert(!std::is_constructible_v<std::ifstream, std::basic_string_view<CharT>>);
static_assert(!std::is_constructible_v<std::ifstream, const std::basic_string_view<CharT>>);
// Char* pointers
if constexpr (!std::is_same_v<CharT, char>)
- static_assert(!std::is_constructible_v<std::ifstream, const CharT *>);
+ static_assert(!std::is_constructible_v<std::ifstream, const CharT*>);
// Iterators
- static_assert(!std::is_convertible_v<std::ifstream, cpp17_input_iterator<const CharT *>>);
+ static_assert(!std::is_convertible_v<std::ifstream, cpp17_input_iterator<const CharT*>>);
return true;
}
@@ -60,7 +59,6 @@ static_assert(test_non_convert_to_path<char8_t>());
static_assert(test_non_convert_to_path<char16_t>());
static_assert(test_non_convert_to_path<char32_t>());
-
int main(int, char**) {
{
fs::path p;
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
index a07e10721be8f4..d7da92f9a41d57 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
@@ -30,17 +30,16 @@ namespace fs = std::filesystem;
template <class CharT>
constexpr bool test_non_convert_to_path() {
-
// String types
static_assert(!std::is_constructible_v<std::ofstream, std::basic_string_view<CharT>>);
static_assert(!std::is_constructible_v<std::ofstream, const std::basic_string_view<CharT>>);
// Char* pointers
if constexpr (!std::is_same_v<CharT, char>)
- static_assert(!std::is_constructible_v<std::ofstream, const CharT *>);
+ static_assert(!std::is_constructible_v<std::ofstream, const CharT*>);
// Iterators
- static_assert(!std::is_convertible_v<std::ofstream, cpp17_input_iterator<const CharT *>>);
+ static_assert(!std::is_convertible_v<std::ofstream, cpp17_input_iterator<const CharT*>>);
return true;
}
>From 0116f4a9f08f849ece3487db713a381262008e1e Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Fri, 15 Mar 2024 01:30:12 +0800
Subject: [PATCH 04/15] Fix test
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
.../file.streams/fstreams/fstream.cons/path.pass.cpp | 4 ++--
.../file.streams/fstreams/ifstream.cons/path.pass.cpp | 4 ++--
.../file.streams/fstreams/ofstream.cons/path.pass.cpp | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
index a787b921a4bf4e..548768fe599469 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
@@ -47,9 +47,9 @@ constexpr bool test_non_convert_to_path() {
static_assert(test_non_convert_to_path<char>());
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+#if !defined(TEST_HAS_NO_WIDE_CHARACTERS) && defined(_LIBCPP_HAS_OPEN_WITH_WCHAR)
static_assert(test_non_convert_to_path<wchar_t>());
-#endif // TEST_HAS_NO_WIDE_CHARACTERS
+#endif // !TEST_HAS_NO_WIDE_CHARACTERS && _LIBCPP_HAS_OPEN_WITH_WCHAR
#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
static_assert(test_non_convert_to_path<char8_t>());
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
index 8d81ec3191dd64..83e0ab0a2f0773 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
@@ -48,9 +48,9 @@ constexpr bool test_non_convert_to_path() {
static_assert(test_non_convert_to_path<char>());
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+#if !defined(TEST_HAS_NO_WIDE_CHARACTERS) && defined(_LIBCPP_HAS_OPEN_WITH_WCHAR)
static_assert(test_non_convert_to_path<wchar_t>());
-#endif // TEST_HAS_NO_WIDE_CHARACTERS
+#endif // !TEST_HAS_NO_WIDE_CHARACTERS && _LIBCPP_HAS_OPEN_WITH_WCHAR
#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
static_assert(test_non_convert_to_path<char8_t>());
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
index d7da92f9a41d57..ab8054bcae4bf2 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
@@ -46,9 +46,9 @@ constexpr bool test_non_convert_to_path() {
static_assert(test_non_convert_to_path<char>());
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+#if !defined(TEST_HAS_NO_WIDE_CHARACTERS) && defined(_LIBCPP_HAS_OPEN_WITH_WCHAR)
static_assert(test_non_convert_to_path<wchar_t>());
-#endif // TEST_HAS_NO_WIDE_CHARACTERS
+#endif // !TEST_HAS_NO_WIDE_CHARACTERS && _LIBCPP_HAS_OPEN_WITH_WCHAR
#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
static_assert(test_non_convert_to_path<char8_t>());
>From af8585830582ae4199691231ebbb7410d63228d2 Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Fri, 15 Mar 2024 19:08:36 +0800
Subject: [PATCH 05/15] Fix test
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
.../file.streams/fstreams/fstream.cons/path.pass.cpp | 4 ++--
.../file.streams/fstreams/ifstream.cons/path.pass.cpp | 4 ++--
.../file.streams/fstreams/ofstream.cons/path.pass.cpp | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
index 548768fe599469..0445996fe38b96 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
@@ -47,9 +47,9 @@ constexpr bool test_non_convert_to_path() {
static_assert(test_non_convert_to_path<char>());
-#if !defined(TEST_HAS_NO_WIDE_CHARACTERS) && defined(_LIBCPP_HAS_OPEN_WITH_WCHAR)
+#if !defined(TEST_HAS_NO_WIDE_CHARACTERS) && !defined(_LIBCPP_HAS_OPEN_WITH_WCHAR)
static_assert(test_non_convert_to_path<wchar_t>());
-#endif // !TEST_HAS_NO_WIDE_CHARACTERS && _LIBCPP_HAS_OPEN_WITH_WCHAR
+#endif // !TEST_HAS_NO_WIDE_CHARACTERS && !_LIBCPP_HAS_OPEN_WITH_WCHAR
#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
static_assert(test_non_convert_to_path<char8_t>());
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
index 83e0ab0a2f0773..45770fe34e5aa9 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
@@ -48,9 +48,9 @@ constexpr bool test_non_convert_to_path() {
static_assert(test_non_convert_to_path<char>());
-#if !defined(TEST_HAS_NO_WIDE_CHARACTERS) && defined(_LIBCPP_HAS_OPEN_WITH_WCHAR)
+#if !defined(TEST_HAS_NO_WIDE_CHARACTERS) && !defined(_LIBCPP_HAS_OPEN_WITH_WCHAR)
static_assert(test_non_convert_to_path<wchar_t>());
-#endif // !TEST_HAS_NO_WIDE_CHARACTERS && _LIBCPP_HAS_OPEN_WITH_WCHAR
+#endif // !TEST_HAS_NO_WIDE_CHARACTERS && !_LIBCPP_HAS_OPEN_WITH_WCHAR
#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
static_assert(test_non_convert_to_path<char8_t>());
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
index ab8054bcae4bf2..a2a0f1808ae877 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
@@ -46,9 +46,9 @@ constexpr bool test_non_convert_to_path() {
static_assert(test_non_convert_to_path<char>());
-#if !defined(TEST_HAS_NO_WIDE_CHARACTERS) && defined(_LIBCPP_HAS_OPEN_WITH_WCHAR)
+#if !defined(TEST_HAS_NO_WIDE_CHARACTERS) && !defined(_LIBCPP_HAS_OPEN_WITH_WCHAR)
static_assert(test_non_convert_to_path<wchar_t>());
-#endif // !TEST_HAS_NO_WIDE_CHARACTERS && _LIBCPP_HAS_OPEN_WITH_WCHAR
+#endif // !TEST_HAS_NO_WIDE_CHARACTERS && !_LIBCPP_HAS_OPEN_WITH_WCHAR
#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
static_assert(test_non_convert_to_path<char8_t>());
>From 44b09c56c7bc04d7a8e06effc249382f49cd62fa Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Fri, 15 Mar 2024 21:05:22 +0800
Subject: [PATCH 06/15] Refine code
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
libcxx/include/fstream | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 5932a42e1b5392..82e225ac77e384 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -1041,7 +1041,7 @@ public:
# endif
_LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
# if _LIBCPP_STD_VER >= 17
- template <class _Tp, std::enable_if_t<std::is_same_v<_Tp, std::filesystem::path>>* = nullptr>
+ template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>>
_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(
const _Tp& __p, ios_base::openmode __mode = ios_base::in)
: basic_ifstream(__p.c_str(), __mode) {}
@@ -1196,7 +1196,7 @@ public:
_LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
# if _LIBCPP_STD_VER >= 17
- template <class _Tp, std::enable_if_t<std::is_same_v<_Tp, std::filesystem::path>>* = nullptr>
+ template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>>
_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(
const _Tp& __p, ios_base::openmode __mode = ios_base::out)
: basic_ofstream(__p.c_str(), __mode) {}
@@ -1356,7 +1356,7 @@ public:
ios_base::openmode __mode = ios_base::in | ios_base::out);
# if _LIBCPP_STD_VER >= 17
- template <class _Tp, std::enable_if_t<std::is_same_v<_Tp, std::filesystem::path>>* = nullptr>
+ template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>>
_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(
const _Tp& __p, ios_base::openmode __mode = ios_base::in | ios_base::out)
: basic_fstream(__p.c_str(), __mode) {}
>From eca56754a3a64f09a98ff80a0f5c775206a3e830 Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Sun, 17 Mar 2024 23:24:38 +0800
Subject: [PATCH 07/15] Address review comments and add release notes
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
libcxx/docs/ReleaseNotes/19.rst | 2 +-
libcxx/include/fstream | 8 ++++++--
.../file.streams/fstreams/fstream.cons/path.pass.cpp | 9 +++++----
.../file.streams/fstreams/ifstream.cons/path.pass.cpp | 9 +++++----
.../file.streams/fstreams/ofstream.cons/path.pass.cpp | 8 +++++---
5 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index 2b62a36ca8e5cd..fb5ab83c740c8f 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -97,7 +97,7 @@ TODO
ABI Affecting Changes
---------------------
-TODO
+ - LWG3430: Disallow implicit conversion of the source arguments to ``std::filesystem::path`` when constructing ``std::basic_*fstream``
Build System Changes
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 9d8bb617cb1243..7128f72e161193 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -78,7 +78,8 @@ public:
basic_ifstream();
explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in);
explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in);
- template<class T> explicit basic_ifstream(const T& s, ios_base::openmode mode = ios_base::in); // Since C++17
+ template<class T>
+ explicit basic_ifstream(const T& s, ios_base::openmode mode = ios_base::in); // Since C++17
basic_ifstream(basic_ifstream&& rhs);
basic_ifstream& operator=(basic_ifstream&& rhs);
@@ -116,7 +117,8 @@ public:
basic_ofstream();
explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out);
- template<class T> explicit basic_ofstream(const T& s, ios_base::openmode mode = ios_base::out); // Since C++17
+ template<class T>
+ explicit basic_ofstream(const T& s, ios_base::openmode mode = ios_base::out); // Since C++17
basic_ofstream(basic_ofstream&& rhs);
basic_ofstream& operator=(basic_ofstream&& rhs);
@@ -190,6 +192,8 @@ typedef basic_fstream<wchar_t> wfstream;
#include <__config>
#include <__fwd/fstream.h>
#include <__locale>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_same.h>
#include <__utility/move.h>
#include <__utility/swap.h>
#include <__utility/unreachable.h>
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
index 0445996fe38b96..30f4fc8720a51d 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
@@ -15,8 +15,9 @@
// plate <class charT, class traits = char_traits<charT> >
// class basic_fstream
-// explicit basic_fstream(const filesystem::path& s,
-// ios_base::openmode mode = ios_base::in|ios_base::out);
+// template<class T>
+// explicit basic_fstream(const T& s, ios_base::openmode mode = ios_base::in); // Since C++17
+// Constraints: is_same_v<T, filesystem::path> is true
#include <fstream>
#include <filesystem>
@@ -51,9 +52,9 @@ static_assert(test_non_convert_to_path<char>());
static_assert(test_non_convert_to_path<wchar_t>());
#endif // !TEST_HAS_NO_WIDE_CHARACTERS && !_LIBCPP_HAS_OPEN_WITH_WCHAR
-#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
+#ifndef TEST_HAS_NO_CHAR8_T
static_assert(test_non_convert_to_path<char8_t>());
-#endif // TEST_STD_VER > 17 && defined(__cpp_char8_t)
+#endif // TEST_HAS_NO_CHAR8_T
static_assert(test_non_convert_to_path<char16_t>());
static_assert(test_non_convert_to_path<char32_t>());
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
index 45770fe34e5aa9..73f0b0c2379f0f 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
@@ -17,8 +17,9 @@
// template <class charT, class traits = char_traits<charT> >
// class basic_ifstream
-// explicit basic_ifstream(const filesystem::path& s,
-// ios_base::openmode mode = ios_base::in);
+// template<class T>
+// explicit basic_ifstream(const T& s, ios_base::openmode mode = ios_base::in); // Since C++17
+// Constraints: is_same_v<T, filesystem::path> is true
#include <cassert>
#include <filesystem>
@@ -52,9 +53,9 @@ static_assert(test_non_convert_to_path<char>());
static_assert(test_non_convert_to_path<wchar_t>());
#endif // !TEST_HAS_NO_WIDE_CHARACTERS && !_LIBCPP_HAS_OPEN_WITH_WCHAR
-#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
+#ifndef TEST_HAS_NO_CHAR8_T
static_assert(test_non_convert_to_path<char8_t>());
-#endif // TEST_STD_VER > 17 && defined(__cpp_char8_t)
+#endif // TEST_HAS_NO_CHAR8_T
static_assert(test_non_convert_to_path<char16_t>());
static_assert(test_non_convert_to_path<char32_t>());
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
index a2a0f1808ae877..10bcc9b7b175d7 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
@@ -15,7 +15,9 @@
// plate <class charT, class traits = char_traits<charT> >
// class basic_ofstream
-// explicit basic_ofstream(const filesystem::path& s, ios_base::openmode mode = ios_base::out);
+// template<class T>
+// explicit basic_ifstream(const T& s, ios_base::openmode mode = ios_base::in); // Since C++17
+// Constraints: is_same_v<T, filesystem::path> is true
#include <cassert>
#include <filesystem>
@@ -50,9 +52,9 @@ static_assert(test_non_convert_to_path<char>());
static_assert(test_non_convert_to_path<wchar_t>());
#endif // !TEST_HAS_NO_WIDE_CHARACTERS && !_LIBCPP_HAS_OPEN_WITH_WCHAR
-#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
+#ifndef TEST_HAS_NO_CHAR8_T
static_assert(test_non_convert_to_path<char8_t>());
-#endif // TEST_STD_VER > 17 && defined(__cpp_char8_t)
+#endif // TEST_HAS_NO_CHAR8_T
static_assert(test_non_convert_to_path<char16_t>());
static_assert(test_non_convert_to_path<char32_t>());
>From 2babb84b22f0c2fc7d9e64413572a9e9724232c5 Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Sun, 17 Mar 2024 23:29:25 +0800
Subject: [PATCH 08/15] Add period
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
libcxx/docs/ReleaseNotes/19.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index fb5ab83c740c8f..009bccc16e8d1f 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -97,7 +97,7 @@ TODO
ABI Affecting Changes
---------------------
- - LWG3430: Disallow implicit conversion of the source arguments to ``std::filesystem::path`` when constructing ``std::basic_*fstream``
+ - LWG3430: Disallow implicit conversion of the source arguments to ``std::filesystem::path`` when constructing ``std::basic_*fstream``.
Build System Changes
>From fe7085358412da253bf4db98871900fba9db9897 Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Mon, 18 Mar 2024 19:17:47 +0800
Subject: [PATCH 09/15] Update release notes
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
libcxx/docs/ReleaseNotes/19.rst | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index 009bccc16e8d1f..a6328540f21bdb 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -80,6 +80,11 @@ Deprecations and Removals
libatomic is not available. If you are one such user, please reach out to the libc++ developers so we can collaborate
on a path for supporting atomics properly on freestanding platforms.
+- LWG3430 disallow implicit conversion of the source arguments to ``std::filesystem::path`` when
+ constructing ``std::basic_*fstream``. This effectively removes the possibility to directly construct
+ a ``std::basic_*fstream`` from a ``std::basic_string_view``, a input-iterator or a C-string, instead
+ you can construct a temporary ``std::basic_string``. This change has been applied to C++17 and later.
+
Upcoming Deprecations and Removals
----------------------------------
>From 79a097389aafe7a172ab77420149f666bb0b994f Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Mon, 18 Mar 2024 19:24:55 +0800
Subject: [PATCH 10/15] Update release notes
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
libcxx/docs/ReleaseNotes/19.rst | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index a6328540f21bdb..b11e4a37a36272 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -102,8 +102,7 @@ TODO
ABI Affecting Changes
---------------------
- - LWG3430: Disallow implicit conversion of the source arguments to ``std::filesystem::path`` when constructing ``std::basic_*fstream``.
-
+TODO
Build System Changes
--------------------
>From e59fcb253470d8897350e98e466829ad53c4f371 Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Mon, 18 Mar 2024 19:25:38 +0800
Subject: [PATCH 11/15] Revert unnecessery changes
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
libcxx/docs/ReleaseNotes/19.rst | 1 +
1 file changed, 1 insertion(+)
diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index b11e4a37a36272..e353fa347ec529 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -100,6 +100,7 @@ LLVM 21
TODO
+
ABI Affecting Changes
---------------------
TODO
>From 8da609286779f30581a0279f1b64c3816281f0de Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Mon, 18 Mar 2024 19:27:12 +0800
Subject: [PATCH 12/15] Revert unnecessery changes
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
libcxx/docs/ReleaseNotes/19.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index e353fa347ec529..6f1ddbbb9843ca 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -100,11 +100,11 @@ LLVM 21
TODO
-
ABI Affecting Changes
---------------------
TODO
+
Build System Changes
--------------------
>From bae96cfd77c632ee810eb0048c904b84b56d97e6 Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Thu, 28 Mar 2024 20:45:43 +0800
Subject: [PATCH 13/15] Remove trailing whitespace
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
libcxx/docs/ReleaseNotes/19.rst | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index 6f1ddbbb9843ca..c707c185473838 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -80,9 +80,9 @@ Deprecations and Removals
libatomic is not available. If you are one such user, please reach out to the libc++ developers so we can collaborate
on a path for supporting atomics properly on freestanding platforms.
-- LWG3430 disallow implicit conversion of the source arguments to ``std::filesystem::path`` when
- constructing ``std::basic_*fstream``. This effectively removes the possibility to directly construct
- a ``std::basic_*fstream`` from a ``std::basic_string_view``, a input-iterator or a C-string, instead
+- LWG3430 disallow implicit conversion of the source arguments to ``std::filesystem::path`` when
+ constructing ``std::basic_*fstream``. This effectively removes the possibility to directly construct
+ a ``std::basic_*fstream`` from a ``std::basic_string_view``, a input-iterator or a C-string, instead
you can construct a temporary ``std::basic_string``. This change has been applied to C++17 and later.
>From 917f988b115f3c1dcb7f7fcdd1a9e90696b36d22 Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Sat, 6 Apr 2024 01:35:30 +0800
Subject: [PATCH 14/15] Use TEST_HAS_OPEN_WITH_WCHAR replace
_LIBCPP_HAS_OPEN_WITH_WCHAR
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
.../file.streams/fstreams/fstream.cons/path.pass.cpp | 4 ++--
.../file.streams/fstreams/ifstream.cons/path.pass.cpp | 4 ++--
.../file.streams/fstreams/ofstream.cons/path.pass.cpp | 4 ++--
libcxx/test/support/test_macros.h | 4 ++++
4 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
index 30f4fc8720a51d..5edf22eaacf31f 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/path.pass.cpp
@@ -48,9 +48,9 @@ constexpr bool test_non_convert_to_path() {
static_assert(test_non_convert_to_path<char>());
-#if !defined(TEST_HAS_NO_WIDE_CHARACTERS) && !defined(_LIBCPP_HAS_OPEN_WITH_WCHAR)
+#if !defined(TEST_HAS_NO_WIDE_CHARACTERS) && !defined(TEST_HAS_OPEN_WITH_WCHAR)
static_assert(test_non_convert_to_path<wchar_t>());
-#endif // !TEST_HAS_NO_WIDE_CHARACTERS && !_LIBCPP_HAS_OPEN_WITH_WCHAR
+#endif // !TEST_HAS_NO_WIDE_CHARACTERS && !TEST_HAS_OPEN_WITH_WCHAR
#ifndef TEST_HAS_NO_CHAR8_T
static_assert(test_non_convert_to_path<char8_t>());
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
index 73f0b0c2379f0f..2f27fd8e6e93d3 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
@@ -49,9 +49,9 @@ constexpr bool test_non_convert_to_path() {
static_assert(test_non_convert_to_path<char>());
-#if !defined(TEST_HAS_NO_WIDE_CHARACTERS) && !defined(_LIBCPP_HAS_OPEN_WITH_WCHAR)
+#if !defined(TEST_HAS_NO_WIDE_CHARACTERS) && !defined(TEST_HAS_OPEN_WITH_WCHAR)
static_assert(test_non_convert_to_path<wchar_t>());
-#endif // !TEST_HAS_NO_WIDE_CHARACTERS && !_LIBCPP_HAS_OPEN_WITH_WCHAR
+#endif // !TEST_HAS_NO_WIDE_CHARACTERS && !TEST_HAS_OPEN_WITH_WCHAR
#ifndef TEST_HAS_NO_CHAR8_T
static_assert(test_non_convert_to_path<char8_t>());
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
index 10bcc9b7b175d7..e55adfd83fc3c7 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/path.pass.cpp
@@ -48,9 +48,9 @@ constexpr bool test_non_convert_to_path() {
static_assert(test_non_convert_to_path<char>());
-#if !defined(TEST_HAS_NO_WIDE_CHARACTERS) && !defined(_LIBCPP_HAS_OPEN_WITH_WCHAR)
+#if !defined(TEST_HAS_NO_WIDE_CHARACTERS) && !defined(TEST_HAS_OPEN_WITH_WCHAR)
static_assert(test_non_convert_to_path<wchar_t>());
-#endif // !TEST_HAS_NO_WIDE_CHARACTERS && !_LIBCPP_HAS_OPEN_WITH_WCHAR
+#endif // !TEST_HAS_NO_WIDE_CHARACTERS && !TEST_HAS_OPEN_WITH_WCHAR
#ifndef TEST_HAS_NO_CHAR8_T
static_assert(test_non_convert_to_path<char8_t>());
diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index 24f69c758f365c..de4b14dff25c18 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -385,6 +385,10 @@ inline Tp const& DoNotOptimize(Tp const& value) {
# define TEST_HAS_NO_UNICODE
#endif
+#if defined(_LIBCPP_HAS_OPEN_WITH_WCHAR)
+# define TEST_HAS_OPEN_WITH_WCHAR
+#endif
+
#if defined(_LIBCPP_HAS_NO_INT128) || defined(_MSVC_STL_VERSION)
# define TEST_HAS_NO_INT128
#endif
>From aaad8330b192096b8d4dc5c40cf6fc613f759059 Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Sat, 6 Apr 2024 01:44:56 +0800
Subject: [PATCH 15/15] format
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
libcxx/test/support/test_macros.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index de4b14dff25c18..7b2dcbb52d0c88 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -386,7 +386,7 @@ inline Tp const& DoNotOptimize(Tp const& value) {
#endif
#if defined(_LIBCPP_HAS_OPEN_WITH_WCHAR)
-# define TEST_HAS_OPEN_WITH_WCHAR
+# define TEST_HAS_OPEN_WITH_WCHAR
#endif
#if defined(_LIBCPP_HAS_NO_INT128) || defined(_MSVC_STL_VERSION)
More information about the libcxx-commits
mailing list