diff --git a/libcxx/.clang-format b/libcxx/.clang-format --- a/libcxx/.clang-format +++ b/libcxx/.clang-format @@ -65,10 +65,9 @@ InsertTrailingCommas: Wrapped KeepEmptyLinesAtTheStartOfBlocks: false MaxEmptyLinesToKeep: 1 -NamespaceIndentation: Inner PackConstructorInitializers: NextLine -PenaltyIndentedWhitespace: 61 +PenaltyIndentedWhitespace: 2 Language: Cpp Standard: c++20 diff --git a/libcxx/include/__format/parser_std_format_spec.h b/libcxx/include/__format/parser_std_format_spec.h --- a/libcxx/include/__format/parser_std_format_spec.h +++ b/libcxx/include/__format/parser_std_format_spec.h @@ -7,6 +7,14 @@ // //===----------------------------------------------------------------------===// +// +// THIS IS AN EXAMPLE FORMATTED WITH +// NamespaceIndentation: Inner +// PenaltyIndentedWhitespace: 2 +// +// TODO REVERT BEFOR LANDING +// + #ifndef _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H #define _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H @@ -52,8 +60,7 @@ if (__begin == __end) __throw_format_error("End of input while parsing format-spec arg-id"); - __format::__parse_number_result __r = - __format::__parse_arg_id(__begin, __end, __parse_ctx); + __format::__parse_number_result __r = __format::__parse_arg_id(__begin, __end, __parse_ctx); if (__r.__ptr == __end || *__r.__ptr != _CharT('}')) __throw_format_error("Invalid arg-id"); @@ -63,8 +70,7 @@ } template -_LIBCPP_HIDE_FROM_ABI constexpr uint32_t -__substitute_arg_id(basic_format_arg<_Context> __format_arg) { +_LIBCPP_HIDE_FROM_ABI constexpr uint32_t __substitute_arg_id(basic_format_arg<_Context> __format_arg) { return visit_format_arg( [](auto __arg) -> uint32_t { using _Type = decltype(__arg); @@ -76,8 +82,7 @@ } using _CT = common_type_t<_Type, decltype(__format::__number_max)>; - if (static_cast<_CT>(__arg) > - static_cast<_CT>(__format::__number_max)) + if (static_cast<_CT>(__arg) > static_cast<_CT>(__format::__number_max)) __throw_format_error("A format-spec arg-id replacement exceeds " "the maximum supported value"); @@ -126,10 +131,10 @@ bool __align; }; -#ifndef _LIBCPP_HAS_NO_UNICODE +# ifndef _LIBCPP_HAS_NO_UNICODE namespace __detail { -/** + /** * Unicode column width estimates. * * Unicode can be stored in several formats: UTF-8, UTF-16, and UTF-32. @@ -171,30 +176,30 @@ * - https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF */ -/** + /** * The first 2 column code point. * * This is the point where the fast UTF-16/32 scanner needs to stop processing. */ -inline constexpr uint32_t __two_column_code_point = 0x1100; + inline constexpr uint32_t __two_column_code_point = 0x1100; -/** Helper concept for an UTF-8 character type. */ -template -concept __utf8_character = same_as<_CharT, char> || same_as<_CharT, char8_t>; + /** Helper concept for an UTF-8 character type. */ + template + concept __utf8_character = same_as<_CharT, char> || same_as<_CharT, char8_t>; -/** Helper concept for an UTF-16 character type. */ -template -concept __utf16_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2) || same_as<_CharT, char16_t>; + /** Helper concept for an UTF-16 character type. */ + template + concept __utf16_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2) || same_as<_CharT, char16_t>; -/** Helper concept for an UTF-32 character type. */ -template -concept __utf32_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4) || same_as<_CharT, char32_t>; + /** Helper concept for an UTF-32 character type. */ + template + concept __utf32_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4) || same_as<_CharT, char32_t>; -/** Helper concept for an UTF-16 or UTF-32 character type. */ -template -concept __utf16_or_32_character = __utf16_character<_CharT> || __utf32_character<_CharT>; + /** Helper concept for an UTF-16 or UTF-32 character type. */ + template + concept __utf16_or_32_character = __utf16_character<_CharT> || __utf32_character<_CharT>; -/** + /** * Converts a code point to the column width. * * The estimations are conforming to [format.string.general]/11 @@ -202,11 +207,10 @@ * This version expects a value less than 0x1'0000, which is a 3-byte UTF-8 * character. */ -_LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_3(uint32_t __c) noexcept { - _LIBCPP_ASSERT(__c < 0x10000, - "Use __column_width_4 or __column_width for larger values"); + _LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_3(uint32_t __c) noexcept { + _LIBCPP_ASSERT(__c < 0x10000, "Use __column_width_4 or __column_width for larger values"); - // clang-format off + // clang-format off return 1 + (__c >= 0x1100 && (__c <= 0x115f || (__c >= 0x2329 && (__c <= 0x232a || (__c >= 0x2e80 && (__c <= 0x303e || @@ -218,93 +222,87 @@ (__c >= 0xff00 && (__c <= 0xff60 || (__c >= 0xffe0 && (__c <= 0xffe6 )))))))))))))))))))); - // clang-format on -} + // clang-format on + } -/** + /** * @overload * * This version expects a value greater than or equal to 0x1'0000, which is a * 4-byte UTF-8 character. */ -_LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_4(uint32_t __c) noexcept { - _LIBCPP_ASSERT(__c >= 0x10000, - "Use __column_width_3 or __column_width for smaller values"); + _LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_4(uint32_t __c) noexcept { + _LIBCPP_ASSERT(__c >= 0x10000, "Use __column_width_3 or __column_width for smaller values"); - // clang-format off + // clang-format off return 1 + (__c >= 0x1'f300 && (__c <= 0x1'f64f || (__c >= 0x1'f900 && (__c <= 0x1'f9ff || (__c >= 0x2'0000 && (__c <= 0x2'fffd || (__c >= 0x3'0000 && (__c <= 0x3'fffd )))))))); - // clang-format on -} + // clang-format on + } -/** + /** * @overload * * The general case, accepting all values. */ -_LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width(uint32_t __c) noexcept { - if (__c < 0x10000) - return __column_width_3(__c); + _LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width(uint32_t __c) noexcept { + if (__c < 0x10000) + return __column_width_3(__c); - return __column_width_4(__c); -} + return __column_width_4(__c); + } -/** + /** * Estimate the column width for the UTF-8 sequence using the fast algorithm. */ -template <__utf8_character _CharT> -_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* -__estimate_column_width_fast(const _CharT* __first, - const _CharT* __last) noexcept { - return _VSTD::find_if(__first, __last, - [](unsigned char __c) { return __c & 0x80; }); -} + template <__utf8_character _CharT> + _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* + __estimate_column_width_fast(const _CharT* __first, const _CharT* __last) noexcept { + return _VSTD::find_if(__first, __last, [](unsigned char __c) { return __c & 0x80; }); + } -/** + /** * @overload * * The implementation for UTF-16/32. */ -template <__utf16_or_32_character _CharT> -_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* -__estimate_column_width_fast(const _CharT* __first, - const _CharT* __last) noexcept { - return _VSTD::find_if(__first, __last, - [](uint32_t __c) { return __c >= 0x1100; }); -} + template <__utf16_or_32_character _CharT> + _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* + __estimate_column_width_fast(const _CharT* __first, const _CharT* __last) noexcept { + return _VSTD::find_if(__first, __last, [](uint32_t __c) { return __c >= 0x1100; }); + } -template -struct _LIBCPP_TEMPLATE_VIS __column_width_result { - /** The number of output columns. */ - size_t __width; - /** + template + struct _LIBCPP_TEMPLATE_VIS __column_width_result { + /** The number of output columns. */ + size_t __width; + /** * The last parsed element. * * This limits the original output to fit in the wanted number of columns. */ - const _CharT* __ptr; -}; + const _CharT* __ptr; + }; -/** + /** * Small helper to determine the width of malformed Unicode. * * @note This function's only needed for UTF-8. During scanning UTF-8 there * are multiple place where it can be detected that the Unicode is malformed. * UTF-16 only requires 1 test and UTF-32 requires no testing. */ -template <__utf8_character _CharT> -_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> -__estimate_column_width_malformed(const _CharT* __first, const _CharT* __last, - size_t __maximum, size_t __result) noexcept { - size_t __size = __last - __first; - size_t __n = _VSTD::min(__size, __maximum); - return {__result + __n, __first + __n}; -} + template <__utf8_character _CharT> + _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_width_malformed( + const _CharT* __first, const _CharT* __last, size_t __maximum, size_t __result) noexcept { + size_t __size = __last - __first; + size_t __n = _VSTD::min(__size, __maximum); + return {__result + __n, __first + __n}; + } -/** + /** * Determines the number of output columns needed to render the input. * * @note When the scanner encounters malformed Unicode it acts as-if every code @@ -317,144 +315,135 @@ * @param __maximum The maximum number of output columns. The returned number * of estimated output columns will not exceed this value. */ -template <__utf8_character _CharT> -_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> -__estimate_column_width(const _CharT* __first, const _CharT* __last, - size_t __maximum) noexcept { - size_t __result = 0; - - while (__first != __last) { - // Based on the number of leading 1 bits the number of code units in the - // code point can be determined. See - // https://en.wikipedia.org/wiki/UTF-8#Encoding - switch (_VSTD::countl_one(static_cast(*__first))) { - case 0: // 1-code unit encoding: all 1 column - ++__result; - ++__first; - break; + template <__utf8_character _CharT> + _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> + __estimate_column_width(const _CharT* __first, const _CharT* __last, size_t __maximum) noexcept { + size_t __result = 0; + + while (__first != __last) { + // Based on the number of leading 1 bits the number of code units in the + // code point can be determined. See + // https://en.wikipedia.org/wiki/UTF-8#Encoding + switch (_VSTD::countl_one(static_cast(*__first))) { + case 0: // 1-code unit encoding: all 1 column + ++__result; + ++__first; + break; + + case 2: // 2-code unit encoding: all 1 column + // Malformed Unicode. + if (__last - __first < 2) [[unlikely]] + return __estimate_column_width_malformed(__first, __last, __maximum, __result); + __first += 2; + ++__result; + break; + + case 3: // 3-code unit encoding: either 1 or 2 columns + // Malformed Unicode. + if (__last - __first < 3) [[unlikely]] + return __estimate_column_width_malformed(__first, __last, __maximum, __result); + { + uint32_t __c = static_cast(*__first++) & 0x0f; + __c <<= 6; + __c |= static_cast(*__first++) & 0x3f; + __c <<= 6; + __c |= static_cast(*__first++) & 0x3f; + __result += __column_width_3(__c); + if (__result > __maximum) + return {__result - 2, __first - 3}; + } + break; + case 4: // 4-code unit encoding: either 1 or 2 columns + // Malformed Unicode. + if (__last - __first < 4) [[unlikely]] + return __estimate_column_width_malformed(__first, __last, __maximum, __result); + { + uint32_t __c = static_cast(*__first++) & 0x07; + __c <<= 6; + __c |= static_cast(*__first++) & 0x3f; + __c <<= 6; + __c |= static_cast(*__first++) & 0x3f; + __c <<= 6; + __c |= static_cast(*__first++) & 0x3f; + __result += __column_width_4(__c); + if (__result > __maximum) + return {__result - 2, __first - 4}; + } + break; + default: + // Malformed Unicode. + return __estimate_column_width_malformed(__first, __last, __maximum, __result); + } - case 2: // 2-code unit encoding: all 1 column - // Malformed Unicode. - if (__last - __first < 2) [[unlikely]] - return __estimate_column_width_malformed(__first, __last, __maximum, - __result); - __first += 2; - ++__result; - break; + if (__result >= __maximum) + return {__result, __first}; + } + return {__result, __first}; + } + + template <__utf16_character _CharT> + _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> + __estimate_column_width(const _CharT* __first, const _CharT* __last, size_t __maximum) noexcept { + size_t __result = 0; + + while (__first != __last) { + uint32_t __c = *__first; + // Is the code unit part of a surrogate pair? See + // https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF + if (__c >= 0xd800 && __c <= 0xDfff) { + // Malformed Unicode. + if (__last - __first < 2) [[unlikely]] + return {__result + 1, __first + 1}; + + __c -= 0xd800; + __c <<= 10; + __c += (*(__first + 1) - 0xdc00); + __c += 0x10000; - case 3: // 3-code unit encoding: either 1 or 2 columns - // Malformed Unicode. - if (__last - __first < 3) [[unlikely]] - return __estimate_column_width_malformed(__first, __last, __maximum, - __result); - { - uint32_t __c = static_cast(*__first++) & 0x0f; - __c <<= 6; - __c |= static_cast(*__first++) & 0x3f; - __c <<= 6; - __c |= static_cast(*__first++) & 0x3f; - __result += __column_width_3(__c); - if (__result > __maximum) - return {__result - 2, __first - 3}; - } - break; - case 4: // 4-code unit encoding: either 1 or 2 columns - // Malformed Unicode. - if (__last - __first < 4) [[unlikely]] - return __estimate_column_width_malformed(__first, __last, __maximum, - __result); - { - uint32_t __c = static_cast(*__first++) & 0x07; - __c <<= 6; - __c |= static_cast(*__first++) & 0x3f; - __c <<= 6; - __c |= static_cast(*__first++) & 0x3f; - __c <<= 6; - __c |= static_cast(*__first++) & 0x3f; __result += __column_width_4(__c); if (__result > __maximum) - return {__result - 2, __first - 4}; + return {__result - 2, __first}; + __first += 2; + } else { + __result += __column_width_3(__c); + if (__result > __maximum) + return {__result - 2, __first}; + ++__first; } - break; - default: - // Malformed Unicode. - return __estimate_column_width_malformed(__first, __last, __maximum, - __result); - } - if (__result >= __maximum) - return {__result, __first}; - } - return {__result, __first}; -} - -template <__utf16_character _CharT> -_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> -__estimate_column_width(const _CharT* __first, const _CharT* __last, - size_t __maximum) noexcept { - size_t __result = 0; - - while (__first != __last) { - uint32_t __c = *__first; - // Is the code unit part of a surrogate pair? See - // https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF - if (__c >= 0xd800 && __c <= 0xDfff) { - // Malformed Unicode. - if (__last - __first < 2) [[unlikely]] - return {__result + 1, __first + 1}; - - __c -= 0xd800; - __c <<= 10; - __c += (*(__first + 1) - 0xdc00); - __c += 0x10000; - - __result += __column_width_4(__c); - if (__result > __maximum) - return {__result - 2, __first}; - __first += 2; - } else { - __result += __column_width_3(__c); - if (__result > __maximum) - return {__result - 2, __first}; - ++__first; + if (__result >= __maximum) + return {__result, __first}; } - if (__result >= __maximum) - return {__result, __first}; + return {__result, __first}; } - return {__result, __first}; -} + template <__utf32_character _CharT> + _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> + __estimate_column_width(const _CharT* __first, const _CharT* __last, size_t __maximum) noexcept { + size_t __result = 0; -template <__utf32_character _CharT> -_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> -__estimate_column_width(const _CharT* __first, const _CharT* __last, - size_t __maximum) noexcept { - size_t __result = 0; + while (__first != __last) { + uint32_t __c = *__first; + __result += __column_width(__c); - while (__first != __last) { - uint32_t __c = *__first; - __result += __column_width(__c); + if (__result > __maximum) + return {__result - 2, __first}; - if (__result > __maximum) - return {__result - 2, __first}; + ++__first; + if (__result >= __maximum) + return {__result, __first}; + } - ++__first; - if (__result >= __maximum) - return {__result, __first}; + return {__result, __first}; } - return {__result, __first}; -} - } // namespace __detail template _LIBCPP_HIDE_FROM_ABI constexpr __string_alignment<_CharT> -__get_string_alignment(const _CharT* __first, const _CharT* __last, - ptrdiff_t __width, ptrdiff_t __precision) noexcept { - _LIBCPP_ASSERT(__width != 0 || __precision != -1, - "The function has no effect and shouldn't be used"); +__get_string_alignment(const _CharT* __first, const _CharT* __last, ptrdiff_t __width, ptrdiff_t __precision) noexcept { + _LIBCPP_ASSERT(__width != 0 || __precision != -1, "The function has no effect and shouldn't be used"); // TODO FMT There might be more optimizations possible: // If __precision == __format::__number_max and the encoding is: @@ -473,12 +462,9 @@ * If our assumption was correct the __pos will be at the end of the input. */ const ptrdiff_t __length = __last - __first; - const _CharT* __limit = - __first + - (__precision == -1 ? __length : _VSTD::min(__length, __precision)); - ptrdiff_t __size = __limit - __first; - const _CharT* __pos = - __detail::__estimate_column_width_fast(__first, __limit); + const _CharT* __limit = __first + (__precision == -1 ? __length : _VSTD::min(__length, __precision)); + ptrdiff_t __size = __limit - __first; + const _CharT* __pos = __detail::__estimate_column_width_fast(__first, __limit); if (__pos == __limit) return {__limit, __size, __size < __width}; @@ -499,9 +485,8 @@ ptrdiff_t __prefix = __pos - __first; if (__precision != -1) { _LIBCPP_ASSERT(__precision > __prefix, "Logic error."); - auto __lengh_info = __detail::__estimate_column_width( - __pos, __last, __precision - __prefix); - __size = __lengh_info.__width + __prefix; + auto __lengh_info = __detail::__estimate_column_width(__pos, __last, __precision - __prefix); + __size = __lengh_info.__width + __prefix; return {__lengh_info.__ptr, __size, __size < __width}; } @@ -518,46 +503,40 @@ * pass one code point more than required to determine the proper result; * that however isn't a problem for the algorithm.) */ - size_t __maximum = 1 + __width - __prefix; - auto __lengh_info = - __detail::__estimate_column_width(__pos, __last, __maximum); + size_t __maximum = 1 + __width - __prefix; + auto __lengh_info = __detail::__estimate_column_width(__pos, __last, __maximum); if (__lengh_info.__ptr != __last) { // Consumed the width number of code units. The exact size of the string // is unknown. We only know we don't need to align the output. - _LIBCPP_ASSERT(static_cast(__lengh_info.__width + __prefix) >= - __width, - "Logic error"); + _LIBCPP_ASSERT(static_cast(__lengh_info.__width + __prefix) >= __width, "Logic error"); return {__last, 0, false}; } __size = __lengh_info.__width + __prefix; return {__last, __size, __size < __width}; } -#else // _LIBCPP_HAS_NO_UNICODE +# else // _LIBCPP_HAS_NO_UNICODE template _LIBCPP_HIDE_FROM_ABI constexpr __string_alignment<_CharT> -__get_string_alignment(const _CharT* __first, const _CharT* __last, - ptrdiff_t __width, ptrdiff_t __precision) noexcept { +__get_string_alignment(const _CharT* __first, const _CharT* __last, ptrdiff_t __width, ptrdiff_t __precision) noexcept { const ptrdiff_t __length = __last - __first; - const _CharT* __limit = - __first + - (__precision == -1 ? __length : _VSTD::min(__length, __precision)); - ptrdiff_t __size = __limit - __first; + const _CharT* __limit = __first + (__precision == -1 ? __length : _VSTD::min(__length, __precision)); + ptrdiff_t __size = __limit - __first; return {__limit, __size, __size < __width}; } -#endif // _LIBCPP_HAS_NO_UNICODE +# endif // _LIBCPP_HAS_NO_UNICODE /// These fields are a filter for which elements to parse. /// /// They default to false so when a new field is added it needs to be opted in /// explicitly. struct __fields { - uint8_t __sign_ : 1 {false}; - uint8_t __alternate_form_ : 1 {false}; - uint8_t __zero_padding_ : 1 {false}; - uint8_t __precision_ : 1 {false}; + uint8_t __sign_ : 1 {false}; + uint8_t __alternate_form_ : 1 {false}; + uint8_t __zero_padding_ : 1 {false}; + uint8_t __precision_ : 1 {false}; uint8_t __locale_specific_form_ : 1 {false}; - uint8_t __type_ : 1 {false}; + uint8_t __type_ : 1 {false}; }; // By not placing this constant in the formatter class it's not duplicated for @@ -621,17 +600,17 @@ }; struct __std { - __alignment __alignment_ : 3; - __sign __sign_ : 2; - bool __alternate_form_ : 1; + __alignment __alignment_ : 3; + __sign __sign_ : 2; + bool __alternate_form_ : 1; bool __locale_specific_form_ : 1; __type __type_; }; struct __chrono { __alignment __alignment_ : 3; - bool __weekday_name_ : 1; - bool __month_name_ : 1; + bool __weekday_name_ : 1; + bool __month_name_ : 1; }; /// Contains the parsed formatting specifications. @@ -698,9 +677,8 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(basic_format_parse_context<_CharT>& __parse_ctx, __fields __fields) -> decltype(__parse_ctx.begin()) { - const _CharT* __begin = __parse_ctx.begin(); - const _CharT* __end = __parse_ctx.end(); + const _CharT* __end = __parse_ctx.end(); if (__begin == __end) return __begin; @@ -739,37 +717,35 @@ } /// \returns the `__parsed_specifications` with the resolved dynamic sizes.. - _LIBCPP_HIDE_FROM_ABI - __parsed_specifications<_CharT> __get_parsed_std_specifications(auto& __ctx) const { + _LIBCPP_HIDE_FROM_ABI __parsed_specifications<_CharT> __get_parsed_std_specifications(auto& __ctx) const { return __parsed_specifications<_CharT>{ - .__std_ = - __std{.__alignment_ = __alignment_, - .__sign_ = __sign_, - .__alternate_form_ = __alternate_form_, - .__locale_specific_form_ = __locale_specific_form_, - .__type_ = __type_}, + .__std_ = __std{.__alignment_ = __alignment_, + .__sign_ = __sign_, + .__alternate_form_ = __alternate_form_, + .__locale_specific_form_ = __locale_specific_form_, + .__type_ = __type_}, .__width_{__get_width(__ctx)}, .__precision_{__get_precision(__ctx)}, .__fill_{__fill_}}; } - __alignment __alignment_ : 3 {__alignment::__default}; - __sign __sign_ : 2 {__sign::__default}; - bool __alternate_form_ : 1 {false}; + __alignment __alignment_ : 3 {__alignment::__default}; + __sign __sign_ : 2 {__sign::__default}; + bool __alternate_form_ : 1 {false}; bool __locale_specific_form_ : 1 {false}; - bool __reserved_0_ : 1 {false}; + bool __reserved_0_ : 1 {false}; __type __type_{__type::__default}; // These two flags are used for formatting chrono. Since the struct has // padding space left it's added to this structure. bool __weekday_name_ : 1 {false}; - bool __month_name_ : 1 {false}; + bool __month_name_ : 1 {false}; uint8_t __reserved_1_ : 6 {0}; uint8_t __reserved_2_ : 6 {0}; // These two flags are only used internally and not part of the // __parsed_specifications. Therefore put them at the end. - bool __width_as_arg_ : 1 {false}; + bool __width_as_arg_ : 1 {false}; bool __precision_as_arg_ : 1 {false}; /// The requested width, either the value or the arg-id. @@ -803,8 +779,9 @@ } _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(const _CharT*& __begin, const _CharT* __end) { - _LIBCPP_ASSERT(__begin != __end, "when called with an empty input the function will cause " - "undefined behavior by evaluating data not in the input"); + _LIBCPP_ASSERT(__begin != __end, + "when called with an empty input the function will cause " + "undefined behavior by evaluating data not in the input"); if (__begin + 1 != __end) { if (__parse_alignment(*(__begin + 1))) { if (*__begin == _CharT('{') || *__begin == _CharT('}')) @@ -866,9 +843,9 @@ if (*__begin == _CharT('{')) { __format::__parse_number_result __r = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx); - __width_as_arg_ = true; - __width_ = __r.__value; - __begin = __r.__ptr; + __width_as_arg_ = true; + __width_ = __r.__value; + __begin = __r.__ptr; return true; } @@ -876,15 +853,16 @@ return false; __format::__parse_number_result __r = __format::__parse_number(__begin, __end); - __width_ = __r.__value; - _LIBCPP_ASSERT(__width_ != 0, "A zero value isn't allowed and should be impossible, " - "due to validations in this function"); + __width_ = __r.__value; + _LIBCPP_ASSERT(__width_ != 0, + "A zero value isn't allowed and should be impossible, " + "due to validations in this function"); __begin = __r.__ptr; return true; } - _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_precision(const _CharT*& __begin, const _CharT* __end, - auto& __parse_ctx) { + _LIBCPP_HIDE_FROM_ABI constexpr bool + __parse_precision(const _CharT*& __begin, const _CharT* __end, auto& __parse_ctx) { if (*__begin != _CharT('.')) return false; @@ -894,9 +872,9 @@ if (*__begin == _CharT('{')) { __format::__parse_number_result __arg_id = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx); - __precision_as_arg_ = true; - __precision_ = __arg_id.__value; - __begin = __arg_id.__ptr; + __precision_as_arg_ = true; + __precision_ = __arg_id.__value; + __begin = __arg_id.__ptr; return true; } @@ -904,9 +882,9 @@ __throw_format_error("The format-spec precision field doesn't contain a value or arg-id"); __format::__parse_number_result __r = __format::__parse_number(__begin, __end); - __precision_ = __r.__value; - __precision_as_arg_ = false; - __begin = __r.__ptr; + __precision_ = __r.__value; + __precision_as_arg_ = false; + __begin = __r.__ptr; return true; } @@ -983,8 +961,7 @@ ++__begin; } - _LIBCPP_HIDE_FROM_ABI - int32_t __get_width(auto& __ctx) const { + _LIBCPP_HIDE_FROM_ABI int32_t __get_width(auto& __ctx) const { if (!__width_as_arg_) return __width_; @@ -994,8 +971,7 @@ return __result; } - _LIBCPP_HIDE_FROM_ABI - int32_t __get_precision(auto& __ctx) const { + _LIBCPP_HIDE_FROM_ABI int32_t __get_precision(auto& __ctx) const { if (!__precision_as_arg_) return __precision_;