[libc-commits] [libc] [libc][stdbit] implement stdc_trailing_zeros (C23) (PR #80344)
via libc-commits
libc-commits at lists.llvm.org
Thu Feb 1 13:41:23 PST 2024
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 edbd93d3706b806e7c91dfd2c359476488dfcc96 995f36dadd927ee7c911b208946d92ef8b6d0396 -- libc/src/stdbit/stdc_trailing_zeros_uc.cpp libc/src/stdbit/stdc_trailing_zeros_uc.h libc/src/stdbit/stdc_trailing_zeros_ui.cpp libc/src/stdbit/stdc_trailing_zeros_ui.h libc/src/stdbit/stdc_trailing_zeros_ul.cpp libc/src/stdbit/stdc_trailing_zeros_ul.h libc/src/stdbit/stdc_trailing_zeros_ull.cpp libc/src/stdbit/stdc_trailing_zeros_ull.h libc/src/stdbit/stdc_trailing_zeros_us.cpp libc/src/stdbit/stdc_trailing_zeros_us.h libc/test/src/stdbit/stdc_trailing_zeros_uc_test.cpp libc/test/src/stdbit/stdc_trailing_zeros_ui_test.cpp libc/test/src/stdbit/stdc_trailing_zeros_ul_test.cpp libc/test/src/stdbit/stdc_trailing_zeros_ull_test.cpp libc/test/src/stdbit/stdc_trailing_zeros_us_test.cpp libc/include/llvm-libc-macros/stdbit-macros.h libc/test/include/stdbit_test.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libc/include/llvm-libc-macros/stdbit-macros.h b/libc/include/llvm-libc-macros/stdbit-macros.h
index a36d221b3c..15e3912883 100644
--- a/libc/include/llvm-libc-macros/stdbit-macros.h
+++ b/libc/include/llvm-libc-macros/stdbit-macros.h
@@ -70,12 +70,12 @@ inline unsigned stdc_trailing_zeros(unsigned long long x) {
unsigned: stdc_leading_ones_ui, \
unsigned long: stdc_leading_ones_ul, \
unsigned long long: stdc_leading_ones_ull)(x)
-#define stdc_trailing_zeros(x) \
+#define stdc_trailing_zeros(x) \
_Generic((x), \
- unsigned char: stdc_trailing_zeros_uc, \
- unsigned short: stdc_trailing_zeros_us, \
- unsigned: stdc_trailing_zeros_ui, \
- unsigned long: stdc_trailing_zeros_ul, \
+ unsigned char: stdc_trailing_zeros_uc, \
+ unsigned short: stdc_trailing_zeros_us, \
+ unsigned: stdc_trailing_zeros_ui, \
+ unsigned long: stdc_trailing_zeros_ul, \
unsigned long long: stdc_trailing_zeros_ull)(x)
#endif // __cplusplus
diff --git a/libc/src/stdbit/stdc_trailing_zeros_ull.cpp b/libc/src/stdbit/stdc_trailing_zeros_ull.cpp
index 9e61eccf2e..77cb20cb1b 100644
--- a/libc/src/stdbit/stdc_trailing_zeros_ull.cpp
+++ b/libc/src/stdbit/stdc_trailing_zeros_ull.cpp
@@ -13,7 +13,8 @@
namespace LIBC_NAMESPACE {
-LLVM_LIBC_FUNCTION(unsigned, stdc_trailing_zeros_ull, (unsigned long long value)) {
+LLVM_LIBC_FUNCTION(unsigned, stdc_trailing_zeros_ull,
+ (unsigned long long value)) {
return static_cast<unsigned>(cpp::countr_zero(value));
}
diff --git a/libc/test/src/stdbit/stdc_trailing_zeros_uc_test.cpp b/libc/test/src/stdbit/stdc_trailing_zeros_uc_test.cpp
index 725b276d9d..b01407a289 100644
--- a/libc/test/src/stdbit/stdc_trailing_zeros_uc_test.cpp
+++ b/libc/test/src/stdbit/stdc_trailing_zeros_uc_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for stdc_trailing_zeros_uc --------------------------------===//
+//===-- Unittests for stdc_trailing_zeros_uc
+//--------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdbit/stdc_trailing_zeros_ui_test.cpp b/libc/test/src/stdbit/stdc_trailing_zeros_ui_test.cpp
index 1ed7e66bf9..81c7b17bed 100644
--- a/libc/test/src/stdbit/stdc_trailing_zeros_ui_test.cpp
+++ b/libc/test/src/stdbit/stdc_trailing_zeros_ui_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for stdc_trailing_zeros_ui --------------------------------===//
+//===-- Unittests for stdc_trailing_zeros_ui
+//--------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdbit/stdc_trailing_zeros_ul_test.cpp b/libc/test/src/stdbit/stdc_trailing_zeros_ul_test.cpp
index c46d48b49e..0d879fa8a8 100644
--- a/libc/test/src/stdbit/stdc_trailing_zeros_ul_test.cpp
+++ b/libc/test/src/stdbit/stdc_trailing_zeros_ul_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for stdc_trailing_zeros_ul --------------------------------===//
+//===-- Unittests for stdc_trailing_zeros_ul
+//--------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdbit/stdc_trailing_zeros_us_test.cpp b/libc/test/src/stdbit/stdc_trailing_zeros_us_test.cpp
index 6e56a99fed..e67598beb4 100644
--- a/libc/test/src/stdbit/stdc_trailing_zeros_us_test.cpp
+++ b/libc/test/src/stdbit/stdc_trailing_zeros_us_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for stdc_trailing_zeros_us --------------------------------===//
+//===-- Unittests for stdc_trailing_zeros_us
+//--------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
``````````
</details>
https://github.com/llvm/llvm-project/pull/80344
More information about the libc-commits
mailing list