From a91d81e95f22f03a0f8bdbbe6484d54784227a2e Mon Sep 17 00:00:00 2001 From: halx99 Date: Wed, 15 Jan 2025 01:26:27 +0800 Subject: [PATCH] Update fmt to v11.1.2 --- 3rdparty/README.md | 2 +- 3rdparty/fmt/CMakeLists.txt | 10 +++--- 3rdparty/fmt/ChangeLog.md | 25 +++++++++++++++ 3rdparty/fmt/include/fmt/base.h | 12 ++++--- 3rdparty/fmt/include/fmt/chrono.h | 4 +-- 3rdparty/fmt/include/fmt/format-inl.h | 6 ++-- 3rdparty/fmt/include/fmt/format.h | 46 +++++++++++++++++---------- 3rdparty/fmt/include/fmt/std.h | 9 +++--- 3rdparty/fmt/include/fmt/xchar.h | 27 +++++++++------- 9 files changed, 94 insertions(+), 47 deletions(-) diff --git a/3rdparty/README.md b/3rdparty/README.md index f451b8f1284d..49162a723f18 100644 --- a/3rdparty/README.md +++ b/3rdparty/README.md @@ -67,7 +67,7 @@ ## {fmt} - [![Upstream](https://img.shields.io/github/v/release/fmtlib/fmt?label=Upstream)](https://github.com/fmtlib/fmt) -- Version: 11.1.1 +- Version: 11.1.2 - License: MIT diff --git a/3rdparty/fmt/CMakeLists.txt b/3rdparty/fmt/CMakeLists.txt index 586ead519b91..059b15023845 100644 --- a/3rdparty/fmt/CMakeLists.txt +++ b/3rdparty/fmt/CMakeLists.txt @@ -427,7 +427,7 @@ if (FMT_INSTALL) # Install the library and headers. install(TARGETS ${INSTALL_TARGETS} - COMPONENT core + COMPONENT fmt-core EXPORT ${targets_export_name} LIBRARY DESTINATION ${FMT_LIB_DIR} ARCHIVE DESTINATION ${FMT_LIB_DIR} @@ -443,13 +443,13 @@ if (FMT_INSTALL) # Install version, config and target files. install(FILES ${project_config} ${version_config} DESTINATION ${FMT_CMAKE_DIR} - COMPONENT core) + COMPONENT fmt-core) install(EXPORT ${targets_export_name} DESTINATION ${FMT_CMAKE_DIR} NAMESPACE fmt:: - COMPONENT core) + COMPONENT fmt-core) install(FILES "${pkgconfig}" DESTINATION "${FMT_PKGCONFIG_DIR}" - COMPONENT core) + COMPONENT fmt-core) endif () function(add_doc_target) @@ -486,7 +486,7 @@ function(add_doc_target) include(GNUInstallDirs) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc-html/ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/fmt - COMPONENT doc OPTIONAL) + COMPONENT fmt-doc OPTIONAL) endfunction() if (FMT_DOC) diff --git a/3rdparty/fmt/ChangeLog.md b/3rdparty/fmt/ChangeLog.md index 09ebaed65255..08ded7d65db1 100644 --- a/3rdparty/fmt/ChangeLog.md +++ b/3rdparty/fmt/ChangeLog.md @@ -1,3 +1,28 @@ +# 11.1.2 - 2025-01-12 + +- Fixed ABI compatibility with earlier 11.x versions + (https://github.com/fmtlib/fmt/issues/4292). + +- Added `wchar_t` support to the `std::bitset` formatter + (https://github.com/fmtlib/fmt/issues/4285, + https://github.com/fmtlib/fmt/pull/4286, + https://github.com/fmtlib/fmt/issues/4289, + https://github.com/fmtlib/fmt/pull/4290). Thanks @phprus. + +- Prefixed CMake components with `fmt-` to simplify usage of {fmt} via + `add_subdirectory` (https://github.com/fmtlib/fmt/issues/4283). + +- Updated docs for meson (https://github.com/fmtlib/fmt/pull/4291). + Thanks @trim21. + +- Fixed a compilation error in chrono on nvcc + (https://github.com/fmtlib/fmt/issues/4297, + https://github.com/fmtlib/fmt/pull/4301). Thanks @breyerml. + +- Fixed various warnings + (https://github.com/fmtlib/fmt/pull/4288, + https://github.com/fmtlib/fmt/pull/4299). Thanks @GamesTrap and @edo9300. + # 11.1.1 - 2024-12-27 - Fixed ABI compatibility with earlier 11.x versions diff --git a/3rdparty/fmt/include/fmt/base.h b/3rdparty/fmt/include/fmt/base.h index 00c51423eeca..c1d09c6d4712 100644 --- a/3rdparty/fmt/include/fmt/base.h +++ b/3rdparty/fmt/include/fmt/base.h @@ -21,7 +21,7 @@ #endif // The fmt library version in the form major * 10000 + minor * 100 + patch. -#define FMT_VERSION 110101 +#define FMT_VERSION 110102 // Detect compiler versions. #if defined(__clang__) && !defined(__ibmxl__) @@ -842,6 +842,12 @@ class basic_specs { for (size_t i = 0; i < size; ++i) fill_data_[i & 3] = static_cast(s[i]); } + + FMT_CONSTEXPR void copy_fill_from(const basic_specs& specs) { + set_fill_size(specs.fill_size()); + for (size_t i = 0; i < max_fill_size; ++i) + fill_data_[i] = specs.fill_data_[i]; + } }; // Format specifiers for built-in and string types. @@ -2270,9 +2276,7 @@ struct locale_ref { public: constexpr locale_ref() : locale_(nullptr) {} - - template - locale_ref(const Locale& loc); + template locale_ref(const Locale& loc); inline explicit operator bool() const noexcept { return locale_ != nullptr; } #endif // FMT_USE_LOCALE diff --git a/3rdparty/fmt/include/fmt/chrono.h b/3rdparty/fmt/include/fmt/chrono.h index abf3671e5b59..50c777c841aa 100644 --- a/3rdparty/fmt/include/fmt/chrono.h +++ b/3rdparty/fmt/include/fmt/chrono.h @@ -261,7 +261,7 @@ namespace detail { using utc_clock = std::chrono::utc_clock; #else struct utc_clock { - void to_sys(); + template void to_sys(T); }; #endif @@ -364,7 +364,7 @@ void write_codecvt(codecvt_result& out, string_view in, template auto write_encoded_tm_str(OutputIt out, string_view in, const std::locale& loc) -> OutputIt { - if (detail::use_utf8 && loc != get_classic_locale()) { + if (const_check(detail::use_utf8) && loc != get_classic_locale()) { // char16_t and char32_t codecvts are broken in MSVC (linkage errors) and // gcc-4. #if FMT_MSC_VERSION != 0 || \ diff --git a/3rdparty/fmt/include/fmt/format-inl.h b/3rdparty/fmt/include/fmt/format-inl.h index 38308bf2a0b1..a5b79dbe49b5 100644 --- a/3rdparty/fmt/include/fmt/format-inl.h +++ b/3rdparty/fmt/include/fmt/format-inl.h @@ -84,7 +84,7 @@ using std::locale; using std::numpunct; using std::use_facet; -template > +template locale_ref::locale_ref(const Locale& loc) : locale_(&loc) { static_assert(std::is_same::value, ""); } @@ -134,7 +134,9 @@ FMT_FUNC auto write_loc(appender out, loc_value value, FMT_FUNC void report_error(const char* message) { #if FMT_USE_EXCEPTIONS - throw format_error(message); + // Use FMT_THROW instead of throw to avoid bogus unreachable code warnings + // from MSVC. + FMT_THROW(format_error(message)); #else fputs(message, stderr); abort(); diff --git a/3rdparty/fmt/include/fmt/format.h b/3rdparty/fmt/include/fmt/format.h index d1b83d18673e..92a1d5b7a04d 100644 --- a/3rdparty/fmt/include/fmt/format.h +++ b/3rdparty/fmt/include/fmt/format.h @@ -1839,7 +1839,9 @@ template class digit_grouping { } public: - explicit digit_grouping(locale_ref loc, bool localized = true) { + template ::value)> + explicit digit_grouping(Locale loc, bool localized = true) { if (!localized) return; auto sep = thousands_sep(loc); grouping_ = sep.grouping; @@ -3639,6 +3641,12 @@ FMT_CONSTEXPR auto native_formatter::format( return write(ctx.out(), val, specs, ctx.locale()); } +// DEPRECATED! https://github.com/fmtlib/fmt/issues/4292. +template +struct is_locale : std::false_type {}; +template +struct is_locale> : std::true_type {}; + // DEPRECATED! template struct vformat_args { using type = basic_format_args>; @@ -3960,8 +3968,7 @@ template struct nested_formatter { write(basic_appender(buf)); auto specs = format_specs(); specs.width = width_; - specs.set_fill( - basic_string_view(specs_.fill(), specs_.fill_size())); + specs.copy_fill_from(specs_); specs.set_align(specs_.align()); return detail::write( ctx.out(), basic_string_view(buf.data(), buf.size()), specs); @@ -4121,41 +4128,46 @@ FMT_API void format_system_error(detail::buffer& out, int error_code, // Can be used to report errors from destructors. FMT_API void report_system_error(int error_code, const char* message) noexcept; -inline auto vformat(detail::locale_ref loc, string_view fmt, format_args args) +template ::value)> +inline auto vformat(const Locale& loc, string_view fmt, format_args args) -> std::string { auto buf = memory_buffer(); - detail::vformat_to(buf, fmt, args, loc); + detail::vformat_to(buf, fmt, args, detail::locale_ref(loc)); return {buf.data(), buf.size()}; } -template -FMT_INLINE auto format(detail::locale_ref loc, format_string fmt, - T&&... args) -> std::string { +template ::value)> +FMT_INLINE auto format(const Locale& loc, format_string fmt, T&&... args) + -> std::string { return vformat(loc, fmt.str, vargs{{args...}}); } -template ::value)> -auto vformat_to(OutputIt out, detail::locale_ref loc, string_view fmt, +auto vformat_to(OutputIt out, const Locale& loc, string_view fmt, format_args args) -> OutputIt { auto&& buf = detail::get_buffer(out); - detail::vformat_to(buf, fmt, args, loc); + detail::vformat_to(buf, fmt, args, detail::locale_ref(loc)); return detail::get_iterator(buf, out); } -template ::value)> -FMT_INLINE auto format_to(OutputIt out, detail::locale_ref loc, +template ::value&& + detail::is_locale::value)> +FMT_INLINE auto format_to(OutputIt out, const Locale& loc, format_string fmt, T&&... args) -> OutputIt { return fmt::vformat_to(out, loc, fmt.str, vargs{{args...}}); } -template -FMT_NODISCARD FMT_INLINE auto formatted_size(detail::locale_ref loc, +template ::value)> +FMT_NODISCARD FMT_INLINE auto formatted_size(const Locale& loc, format_string fmt, T&&... args) -> size_t { auto buf = detail::counting_buffer<>(); - detail::vformat_to(buf, fmt.str, vargs{{args...}}, loc); + detail::vformat_to(buf, fmt.str, vargs{{args...}}, + detail::locale_ref(loc)); return buf.count(); } diff --git a/3rdparty/fmt/include/fmt/std.h b/3rdparty/fmt/include/fmt/std.h index b00e402255f5..54eb2c2a73d4 100644 --- a/3rdparty/fmt/include/fmt/std.h +++ b/3rdparty/fmt/include/fmt/std.h @@ -184,7 +184,8 @@ FMT_END_NAMESPACE FMT_BEGIN_NAMESPACE FMT_EXPORT template -struct formatter, Char> : nested_formatter { +struct formatter, Char> + : nested_formatter, Char> { private: // Functor because C++11 doesn't support generic lambdas. struct writer { @@ -204,7 +205,7 @@ struct formatter, Char> : nested_formatter { template auto format(const std::bitset& bs, FormatContext& ctx) const -> decltype(ctx.out()) { - return write_padded(ctx, writer{bs}); + return this->write_padded(ctx, writer{bs}); } }; @@ -695,9 +696,7 @@ template struct formatter, Char> { auto outer_specs = format_specs(); outer_specs.width = specs.width; - auto fill = specs.template fill(); - if (fill) - outer_specs.set_fill(basic_string_view(fill, specs.fill_size())); + outer_specs.copy_fill_from(specs); outer_specs.set_align(specs.align()); specs.width = 0; diff --git a/3rdparty/fmt/include/fmt/xchar.h b/3rdparty/fmt/include/fmt/xchar.h index 4cbda5421130..9f7f889d64d5 100644 --- a/3rdparty/fmt/include/fmt/xchar.h +++ b/3rdparty/fmt/include/fmt/xchar.h @@ -191,9 +191,11 @@ auto format(const S& fmt, T&&... args) -> std::basic_string { fmt::make_format_args>(args...)); } -template , - FMT_ENABLE_IF(detail::is_exotic_char::value)> -inline auto vformat(detail::locale_ref loc, const S& fmt, +template , + FMT_ENABLE_IF(detail::is_locale::value&& + detail::is_exotic_char::value)> +inline auto vformat(const Locale& loc, const S& fmt, typename detail::vformat_args::type args) -> std::basic_string { auto buf = basic_memory_buffer(); @@ -202,10 +204,11 @@ inline auto vformat(detail::locale_ref loc, const S& fmt, return {buf.data(), buf.size()}; } -template , - FMT_ENABLE_IF(detail::is_exotic_char::value)> -inline auto format(detail::locale_ref loc, const S& fmt, T&&... args) + FMT_ENABLE_IF(detail::is_locale::value&& + detail::is_exotic_char::value)> +inline auto format(const Locale& loc, const S& fmt, T&&... args) -> std::basic_string { return vformat(loc, detail::to_string_view(fmt), fmt::make_format_args>(args...)); @@ -232,11 +235,12 @@ inline auto format_to(OutputIt out, const S& fmt, T&&... args) -> OutputIt { fmt::make_format_args>(args...)); } -template , FMT_ENABLE_IF(detail::is_output_iterator::value&& - detail::is_exotic_char::value)> -inline auto vformat_to(OutputIt out, detail::locale_ref loc, const S& fmt, + detail::is_locale::value&& + detail::is_exotic_char::value)> +inline auto vformat_to(OutputIt out, const Locale& loc, const S& fmt, typename detail::vformat_args::type args) -> OutputIt { auto&& buf = detail::get_buffer(out); @@ -244,11 +248,12 @@ inline auto vformat_to(OutputIt out, detail::locale_ref loc, const S& fmt, return detail::get_iterator(buf, out); } -template , bool enable = detail::is_output_iterator::value && + detail::is_locale::value && detail::is_exotic_char::value> -inline auto format_to(OutputIt out, detail::locale_ref loc, const S& fmt, +inline auto format_to(OutputIt out, const Locale& loc, const S& fmt, T&&... args) -> typename std::enable_if::type { return vformat_to(out, loc, detail::to_string_view(fmt),