[libc-commits] [libc] [libc] Support %lc in printf (PR #169301)

via libc-commits libc-commits at lists.llvm.org
Mon Nov 24 01:27:50 PST 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- libc/src/stdio/printf_core/char_converter.h libc/test/src/stdio/printf_core/converter_test.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libc/src/stdio/printf_core/char_converter.h b/libc/src/stdio/printf_core/char_converter.h
index 58ade4fbf..fd6952a72 100644
--- a/libc/src/stdio/printf_core/char_converter.h
+++ b/libc/src/stdio/printf_core/char_converter.h
@@ -45,8 +45,7 @@ LIBC_INLINE int convert_char(Writer<write_mode> *writer,
     for (int i = 0; i < ret; ++i) {
       RET_IF_RESULT_NEGATIVE(writer->write(mb_str[i]));
     }
-  }
-  else {
+  } else {
     c = static_cast<char>(to_conv.conv_val_raw);
     RET_IF_RESULT_NEGATIVE(writer->write(c));
   }
diff --git a/libc/test/src/stdio/printf_core/converter_test.cpp b/libc/test/src/stdio/printf_core/converter_test.cpp
index 2f7842fa9..341bdd550 100644
--- a/libc/test/src/stdio/printf_core/converter_test.cpp
+++ b/libc/test/src/stdio/printf_core/converter_test.cpp
@@ -278,7 +278,8 @@ TEST_F(LlvmLibcPrintfConverterTest, WideCharConversionLeftJustified) {
   left_justified_conv.has_conv = true;
   left_justified_conv.raw_string = "%-4c";
   left_justified_conv.conv_name = 'c';
-  left_justified_conv.length_modifier = LIBC_NAMESPACE::printf_core::LengthModifier::l;
+  left_justified_conv.length_modifier =
+      LIBC_NAMESPACE::printf_core::LengthModifier::l;
   left_justified_conv.flags =
       LIBC_NAMESPACE::printf_core::FormatFlags::LEFT_JUSTIFIED;
   left_justified_conv.min_width = 4;
@@ -296,7 +297,8 @@ TEST_F(LlvmLibcPrintfConverterTest, WideCharConversionRightJustified) {
   right_justified_conv.has_conv = true;
   right_justified_conv.raw_string = "%4c";
   right_justified_conv.conv_name = 'c';
-  right_justified_conv.length_modifier = LIBC_NAMESPACE::printf_core::LengthModifier::l;
+  right_justified_conv.length_modifier =
+      LIBC_NAMESPACE::printf_core::LengthModifier::l;
   right_justified_conv.min_width = 4;
   right_justified_conv.conv_val_raw = static_cast<wchar_t>(L'S');
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/169301


More information about the libc-commits mailing list