From 990dd68e7f2e76dd40076166beab77b50589f381 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sat, 3 Jul 2021 13:37:01 +0300 Subject: [PATCH] Update cpp fmt to 8.0.1 --- vendor/Fmt/CMakeLists.txt | 1 - vendor/Fmt/format.cc | 3 ++ vendor/Fmt/include/fmt/color.h | 2 +- vendor/Fmt/include/fmt/core.h | 82 ++++++++++++++--------------- vendor/Fmt/include/fmt/format-inl.h | 1 - vendor/Fmt/include/fmt/format.h | 41 ++++++++------- vendor/Fmt/include/fmt/os.h | 2 +- vendor/Fmt/include/fmt/posix.h | 2 - vendor/Fmt/include/fmt/ranges.h | 3 +- vendor/Fmt/include/fmt/xchar.h | 2 +- 10 files changed, 69 insertions(+), 70 deletions(-) delete mode 100644 vendor/Fmt/include/fmt/posix.h diff --git a/vendor/Fmt/CMakeLists.txt b/vendor/Fmt/CMakeLists.txt index e12f35b2..6c2b1d02 100644 --- a/vendor/Fmt/CMakeLists.txt +++ b/vendor/Fmt/CMakeLists.txt @@ -10,7 +10,6 @@ add_library(FmtLib STATIC include/fmt/locale.h include/fmt/os.h include/fmt/ostream.h - include/fmt/posix.h include/fmt/printf.h include/fmt/ranges.h include/fmt/xchar.h diff --git a/vendor/Fmt/format.cc b/vendor/Fmt/format.cc index 187dcb73..66925b42 100644 --- a/vendor/Fmt/format.cc +++ b/vendor/Fmt/format.cc @@ -47,6 +47,9 @@ template FMT_API char detail::decimal_point_impl(locale_ref); template FMT_API void detail::buffer::append(const char*, const char*); +// DEPRECATED! +// There is no correspondent extern template in format.h because of +// incompatibility between clang and gcc (#2377). template FMT_API void detail::vformat_to( detail::buffer&, string_view, basic_format_args, detail::locale_ref); diff --git a/vendor/Fmt/include/fmt/color.h b/vendor/Fmt/include/fmt/color.h index 7fa5490e..3d5490e8 100644 --- a/vendor/Fmt/include/fmt/color.h +++ b/vendor/Fmt/include/fmt/color.h @@ -507,7 +507,7 @@ void vformat_to(buffer& buf, const text_style& ts, auto background = detail::make_background_color(ts.get_background()); buf.append(background.begin(), background.end()); } - detail::vformat_to(buf, format_str, args); + detail::vformat_to(buf, format_str, args, {}); if (has_style) detail::reset_color(buf); } diff --git a/vendor/Fmt/include/fmt/core.h b/vendor/Fmt/include/fmt/core.h index 4c1f5e2c..d058398a 100644 --- a/vendor/Fmt/include/fmt/core.h +++ b/vendor/Fmt/include/fmt/core.h @@ -16,7 +16,7 @@ #include // The fmt library version in the form major * 10000 + minor * 100 + patch. -#define FMT_VERSION 80000 +#define FMT_VERSION 80001 #ifdef __clang__ # define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) @@ -24,7 +24,7 @@ # define FMT_CLANG_VERSION 0 #endif -#if defined(__GNUC__) && !defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) # define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) # define FMT_GCC_PRAGMA(arg) _Pragma(arg) #else @@ -64,7 +64,8 @@ # define FMT_HAS_FEATURE(x) 0 #endif -#if defined(__has_include) && !defined(__INTELLISENSE__) && \ +#if defined(__has_include) && \ + (!defined(__INTELLISENSE__) || FMT_MSC_VER > 1900) && \ (!FMT_ICC_VERSION || FMT_ICC_VERSION >= 1600) # define FMT_HAS_INCLUDE(x) __has_include(x) #else @@ -228,12 +229,12 @@ # define FMT_INLINE_NAMESPACE namespace # define FMT_END_NAMESPACE \ } \ - using namespace v7; \ + using namespace v8; \ } # endif # define FMT_BEGIN_NAMESPACE \ namespace fmt { \ - FMT_INLINE_NAMESPACE v7 { + FMT_INLINE_NAMESPACE v8 { #endif #ifndef FMT_MODULE_EXPORT @@ -316,9 +317,9 @@ FMT_BEGIN_NAMESPACE FMT_MODULE_EXPORT_BEGIN // Implementations of enable_if_t and other metafunctions for older systems. -template +template using enable_if_t = typename std::enable_if::type; -template +template using conditional_t = typename std::conditional::type; template using bool_constant = std::integral_constant; template @@ -332,6 +333,11 @@ struct monostate { constexpr monostate() {} }; +// Suppress "unused variable" warnings with the method described in +// https://herbsutter.com/2009/10/18/mailbag-shutting-up-compiler-warnings/. +// (void)var does not work on many Intel compilers. +template FMT_CONSTEXPR void ignore_unused(const T&...) {} + // An enable_if helper to be used in template parameters which results in much // shorter symbols: https://godbolt.org/z/sWw4vP. Extra parentheses are needed // to workaround a bug in MSVC 2019 (see #1140 and #1186). @@ -360,7 +366,8 @@ FMT_NORETURN FMT_API void assert_fail(const char* file, int line, #ifndef FMT_ASSERT # ifdef NDEBUG // FMT_ASSERT is not empty to avoid -Werror=empty-body. -# define FMT_ASSERT(condition, message) ((void)0) +# define FMT_ASSERT(condition, message) \ + ::fmt::ignore_unused((condition), (message)) # else # define FMT_ASSERT(condition, message) \ ((condition) /* void() fails with -Winvalid-constexpr on clang 4.0.1 */ \ @@ -525,39 +532,21 @@ using string_view = basic_string_view; template struct is_char : std::false_type {}; template <> struct is_char : std::true_type {}; -/** - \rst - Returns a string view of `s`. In order to add custom string type support to - {fmt} provide an overload of `to_string_view` for it in the same namespace as - the type for the argument-dependent lookup to work. - - **Example**:: - - namespace my_ns { - inline string_view to_string_view(const my_string& s) { - return {s.data(), s.length()}; - } - } - std::string message = fmt::format(my_string("The answer is {}"), 42); - \endrst - */ +// Returns a string view of `s`. template ::value)> FMT_INLINE auto to_string_view(const Char* s) -> basic_string_view { return s; } - template inline auto to_string_view(const std::basic_string& s) -> basic_string_view { return s; } - template constexpr auto to_string_view(basic_string_view s) -> basic_string_view { return s; } - template >::value)> inline auto to_string_view(detail::std_string_view s) @@ -581,7 +570,7 @@ constexpr auto to_string_view(const S& s) FMT_BEGIN_DETAIL_NAMESPACE void to_string_view(...); -using fmt::v7::to_string_view; +using fmt::v8::to_string_view; // Specifies whether S is a string type convertible to fmt::basic_string_view. // It should be a constexpr function but MSVC 2017 fails to compile it in @@ -624,7 +613,7 @@ template using char_t = typename detail::char_t_impl::type; \rst Parsing context consisting of a format string range being parsed and an argument counter for automatic indexing. - You can use the ```format_parse_context`` type alias for ``char`` instead. + You can use the ``format_parse_context`` type alias for ``char`` instead. \endrst */ template @@ -2420,7 +2409,7 @@ FMT_CONSTEXPR FMT_INLINE void parse_format_string( if (pbegin == pend) return; for (;;) { const Char* p = nullptr; - if (!find(pbegin, pend, '}', p)) + if (!find(pbegin, pend, Char('}'), p)) return handler_.on_text(pbegin, pend); ++p; if (p == pend || *p != '}') @@ -2435,7 +2424,7 @@ FMT_CONSTEXPR FMT_INLINE void parse_format_string( // Doing two passes with memchr (one for '{' and another for '}') is up to // 2.5x faster than the naive one-pass implementation on big format strings. const Char* p = begin; - if (*begin != '{' && !find(begin + 1, end, '{', p)) + if (*begin != '{' && !find(begin + 1, end, Char('{'), p)) return write(begin, end); write(begin, p); begin = parse_replacement_field(p, end, handler); @@ -2588,8 +2577,8 @@ FMT_CONSTEXPR auto check_cstring_type_spec(Char spec, ErrorHandler&& eh = {}) return false; } -template -FMT_CONSTEXPR void check_string_type_spec(Char spec, ErrorHandler&& eh) { +template +FMT_CONSTEXPR void check_string_type_spec(Char spec, ErrorHandler&& eh = {}) { if (spec != 0 && spec != 's') eh.on_error("invalid type specifier"); } @@ -2656,21 +2645,28 @@ constexpr auto get_arg_index_by_name(basic_string_view name) -> int { if constexpr (detail::is_statically_named_arg()) { if (name == T::name) return N; } - if constexpr (sizeof...(Args) > 0) + if constexpr (sizeof...(Args) > 0) { return get_arg_index_by_name(name); - (void)name; // Workaround an MSVC bug about "unused" parameter. - return invalid_arg_index; + } else { + (void)name; // Workaround an MSVC bug about "unused" parameter. + return invalid_arg_index; + } } #endif template FMT_CONSTEXPR auto get_arg_index_by_name(basic_string_view name) -> int { #if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS - if constexpr (sizeof...(Args) > 0) + if constexpr (sizeof...(Args) > 0) { return get_arg_index_by_name<0, Args...>(name); -#endif + } else { + (void)name; + return invalid_arg_index; + } +#else (void)name; return invalid_arg_index; +#endif } template @@ -2731,14 +2727,14 @@ void check_format_string(S format_str) { remove_cvref_t...>; FMT_CONSTEXPR bool invalid_format = (parse_format_string(s, checker(s, {})), true); - (void)invalid_format; + ignore_unused(invalid_format); } template void vformat_to( buffer& buf, basic_string_view fmt, basic_format_args)> args, - detail::locale_ref loc = {}); + locale_ref loc = {}); FMT_API void vprint_mojibake(std::FILE*, string_view, format_args); #ifndef _WIN32 @@ -2896,7 +2892,7 @@ template OutputIt { using detail::get_buffer; auto&& buf = get_buffer(out); - detail::vformat_to(buf, string_view(fmt), args); + detail::vformat_to(buf, string_view(fmt), args, {}); return detail::get_iterator(buf); } @@ -2933,7 +2929,7 @@ auto vformat_to_n(OutputIt out, size_t n, string_view fmt, format_args args) using buffer = detail::iterator_buffer; auto buf = buffer(out, n); - detail::vformat_to(buf, fmt, args); + detail::vformat_to(buf, fmt, args, {}); return {buf.out(), buf.count()}; } @@ -2955,7 +2951,7 @@ FMT_INLINE auto format_to_n(OutputIt out, size_t n, format_string fmt, template FMT_INLINE auto formatted_size(format_string fmt, T&&... args) -> size_t { auto buf = detail::counting_buffer<>(); - detail::vformat_to(buf, string_view(fmt), fmt::make_format_args(args...)); + detail::vformat_to(buf, string_view(fmt), fmt::make_format_args(args...), {}); return buf.count(); } diff --git a/vendor/Fmt/include/fmt/format-inl.h b/vendor/Fmt/include/fmt/format-inl.h index a802aea5..94a36d1b 100644 --- a/vendor/Fmt/include/fmt/format-inl.h +++ b/vendor/Fmt/include/fmt/format-inl.h @@ -563,7 +563,6 @@ class bigint { (*this)[bigit_index] = static_cast(sum); sum >>= bits::value; } - --num_result_bigits; remove_leading_zeros(); exp_ *= 2; } diff --git a/vendor/Fmt/include/fmt/format.h b/vendor/Fmt/include/fmt/format.h index 03ae1c96..5398a23a 100644 --- a/vendor/Fmt/include/fmt/format.h +++ b/vendor/Fmt/include/fmt/format.h @@ -520,9 +520,9 @@ FMT_CONSTEXPR inline size_t compute_width(string_view s) { 1 + (error == 0 && cp >= 0x1100 && (cp <= 0x115f || // Hangul Jamo init. consonants - cp == 0x2329 || // LEFT-POINTING ANGLE BRACKET〈 - cp == 0x232a || // RIGHT-POINTING ANGLE BRACKET 〉 - // CJK ... Yi except Unicode Character “〿”: + cp == 0x2329 || // LEFT-POINTING ANGLE BRACKET + cp == 0x232a || // RIGHT-POINTING ANGLE BRACKET + // CJK ... Yi except IDEOGRAPHIC HALF FILL SPACE: (cp >= 0x2e80 && cp <= 0xa4cf && cp != 0x303f) || (cp >= 0xac00 && cp <= 0xd7a3) || // Hangul Syllables (cp >= 0xf900 && cp <= 0xfaff) || // CJK Compatibility Ideographs @@ -603,7 +603,7 @@ enum { inline_buffer_size = 500 }; A dynamically growing memory buffer for trivially copyable/constructible types with the first ``SIZE`` elements stored in the object itself. - You can use the ```memory_buffer`` type alias for ``char`` instead. + You can use the ``memory_buffer`` type alias for ``char`` instead. **Example**:: @@ -859,7 +859,7 @@ template struct basic_data { static const uint64_t log10_2_significand = 0x4d104d427de7fbcc; // GCC generates slightly better code for pairs than chars. - FMT_API static constexpr const char digits[][2] = { + FMT_API static constexpr const char digits[100][2] = { {'0', '0'}, {'0', '1'}, {'0', '2'}, {'0', '3'}, {'0', '4'}, {'0', '5'}, {'0', '6'}, {'0', '7'}, {'0', '8'}, {'0', '9'}, {'1', '0'}, {'1', '1'}, {'1', '2'}, {'1', '3'}, {'1', '4'}, {'1', '5'}, {'1', '6'}, {'1', '7'}, @@ -879,11 +879,13 @@ template struct basic_data { {'9', '6'}, {'9', '7'}, {'9', '8'}, {'9', '9'}}; FMT_API static constexpr const char hex_digits[] = "0123456789abcdef"; - FMT_API static constexpr const char signs[] = {0, '-', '+', ' '}; + FMT_API static constexpr const char signs[4] = {0, '-', '+', ' '}; FMT_API static constexpr const unsigned prefixes[4] = {0, 0, 0x1000000u | '+', 0x1000000u | ' '}; - FMT_API static constexpr const char left_padding_shifts[] = {31, 31, 0, 1, 0}; - FMT_API static constexpr const char right_padding_shifts[] = {0, 31, 0, 1, 0}; + FMT_API static constexpr const char left_padding_shifts[5] = {31, 31, 0, 1, + 0}; + FMT_API static constexpr const char right_padding_shifts[5] = {0, 31, 0, 1, + 0}; }; #ifdef FMT_SHARED @@ -1023,7 +1025,7 @@ template <> inline auto decimal_point(locale_ref loc) -> wchar_t { // Compares two characters for equality. template auto equal2(const Char* lhs, const char* rhs) -> bool { - return lhs[0] == rhs[0] && lhs[1] == rhs[1]; + return lhs[0] == Char(rhs[0]) && lhs[1] == Char(rhs[1]); } inline auto equal2(const char* lhs, const char* rhs) -> bool { return memcmp(lhs, rhs, 2) == 0; @@ -1567,6 +1569,7 @@ FMT_CONSTEXPR auto write(OutputIt out, basic_string_view> s, const basic_format_specs& specs, locale_ref) -> OutputIt { + check_string_type_spec(specs.type); return write(out, s, specs); } template @@ -2621,9 +2624,10 @@ auto to_string(const basic_memory_buffer& buf) FMT_BEGIN_DETAIL_NAMESPACE template -void vformat_to(buffer& buf, basic_string_view fmt, - basic_format_args>> args, - locale_ref loc) { +void vformat_to( + buffer& buf, basic_string_view fmt, + basic_format_args)> args, + locale_ref loc) { // workaround for msvc bug regarding name-lookup in module // link names into function scope using detail::arg_formatter; @@ -2703,10 +2707,6 @@ void vformat_to(buffer& buf, basic_string_view fmt, } #ifndef FMT_HEADER_ONLY -extern template void vformat_to(detail::buffer&, string_view, - basic_format_args, - detail::locale_ref); - extern template FMT_API auto thousands_sep_impl(locale_ref) -> thousands_sep_result; extern template FMT_API auto thousands_sep_impl(locale_ref) @@ -2730,6 +2730,8 @@ extern template auto snprintf_float(long double value, #endif // FMT_HEADER_ONLY FMT_END_DETAIL_NAMESPACE + +#if FMT_USE_USER_DEFINED_LITERALS inline namespace literals { /** \rst @@ -2741,18 +2743,18 @@ inline namespace literals { fmt::print("Elapsed time: {s:.2f} seconds", "s"_a=1.23); \endrst */ -#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS +# if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS template constexpr auto operator""_a() -> detail::udl_arg, sizeof(Str.data) / sizeof(decltype(Str.data[0])), Str> { return {}; } -#else +# else constexpr auto operator"" _a(const char* s, size_t) -> detail::udl_arg { return {s}; } -#endif +# endif /** \rst @@ -2769,6 +2771,7 @@ constexpr auto operator"" _format(const char* s, size_t n) return {{s, n}}; } } // namespace literals +#endif // FMT_USE_USER_DEFINED_LITERALS template ::value)> inline auto vformat(const Locale& loc, string_view fmt, format_args args) diff --git a/vendor/Fmt/include/fmt/os.h b/vendor/Fmt/include/fmt/os.h index c447831e..f6c0f329 100644 --- a/vendor/Fmt/include/fmt/os.h +++ b/vendor/Fmt/include/fmt/os.h @@ -394,7 +394,7 @@ struct ostream_params { FMT_END_DETAIL_NAMESPACE -static constexpr detail::buffer_size buffer_size; +constexpr detail::buffer_size buffer_size; /** A fast output stream which is not thread-safe. */ class FMT_API ostream final : private detail::buffer { diff --git a/vendor/Fmt/include/fmt/posix.h b/vendor/Fmt/include/fmt/posix.h deleted file mode 100644 index da19e9d5..00000000 --- a/vendor/Fmt/include/fmt/posix.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "os.h" -#warning "fmt/posix.h is deprecated; use fmt/os.h instead" diff --git a/vendor/Fmt/include/fmt/ranges.h b/vendor/Fmt/include/fmt/ranges.h index 52961389..f0390df2 100644 --- a/vendor/Fmt/include/fmt/ranges.h +++ b/vendor/Fmt/include/fmt/ranges.h @@ -392,7 +392,8 @@ struct formatter, Char> { auto format(const tuple_join_view& value, FormatContext& ctx, detail::index_sequence) -> typename FormatContext::iterator { - return format_args(value, ctx, std::get(value.tuple)...); + using std::get; + return format_args(value, ctx, get(value.tuple)...); } template diff --git a/vendor/Fmt/include/fmt/xchar.h b/vendor/Fmt/include/fmt/xchar.h index 74c69045..a0dd032f 100644 --- a/vendor/Fmt/include/fmt/xchar.h +++ b/vendor/Fmt/include/fmt/xchar.h @@ -142,7 +142,7 @@ FMT_DEPRECATED auto format_to(basic_memory_buffer& buf, const S& format_str, Args&&... args) -> typename buffer_context::iterator { const auto& vargs = fmt::make_args_checked(format_str, args...); - detail::vformat_to(buf, to_string_view(format_str), vargs); + detail::vformat_to(buf, to_string_view(format_str), vargs, {}); return detail::buffer_appender(buf); }