[libc-commits] [libc] [libc] implement stdc_leading_zeros_u* for stdbit.h (PR #79669)

via libc-commits libc-commits at lists.llvm.org
Fri Jan 26 16:10:43 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 26cc651f1b2a9c74ce332a14f0e35c03db34876b d6c96e36ab3ec447bfef3a383191821ded8f0c0c -- libc/include/llvm-libc-macros/stdbit-macros.h libc/src/stdbit/stdc_leading_zeros_uc.cpp libc/src/stdbit/stdc_leading_zeros_uc.h libc/src/stdbit/stdc_leading_zeros_ui.cpp libc/src/stdbit/stdc_leading_zeros_ui.h libc/src/stdbit/stdc_leading_zeros_ul.cpp libc/src/stdbit/stdc_leading_zeros_ul.h libc/src/stdbit/stdc_leading_zeros_ull.cpp libc/src/stdbit/stdc_leading_zeros_ull.h libc/src/stdbit/stdc_leading_zeros_us.cpp libc/src/stdbit/stdc_leading_zeros_us.h libc/test/include/stdbit_test.cpp libc/test/src/stdbit/stdc_leading_zeros_uc_test.cpp libc/test/src/stdbit/stdc_leading_zeros_ui_test.cpp libc/test/src/stdbit/stdc_leading_zeros_ul_test.cpp libc/test/src/stdbit/stdc_leading_zeros_ull_test.cpp libc/test/src/stdbit/stdc_leading_zeros_us_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 183328877c..febe95fe0a 100644
--- a/libc/include/llvm-libc-macros/stdbit-macros.h
+++ b/libc/include/llvm-libc-macros/stdbit-macros.h
@@ -9,11 +9,12 @@
 #ifndef __LLVM_LIBC_MACROS_STDBIT_MACROS_H
 #define __LLVM_LIBC_MACROS_STDBIT_MACROS_H
 
-#define stdc_leading_zeros(x) _Generic((x), \
-  unsigned char: stdc_leading_zeros_uc, \
-  unsigned short: stdc_leading_zeros_us, \
-  unsigned: stdc_leading_zeros_ui, \
-  unsigned long: stdc_leading_zeros_ul, \
-  unsigned long long: stdc_leading_zeros_ull)(x)
+#define stdc_leading_zeros(x)                                                  \
+  _Generic((x),                                                                \
+      unsigned char: stdc_leading_zeros_uc,                                    \
+      unsigned short: stdc_leading_zeros_us,                                   \
+      unsigned: stdc_leading_zeros_ui,                                         \
+      unsigned long: stdc_leading_zeros_ul,                                    \
+      unsigned long long: stdc_leading_zeros_ull)(x)
 
 #endif // __LLVM_LIBC_MACROS_STDBIT_MACROS_H
diff --git a/libc/src/stdbit/stdc_leading_zeros_uc.cpp b/libc/src/stdbit/stdc_leading_zeros_uc.cpp
index a985700274..8c27043e05 100644
--- a/libc/src/stdbit/stdc_leading_zeros_uc.cpp
+++ b/libc/src/stdbit/stdc_leading_zeros_uc.cpp
@@ -13,7 +13,8 @@
 
 namespace LIBC_NAMESPACE {
 
-LLVM_LIBC_FUNCTION(unsigned char, stdc_leading_zeros_uc, (unsigned char value)) {
+LLVM_LIBC_FUNCTION(unsigned char, stdc_leading_zeros_uc,
+                   (unsigned char value)) {
   return static_cast<unsigned char>(cpp::countl_zero(value));
 }
 
diff --git a/libc/src/stdbit/stdc_leading_zeros_ul.cpp b/libc/src/stdbit/stdc_leading_zeros_ul.cpp
index 4ce56be04f..cf21ff449a 100644
--- a/libc/src/stdbit/stdc_leading_zeros_ul.cpp
+++ b/libc/src/stdbit/stdc_leading_zeros_ul.cpp
@@ -13,7 +13,8 @@
 
 namespace LIBC_NAMESPACE {
 
-LLVM_LIBC_FUNCTION(unsigned long, stdc_leading_zeros_ul, (unsigned long value)) {
+LLVM_LIBC_FUNCTION(unsigned long, stdc_leading_zeros_ul,
+                   (unsigned long value)) {
   return static_cast<unsigned long>(cpp::countl_zero(value));
 }
 
diff --git a/libc/src/stdbit/stdc_leading_zeros_ull.cpp b/libc/src/stdbit/stdc_leading_zeros_ull.cpp
index 5abd6a6e7a..d488559bbd 100644
--- a/libc/src/stdbit/stdc_leading_zeros_ull.cpp
+++ b/libc/src/stdbit/stdc_leading_zeros_ull.cpp
@@ -13,7 +13,8 @@
 
 namespace LIBC_NAMESPACE {
 
-LLVM_LIBC_FUNCTION(unsigned long long, stdc_leading_zeros_ull, (unsigned long long value)) {
+LLVM_LIBC_FUNCTION(unsigned long long, stdc_leading_zeros_ull,
+                   (unsigned long long value)) {
   return static_cast<unsigned long long>(cpp::countl_zero(value));
 }
 
diff --git a/libc/src/stdbit/stdc_leading_zeros_us.cpp b/libc/src/stdbit/stdc_leading_zeros_us.cpp
index 0c14d5374a..84df2b842d 100644
--- a/libc/src/stdbit/stdc_leading_zeros_us.cpp
+++ b/libc/src/stdbit/stdc_leading_zeros_us.cpp
@@ -13,7 +13,8 @@
 
 namespace LIBC_NAMESPACE {
 
-LLVM_LIBC_FUNCTION(unsigned short, stdc_leading_zeros_us, (unsigned short value)) {
+LLVM_LIBC_FUNCTION(unsigned short, stdc_leading_zeros_us,
+                   (unsigned short value)) {
   return static_cast<unsigned short>(cpp::countl_zero(value));
 }
 
diff --git a/libc/test/src/stdbit/stdc_leading_zeros_uc_test.cpp b/libc/test/src/stdbit/stdc_leading_zeros_uc_test.cpp
index 76f32dea18..ad87c14804 100644
--- a/libc/test/src/stdbit/stdc_leading_zeros_uc_test.cpp
+++ b/libc/test/src/stdbit/stdc_leading_zeros_uc_test.cpp
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/stdbit/stdc_leading_zeros_uc.h"
 #include "src/__support/CPP/limits.h"
+#include "src/stdbit/stdc_leading_zeros_uc.h"
 #include "test/UnitTest/Test.h"
 
 #define LZ(x) LIBC_NAMESPACE::stdc_leading_zeros_uc((x))
diff --git a/libc/test/src/stdbit/stdc_leading_zeros_ui_test.cpp b/libc/test/src/stdbit/stdc_leading_zeros_ui_test.cpp
index e1d6653fd3..a3dde44a8c 100644
--- a/libc/test/src/stdbit/stdc_leading_zeros_ui_test.cpp
+++ b/libc/test/src/stdbit/stdc_leading_zeros_ui_test.cpp
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/stdbit/stdc_leading_zeros_ui.h"
 #include "src/__support/CPP/limits.h"
+#include "src/stdbit/stdc_leading_zeros_ui.h"
 #include "test/UnitTest/Test.h"
 #include <stddef.h>
 
diff --git a/libc/test/src/stdbit/stdc_leading_zeros_ul_test.cpp b/libc/test/src/stdbit/stdc_leading_zeros_ul_test.cpp
index fe085533dc..1a1df653c8 100644
--- a/libc/test/src/stdbit/stdc_leading_zeros_ul_test.cpp
+++ b/libc/test/src/stdbit/stdc_leading_zeros_ul_test.cpp
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/stdbit/stdc_leading_zeros_ul.h"
 #include "src/__support/CPP/limits.h"
+#include "src/stdbit/stdc_leading_zeros_ul.h"
 #include "test/UnitTest/Test.h"
 #include <stddef.h>
 
diff --git a/libc/test/src/stdbit/stdc_leading_zeros_ull_test.cpp b/libc/test/src/stdbit/stdc_leading_zeros_ull_test.cpp
index c6ef95dab8..fe5058c4d2 100644
--- a/libc/test/src/stdbit/stdc_leading_zeros_ull_test.cpp
+++ b/libc/test/src/stdbit/stdc_leading_zeros_ull_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for stdc_leading_zeros_ull -------------------------------===//
+//===-- Unittests for stdc_leading_zeros_ull
+//-------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/stdbit/stdc_leading_zeros_ull.h"
 #include "src/__support/CPP/limits.h"
+#include "src/stdbit/stdc_leading_zeros_ull.h"
 #include "test/UnitTest/Test.h"
 #include <stddef.h>
 
diff --git a/libc/test/src/stdbit/stdc_leading_zeros_us_test.cpp b/libc/test/src/stdbit/stdc_leading_zeros_us_test.cpp
index 0e50eeae8a..8324f3a969 100644
--- a/libc/test/src/stdbit/stdc_leading_zeros_us_test.cpp
+++ b/libc/test/src/stdbit/stdc_leading_zeros_us_test.cpp
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/stdbit/stdc_leading_zeros_us.h"
 #include "src/__support/CPP/limits.h"
+#include "src/stdbit/stdc_leading_zeros_us.h"
 #include "test/UnitTest/Test.h"
 
 #define LZ(x) LIBC_NAMESPACE::stdc_leading_zeros_us((x))

``````````

</details>


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


More information about the libc-commits mailing list