[libcxx-commits] [libcxx] [libc++] Refactor std::print to allow for constant folding of the format part (PR #185459)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 9 09:59:18 PDT 2026


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 -- libcxx/test/benchmarks/format/print.bench.cpp libcxx/include/__ostream/print.h libcxx/include/print --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/libcxx/include/__ostream/print.h b/libcxx/include/__ostream/print.h
index 88a0f2ca0..4409b36de 100644
--- a/libcxx/include/__ostream/print.h
+++ b/libcxx/include/__ostream/print.h
@@ -116,7 +116,7 @@ _LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, fo
 #        ifndef _LIBCPP_WIN32API
       __print::__output_unicode_posix(__file, __result, true);
 #        elif _LIBCPP_HAS_WIDE_CHARACTERS
-    __print::__output_unicode_windows(__file, __result, true);
+      __print::__output_unicode_windows(__file, __result, true);
 #        else
 #          error "Windows builds with wchar_t disabled are not supported."
 #        endif
diff --git a/libcxx/include/print b/libcxx/include/print
index f12785308..766bac104 100644
--- a/libcxx/include/print
+++ b/libcxx/include/print
@@ -214,8 +214,7 @@ _LIBCPP_HIDE_FROM_ABI inline bool __is_terminal([[maybe_unused]] FILE* __stream)
 }
 
 template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
-_LIBCPP_HIDE_FROM_ABI inline void
-__output_nonunicode(FILE* __stream, string_view __text) {
+_LIBCPP_HIDE_FROM_ABI inline void __output_nonunicode(FILE* __stream, string_view __text) {
   _LIBCPP_ASSERT_NON_NULL(__stream, "__stream must be a valid pointer to an output C stream");
   size_t __size = fwrite(__text.data(), 1, __text.size(), __stream);
   if (__size < __text.size()) {
@@ -243,8 +242,7 @@ _LIBCPP_HIDE_FROM_ABI inline void __output_unicode_posix(FILE* __stream, string_
 
 #      if _LIBCPP_HAS_WIDE_CHARACTERS
 template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
-_LIBCPP_HIDE_FROM_ABI inline void
-__vprint_unicode_windows(FILE* __stream, string_view __text, bool __is_terminal) {
+_LIBCPP_HIDE_FROM_ABI inline void __vprint_unicode_windows(FILE* __stream, string_view __text, bool __is_terminal) {
   if (!__is_terminal)
     return __print::__output_nonunicode(__stream, __text);
 

``````````

</details>


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


More information about the libcxx-commits mailing list