[libcxx-commits] [libcxx] [libc++][test] Don't include `test_format_context.h` in `parse.pass.cpp` (PR #83734)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Mar 3 11:07:36 PST 2024
https://github.com/frederick-vs-ja updated https://github.com/llvm/llvm-project/pull/83734
>From 3cbe4fe17a29c7c5d51940b49e235d38f7c8aeff Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 4 Mar 2024 02:08:42 +0800
Subject: [PATCH 1/3] [libc++][test] Don't include `test_format_context.h` in
`format.tuple/parse.pass.cpp`
The test doesn't need to call `test_format_context_create` to create a `basic_format_context`, so it shouldn't include `test_format_context.h`.
Discovered when implementing `formatter<tuple>` in MSVC STL. With the inclusion removed, local test passes when using enhanced MSVC STL.
---
libcxx/test/std/utilities/format/format.tuple/parse.pass.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/libcxx/test/std/utilities/format/format.tuple/parse.pass.cpp b/libcxx/test/std/utilities/format/format.tuple/parse.pass.cpp
index 5cabbda63dd02e..313f8ef8d220d0 100644
--- a/libcxx/test/std/utilities/format/format.tuple/parse.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.tuple/parse.pass.cpp
@@ -27,7 +27,6 @@
#include <tuple>
#include <utility>
-#include "test_format_context.h"
#include "test_macros.h"
#include "make_string.h"
>From 21c888b9bd59352e48ecc920afee868a317988cd Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 4 Mar 2024 02:37:02 +0800
Subject: [PATCH 2/3] Workaround for MSVC STL and LWG3989
---
libcxx/test/std/utilities/format/format.tuple/parse.pass.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libcxx/test/std/utilities/format/format.tuple/parse.pass.cpp b/libcxx/test/std/utilities/format/format.tuple/parse.pass.cpp
index 313f8ef8d220d0..73b7b0e3e7016c 100644
--- a/libcxx/test/std/utilities/format/format.tuple/parse.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.tuple/parse.pass.cpp
@@ -24,6 +24,7 @@
#include <cassert>
#include <concepts>
#include <format>
+#include <memory>
#include <tuple>
#include <utility>
@@ -40,7 +41,7 @@ constexpr void test(StringViewT fmt, std::size_t offset) {
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset);
}
template <class CharT, class Arg>
>From 8c4dd9c892e23e4260d8d8fb24950e4a81f4faf6 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 4 Mar 2024 03:07:22 +0800
Subject: [PATCH 3/3] Remove other redundant `test_format_context.h` inclusion
And consistently use
`assert(std::to_address(it) == std::to_address(fmt.end()) - offset)`
due to LWG3989
---
.../container.adaptors.format/parse.pass.cpp | 3 +--
.../sequences/vector.bool/vector.bool.fmt/parse.pass.cpp | 3 +--
.../thread.thread.class/thread.thread.id/parse.pass.cpp | 3 +--
.../format.formatter.spec/formatter.bool.pass.cpp | 2 +-
.../format.formatter.spec/formatter.c_string.pass.cpp | 2 +-
.../format.formatter.spec/formatter.char.pass.cpp | 2 +-
.../format.formatter.spec/formatter.char_array.pass.cpp | 2 +-
.../format.formatter.spec/formatter.floating_point.pass.cpp | 2 +-
.../format.formatter.spec/formatter.handle.pass.cpp | 2 +-
.../format.formatter.spec/formatter.pointer.pass.cpp | 2 +-
.../format.formatter.spec/formatter.signed_integral.pass.cpp | 2 +-
.../format.formatter.spec/formatter.string.pass.cpp | 2 +-
.../format.formatter.spec/formatter.unsigned_integral.pass.cpp | 2 +-
.../format/format.range/format.range.fmtdef/parse.pass.cpp | 3 +--
.../format/format.range/format.range.fmtmap/parse.pass.cpp | 3 +--
.../format/format.range/format.range.fmtset/parse.pass.cpp | 3 +--
.../format/format.range/format.range.fmtstr/parse.pass.cpp | 3 +--
.../format/format.range/format.range.formatter/parse.pass.cpp | 3 +--
libcxx/test/std/utilities/format/format.tuple/parse.pass.cpp | 2 +-
19 files changed, 19 insertions(+), 27 deletions(-)
diff --git a/libcxx/test/std/containers/container.adaptors/container.adaptors.format/parse.pass.cpp b/libcxx/test/std/containers/container.adaptors/container.adaptors.format/parse.pass.cpp
index 136910b90c909a..16503565ac62ff 100644
--- a/libcxx/test/std/containers/container.adaptors/container.adaptors.format/parse.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/container.adaptors.format/parse.pass.cpp
@@ -30,7 +30,6 @@
#include <queue>
#include <stack>
-#include "test_format_context.h"
#include "test_macros.h"
#include "make_string.h"
@@ -44,7 +43,7 @@ constexpr void test_parse(StringViewT fmt, std::size_t offset) {
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
}
template <class StringViewT>
diff --git a/libcxx/test/std/containers/sequences/vector.bool/vector.bool.fmt/parse.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/vector.bool.fmt/parse.pass.cpp
index c761039442196f..63a3662da9e921 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/vector.bool.fmt/parse.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/vector.bool.fmt/parse.pass.cpp
@@ -27,7 +27,6 @@
#include <format>
#include <vector>
-#include "test_format_context.h"
#include "test_macros.h"
#include "make_string.h"
@@ -41,7 +40,7 @@ constexpr void test_parse(StringViewT fmt, std::size_t offset) {
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
}
template <class CharT>
diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/parse.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/parse.pass.cpp
index 8523bc89497174..6670c422a8ca59 100644
--- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/parse.pass.cpp
+++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/parse.pass.cpp
@@ -26,7 +26,6 @@
#include <concepts>
#include <thread>
-#include "test_format_context.h"
#include "test_macros.h"
#include "make_string.h"
@@ -40,7 +39,7 @@ constexpr void test_parse(StringViewT fmt, std::size_t offset) {
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
}
template <class CharT>
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.bool.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.bool.pass.cpp
index efea2889ce3b5a..369154dfe60d69 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.bool.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.bool.pass.cpp
@@ -38,7 +38,7 @@ void test(StringT expected, StringViewT fmt, bool arg, std::size_t offset) {
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
StringT result;
auto out = std::back_inserter(result);
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.c_string.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.c_string.pass.cpp
index f363bc3032003c..7f4b8798ce34be 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.c_string.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.c_string.pass.cpp
@@ -38,7 +38,7 @@ void test(StringT expected, StringViewT fmt, const CharT* a, std::size_t offset)
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
StringT result;
auto out = std::back_inserter(result);
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char.pass.cpp
index 554def930020a9..e57561f1613d0d 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char.pass.cpp
@@ -39,7 +39,7 @@ void test(StringT expected, StringViewT fmt, ArgumentT arg, std::size_t offset)
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
StringT result;
auto out = std::back_inserter(result);
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char_array.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char_array.pass.cpp
index 295ba7f67bbc5b..a166aeb4f08fa0 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char_array.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char_array.pass.cpp
@@ -51,7 +51,7 @@ struct Tester {
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename std::basic_string_view<CharT>::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
std::basic_string<CharT> result;
auto out = std::back_inserter(result);
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.floating_point.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.floating_point.pass.cpp
index 206b0214cf5fd7..c076f7d2a93f16 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.floating_point.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.floating_point.pass.cpp
@@ -49,7 +49,7 @@ void test(std::basic_string_view<CharT> fmt, ArithmeticT arg, std::basic_string<
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename std::basic_string_view<CharT>::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
std::basic_string<CharT> result;
auto out = std::back_inserter(result);
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.handle.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.handle.pass.cpp
index e2b3d6b3d23701..3033f16ef29852 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.handle.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.handle.pass.cpp
@@ -43,7 +43,7 @@ void test(std::string expected, std::string_view fmt, color arg, std::size_t off
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename std::string_view::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
std::string result;
auto out = std::back_inserter(result);
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.pointer.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.pointer.pass.cpp
index aa10f34c95b796..f1a6335bf9424e 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.pointer.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.pointer.pass.cpp
@@ -44,7 +44,7 @@ void test(StringT expected, StringViewT fmt, PointerT arg, std::size_t offset) {
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
StringT result;
auto out = std::back_inserter(result);
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.signed_integral.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.signed_integral.pass.cpp
index e5db5dac0c569d..6d06070dce4229 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.signed_integral.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.signed_integral.pass.cpp
@@ -46,7 +46,7 @@ void test(StringT expected, StringViewT fmt, ArithmeticT arg, std::size_t offset
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
StringT result;
auto out = std::back_inserter(result);
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.string.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.string.pass.cpp
index 73df7464dcb7a7..ee41f9c96fe9c2 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.string.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.string.pass.cpp
@@ -46,7 +46,7 @@ void test(StringT expected, StringViewT fmt, StringT a, std::size_t offset) {
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
StringT result;
auto out = std::back_inserter(result);
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.unsigned_integral.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.unsigned_integral.pass.cpp
index eb70115bf5de59..ad130f3e16d95d 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.unsigned_integral.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.unsigned_integral.pass.cpp
@@ -46,7 +46,7 @@ void test(StringT expected, StringViewT fmt, ArithmeticT arg, std::size_t offset
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
StringT result;
auto out = std::back_inserter(result);
diff --git a/libcxx/test/std/utilities/format/format.range/format.range.fmtdef/parse.pass.cpp b/libcxx/test/std/utilities/format/format.range/format.range.fmtdef/parse.pass.cpp
index 9f9b4d4545a892..c2718d2f6ee4a0 100644
--- a/libcxx/test/std/utilities/format/format.range/format.range.fmtdef/parse.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.range/format.range.fmtdef/parse.pass.cpp
@@ -23,7 +23,6 @@
#include <concepts>
#include <format>
-#include "test_format_context.h"
#include "test_macros.h"
#include "make_string.h"
@@ -37,7 +36,7 @@ constexpr void test_parse(StringViewT fmt, std::size_t offset) {
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
}
template <class CharT>
diff --git a/libcxx/test/std/utilities/format/format.range/format.range.fmtmap/parse.pass.cpp b/libcxx/test/std/utilities/format/format.range/format.range.fmtmap/parse.pass.cpp
index daa92214845ba9..ec1de730b950fd 100644
--- a/libcxx/test/std/utilities/format/format.range/format.range.fmtmap/parse.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.range/format.range.fmtmap/parse.pass.cpp
@@ -26,7 +26,6 @@
#include <format>
#include <map>
-#include "test_format_context.h"
#include "test_macros.h"
#include "make_string.h"
@@ -40,7 +39,7 @@ constexpr void test_parse(StringViewT fmt, std::size_t offset) {
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
}
template <class CharT>
diff --git a/libcxx/test/std/utilities/format/format.range/format.range.fmtset/parse.pass.cpp b/libcxx/test/std/utilities/format/format.range/format.range.fmtset/parse.pass.cpp
index 843855f4e6d076..b01d35de04f587 100644
--- a/libcxx/test/std/utilities/format/format.range/format.range.fmtset/parse.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.range/format.range.fmtset/parse.pass.cpp
@@ -26,7 +26,6 @@
#include <format>
#include <set>
-#include "test_format_context.h"
#include "test_macros.h"
#include "make_string.h"
@@ -40,7 +39,7 @@ constexpr void test_parse(StringViewT fmt, std::size_t offset) {
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
}
template <class CharT>
diff --git a/libcxx/test/std/utilities/format/format.range/format.range.fmtstr/parse.pass.cpp b/libcxx/test/std/utilities/format/format.range/format.range.fmtstr/parse.pass.cpp
index 7acee9cb9dc51a..bcc724b25c333b 100644
--- a/libcxx/test/std/utilities/format/format.range/format.range.fmtstr/parse.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.range/format.range.fmtstr/parse.pass.cpp
@@ -25,7 +25,6 @@
#include <format>
#include "format.functions.tests.h"
-#include "test_format_context.h"
#include "test_macros.h"
template <class FormatterT, class StringViewT>
@@ -36,7 +35,7 @@ constexpr void test_parse(StringViewT fmt, std::size_t offset) {
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
}
template <class StringViewT>
diff --git a/libcxx/test/std/utilities/format/format.range/format.range.formatter/parse.pass.cpp b/libcxx/test/std/utilities/format/format.range/format.range.formatter/parse.pass.cpp
index 87774c26208771..01eadf57c28ff3 100644
--- a/libcxx/test/std/utilities/format/format.range/format.range.formatter/parse.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.range/format.range.formatter/parse.pass.cpp
@@ -26,7 +26,6 @@
#include <concepts>
#include <format>
-#include "test_format_context.h"
#include "test_macros.h"
#include "make_string.h"
@@ -40,7 +39,7 @@ constexpr void test_parse(StringViewT fmt, std::size_t offset) {
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(it == fmt.end() - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
}
template <class CharT>
diff --git a/libcxx/test/std/utilities/format/format.tuple/parse.pass.cpp b/libcxx/test/std/utilities/format/format.tuple/parse.pass.cpp
index 73b7b0e3e7016c..f747a6adbc7506 100644
--- a/libcxx/test/std/utilities/format/format.tuple/parse.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.tuple/parse.pass.cpp
@@ -41,7 +41,7 @@ constexpr void test(StringViewT fmt, std::size_t offset) {
static_assert(std::semiregular<decltype(formatter)>);
std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
- assert(std::to_address(it) == std::to_address(fmt.end()) - offset);
+ assert(std::to_address(it) == std::to_address(fmt.end()) - offset); // LWG3989
}
template <class CharT, class Arg>
More information about the libcxx-commits
mailing list