Skip to content

Commit 3bfec6e

Browse files
committed
[upstream_utils] Upgrade to fmt 11.1.3
1 parent 48ce2dc commit 3bfec6e

File tree

9 files changed

+102
-71
lines changed

9 files changed

+102
-71
lines changed

Diff for: upstream_utils/fmt.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def copy_upstream_src(wpilib_root):
3434
def main():
3535
name = "fmt"
3636
url = "https://github.com/fmtlib/fmt"
37-
tag = "11.1.0"
37+
tag = "11.1.3"
3838

3939
fmt = Lib(name, url, tag, copy_upstream_src)
4040
fmt.main()

Diff for: wpiutil/src/main/native/thirdparty/fmtlib/include/fmt/base.h

+38-15
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#endif
2222

2323
// The fmt library version in the form major * 10000 + minor * 100 + patch.
24-
#define FMT_VERSION 110100
24+
#define FMT_VERSION 110103
2525

2626
// Detect compiler versions.
2727
#if defined(__clang__) && !defined(__ibmxl__)
@@ -96,9 +96,9 @@
9696
// Detect C++14 relaxed constexpr.
9797
#ifdef FMT_USE_CONSTEXPR
9898
// Use the provided definition.
99-
#elif FMT_GCC_VERSION >= 600 && FMT_CPLUSPLUS >= 201402L
100-
// GCC only allows throw in constexpr since version 6:
101-
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67371.
99+
#elif FMT_GCC_VERSION >= 702 && FMT_CPLUSPLUS >= 201402L
100+
// GCC only allows constexpr member functions in non-literal types since 7.2:
101+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66297.
102102
# define FMT_USE_CONSTEXPR 1
103103
#elif FMT_ICC_VERSION
104104
# define FMT_USE_CONSTEXPR 0 // https://github.com/fmtlib/fmt/issues/1628
@@ -161,6 +161,20 @@
161161
# define FMT_CATCH(x) if (false)
162162
#endif
163163

164+
#ifdef FMT_NO_UNIQUE_ADDRESS
165+
// Use the provided definition.
166+
#elif FMT_CPLUSPLUS < 202002L
167+
// Not supported.
168+
#elif FMT_HAS_CPP_ATTRIBUTE(no_unique_address)
169+
# define FMT_NO_UNIQUE_ADDRESS [[no_unique_address]]
170+
// VS2019 v16.10 and later except clang-cl (https://reviews.llvm.org/D110485).
171+
#elif FMT_MSC_VERSION >= 1929 && !FMT_CLANG_VERSION
172+
# define FMT_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
173+
#endif
174+
#ifndef FMT_NO_UNIQUE_ADDRESS
175+
# define FMT_NO_UNIQUE_ADDRESS
176+
#endif
177+
164178
#if FMT_HAS_CPP17_ATTRIBUTE(fallthrough)
165179
# define FMT_FALLTHROUGH [[fallthrough]]
166180
#elif defined(__clang__)
@@ -285,7 +299,7 @@
285299

286300
// Enable minimal optimizations for more compact code in debug mode.
287301
FMT_PRAGMA_GCC(push_options)
288-
#if !defined(__OPTIMIZE__) && !defined(__CUDACC__)
302+
#if !defined(__OPTIMIZE__) && !defined(__CUDACC__) && !defined(FMT_MODULE)
289303
FMT_PRAGMA_GCC(optimize("Og"))
290304
#endif
291305
FMT_PRAGMA_CLANG(diagnostic push)
@@ -725,13 +739,15 @@ class basic_specs {
725739
max_fill_size = 4
726740
};
727741

728-
size_t data_ = 1 << fill_size_shift;
742+
unsigned data_ = 1 << fill_size_shift;
743+
static_assert(sizeof(data_) * CHAR_BIT >= 18, "");
729744

730745
// Character (code unit) type is erased to prevent template bloat.
731746
char fill_data_[max_fill_size] = {' '};
732747

733748
FMT_CONSTEXPR void set_fill_size(size_t size) {
734-
data_ = (data_ & ~fill_size_mask) | (size << fill_size_shift);
749+
data_ = (data_ & ~fill_size_mask) |
750+
(static_cast<unsigned>(size) << fill_size_shift);
735751
}
736752

737753
public:
@@ -828,6 +844,12 @@ class basic_specs {
828844
for (size_t i = 0; i < size; ++i)
829845
fill_data_[i & 3] = static_cast<char>(s[i]);
830846
}
847+
848+
FMT_CONSTEXPR void copy_fill_from(const basic_specs& specs) {
849+
set_fill_size(specs.fill_size());
850+
for (size_t i = 0; i < max_fill_size; ++i)
851+
fill_data_[i] = specs.fill_data_[i];
852+
}
831853
};
832854

833855
// Format specifiers for built-in and string types.
@@ -1099,7 +1121,7 @@ using use_formatter =
10991121
bool_constant<(std::is_class<T>::value || std::is_enum<T>::value ||
11001122
std::is_union<T>::value || std::is_array<T>::value) &&
11011123
!has_to_string_view<T>::value && !is_named_arg<T>::value &&
1102-
!use_format_as<T>::value && !use_format_as_member<T>::value>;
1124+
!use_format_as<T>::value && !use_format_as_member<U>::value>;
11031125

11041126
template <typename Char, typename T, typename U = remove_const_t<T>>
11051127
auto has_formatter_impl(T* p, buffered_context<Char>* ctx = nullptr)
@@ -2256,9 +2278,7 @@ struct locale_ref {
22562278

22572279
public:
22582280
constexpr locale_ref() : locale_(nullptr) {}
2259-
2260-
template <typename Locale, FMT_ENABLE_IF(sizeof(Locale::collate) != 0)>
2261-
locale_ref(const Locale& loc);
2281+
template <typename Locale> locale_ref(const Locale& loc);
22622282

22632283
inline explicit operator bool() const noexcept { return locale_ != nullptr; }
22642284
#endif // FMT_USE_LOCALE
@@ -2604,10 +2624,11 @@ template <typename Context> class basic_format_args {
26042624
};
26052625

26062626
// A formatting context.
2607-
class context : private detail::locale_ref {
2627+
class context {
26082628
private:
26092629
appender out_;
26102630
format_args args_;
2631+
FMT_NO_UNIQUE_ADDRESS detail::locale_ref loc_;
26112632

26122633
public:
26132634
/// The character type for the output.
@@ -2623,7 +2644,7 @@ class context : private detail::locale_ref {
26232644
/// in the object so make sure they have appropriate lifetimes.
26242645
FMT_CONSTEXPR context(iterator out, format_args args,
26252646
detail::locale_ref loc = {})
2626-
: locale_ref(loc), out_(out), args_(args) {}
2647+
: out_(out), args_(args), loc_(loc) {}
26272648
context(context&&) = default;
26282649
context(const context&) = delete;
26292650
void operator=(const context&) = delete;
@@ -2635,14 +2656,15 @@ class context : private detail::locale_ref {
26352656
FMT_CONSTEXPR auto arg_id(string_view name) const -> int {
26362657
return args_.get_id(name);
26372658
}
2659+
auto args() const -> const format_args& { return args_; }
26382660

26392661
// Returns an iterator to the beginning of the output range.
26402662
FMT_CONSTEXPR auto out() const -> iterator { return out_; }
26412663

26422664
// Advances the begin iterator to `it`.
26432665
FMT_CONSTEXPR void advance_to(iterator) {}
26442666

2645-
FMT_CONSTEXPR auto locale() const -> detail::locale_ref { return *this; }
2667+
FMT_CONSTEXPR auto locale() const -> detail::locale_ref { return loc_; }
26462668
};
26472669

26482670
template <typename Char = char> struct runtime_format_string {
@@ -2659,7 +2681,8 @@ template <typename Char = char> struct runtime_format_string {
26592681
*/
26602682
inline auto runtime(string_view s) -> runtime_format_string<> { return {{s}}; }
26612683

2662-
/// A compile-time format string.
2684+
/// A compile-time format string. Use `format_string` in the public API to
2685+
/// prevent type deduction.
26632686
template <typename... T> struct fstring {
26642687
private:
26652688
static constexpr int num_static_named_args =

Diff for: wpiutil/src/main/native/thirdparty/fmtlib/include/fmt/chrono.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ namespace detail {
261261
using utc_clock = std::chrono::utc_clock;
262262
#else
263263
struct utc_clock {
264-
void to_sys();
264+
template <typename T> void to_sys(T);
265265
};
266266
#endif
267267

@@ -364,7 +364,7 @@ void write_codecvt(codecvt_result<CodeUnit>& out, string_view in,
364364
template <typename OutputIt>
365365
auto write_encoded_tm_str(OutputIt out, string_view in, const std::locale& loc)
366366
-> OutputIt {
367-
if (detail::use_utf8 && loc != get_classic_locale()) {
367+
if (const_check(detail::use_utf8) && loc != get_classic_locale()) {
368368
// char16_t and char32_t codecvts are broken in MSVC (linkage errors) and
369369
// gcc-4.
370370
#if FMT_MSC_VERSION != 0 || \

Diff for: wpiutil/src/main/native/thirdparty/fmtlib/include/fmt/format-inl.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ using std::locale;
8484
using std::numpunct;
8585
using std::use_facet;
8686

87-
template <typename Locale, enable_if_t<(sizeof(Locale::collate) != 0), int>>
87+
template <typename Locale>
8888
locale_ref::locale_ref(const Locale& loc) : locale_(&loc) {
8989
static_assert(std::is_same<Locale, locale>::value, "");
9090
}
@@ -134,7 +134,9 @@ FMT_FUNC auto write_loc(appender out, loc_value value,
134134

135135
FMT_FUNC void report_error(const char* message) {
136136
#if FMT_USE_EXCEPTIONS
137-
throw format_error(message);
137+
// Use FMT_THROW instead of throw to avoid bogus unreachable code warnings
138+
// from MSVC.
139+
FMT_THROW(format_error(message));
138140
#else
139141
fputs(message, stderr);
140142
abort();

Diff for: wpiutil/src/main/native/thirdparty/fmtlib/include/fmt/format.h

+33-33
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,6 @@ FMT_END_NAMESPACE
151151
# endif // FMT_USE_EXCEPTIONS
152152
#endif // FMT_THROW
153153

154-
#ifdef FMT_NO_UNIQUE_ADDRESS
155-
// Use the provided definition.
156-
#elif FMT_CPLUSPLUS < 202002L
157-
// Not supported.
158-
#elif FMT_HAS_CPP_ATTRIBUTE(no_unique_address)
159-
# define FMT_NO_UNIQUE_ADDRESS [[no_unique_address]]
160-
// VS2019 v16.10 and later except clang-cl (https://reviews.llvm.org/D110485).
161-
#elif FMT_MSC_VERSION >= 1929 && !FMT_CLANG_VERSION
162-
# define FMT_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
163-
#endif
164-
#ifndef FMT_NO_UNIQUE_ADDRESS
165-
# define FMT_NO_UNIQUE_ADDRESS
166-
#endif
167-
168154
// Defining FMT_REDUCE_INT_INSTANTIATIONS to 1, will reduce the number of
169155
// integer formatter template instantiations to just one by only using the
170156
// largest integer type. This results in a reduction in binary size but will
@@ -241,7 +227,9 @@ FMT_CONSTEXPR inline void abort_fuzzing_if(bool condition) {
241227
#if defined(FMT_USE_STRING_VIEW)
242228
template <typename Char> using std_string_view = std::basic_string_view<Char>;
243229
#else
244-
template <typename T> struct std_string_view {};
230+
template <typename Char> struct std_string_view {
231+
operator basic_string_view<Char>() const;
232+
};
245233
#endif
246234

247235
template <typename Char, Char... C> struct string_literal {
@@ -1217,7 +1205,7 @@ FMT_CONSTEXPR FMT_INLINE auto format_decimal(Char* out, UInt value,
12171205
}
12181206

12191207
template <typename Char, typename UInt, typename OutputIt,
1220-
FMT_ENABLE_IF(is_back_insert_iterator<OutputIt>::value)>
1208+
FMT_ENABLE_IF(!std::is_pointer<remove_cvref_t<OutputIt>>::value)>
12211209
FMT_CONSTEXPR auto format_decimal(OutputIt out, UInt value, int num_digits)
12221210
-> OutputIt {
12231211
if (auto ptr = to_pointer<Char>(out, to_unsigned(num_digits))) {
@@ -1853,7 +1841,9 @@ template <typename Char> class digit_grouping {
18531841
}
18541842

18551843
public:
1856-
explicit digit_grouping(locale_ref loc, bool localized = true) {
1844+
template <typename Locale,
1845+
FMT_ENABLE_IF(std::is_same<Locale, locale_ref>::value)>
1846+
explicit digit_grouping(Locale loc, bool localized = true) {
18571847
if (!localized) return;
18581848
auto sep = thousands_sep<Char>(loc);
18591849
grouping_ = sep.grouping;
@@ -3653,6 +3643,12 @@ FMT_CONSTEXPR auto native_formatter<T, Char, TYPE>::format(
36533643
return write<Char>(ctx.out(), val, specs, ctx.locale());
36543644
}
36553645

3646+
// DEPRECATED! https://github.com/fmtlib/fmt/issues/4292.
3647+
template <typename T, typename Enable = void>
3648+
struct is_locale : std::false_type {};
3649+
template <typename T>
3650+
struct is_locale<T, void_t<decltype(T::classic())>> : std::true_type {};
3651+
36563652
// DEPRECATED!
36573653
template <typename Char = char> struct vformat_args {
36583654
using type = basic_format_args<buffered_context<Char>>;
@@ -3974,8 +3970,7 @@ template <typename T, typename Char = char> struct nested_formatter {
39743970
write(basic_appender<Char>(buf));
39753971
auto specs = format_specs();
39763972
specs.width = width_;
3977-
specs.set_fill(
3978-
basic_string_view<Char>(specs_.fill<Char>(), specs_.fill_size()));
3973+
specs.copy_fill_from(specs_);
39793974
specs.set_align(specs_.align());
39803975
return detail::write<Char>(
39813976
ctx.out(), basic_string_view<Char>(buf.data(), buf.size()), specs);
@@ -4135,41 +4130,46 @@ FMT_API void format_system_error(detail::buffer<char>& out, int error_code,
41354130
// Can be used to report errors from destructors.
41364131
FMT_API void report_system_error(int error_code, const char* message) noexcept;
41374132

4138-
inline auto vformat(detail::locale_ref loc, string_view fmt, format_args args)
4133+
template <typename Locale, FMT_ENABLE_IF(detail::is_locale<Locale>::value)>
4134+
inline auto vformat(const Locale& loc, string_view fmt, format_args args)
41394135
-> std::string {
41404136
auto buf = memory_buffer();
4141-
detail::vformat_to(buf, fmt, args, loc);
4137+
detail::vformat_to(buf, fmt, args, detail::locale_ref(loc));
41424138
return {buf.data(), buf.size()};
41434139
}
41444140

4145-
template <typename... T>
4146-
FMT_INLINE auto format(detail::locale_ref loc, format_string<T...> fmt,
4147-
T&&... args) -> std::string {
4141+
template <typename Locale, typename... T,
4142+
FMT_ENABLE_IF(detail::is_locale<Locale>::value)>
4143+
FMT_INLINE auto format(const Locale& loc, format_string<T...> fmt, T&&... args)
4144+
-> std::string {
41484145
return vformat(loc, fmt.str, vargs<T...>{{args...}});
41494146
}
41504147

4151-
template <typename OutputIt,
4148+
template <typename OutputIt, typename Locale,
41524149
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>
4153-
auto vformat_to(OutputIt out, detail::locale_ref loc, string_view fmt,
4150+
auto vformat_to(OutputIt out, const Locale& loc, string_view fmt,
41544151
format_args args) -> OutputIt {
41554152
auto&& buf = detail::get_buffer<char>(out);
4156-
detail::vformat_to(buf, fmt, args, loc);
4153+
detail::vformat_to(buf, fmt, args, detail::locale_ref(loc));
41574154
return detail::get_iterator(buf, out);
41584155
}
41594156

4160-
template <typename OutputIt, typename... T,
4161-
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>
4162-
FMT_INLINE auto format_to(OutputIt out, detail::locale_ref loc,
4157+
template <typename OutputIt, typename Locale, typename... T,
4158+
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value&&
4159+
detail::is_locale<Locale>::value)>
4160+
FMT_INLINE auto format_to(OutputIt out, const Locale& loc,
41634161
format_string<T...> fmt, T&&... args) -> OutputIt {
41644162
return fmt::vformat_to(out, loc, fmt.str, vargs<T...>{{args...}});
41654163
}
41664164

4167-
template <typename... T>
4168-
FMT_NODISCARD FMT_INLINE auto formatted_size(detail::locale_ref loc,
4165+
template <typename Locale, typename... T,
4166+
FMT_ENABLE_IF(detail::is_locale<Locale>::value)>
4167+
FMT_NODISCARD FMT_INLINE auto formatted_size(const Locale& loc,
41694168
format_string<T...> fmt,
41704169
T&&... args) -> size_t {
41714170
auto buf = detail::counting_buffer<>();
4172-
detail::vformat_to(buf, fmt.str, vargs<T...>{{args...}}, loc);
4171+
detail::vformat_to(buf, fmt.str, vargs<T...>{{args...}},
4172+
detail::locale_ref(loc));
41734173
return buf.count();
41744174
}
41754175

Diff for: wpiutil/src/main/native/thirdparty/fmtlib/include/fmt/ostream.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ inline void vprint(std::ostream& os, string_view fmt, format_args args) {
150150
FMT_EXPORT template <typename... T>
151151
void print(std::ostream& os, format_string<T...> fmt, T&&... args) {
152152
fmt::vargs<T...> vargs = {{args...}};
153-
if (detail::use_utf8) return vprint(os, fmt.str, vargs);
153+
if (detail::const_check(detail::use_utf8)) return vprint(os, fmt.str, vargs);
154154
auto buffer = memory_buffer();
155155
detail::vformat_to(buffer, fmt.str, vargs);
156156
detail::write_buffer(os, buffer);

Diff for: wpiutil/src/main/native/thirdparty/fmtlib/include/fmt/ranges.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,9 @@ struct formatter<
527527
template <typename R, typename Char>
528528
struct formatter<
529529
R, Char,
530-
enable_if_t<range_format_kind<R, Char>::value == range_format::map>> {
530+
enable_if_t<conjunction<
531+
bool_constant<range_format_kind<R, Char>::value == range_format::map>,
532+
detail::is_formattable_delayed<R, Char>>::value>> {
531533
private:
532534
using map_type = detail::maybe_const_range<R>;
533535
using element_type = detail::uncvref_type<map_type>;

Diff for: wpiutil/src/main/native/thirdparty/fmtlib/include/fmt/std.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ FMT_END_NAMESPACE
184184
FMT_BEGIN_NAMESPACE
185185
FMT_EXPORT
186186
template <std::size_t N, typename Char>
187-
struct formatter<std::bitset<N>, Char> : nested_formatter<string_view> {
187+
struct formatter<std::bitset<N>, Char>
188+
: nested_formatter<basic_string_view<Char>, Char> {
188189
private:
189190
// Functor because C++11 doesn't support generic lambdas.
190191
struct writer {
@@ -204,7 +205,7 @@ struct formatter<std::bitset<N>, Char> : nested_formatter<string_view> {
204205
template <typename FormatContext>
205206
auto format(const std::bitset<N>& bs, FormatContext& ctx) const
206207
-> decltype(ctx.out()) {
207-
return write_padded(ctx, writer{bs});
208+
return this->write_padded(ctx, writer{bs});
208209
}
209210
};
210211

@@ -695,9 +696,7 @@ template <typename T, typename Char> struct formatter<std::complex<T>, Char> {
695696

696697
auto outer_specs = format_specs();
697698
outer_specs.width = specs.width;
698-
auto fill = specs.template fill<Char>();
699-
if (fill)
700-
outer_specs.set_fill(basic_string_view<Char>(fill, specs.fill_size()));
699+
outer_specs.copy_fill_from(specs);
701700
outer_specs.set_align(specs.align());
702701

703702
specs.width = 0;

0 commit comments

Comments
 (0)