[libcxx-commits] [libcxx] 7e6bcb3 - [libc++][format] Fixes vector<bool> requirements.
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Sat May 6 05:07:41 PDT 2023
Author: Mark de Wever
Date: 2023-05-06T14:00:29+02:00
New Revision: 7e6bcb35a8116a653e4cdf660643e80459c5efce
URL: https://github.com/llvm/llvm-project/commit/7e6bcb35a8116a653e4cdf660643e80459c5efce
DIFF: https://github.com/llvm/llvm-project/commit/7e6bcb35a8116a653e4cdf660643e80459c5efce.diff
LOG: [libc++][format] Fixes vector<bool> requirements.
Makes sure the formatter for the vector<bool>::reference is enabled
when only the header <vector> is included. Before this change it
required <vector> and <format> to be included. This violated the
requirements in the Standard.
Fixes: https://llvm.org/PR61314
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D149543
Added:
libcxx/test/std/containers/sequences/vector.bool/vector.bool.fmt/types.compile.pass.cpp
Modified:
libcxx/docs/ReleaseNotes.rst
libcxx/include/mutex
libcxx/include/string
libcxx/include/string_view
libcxx/include/vector
libcxx/test/libcxx/transitive_includes/cxx03.csv
libcxx/test/libcxx/transitive_includes/cxx11.csv
libcxx/test/libcxx/transitive_includes/cxx14.csv
libcxx/test/libcxx/transitive_includes/cxx17.csv
libcxx/test/libcxx/transitive_includes/cxx20.csv
libcxx/test/libcxx/transitive_includes/cxx2b.csv
Removed:
################################################################################
diff --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst
index fdbfdacfd36c2..952aa3bee4f51 100644
--- a/libcxx/docs/ReleaseNotes.rst
+++ b/libcxx/docs/ReleaseNotes.rst
@@ -69,6 +69,11 @@ Deprecations and Removals
- ``<algorithm>`` no longer includes ``<chrono>`` in any C++ version (it was prevously included in C++17 and earlier).
+- ``<string>`` no longer includes ``<vector>`` in any C++ version (it was prevously included in C++20 and earlier).
+
+- ``<string>``, ``<string_view>``, and ``<mutex>`` no longer include ``<functional>``
+ in any C++ version (it was prevously included in C++20 and earlier).
+
- The headers ``<experimental/algorithm>`` and ``<experimental/functional>`` have been removed, since all the contents
have been implemented in namespace ``std`` for at least two releases.
diff --git a/libcxx/include/mutex b/libcxx/include/mutex
index ed9b43d591089..74945b975b722 100644
--- a/libcxx/include/mutex
+++ b/libcxx/include/mutex
@@ -715,7 +715,6 @@ _LIBCPP_POP_MACROS
# include <cstdlib>
# include <cstring>
# include <ctime>
-# include <functional>
# include <initializer_list>
# include <new>
# include <stdexcept>
diff --git a/libcxx/include/string b/libcxx/include/string
index 1de3fb76ec42f..b6e0841ccc2f5 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -4389,13 +4389,11 @@ _LIBCPP_POP_MACROS
# include <algorithm>
# include <concepts>
# include <cstdlib>
-# include <functional>
# include <iterator>
# include <new>
# include <type_traits>
# include <typeinfo>
# include <utility>
-# include <vector>
#endif
#endif // _LIBCPP_STRING
diff --git a/libcxx/include/string_view b/libcxx/include/string_view
index f8cecfba94284..ac7d182a7f296 100644
--- a/libcxx/include/string_view
+++ b/libcxx/include/string_view
@@ -1047,7 +1047,6 @@ _LIBCPP_POP_MACROS
# include <algorithm>
# include <concepts>
# include <cstdlib>
-# include <functional>
# include <iterator>
# include <type_traits>
#endif
diff --git a/libcxx/include/vector b/libcxx/include/vector
index d90eb1666c360..a1366d0a9c2d9 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -293,6 +293,7 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++
#include <__debug>
#include <__format/enable_insertable.h>
#include <__format/formatter.h>
+#include <__format/formatter_bool.h>
#include <__functional/hash.h>
#include <__functional/unary_function.h>
#include <__iterator/advance.h>
@@ -3325,7 +3326,7 @@ inline constexpr bool __format::__enable_insertable<vector<wchar_t>> = true;
#endif // _LIBCPP_STD_VER >= 20
-#if _LIBCPP_STD_VER >= 23
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) && _LIBCPP_STD_VER >= 23
template <class _Tp, class CharT>
// Since is-vector-bool-reference is only used once it's inlined here.
requires same_as<typename _Tp::__container, vector<bool, typename _Tp::__container::allocator_type>>
@@ -3344,7 +3345,7 @@ public:
return __underlying_.format(__ref, __ctx);
}
};
-#endif // _LIBCPP_STD_VER >= 23
+#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) && _LIBCPP_STD_VER >= 23
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index 48f8893049ec7..7460de6733c82 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -575,7 +575,6 @@ mutex cstdint
mutex cstdlib
mutex cstring
mutex ctime
-mutex functional
mutex initializer_list
mutex iosfwd
mutex limits
@@ -805,7 +804,6 @@ string cstdio
string cstdlib
string cstring
string cwchar
-string functional
string initializer_list
string iosfwd
string iterator
@@ -817,7 +815,6 @@ string tuple
string type_traits
string typeinfo
string utility
-string vector
string version
string_view algorithm
string_view compare
@@ -828,7 +825,6 @@ string_view cstdio
string_view cstdlib
string_view cstring
string_view cwchar
-string_view functional
string_view initializer_list
string_view iosfwd
string_view iterator
@@ -964,7 +960,9 @@ variant typeinfo
variant utility
variant version
vector algorithm
+vector array
vector atomic
+vector cerrno
vector climits
vector compare
vector concepts
@@ -975,8 +973,11 @@ vector cstring
vector initializer_list
vector iosfwd
vector limits
+vector locale
vector new
vector stdexcept
+vector string
+vector string_view
vector tuple
vector type_traits
vector typeinfo
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index 0a987744a288e..1a8c4214beb97 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -575,7 +575,6 @@ mutex cstdint
mutex cstdlib
mutex cstring
mutex ctime
-mutex functional
mutex initializer_list
mutex iosfwd
mutex limits
@@ -806,7 +805,6 @@ string cstdio
string cstdlib
string cstring
string cwchar
-string functional
string initializer_list
string iosfwd
string iterator
@@ -818,7 +816,6 @@ string tuple
string type_traits
string typeinfo
string utility
-string vector
string version
string_view algorithm
string_view compare
@@ -829,7 +826,6 @@ string_view cstdio
string_view cstdlib
string_view cstring
string_view cwchar
-string_view functional
string_view initializer_list
string_view iosfwd
string_view iterator
@@ -965,7 +961,9 @@ variant typeinfo
variant utility
variant version
vector algorithm
+vector array
vector atomic
+vector cerrno
vector climits
vector compare
vector concepts
@@ -976,8 +974,11 @@ vector cstring
vector initializer_list
vector iosfwd
vector limits
+vector locale
vector new
vector stdexcept
+vector string
+vector string_view
vector tuple
vector type_traits
vector typeinfo
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index f7fd6101a492f..43888fe8f3037 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -577,7 +577,6 @@ mutex cstdint
mutex cstdlib
mutex cstring
mutex ctime
-mutex functional
mutex initializer_list
mutex iosfwd
mutex limits
@@ -808,7 +807,6 @@ string cstdio
string cstdlib
string cstring
string cwchar
-string functional
string initializer_list
string iosfwd
string iterator
@@ -820,7 +818,6 @@ string tuple
string type_traits
string typeinfo
string utility
-string vector
string version
string_view algorithm
string_view compare
@@ -831,7 +828,6 @@ string_view cstdio
string_view cstdlib
string_view cstring
string_view cwchar
-string_view functional
string_view initializer_list
string_view iosfwd
string_view iterator
@@ -967,7 +963,9 @@ variant typeinfo
variant utility
variant version
vector algorithm
+vector array
vector atomic
+vector cerrno
vector climits
vector compare
vector concepts
@@ -978,8 +976,11 @@ vector cstring
vector initializer_list
vector iosfwd
vector limits
+vector locale
vector new
vector stdexcept
+vector string
+vector string_view
vector tuple
vector type_traits
vector typeinfo
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index f7fd6101a492f..43888fe8f3037 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -577,7 +577,6 @@ mutex cstdint
mutex cstdlib
mutex cstring
mutex ctime
-mutex functional
mutex initializer_list
mutex iosfwd
mutex limits
@@ -808,7 +807,6 @@ string cstdio
string cstdlib
string cstring
string cwchar
-string functional
string initializer_list
string iosfwd
string iterator
@@ -820,7 +818,6 @@ string tuple
string type_traits
string typeinfo
string utility
-string vector
string version
string_view algorithm
string_view compare
@@ -831,7 +828,6 @@ string_view cstdio
string_view cstdlib
string_view cstring
string_view cwchar
-string_view functional
string_view initializer_list
string_view iosfwd
string_view iterator
@@ -967,7 +963,9 @@ variant typeinfo
variant utility
variant version
vector algorithm
+vector array
vector atomic
+vector cerrno
vector climits
vector compare
vector concepts
@@ -978,8 +976,11 @@ vector cstring
vector initializer_list
vector iosfwd
vector limits
+vector locale
vector new
vector stdexcept
+vector string
+vector string_view
vector tuple
vector type_traits
vector typeinfo
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index bb6023ab878ae..cb65ac77ce4d9 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -583,7 +583,6 @@ mutex cstdint
mutex cstdlib
mutex cstring
mutex ctime
-mutex functional
mutex initializer_list
mutex iosfwd
mutex limits
@@ -814,7 +813,6 @@ string cstdio
string cstdlib
string cstring
string cwchar
-string functional
string initializer_list
string iosfwd
string iterator
@@ -826,7 +824,6 @@ string tuple
string type_traits
string typeinfo
string utility
-string vector
string version
string_view algorithm
string_view compare
@@ -837,7 +834,6 @@ string_view cstdio
string_view cstdlib
string_view cstring
string_view cwchar
-string_view functional
string_view initializer_list
string_view iosfwd
string_view iterator
@@ -972,7 +968,9 @@ variant typeinfo
variant utility
variant version
vector algorithm
+vector array
vector atomic
+vector cerrno
vector climits
vector compare
vector concepts
@@ -983,8 +981,11 @@ vector cstring
vector initializer_list
vector iosfwd
vector limits
+vector locale
vector new
vector stdexcept
+vector string
+vector string_view
vector tuple
vector type_traits
vector typeinfo
diff --git a/libcxx/test/libcxx/transitive_includes/cxx2b.csv b/libcxx/test/libcxx/transitive_includes/cxx2b.csv
index 2569634d3ef86..7c1c0f49a8ee1 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx2b.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx2b.csv
@@ -646,15 +646,21 @@ variant limits
variant new
variant tuple
variant version
+vector array
+vector cerrno
vector climits
vector compare
vector cstddef
vector cstdint
+vector cstdlib
vector cstring
vector initializer_list
vector iosfwd
vector limits
+vector locale
vector new
vector stdexcept
+vector string
+vector string_view
vector tuple
vector version
diff --git a/libcxx/test/std/containers/sequences/vector.bool/vector.bool.fmt/types.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/vector.bool.fmt/types.compile.pass.cpp
new file mode 100644
index 0000000000000..1b8d06c315400
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/vector.bool.fmt/types.compile.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+// 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
+// UNSUPPORTED: libcpp-has-no-incomplete-format
+
+// <vector>
+
+// template<class T, class charT> requires is-vector-bool-reference<T>
+// struct formatter<T, charT>;
+
+// [format.formatter.spec]/4
+// If the library provides an explicit or partial specialization of
+// formatter<T, charT>, that specialization is enabled and meets the
+// Formatter requirements except as noted otherwise.
+//
+// Tests parts of the BasicFormatter requirements. Like the formattable concept
+// it uses the semiregular concept. It test does not use the formattable
+// concept since it is the intention the formatter is available without
+// including the format header.
+
+// TODO FMT Evaluate what to do with [format.formatter.spec]/2
+// [format.formatter.spec]/2
+// Each header that declares the template formatter provides the following
+// enabled specializations:
+// Then there is a list of formatters, but is that really useful?
+// Note this should be discussed in LEWG.
+
+#include <concepts>
+#include <vector>
+
+#include "test_macros.h"
+
+static_assert(std::semiregular<std::formatter<std::vector<bool>::reference, char>>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(std::semiregular<std::formatter<std::vector<bool>::reference, wchar_t>>);
+#endif
More information about the libcxx-commits
mailing list