Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO-NOT-MERGE] testing the power of clang-19 #3

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 32 additions & 29 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ template <typename Char> FMT_CONSTEXPR auto length(const Char* s) -> size_t {
}

template <typename Char>
FMT_CONSTEXPR auto compare(const Char* s1, const Char* s2, std::size_t n)
-> int {
FMT_CONSTEXPR auto compare(const Char* s1, const Char* s2,
std::size_t n) -> int {
for (; n != 0; ++s1, ++s2, --n) {
if (*s1 < *s2) return -1;
if (*s1 > *s2) return 1;
Expand Down Expand Up @@ -2048,12 +2048,17 @@ FMT_EXPORT using format_args = basic_format_args<format_context>;
# define FMT_ENUM_UNDERLYING_TYPE(type) : type
#endif
namespace align {
enum type FMT_ENUM_UNDERLYING_TYPE(unsigned char){none, left, right, center,
numeric};
enum type FMT_ENUM_UNDERLYING_TYPE(unsigned char) {
none,
left,
right,
center,
numeric
};
}
using align_t = align::type;
namespace sign {
enum type FMT_ENUM_UNDERLYING_TYPE(unsigned char){none, minus, plus, space};
enum type FMT_ENUM_UNDERLYING_TYPE(unsigned char) { none, minus, plus, space };
}
using sign_t = sign::type;

Expand Down Expand Up @@ -2325,10 +2330,9 @@ template <typename Char> struct dynamic_spec_id_handler {

// Parses [integer | "{" [arg_id] "}"].
template <typename Char>
FMT_CONSTEXPR auto parse_dynamic_spec(const Char* begin, const Char* end,
int& value, arg_ref<Char>& ref,
basic_format_parse_context<Char>& ctx)
-> const Char* {
FMT_CONSTEXPR auto parse_dynamic_spec(
const Char* begin, const Char* end, int& value, arg_ref<Char>& ref,
basic_format_parse_context<Char>& ctx) -> const Char* {
FMT_ASSERT(begin != end, "");
if ('0' <= *begin && *begin <= '9') {
int val = parse_nonnegative_int(begin, end, -1);
Expand All @@ -2347,10 +2351,9 @@ FMT_CONSTEXPR auto parse_dynamic_spec(const Char* begin, const Char* end,
}

template <typename Char>
FMT_CONSTEXPR auto parse_precision(const Char* begin, const Char* end,
int& value, arg_ref<Char>& ref,
basic_format_parse_context<Char>& ctx)
-> const Char* {
FMT_CONSTEXPR auto parse_precision(
const Char* begin, const Char* end, int& value, arg_ref<Char>& ref,
basic_format_parse_context<Char>& ctx) -> const Char* {
++begin;
if (begin == end || *begin == '}') {
report_error("invalid precision");
Expand Down Expand Up @@ -2642,8 +2645,8 @@ template <typename T> struct strip_named_arg<T, true> {

template <typename T, typename ParseContext>
FMT_VISIBILITY("hidden") // Suppress an ld warning on macOS (#3769).
FMT_CONSTEXPR auto parse_format_specs(ParseContext& ctx)
-> decltype(ctx.begin()) {
FMT_CONSTEXPR
auto parse_format_specs(ParseContext& ctx) -> decltype(ctx.begin()) {
using char_type = typename ParseContext::char_type;
using context = buffered_context<char_type>;
using mapped_type = conditional_t<
Expand Down Expand Up @@ -2741,8 +2744,8 @@ template <typename Char, typename... Args> class format_string_checker {
on_format_specs(id, begin, begin); // Call parse() on empty specs.
}

FMT_CONSTEXPR auto on_format_specs(int id, const Char* begin, const Char*)
-> const Char* {
FMT_CONSTEXPR auto on_format_specs(int id, const Char* begin,
const Char*) -> const Char* {
context_.advance_to(begin);
// id >= 0 check is a workaround for gcc 10 bug (#2065).
return id >= 0 && id < num_args ? parse_funcs_[id](context_) : begin;
Expand Down Expand Up @@ -2824,8 +2827,8 @@ template <typename T, typename Char, type TYPE> struct native_formatter {
}

template <typename FormatContext>
FMT_CONSTEXPR auto format(const T& val, FormatContext& ctx) const
-> decltype(ctx.out());
FMT_CONSTEXPR auto format(const T& val,
FormatContext& ctx) const -> decltype(ctx.out());
};
} // namespace detail

Expand Down Expand Up @@ -2900,8 +2903,8 @@ inline auto runtime(string_view s) -> runtime_format_string<> { return {{s}}; }
template <typename OutputIt,
FMT_ENABLE_IF(detail::is_output_iterator<remove_cvref_t<OutputIt>,
char>::value)>
auto vformat_to(OutputIt&& out, string_view fmt, format_args args)
-> remove_cvref_t<OutputIt> {
auto vformat_to(OutputIt&& out, string_view fmt,
format_args args) -> remove_cvref_t<OutputIt> {
auto&& buf = detail::get_buffer<char>(out);
detail::vformat_to(buf, fmt, args, {});
return detail::get_iterator(buf, out);
Expand All @@ -2920,8 +2923,8 @@ auto vformat_to(OutputIt&& out, string_view fmt, format_args args)
template <typename OutputIt, typename... T,
FMT_ENABLE_IF(detail::is_output_iterator<remove_cvref_t<OutputIt>,
char>::value)>
FMT_INLINE auto format_to(OutputIt&& out, format_string<T...> fmt, T&&... args)
-> remove_cvref_t<OutputIt> {
FMT_INLINE auto format_to(OutputIt&& out, format_string<T...> fmt,
T&&... args) -> remove_cvref_t<OutputIt> {
return vformat_to(FMT_FWD(out), fmt, fmt::make_format_args(args...));
}

Expand All @@ -2934,8 +2937,8 @@ template <typename OutputIt> struct format_to_n_result {

template <typename OutputIt, typename... T,
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>
auto vformat_to_n(OutputIt out, size_t n, string_view fmt, format_args args)
-> format_to_n_result<OutputIt> {
auto vformat_to_n(OutputIt out, size_t n, string_view fmt,
format_args args) -> format_to_n_result<OutputIt> {
using traits = detail::fixed_buffer_traits;
auto buf = detail::iterator_buffer<OutputIt, char, traits>(out, n);
detail::vformat_to(buf, fmt, args, {});
Expand Down Expand Up @@ -2977,15 +2980,15 @@ struct format_to_result {
};

template <size_t N>
auto vformat_to(char (&out)[N], string_view fmt, format_args args)
-> format_to_result<char*> {
auto vformat_to(char (&out)[N], string_view fmt,
format_args args) -> format_to_result<char*> {
auto result = vformat_to_n(out, N, fmt, args);
return {result.out, result.size > N};
}

template <size_t N, typename... T>
FMT_INLINE auto format_to(char (&out)[N], format_string<T...> fmt, T&&... args)
-> format_to_result<char*> {
FMT_INLINE auto format_to(char (&out)[N], format_string<T...> fmt,
T&&... args) -> format_to_result<char*> {
auto result = fmt::format_to_n(out, N, fmt, static_cast<T&&>(args)...);
return {result.out, result.size > N};
}
Expand Down
50 changes: 24 additions & 26 deletions include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ template <typename To, typename From,
FMT_ENABLE_IF(!std::is_same<From, To>::value &&
std::numeric_limits<From>::is_signed ==
std::numeric_limits<To>::is_signed)>
FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)
-> To {
FMT_CONSTEXPR auto lossless_integral_conversion(const From from,
int& ec) -> To {
ec = 0;
using F = std::numeric_limits<From>;
using T = std::numeric_limits<To>;
Expand All @@ -102,8 +102,8 @@ template <typename To, typename From,
FMT_ENABLE_IF(!std::is_same<From, To>::value &&
std::numeric_limits<From>::is_signed !=
std::numeric_limits<To>::is_signed)>
FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)
-> To {
FMT_CONSTEXPR auto lossless_integral_conversion(const From from,
int& ec) -> To {
ec = 0;
using F = std::numeric_limits<From>;
using T = std::numeric_limits<To>;
Expand Down Expand Up @@ -135,8 +135,8 @@ FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)

template <typename To, typename From,
FMT_ENABLE_IF(std::is_same<From, To>::value)>
FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)
-> To {
FMT_CONSTEXPR auto lossless_integral_conversion(const From from,
int& ec) -> To {
ec = 0;
return from;
} // function
Expand Down Expand Up @@ -389,8 +389,8 @@ void write_codecvt(codecvt_result<CodeUnit>& out, string_view in_buf,
}

template <typename OutputIt>
auto write_encoded_tm_str(OutputIt out, string_view in, const std::locale& loc)
-> OutputIt {
auto write_encoded_tm_str(OutputIt out, string_view in,
const std::locale& loc) -> OutputIt {
if (detail::use_utf8() && loc != get_classic_locale()) {
// char16_t and char32_t codecvts are broken in MSVC (linkage errors) and
// gcc-4.
Expand Down Expand Up @@ -419,17 +419,17 @@ auto write_encoded_tm_str(OutputIt out, string_view in, const std::locale& loc)

template <typename Char, typename OutputIt,
FMT_ENABLE_IF(!std::is_same<Char, char>::value)>
auto write_tm_str(OutputIt out, string_view sv, const std::locale& loc)
-> OutputIt {
auto write_tm_str(OutputIt out, string_view sv,
const std::locale& loc) -> OutputIt {
codecvt_result<Char> unit;
write_codecvt(unit, sv, loc);
return copy<Char>(unit.buf, unit.end, out);
}

template <typename Char, typename OutputIt,
FMT_ENABLE_IF(std::is_same<Char, char>::value)>
auto write_tm_str(OutputIt out, string_view sv, const std::locale& loc)
-> OutputIt {
auto write_tm_str(OutputIt out, string_view sv,
const std::locale& loc) -> OutputIt {
return write_encoded_tm_str(out, sv, loc);
}

Expand Down Expand Up @@ -497,9 +497,8 @@ auto fmt_duration_cast(std::chrono::duration<FromRep, FromPeriod> from) -> To {
}

template <typename Duration>
auto to_time_t(
std::chrono::time_point<std::chrono::system_clock, Duration> time_point)
-> std::time_t {
auto to_time_t(std::chrono::time_point<std::chrono::system_clock, Duration>
time_point) -> std::time_t {
// Cannot use std::chrono::system_clock::to_time_t since this would first
// require a cast to std::chrono::system_clock::time_point, which could
// overflow.
Expand Down Expand Up @@ -601,9 +600,8 @@ inline auto gmtime(std::time_t time) -> std::tm {
}

template <typename Duration>
inline auto gmtime(
std::chrono::time_point<std::chrono::system_clock, Duration> time_point)
-> std::tm {
inline auto gmtime(std::chrono::time_point<std::chrono::system_clock, Duration>
time_point) -> std::tm {
return gmtime(detail::to_time_t(time_point));
}

Expand Down Expand Up @@ -2219,8 +2217,8 @@ struct formatter<year_month_day, Char> : private formatter<std::tm, Char> {
}

template <typename FormatContext>
auto format(year_month_day val, FormatContext& ctx) const
-> decltype(ctx.out()) {
auto format(year_month_day val,
FormatContext& ctx) const -> decltype(ctx.out()) {
auto time = std::tm();
time.tm_year = static_cast<int>(val.year()) - 1900;
time.tm_mon = static_cast<int>(static_cast<unsigned>(val.month())) - 1;
Expand Down Expand Up @@ -2270,8 +2268,8 @@ struct formatter<std::chrono::duration<Rep, Period>, Char> {
}

template <typename FormatContext>
auto format(std::chrono::duration<Rep, Period> d, FormatContext& ctx) const
-> decltype(ctx.out()) {
auto format(std::chrono::duration<Rep, Period> d,
FormatContext& ctx) const -> decltype(ctx.out()) {
auto specs = specs_;
auto precision = specs.precision;
specs.precision = -1;
Expand Down Expand Up @@ -2342,8 +2340,8 @@ struct formatter<std::chrono::local_time<Duration>, Char>
}

template <typename FormatContext>
auto format(std::chrono::local_time<Duration> val, FormatContext& ctx) const
-> decltype(ctx.out()) {
auto format(std::chrono::local_time<Duration> val,
FormatContext& ctx) const -> decltype(ctx.out()) {
using period = typename Duration::period;
if (period::num != 1 || period::den != 1 ||
std::is_floating_point<typename Duration::rep>::value) {
Expand Down Expand Up @@ -2420,8 +2418,8 @@ template <typename Char> struct formatter<std::tm, Char> {
}

template <typename FormatContext>
auto format(const std::tm& tm, FormatContext& ctx) const
-> decltype(ctx.out()) {
auto format(const std::tm& tm,
FormatContext& ctx) const -> decltype(ctx.out()) {
return do_format<FormatContext, std::chrono::seconds>(tm, ctx, nullptr);
}
};
Expand Down
26 changes: 13 additions & 13 deletions include/fmt/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ enum class color : uint32_t {
white_smoke = 0xF5F5F5, // rgb(245,245,245)
yellow = 0xFFFF00, // rgb(255,255,0)
yellow_green = 0x9ACD32 // rgb(154,205,50)
}; // enum class color
}; // enum class color

enum class terminal_color : uint8_t {
black = 30,
Expand Down Expand Up @@ -257,8 +257,8 @@ class text_style {
return *this;
}

friend FMT_CONSTEXPR auto operator|(text_style lhs, const text_style& rhs)
-> text_style {
friend FMT_CONSTEXPR auto operator|(text_style lhs,
const text_style& rhs) -> text_style {
return lhs |= rhs;
}

Expand Down Expand Up @@ -322,8 +322,8 @@ FMT_CONSTEXPR inline auto bg(detail::color_type background) noexcept
return text_style(false, background);
}

FMT_CONSTEXPR inline auto operator|(emphasis lhs, emphasis rhs) noexcept
-> text_style {
FMT_CONSTEXPR inline auto operator|(emphasis lhs,
emphasis rhs) noexcept -> text_style {
return text_style(lhs) | rhs;
}

Expand Down Expand Up @@ -405,8 +405,8 @@ template <typename Char> struct ansi_color_escape {
out[2] = static_cast<Char>('0' + c % 10);
out[3] = static_cast<Char>(delimiter);
}
static FMT_CONSTEXPR auto has_emphasis(emphasis em, emphasis mask) noexcept
-> bool {
static FMT_CONSTEXPR auto has_emphasis(emphasis em,
emphasis mask) noexcept -> bool {
return static_cast<uint8_t>(em) & static_cast<uint8_t>(mask);
}
};
Expand Down Expand Up @@ -502,8 +502,8 @@ void print(const text_style& ts, format_string<T...> fmt, T&&... args) {
return print(stdout, ts, fmt, std::forward<T>(args)...);
}

inline auto vformat(const text_style& ts, string_view fmt, format_args args)
-> std::string {
inline auto vformat(const text_style& ts, string_view fmt,
format_args args) -> std::string {
auto buf = memory_buffer();
detail::vformat_to(buf, ts, fmt, args);
return fmt::to_string(buf);
Expand All @@ -522,8 +522,8 @@ inline auto vformat(const text_style& ts, string_view fmt, format_args args)
* ```
*/
template <typename... T>
inline auto format(const text_style& ts, format_string<T...> fmt, T&&... args)
-> std::string {
inline auto format(const text_style& ts, format_string<T...> fmt,
T&&... args) -> std::string {
return fmt::vformat(ts, fmt, fmt::make_format_args(args...));
}

Expand Down Expand Up @@ -557,8 +557,8 @@ inline auto format_to(OutputIt out, const text_style& ts,
template <typename T, typename Char>
struct formatter<detail::styled_arg<T>, Char> : formatter<T, Char> {
template <typename FormatContext>
auto format(const detail::styled_arg<T>& arg, FormatContext& ctx) const
-> decltype(ctx.out()) {
auto format(const detail::styled_arg<T>& arg,
FormatContext& ctx) const -> decltype(ctx.out()) {
const auto& ts = arg.style;
const auto& value = arg.value;
auto out = ctx.out();
Expand Down
12 changes: 6 additions & 6 deletions include/fmt/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ FMT_EXPORT class compiled_string {};
namespace detail {

template <typename T, typename InputIt>
FMT_CONSTEXPR inline auto copy(InputIt begin, InputIt end, counting_iterator it)
-> counting_iterator {
FMT_CONSTEXPR inline auto copy(InputIt begin, InputIt end,
counting_iterator it) -> counting_iterator {
return it + (end - begin);
}

Expand Down Expand Up @@ -484,8 +484,8 @@ FMT_CONSTEXPR OutputIt format_to(OutputIt out, const S&, Args&&... args) {

template <typename OutputIt, typename S, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
auto format_to_n(OutputIt out, size_t n, const S& fmt, Args&&... args)
-> format_to_n_result<OutputIt> {
auto format_to_n(OutputIt out, size_t n, const S& fmt,
Args&&... args) -> format_to_n_result<OutputIt> {
using traits = detail::fixed_buffer_traits;
auto buf = detail::iterator_buffer<OutputIt, char, traits>(out, n);
fmt::format_to(std::back_inserter(buf), fmt, std::forward<Args>(args)...);
Expand All @@ -494,8 +494,8 @@ auto format_to_n(OutputIt out, size_t n, const S& fmt, Args&&... args)

template <typename S, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
FMT_CONSTEXPR20 auto formatted_size(const S& fmt, const Args&... args)
-> size_t {
FMT_CONSTEXPR20 auto formatted_size(const S& fmt,
const Args&... args) -> size_t {
return fmt::format_to(detail::counting_iterator(), fmt, args...).count();
}

Expand Down
Loading
Loading