Improve debug codegen

This commit is contained in:
Victor Zverovich 2024-09-05 20:18:52 -07:00
parent f288f45e46
commit 8ed4a9dcc1
2 changed files with 35 additions and 25 deletions

View File

@ -15,21 +15,16 @@ jobs:
# https://github.com/actions/virtual-environments. # https://github.com/actions/virtual-environments.
os: [windows-2019] os: [windows-2019]
platform: [Win32, x64] platform: [Win32, x64]
toolset: [v140, v141, v142] toolset: [v141, v142]
standard: [14, 17, 20] standard: [14, 17, 20]
shared: ["", -DBUILD_SHARED_LIBS=ON] shared: ["", -DBUILD_SHARED_LIBS=ON]
build_type: [Debug, Release] build_type: [Debug, Release]
exclude: exclude:
- { toolset: v140, standard: 17 }
- { toolset: v140, standard: 20 }
- { toolset: v141, standard: 14 }
- { toolset: v141, standard: 20 } - { toolset: v141, standard: 20 }
- { toolset: v142, standard: 14 } - { toolset: v142, standard: 14 }
- { platform: Win32, toolset: v140 }
- { platform: Win32, toolset: v141 } - { platform: Win32, toolset: v141 }
- { platform: Win32, standard: 14 } - { platform: Win32, standard: 14 }
- { platform: Win32, standard: 20 } - { platform: Win32, standard: 20 }
- { platform: x64, toolset: v140, shared: -DBUILD_SHARED_LIBS=ON }
- { platform: x64, toolset: v141, shared: -DBUILD_SHARED_LIBS=ON } - { platform: x64, toolset: v141, shared: -DBUILD_SHARED_LIBS=ON }
- { platform: x64, standard: 14, shared: -DBUILD_SHARED_LIBS=ON } - { platform: x64, standard: 14, shared: -DBUILD_SHARED_LIBS=ON }
- { platform: x64, standard: 20, shared: -DBUILD_SHARED_LIBS=ON } - { platform: x64, standard: 20, shared: -DBUILD_SHARED_LIBS=ON }

View File

@ -2238,8 +2238,19 @@ template <typename Context> class value {
} }
FMT_ALWAYS_INLINE value(const void* val) : pointer(val) {} FMT_ALWAYS_INLINE value(const void* val) : pointer(val) {}
template <typename T> template <typename T,
FMT_CONSTEXPR20 FMT_ALWAYS_INLINE value(T&& val, custom_tag = {}) { FMT_ENABLE_IF(
!std::is_same<T, decltype(detail::arg_mapper<char_type>::map(
std::declval<T&>()))>::value)>
FMT_CONSTEXPR20 FMT_ALWAYS_INLINE value(T&& val) {
*this = arg_mapper<typename Context::char_type>::map(val);
}
template <
typename T,
FMT_ENABLE_IF(std::is_same<T, decltype(detail::arg_mapper<char_type>::map(
std::declval<T&>()))>::value)>
FMT_CONSTEXPR20 FMT_ALWAYS_INLINE value(T&& val) {
// Use enum instead of constexpr because the latter may generate code. // Use enum instead of constexpr because the latter may generate code.
enum { formattable_char = !std::is_same<T, unformattable_char>::value }; enum { formattable_char = !std::is_same<T, unformattable_char>::value };
static_assert(formattable_char, "mixing character types is disallowed"); static_assert(formattable_char, "mixing character types is disallowed");
@ -2374,8 +2385,7 @@ struct named_arg_store {
template <typename... T> template <typename... T>
FMT_CONSTEXPR FMT_ALWAYS_INLINE named_arg_store(T&... values) FMT_CONSTEXPR FMT_ALWAYS_INLINE named_arg_store(T&... values)
: args{{named_args, NUM_NAMED_ARGS}, : args{{named_args, NUM_NAMED_ARGS}, values...} {
arg_mapper<typename Context::char_type>::map(values)...} {
int arg_index = 0, named_arg_index = 0; int arg_index = 0, named_arg_index = 0;
FMT_APPLY_VARIADIC( FMT_APPLY_VARIADIC(
init_named_arg(named_args, arg_index, named_arg_index, values)); init_named_arg(named_args, arg_index, named_arg_index, values));
@ -2636,6 +2646,10 @@ template <typename Context> class basic_format_args {
return static_cast<detail::type>((desc_ >> shift) & mask); return static_cast<detail::type>((desc_ >> shift) & mask);
} }
template <size_t NUM_ARGS, size_t NUM_NAMED_ARGS, unsigned long long DESC>
using store =
detail::format_arg_store<Context, NUM_ARGS, NUM_NAMED_ARGS, DESC>;
public: public:
using format_arg = basic_format_arg<Context>; using format_arg = basic_format_arg<Context>;
@ -2646,33 +2660,26 @@ template <typename Context> class basic_format_args {
FMT_ENABLE_IF(NUM_ARGS <= detail::max_packed_args && FMT_ENABLE_IF(NUM_ARGS <= detail::max_packed_args &&
NUM_NAMED_ARGS == 0)> NUM_NAMED_ARGS == 0)>
constexpr FMT_ALWAYS_INLINE basic_format_args( constexpr FMT_ALWAYS_INLINE basic_format_args(
const detail::format_arg_store<Context, NUM_ARGS, NUM_NAMED_ARGS, DESC>& const store<NUM_ARGS, NUM_NAMED_ARGS, DESC>& s)
store) : desc_(DESC), values_(s.args) {}
: desc_(DESC), values_(store.args) {}
template <size_t NUM_ARGS, size_t NUM_NAMED_ARGS, unsigned long long DESC, template <size_t NUM_ARGS, size_t NUM_NAMED_ARGS, unsigned long long DESC,
FMT_ENABLE_IF(NUM_ARGS <= detail::max_packed_args && FMT_ENABLE_IF(NUM_ARGS <= detail::max_packed_args &&
NUM_NAMED_ARGS != 0)> NUM_NAMED_ARGS != 0)>
constexpr FMT_ALWAYS_INLINE basic_format_args( constexpr basic_format_args(const store<NUM_ARGS, NUM_NAMED_ARGS, DESC>& s)
const detail::format_arg_store<Context, NUM_ARGS, NUM_NAMED_ARGS, DESC>& : desc_(DESC | detail::has_named_args_bit), values_(s.args.args + 1) {}
store)
: desc_(DESC), values_(store.args.args + 1) {}
template <size_t NUM_ARGS, size_t NUM_NAMED_ARGS, unsigned long long DESC, template <size_t NUM_ARGS, size_t NUM_NAMED_ARGS, unsigned long long DESC,
FMT_ENABLE_IF(NUM_ARGS > detail::max_packed_args && FMT_ENABLE_IF(NUM_ARGS > detail::max_packed_args &&
NUM_NAMED_ARGS == 0)> NUM_NAMED_ARGS == 0)>
constexpr basic_format_args( constexpr basic_format_args(const store<NUM_ARGS, NUM_NAMED_ARGS, DESC>& s)
const detail::format_arg_store<Context, NUM_ARGS, NUM_NAMED_ARGS, DESC>& : desc_(DESC), args_(s.args) {}
store)
: desc_(DESC), args_(store.args + (NUM_NAMED_ARGS != 0 ? 1 : 0)) {}
template <size_t NUM_ARGS, size_t NUM_NAMED_ARGS, unsigned long long DESC, template <size_t NUM_ARGS, size_t NUM_NAMED_ARGS, unsigned long long DESC,
FMT_ENABLE_IF(NUM_ARGS > detail::max_packed_args && FMT_ENABLE_IF(NUM_ARGS > detail::max_packed_args &&
NUM_NAMED_ARGS != 0)> NUM_NAMED_ARGS != 0)>
constexpr basic_format_args( constexpr basic_format_args(const store<NUM_ARGS, NUM_NAMED_ARGS, DESC>& s)
const detail::format_arg_store<Context, NUM_ARGS, NUM_NAMED_ARGS, DESC>& : desc_(DESC | detail::has_named_args_bit), args_(s.args.args + 1) {}
store)
: desc_(DESC), args_(store.args.args + 1) {}
/// Constructs a `basic_format_args` object from a dynamic list of arguments. /// Constructs a `basic_format_args` object from a dynamic list of arguments.
constexpr basic_format_args(const format_arg* args, int count, constexpr basic_format_args(const format_arg* args, int count,
@ -2870,6 +2877,8 @@ struct formatter<T, Char,
# define FMT_CUSTOM , detail::custom_tag() # define FMT_CUSTOM , detail::custom_tag()
#endif #endif
template <typename T> constexpr T& identity(T& x) { return x; }
/** /**
* Constructs an object that stores references to arguments and can be * Constructs an object that stores references to arguments and can be
* implicitly converted to `format_args`. `Context` can be omitted in which case * implicitly converted to `format_args`. `Context` can be omitted in which case
@ -2901,6 +2910,12 @@ constexpr auto make_format_args(T&... args)
} }
#endif #endif
template <typename... T>
using vargs =
detail::format_arg_store<context, sizeof...(T),
detail::count_named_args<T...>(),
detail::make_descriptor<context, T...>()>;
/** /**
* Returns a named argument to be used in a formatting function. * Returns a named argument to be used in a formatting function.
* It should only be used in a call to a formatting function. * It should only be used in a call to a formatting function.