[libcxx-commits] [libcxx] [libc++] Add basic constant folding for std::format (PR #107197)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Feb 3 11:28:14 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 956cfa69b153a0e798060f67e713790eeefebc04 0db3132b818ba1fd1f8d5b5d684e5170d31375df --extensions ,h,cpp -- libcxx/include/__config libcxx/include/__format/format_functions.h libcxx/test/benchmarks/format/format.bench.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/include/__format/format_functions.h b/libcxx/include/__format/format_functions.h
index fd71f53b51..43d1a6ce1f 100644
--- a/libcxx/include/__format/format_functions.h
+++ b/libcxx/include/__format/format_functions.h
@@ -456,7 +456,6 @@ template <class _CharT>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<basic_string<_CharT>> __try_constant_folding_format(
basic_string_view<_CharT> __fmt,
basic_format_args<basic_format_context<back_insert_iterator<__format::__output_buffer<_CharT>>, _CharT>> __args) {
-
// Fold strings not containing '{' or '}' to just return the string
if (bool __is_identity = [&] [[__gnu__::__pure__]] // Make sure the compiler knows this call can be eliminated
{ return std::ranges::find_first_of(__fmt, array{'{', '}'}) == __fmt.end(); }();
``````````
</details>
https://github.com/llvm/llvm-project/pull/107197
More information about the libcxx-commits
mailing list