[libcxx-commits] [libcxx] 9adf78d - [NFC][libc++][format] Small improvements.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sat Feb 18 09:59:49 PST 2023


Author: Mark de Wever
Date: 2023-02-18T18:59:32+01:00
New Revision: 9adf78d6a79160d9c24909c975b33ffe42808314

URL: https://github.com/llvm/llvm-project/commit/9adf78d6a79160d9c24909c975b33ffe42808314
DIFF: https://github.com/llvm/llvm-project/commit/9adf78d6a79160d9c24909c975b33ffe42808314.diff

LOG: [NFC][libc++][format] Small improvements.

While working on the formatter for the thread::id several minor issues
where spotted. This fixes them.

Added: 
    

Modified: 
    libcxx/include/__format/formatter_pointer.h
    libcxx/include/__format/parser_std_format_spec.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__format/formatter_pointer.h b/libcxx/include/__format/formatter_pointer.h
index 1fb5ce3d533a1..fe1b3cb496f1a 100644
--- a/libcxx/include/__format/formatter_pointer.h
+++ b/libcxx/include/__format/formatter_pointer.h
@@ -32,8 +32,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 template <__fmt_char_type _CharT>
 struct _LIBCPP_TEMPLATE_VIS __formatter_pointer {
 public:
-  constexpr __formatter_pointer() { __parser_.__alignment_ = __format_spec::__alignment::__right; }
-
   _LIBCPP_HIDE_FROM_ABI constexpr auto
   parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
     auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_pointer);
@@ -48,7 +46,7 @@ struct _LIBCPP_TEMPLATE_VIS __formatter_pointer {
     return __formatter::__format_integer(reinterpret_cast<uintptr_t>(__ptr), __ctx, __specs);
   }
 
-  __format_spec::__parser<_CharT> __parser_;
+  __format_spec::__parser<_CharT> __parser_{.__alignment_ = __format_spec::__alignment::__right};
 };
 
 // [format.formatter.spec]/2.4

diff  --git a/libcxx/include/__format/parser_std_format_spec.h b/libcxx/include/__format/parser_std_format_spec.h
index 4fff9ad859d1a..15041602df5c0 100644
--- a/libcxx/include/__format/parser_std_format_spec.h
+++ b/libcxx/include/__format/parser_std_format_spec.h
@@ -118,7 +118,7 @@ struct __fields {
   // formatters use the colon to mark the beginning of the
   // underlying-format-spec. To avoid parsing ambiguities these formatter
   // specializations prohibit the use of the colon as a fill character.
-  uint8_t __allow_colon_in_fill_ : 1 {false};
+  uint8_t __use_range_fill_ : 1 {false};
 };
 
 // By not placing this constant in the formatter class it's not duplicated for
@@ -140,8 +140,8 @@ inline constexpr __fields __fields_string{.__precision_ = true, .__type_ = true}
 inline constexpr __fields __fields_pointer{.__type_ = true};
 
 #  if _LIBCPP_STD_VER >= 23
-inline constexpr __fields __fields_tuple{.__type_ = false, .__allow_colon_in_fill_ = true};
-inline constexpr __fields __fields_range{.__type_ = false, .__allow_colon_in_fill_ = true};
+inline constexpr __fields __fields_tuple{.__use_range_fill_ = true};
+inline constexpr __fields __fields_range{.__use_range_fill_ = true};
 #  endif
 
 enum class _LIBCPP_ENUM_VIS __alignment : uint8_t {
@@ -276,7 +276,7 @@ class _LIBCPP_TEMPLATE_VIS __parser {
     if (__begin == __end)
       return __begin;
 
-    if (__parse_fill_align(__begin, __end, __fields.__allow_colon_in_fill_) && __begin == __end)
+    if (__parse_fill_align(__begin, __end, __fields.__use_range_fill_) && __begin == __end)
       return __begin;
 
     if (__fields.__sign_ && __parse_sign(__begin) && __begin == __end)


        


More information about the libcxx-commits mailing list