[libcxx-commits] [libcxx] [libc++] Use _BitInt and __builtin_popcountg in bitset::count() (PR #160679)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Sep 25 03:14:20 PDT 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 -- libcxx/include/bitset
``````````
: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/bitset b/libcxx/include/bitset
index d8bb93845..2ea01e12b 100644
--- a/libcxx/include/bitset
+++ b/libcxx/include/bitset
@@ -867,11 +867,11 @@ bitset<_Size>::to_string(char __zero, char __one) const {
template <size_t _Size>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t bitset<_Size>::count() const _NOEXCEPT {
-#ifdef _LIBCPP_COMPILER_CLANG_BASED
+# ifdef _LIBCPP_COMPILER_CLANG_BASED
if constexpr (_Size <= __base::__bits_per_word) {
return __builtin_popcountg(static_cast<unsigned _BitInt(_Size)>(__base::__first_));
} else
-#endif
+# endif
{
return static_cast<size_t>(std::count(__base::__make_iter(0), __base::__make_iter(_Size), true));
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/160679
More information about the libcxx-commits
mailing list