[all-commits] [llvm/llvm-project] 35fe7e: [libc] Update printf_core::Writer to template on c...

Alex Strelnikov via All-commits all-commits at lists.llvm.org
Tue Sep 8 06:57:32 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 35fe7e14ecb4e50182fe93123e1876824d14bb94
      https://github.com/llvm/llvm-project/commit/35fe7e14ecb4e50182fe93123e1876824d14bb94
  Author: Alex Strelnikov <strel at google.com>
  Date:   2026-09-08 (Tue, 08 Sep 2026)

  Changed paths:
    M libc/src/__support/printf_core/char_converter.h
    M libc/src/__support/printf_core/converter.h
    M libc/src/__support/printf_core/fixed_converter.h
    M libc/src/__support/printf_core/float_dec_converter.h
    M libc/src/__support/printf_core/float_dec_converter_limited.h
    M libc/src/__support/printf_core/float_hex_converter.h
    M libc/src/__support/printf_core/float_inf_nan_converter.h
    M libc/src/__support/printf_core/int_converter.h
    A libc/src/__support/printf_core/overflow_modes.def
    M libc/src/__support/printf_core/printf_main.h
    M libc/src/__support/printf_core/ptr_converter.h
    M libc/src/__support/printf_core/strerror_converter.h
    M libc/src/__support/printf_core/string_converter.h
    M libc/src/__support/printf_core/vasprintf_internal.h
    M libc/src/__support/printf_core/vfprintf_internal.h
    M libc/src/__support/printf_core/write_int_converter.h
    R libc/src/__support/printf_core/write_modes.def
    M libc/src/__support/printf_core/writer.h
    M libc/src/err/report.cpp
    M libc/src/stdio/baremetal/vfprintf_internal.h
    M libc/src/stdio/snprintf.cpp
    M libc/src/stdio/snprintf_modular.cpp
    M libc/src/stdio/sprintf.cpp
    M libc/src/stdio/sprintf_modular.cpp
    M libc/src/stdio/vsnprintf.cpp
    M libc/src/stdio/vsnprintf_modular.cpp
    M libc/src/stdio/vsprintf.cpp
    M libc/src/stdio/vsprintf_modular.cpp
    M libc/src/stdlib/str_from_util.h
    M libc/src/stdlib/strfromd.cpp
    M libc/src/stdlib/strfromf.cpp
    M libc/src/stdlib/strfroml.cpp
    M libc/src/time/asctime_utils.h
    M libc/src/time/strftime.cpp
    M libc/src/time/strftime_core/composite_converter.h
    M libc/src/time/strftime_core/converter.h
    M libc/src/time/strftime_core/num_converter.h
    M libc/src/time/strftime_core/str_converter.h
    M libc/src/time/strftime_core/strftime_main.h
    M libc/src/time/strftime_l.cpp
    M libc/test/src/__support/printf_core/converter_test.cpp
    M libc/test/src/__support/printf_core/writer_test.cpp

  Log Message:
  -----------
  [libc] Update printf_core::Writer to template on character type. (#220669)

This is motivated by working toward `swprintf`.

The primary goal is to enable a `CharT` template type parameter on
`printf_core::Writer`. This requires refactoring how the "overflow
write" logic is set up to get around the limitation on function template
partial specialization.

Key changes to `printf_core::Writer` and friends:
* Separate the overflow write logic from `WriteBuffer` into an
`OverflowWriter` template where specializations handle dispatch, and
remove the `WriteBuffer` subclasses.
* Rename from `WriteMode` to `OverflowMode` to try and shorten the
enumerators with minimal loss to clarity, and reduce the number of modes
to only two: `DROP_OVERFLOW` and `CALLBACK`.
* The number of dynamic function calls for flushing and resizing use
cases stays the same by templating the callback on a `WriteSink`.

At this stage the extra `CharT` template type parameter is added in this
PR mainly to ensure the setup works without running into function
template partial specializations. Fully expanding `Writer` with
`wchar_t` will be done in follow-up PRs.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list