[libc-commits] [libc] [libc] [Task] Prepare to enable disabled warnings (PR #122835)

Vinay Deshmukh via libc-commits libc-commits at lists.llvm.org
Thu Jan 16 03:59:56 PST 2025


https://github.com/vinay-deshmukh updated https://github.com/llvm/llvm-project/pull/122835

>From 00a77f0e69b327a31ae2559805aa1420859013f5 Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <32487576+vinay-deshmukh at users.noreply.github.com>
Date: Mon, 13 Jan 2025 19:36:36 -0500
Subject: [PATCH 01/10] -Wunused

---
 libc/test/UnitTest/LibcDeathTestExecutors.cpp | 2 +-
 libc/test/UnitTest/LibcTest.h                 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libc/test/UnitTest/LibcDeathTestExecutors.cpp b/libc/test/UnitTest/LibcDeathTestExecutors.cpp
index 943e2c23c5fde9..18e23ba39057dd 100644
--- a/libc/test/UnitTest/LibcDeathTestExecutors.cpp
+++ b/libc/test/UnitTest/LibcDeathTestExecutors.cpp
@@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
 namespace testing {
 
 bool Test::testProcessKilled(testutils::FunctionCaller *Func, int Signal,
-                             const char *LHSStr, const char *RHSStr,
+                             const char *LHSStr, const char */*RHSStr*/,
                              internal::Location Loc) {
   testutils::ProcessStatus Result =
       testutils::invoke_in_subprocess(Func, TIMEOUT_MS);
diff --git a/libc/test/UnitTest/LibcTest.h b/libc/test/UnitTest/LibcTest.h
index b4e3819ea958de..124748ba343270 100644
--- a/libc/test/UnitTest/LibcTest.h
+++ b/libc/test/UnitTest/LibcTest.h
@@ -81,7 +81,7 @@ struct Message {
 // A trivial object to catch the Message, this enables custom logging and
 // returning from the test function, see LIBC_TEST_SCAFFOLDING_ below.
 struct Failure {
-  void operator=(Message msg) {}
+  void operator=(Message /*msg*/) {}
 };
 
 struct RunContext {

>From 3c023eda589f971a34d2ff065f3d0edd3db044f5 Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <32487576+vinay-deshmukh at users.noreply.github.com>
Date: Mon, 13 Jan 2025 19:38:26 -0500
Subject: [PATCH 02/10] -Wno-global-constructors for TEST_F

---
 libc/cmake/modules/LLVMLibCCompileOptionRules.cmake | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
index 520b486c8baf93..bf6c1c51a5c23a 100644
--- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
+++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
@@ -246,6 +246,7 @@ function(_get_common_test_compile_options output_var c_test flags)
     # -DLIBC_WNO_ERROR=ON if you can't build cleanly with -Werror.
     if(NOT LIBC_WNO_ERROR)
       list(APPEND compile_options "-Werror")
+      list(APPEND compile_options "-Wno-global-constructors")
     endif()
     list(APPEND compile_options "-Wconversion")
     list(APPEND compile_options "-Wno-sign-conversion")
@@ -267,7 +268,7 @@ function(_get_common_test_compile_options output_var c_test flags)
       list(APPEND compile_options "-Wnonportable-system-include-path")
       list(APPEND compile_options "-Wstrict-prototypes")
       list(APPEND compile_options "-Wthread-safety")
-      list(APPEND compile_options "-Wglobal-constructors")
+      # list(APPEND compile_options "-Wglobal-constructors") # triggered in TEST_F implementation
     endif()
   endif()
   set(${output_var} ${compile_options} PARENT_SCOPE)

>From bbec43a0c06e7de96cbab12b6cad7920da4eaac0 Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <32487576+vinay-deshmukh at users.noreply.github.com>
Date: Mon, 13 Jan 2025 19:35:58 -0500
Subject: [PATCH 03/10] trigger warnings

---
 .../modules/LLVMLibCCompileOptionRules.cmake  | 30 +++++++++----------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
index 8dcee1ec422464..520b486c8baf93 100644
--- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
+++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
@@ -241,17 +241,17 @@ function(_get_common_test_compile_options output_var c_test flags)
       list(APPEND compile_options "-ffixed-point")
     endif()
 
-    # list(APPEND compile_options "-Wall")
-    # list(APPEND compile_options "-Wextra")
+    list(APPEND compile_options "-Wall")
+    list(APPEND compile_options "-Wextra")
     # -DLIBC_WNO_ERROR=ON if you can't build cleanly with -Werror.
     if(NOT LIBC_WNO_ERROR)
-      # list(APPEND compile_options "-Werror")
+      list(APPEND compile_options "-Werror")
     endif()
-    # list(APPEND compile_options "-Wconversion")
-    # list(APPEND compile_options "-Wno-sign-conversion")
-    # list(APPEND compile_options "-Wimplicit-fallthrough")
-    # list(APPEND compile_options "-Wwrite-strings")
-    # list(APPEND compile_options "-Wextra-semi")
+    list(APPEND compile_options "-Wconversion")
+    list(APPEND compile_options "-Wno-sign-conversion")
+    list(APPEND compile_options "-Wimplicit-fallthrough")
+    list(APPEND compile_options "-Wwrite-strings")
+    list(APPEND compile_options "-Wextra-semi")
     # Silence this warning because _Complex is a part of C99.
     if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
       if(NOT c_test)
@@ -262,13 +262,13 @@ function(_get_common_test_compile_options output_var c_test flags)
       list(APPEND compile_options "-Wno-gnu-imaginary-constant")
     endif()
     list(APPEND compile_options "-Wno-pedantic")
-    # if(NOT CMAKE_COMPILER_IS_GNUCXX)
-    #   list(APPEND compile_options "-Wnewline-eof")
-    #   list(APPEND compile_options "-Wnonportable-system-include-path")
-    #   list(APPEND compile_options "-Wstrict-prototypes")
-    #   list(APPEND compile_options "-Wthread-safety")
-    #   list(APPEND compile_options "-Wglobal-constructors")
-    # endif()
+    if(NOT CMAKE_COMPILER_IS_GNUCXX)
+      list(APPEND compile_options "-Wnewline-eof")
+      list(APPEND compile_options "-Wnonportable-system-include-path")
+      list(APPEND compile_options "-Wstrict-prototypes")
+      list(APPEND compile_options "-Wthread-safety")
+      list(APPEND compile_options "-Wglobal-constructors")
+    endif()
   endif()
   set(${output_var} ${compile_options} PARENT_SCOPE)
 endfunction()

>From badca59e41be871cc5a5f8017aa39aaf5c4952eb Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <32487576+vinay-deshmukh at users.noreply.github.com>
Date: Mon, 13 Jan 2025 19:46:26 -0500
Subject: [PATCH 04/10] -Wimplicit-int-conversion

---
 libc/src/__support/CPP/bit.h                  |  4 +-
 libc/src/string/memory_utils/utils.h          |  2 +-
 libc/test/include/stdbit_stub.h               | 42 +++++++++----------
 libc/test/src/__support/CPP/bit_test.cpp      |  2 +-
 .../__support/CPP/integer_sequence_test.cpp   |  2 +-
 libc/test/src/__support/arg_list_test.cpp     |  8 ++--
 libc/test/src/__support/big_int_test.cpp      |  2 +-
 libc/test/src/__support/hash_test.cpp         |  2 +-
 libc/test/src/__support/math_extras_test.cpp  |  8 ++--
 libc/test/src/math/FModTest.h                 |  8 ++--
 .../test/src/string/memory_utils/op_tests.cpp |  6 +--
 libc/test/src/strings/bzero_test.cpp          |  2 +-
 libc/utils/MPFRWrapper/MPFRUtils.h            |  4 +-
 13 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/libc/src/__support/CPP/bit.h b/libc/src/__support/CPP/bit.h
index adcd0472747d01..82b9eb51282625 100644
--- a/libc/src/__support/CPP/bit.h
+++ b/libc/src/__support/CPP/bit.h
@@ -232,7 +232,7 @@ rotl(T value, int rotate) {
     return value;
   if (rotate < 0)
     return cpp::rotr<T>(value, -rotate);
-  return (value << rotate) | (value >> (N - rotate));
+  return static_cast<T>((value << rotate) | (value >> (N - rotate)));
 }
 
 template <typename T>
@@ -244,7 +244,7 @@ rotr(T value, int rotate) {
     return value;
   if (rotate < 0)
     return cpp::rotl<T>(value, -rotate);
-  return (value >> rotate) | (value << (N - rotate));
+  return static_cast<T>((value >> rotate) | (value << (N - rotate)));
 }
 
 // TODO: Do we need this function at all? How is it different from
diff --git a/libc/src/string/memory_utils/utils.h b/libc/src/string/memory_utils/utils.h
index cae65bddd92f6e..eb44e856a1a718 100644
--- a/libc/src/string/memory_utils/utils.h
+++ b/libc/src/string/memory_utils/utils.h
@@ -263,7 +263,7 @@ LIBC_INLINE void store_aligned(ValueType value, Ptr dst) {
   static_assert(sizeof(ValueType) >= (sizeof(T) + ... + sizeof(TS)));
   constexpr size_t SHIFT = sizeof(T) * 8;
   if constexpr (Endian::IS_LITTLE) {
-    store<T>(assume_aligned<sizeof(T)>(dst), value & ~T(0));
+    store<T>(assume_aligned<sizeof(T)>(dst), static_cast<T>(value & ~T(0)));
     if constexpr (sizeof...(TS) > 0)
       store_aligned<ValueType, TS...>(value >> SHIFT, dst + sizeof(T));
   } else if constexpr (Endian::IS_BIG) {
diff --git a/libc/test/include/stdbit_stub.h b/libc/test/include/stdbit_stub.h
index 8a8e30e889d6d7..58baf493d8adb8 100644
--- a/libc/test/include/stdbit_stub.h
+++ b/libc/test/include/stdbit_stub.h
@@ -17,11 +17,11 @@
 #include <stdbool.h> // bool in C
 
 #define STDBIT_STUB_FUNCTION(FUNC_NAME, LEADING_VAL)                           \
-  unsigned FUNC_NAME##_uc(unsigned char x) { return LEADING_VAL##AU; }         \
-  unsigned FUNC_NAME##_us(unsigned short x) { return LEADING_VAL##BU; }        \
-  unsigned FUNC_NAME##_ui(unsigned int x) { return LEADING_VAL##CU; }          \
-  unsigned FUNC_NAME##_ul(unsigned long x) { return LEADING_VAL##DU; }         \
-  unsigned FUNC_NAME##_ull(unsigned long long x) { return LEADING_VAL##EU; }
+  unsigned FUNC_NAME##_uc(unsigned char) { return LEADING_VAL##AU; }         \
+  unsigned FUNC_NAME##_us(unsigned short) { return LEADING_VAL##BU; }        \
+  unsigned FUNC_NAME##_ui(unsigned int) { return LEADING_VAL##CU; }          \
+  unsigned FUNC_NAME##_ul(unsigned long) { return LEADING_VAL##DU; }         \
+  unsigned FUNC_NAME##_ull(unsigned long long) { return LEADING_VAL##EU; }
 
 __BEGIN_C_DECLS
 
@@ -36,24 +36,24 @@ STDBIT_STUB_FUNCTION(stdc_first_trailing_one, 0x1)
 STDBIT_STUB_FUNCTION(stdc_count_zeros, 0x2)
 STDBIT_STUB_FUNCTION(stdc_count_ones, 0x3)
 
-bool stdc_has_single_bit_uc(unsigned char x) { return false; }
-bool stdc_has_single_bit_us(unsigned short x) { return false; }
-bool stdc_has_single_bit_ui(unsigned x) { return false; }
-bool stdc_has_single_bit_ul(unsigned long x) { return false; }
-bool stdc_has_single_bit_ull(unsigned long long x) { return false; }
+bool stdc_has_single_bit_uc(unsigned char) { return false; }
+bool stdc_has_single_bit_us(unsigned short) { return false; }
+bool stdc_has_single_bit_ui(unsigned) { return false; }
+bool stdc_has_single_bit_ul(unsigned long) { return false; }
+bool stdc_has_single_bit_ull(unsigned long long) { return false; }
 
 STDBIT_STUB_FUNCTION(stdc_bit_width, 0x4)
 
-unsigned char stdc_bit_floor_uc(unsigned char x) { return 0x5AU; }
-unsigned short stdc_bit_floor_us(unsigned short x) { return 0x5BU; }
-unsigned stdc_bit_floor_ui(unsigned x) { return 0x5CU; }
-unsigned long stdc_bit_floor_ul(unsigned long x) { return 0x5DUL; }
-unsigned long long stdc_bit_floor_ull(unsigned long long x) { return 0x5EULL; }
-
-unsigned char stdc_bit_ceil_uc(unsigned char x) { return 0x6AU; }
-unsigned short stdc_bit_ceil_us(unsigned short x) { return 0x6BU; }
-unsigned stdc_bit_ceil_ui(unsigned x) { return 0x6CU; }
-unsigned long stdc_bit_ceil_ul(unsigned long x) { return 0x6DUL; }
-unsigned long long stdc_bit_ceil_ull(unsigned long long x) { return 0x6EULL; }
+unsigned char stdc_bit_floor_uc(unsigned char) { return 0x5AU; }
+unsigned short stdc_bit_floor_us(unsigned short) { return 0x5BU; }
+unsigned stdc_bit_floor_ui(unsigned) { return 0x5CU; }
+unsigned long stdc_bit_floor_ul(unsigned long) { return 0x5DUL; }
+unsigned long long stdc_bit_floor_ull(unsigned long long) { return 0x5EULL; }
+
+unsigned char stdc_bit_ceil_uc(unsigned char) { return 0x6AU; }
+unsigned short stdc_bit_ceil_us(unsigned short) { return 0x6BU; }
+unsigned stdc_bit_ceil_ui(unsigned) { return 0x6CU; }
+unsigned long stdc_bit_ceil_ul(unsigned long) { return 0x6DUL; }
+unsigned long long stdc_bit_ceil_ull(unsigned long long) { return 0x6EULL; }
 
 __END_C_DECLS
diff --git a/libc/test/src/__support/CPP/bit_test.cpp b/libc/test/src/__support/CPP/bit_test.cpp
index 9429b66ad1f981..9389e96642d1ef 100644
--- a/libc/test/src/__support/CPP/bit_test.cpp
+++ b/libc/test/src/__support/CPP/bit_test.cpp
@@ -41,7 +41,7 @@ TYPED_TEST(LlvmLibcBitTest, HasSingleBit, UnsignedTypes) {
   constexpr auto LSB = T(1);
   constexpr auto MSB = T(~(ALL_ONES >> 1));
   for (T value = 1; value; value <<= 1) {
-    auto two_bits_value = value | ((value <= MIDPOINT) ? MSB : LSB);
+    T two_bits_value = value | ((value <= MIDPOINT) ? MSB : LSB);
     EXPECT_FALSE(has_single_bit<T>(two_bits_value));
   }
 }
diff --git a/libc/test/src/__support/CPP/integer_sequence_test.cpp b/libc/test/src/__support/CPP/integer_sequence_test.cpp
index fe378522b446b9..3a5ad77c9e8747 100644
--- a/libc/test/src/__support/CPP/integer_sequence_test.cpp
+++ b/libc/test/src/__support/CPP/integer_sequence_test.cpp
@@ -23,7 +23,7 @@ TEST(LlvmLibcIntegerSequencetTest, Basic) {
       (is_same_v<ULLSeq, make_integer_sequence<unsigned long long, 4>>));
 }
 
-template <typename T, T... Ts> bool checkArray(integer_sequence<T, Ts...> seq) {
+template <typename T, T... Ts> bool checkArray(integer_sequence<T, Ts...> /*seq*/) {
   T arr[sizeof...(Ts)]{Ts...};
 
   for (T i = 0; i < static_cast<T>(sizeof...(Ts)); i++)
diff --git a/libc/test/src/__support/arg_list_test.cpp b/libc/test/src/__support/arg_list_test.cpp
index 79a715e9106870..cd6c5696953c81 100644
--- a/libc/test/src/__support/arg_list_test.cpp
+++ b/libc/test/src/__support/arg_list_test.cpp
@@ -72,9 +72,9 @@ long int check_primitives(int first, ...) {
   count += args.next_var<unsigned long>();
   count += args.next_var<long long>();
   count += args.next_var<unsigned long long>();
-  count += args.next_var<double>();
-  count += args.next_var<double>();
-  count += args.next_var<long double>();
+  count += static_cast<long>(args.next_var<double>());
+  count += static_cast<long>(args.next_var<double>());
+  count += static_cast<long>(args.next_var<long double>());
   count += *args.next_var<int *>();
   return count;
 }
@@ -112,7 +112,7 @@ long int check_struct_type(int first, ...) {
 
   S s = args.next_var<S>();
   int last = args.next_var<int>();
-  return s.c + s.s + s.i + s.l + s.f + s.d + last;
+  return s.c + s.s + s.i + s.l + static_cast<long>(s.f) + static_cast<long>(s.d) + last;
 }
 
 TEST(LlvmLibcArgListTest, TestStructTypes) {
diff --git a/libc/test/src/__support/big_int_test.cpp b/libc/test/src/__support/big_int_test.cpp
index 2666ed978dad7a..68afecb17057d3 100644
--- a/libc/test/src/__support/big_int_test.cpp
+++ b/libc/test/src/__support/big_int_test.cpp
@@ -197,7 +197,7 @@ TYPED_TEST(LlvmLibcUIntClassTest, CountBits, Types) {
     for (size_t i = 0; i < T::BITS; ++i) {
       const auto l_one = T::all_ones() << i; // 0b111...000
       const auto r_one = T::all_ones() >> i; // 0b000...111
-      const int zeros = i;
+      const int zeros = static_cast<int>(i);
       const int ones = T::BITS - zeros;
       ASSERT_EQ(cpp::countr_one(r_one), ones);
       ASSERT_EQ(cpp::countl_one(l_one), ones);
diff --git a/libc/test/src/__support/hash_test.cpp b/libc/test/src/__support/hash_test.cpp
index f23a43a3bc5e4d..94c884cc7fb17e 100644
--- a/libc/test/src/__support/hash_test.cpp
+++ b/libc/test/src/__support/hash_test.cpp
@@ -78,7 +78,7 @@ TEST(LlvmLibcHashTest, Avalanche) {
       }
       for (size_t i = 0; i < sz; ++i) {
         for (size_t j = 0; j < 8; ++j) {
-          uint8_t mask = 1 << j;
+          uint8_t mask = static_cast<uint8_t>(1 << j);
           mem.data[i] ^= mask;
           {
             LIBC_NAMESPACE::internal::HashState state{0xabcdef1234567890};
diff --git a/libc/test/src/__support/math_extras_test.cpp b/libc/test/src/__support/math_extras_test.cpp
index 08c090017c1a19..887164cfb398df 100644
--- a/libc/test/src/__support/math_extras_test.cpp
+++ b/libc/test/src/__support/math_extras_test.cpp
@@ -73,27 +73,27 @@ TEST(LlvmLibcBlockMathExtrasTest, mask_trailing_ones) {
 TYPED_TEST(LlvmLibcBitTest, FirstLeadingZero, UnsignedTypesNoBigInt) {
   EXPECT_EQ(first_leading_zero<T>(cpp::numeric_limits<T>::max()), 0);
   for (int i = 0U; i != cpp::numeric_limits<T>::digits; ++i)
-    EXPECT_EQ(first_leading_zero<T>(~(T(1) << i)),
+    EXPECT_EQ(first_leading_zero<T>(static_cast<T>(~(T(1) << i))),
               cpp::numeric_limits<T>::digits - i);
 }
 
 TYPED_TEST(LlvmLibcBitTest, FirstLeadingOne, UnsignedTypesNoBigInt) {
   EXPECT_EQ(first_leading_one<T>(static_cast<T>(0)), 0);
   for (int i = 0U; i != cpp::numeric_limits<T>::digits; ++i)
-    EXPECT_EQ(first_leading_one<T>(T(1) << i),
+    EXPECT_EQ(first_leading_one<T>(static_cast<T>(T(1) << i)),
               cpp::numeric_limits<T>::digits - i);
 }
 
 TYPED_TEST(LlvmLibcBitTest, FirstTrailingZero, UnsignedTypesNoBigInt) {
   EXPECT_EQ(first_trailing_zero<T>(cpp::numeric_limits<T>::max()), 0);
   for (int i = 0U; i != cpp::numeric_limits<T>::digits; ++i)
-    EXPECT_EQ(first_trailing_zero<T>(~(T(1) << i)), i + 1);
+    EXPECT_EQ(first_trailing_zero<T>(static_cast<T>(~(T(1) << i))), i + 1);
 }
 
 TYPED_TEST(LlvmLibcBitTest, FirstTrailingOne, UnsignedTypesNoBigInt) {
   EXPECT_EQ(first_trailing_one<T>(cpp::numeric_limits<T>::max()), 0);
   for (int i = 0U; i != cpp::numeric_limits<T>::digits; ++i)
-    EXPECT_EQ(first_trailing_one<T>(T(1) << i), i + 1);
+    EXPECT_EQ(first_trailing_one<T>(static_cast<T>(T(1) << i)), i + 1);
 }
 
 TYPED_TEST(LlvmLibcBitTest, CountZeros, UnsignedTypesNoBigInt) {
diff --git a/libc/test/src/math/FModTest.h b/libc/test/src/math/FModTest.h
index 32c009ab88286d..c32328584582fc 100644
--- a/libc/test/src/math/FModTest.h
+++ b/libc/test/src/math/FModTest.h
@@ -54,7 +54,7 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
 
     // fmod (+inf, y) == aNaN plus invalid exception.
     TEST_SPECIAL(inf, 3.0, aNaN, true, FE_INVALID);
-    TEST_SPECIAL(inf, -1.1L, aNaN, true, FE_INVALID);
+    TEST_SPECIAL(inf, static_cast<T>(-1.1L), aNaN, true, FE_INVALID);
     TEST_SPECIAL(inf, 0.0, aNaN, true, FE_INVALID);
     TEST_SPECIAL(inf, neg_zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(inf, min_denormal, aNaN, true, FE_INVALID);
@@ -65,7 +65,7 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
 
     // fmod (-inf, y) == aNaN plus invalid exception.
     TEST_SPECIAL(neg_inf, 3.0, aNaN, true, FE_INVALID);
-    TEST_SPECIAL(neg_inf, -1.1L, aNaN, true, FE_INVALID);
+    TEST_SPECIAL(neg_inf, static_cast<T>(-1.1L), aNaN, true, FE_INVALID);
     TEST_SPECIAL(neg_inf, 0.0, aNaN, true, FE_INVALID);
     TEST_SPECIAL(neg_inf, neg_zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(neg_inf, min_denormal, aNaN, true, FE_INVALID);
@@ -76,7 +76,7 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
 
     // fmod (x, +0) == aNaN plus invalid exception.
     TEST_SPECIAL(3.0, 0.0, aNaN, true, FE_INVALID);
-    TEST_SPECIAL(-1.1L, 0.0, aNaN, true, FE_INVALID);
+    TEST_SPECIAL(static_cast<T>(-1.1L), 0.0, aNaN, true, FE_INVALID);
     TEST_SPECIAL(0.0, 0.0, aNaN, true, FE_INVALID);
     TEST_SPECIAL(neg_zero, 0.0, aNaN, true, FE_INVALID);
     TEST_SPECIAL(min_denormal, 0.0, aNaN, true, FE_INVALID);
@@ -85,7 +85,7 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
 
     // fmod (x, -0) == aNaN plus invalid exception.
     TEST_SPECIAL(3.0, neg_zero, aNaN, true, FE_INVALID);
-    TEST_SPECIAL(-1.1L, neg_zero, aNaN, true, FE_INVALID);
+    TEST_SPECIAL(static_cast<T>(-1.1L), neg_zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(0.0, neg_zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(neg_zero, neg_zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(min_denormal, neg_zero, aNaN, true, FE_INVALID);
diff --git a/libc/test/src/string/memory_utils/op_tests.cpp b/libc/test/src/string/memory_utils/op_tests.cpp
index c6197d1afa266b..0b12c7da003f3c 100644
--- a/libc/test/src/string/memory_utils/op_tests.cpp
+++ b/libc/test/src/string/memory_utils/op_tests.cpp
@@ -72,7 +72,7 @@ void CopyAdaptor(cpp::span<char> dst, cpp::span<char> src, size_t size) {
   FnImpl(as_byte(dst), as_byte(src), size);
 }
 template <size_t Size, auto FnImpl>
-void CopyBlockAdaptor(cpp::span<char> dst, cpp::span<char> src, size_t size) {
+void CopyBlockAdaptor(cpp::span<char> dst, cpp::span<char> src, size_t /*size*/) {
   FnImpl(as_byte(dst), as_byte(src));
 }
 
@@ -153,7 +153,7 @@ void SetAdaptor(cpp::span<char> dst, uint8_t value, size_t size) {
   FnImpl(as_byte(dst), value, size);
 }
 template <size_t Size, auto FnImpl>
-void SetBlockAdaptor(cpp::span<char> dst, uint8_t value, size_t size) {
+void SetBlockAdaptor(cpp::span<char> dst, uint8_t value, size_t /*size*/) {
   FnImpl(as_byte(dst), value);
 }
 
@@ -242,7 +242,7 @@ int CmpAdaptor(cpp::span<char> p1, cpp::span<char> p2, size_t size) {
   return (int)FnImpl(as_byte(p1), as_byte(p2), size);
 }
 template <size_t Size, auto FnImpl>
-int CmpBlockAdaptor(cpp::span<char> p1, cpp::span<char> p2, size_t size) {
+int CmpBlockAdaptor(cpp::span<char> p1, cpp::span<char> p2, size_t /*size*/) {
   return (int)FnImpl(as_byte(p1), as_byte(p2));
 }
 
diff --git a/libc/test/src/strings/bzero_test.cpp b/libc/test/src/strings/bzero_test.cpp
index 4d4112f4be8ee1..e3091556da2762 100644
--- a/libc/test/src/strings/bzero_test.cpp
+++ b/libc/test/src/strings/bzero_test.cpp
@@ -14,7 +14,7 @@
 namespace LIBC_NAMESPACE_DECL {
 
 // Adapt CheckMemset signature to bzero.
-static inline void Adaptor(cpp::span<char> p1, uint8_t value, size_t size) {
+static inline void Adaptor(cpp::span<char> p1, uint8_t /*value*/, size_t size) {
   LIBC_NAMESPACE::bzero(p1.begin(), size);
 }
 
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.h b/libc/utils/MPFRWrapper/MPFRUtils.h
index c7a57819f68b79..791936d78cb67d 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.h
+++ b/libc/utils/MPFRWrapper/MPFRUtils.h
@@ -352,7 +352,7 @@ template <Operation op, typename InputType, typename OutputType>
 __attribute__((no_sanitize("address"))) cpp::enable_if_t<
     is_valid_operation<op, InputType, OutputType>(),
     internal::MPFRMatcher<op, /*is_silent*/ false, InputType, OutputType>>
-get_mpfr_matcher(InputType input, OutputType output_unused,
+get_mpfr_matcher(InputType input, OutputType /*output_unused*/,
                  double ulp_tolerance, RoundingMode rounding) {
   return internal::MPFRMatcher<op, /*is_silent*/ false, InputType, OutputType>(
       input, ulp_tolerance, rounding);
@@ -362,7 +362,7 @@ template <Operation op, typename InputType, typename OutputType>
 __attribute__((no_sanitize("address"))) cpp::enable_if_t<
     is_valid_operation<op, InputType, OutputType>(),
     internal::MPFRMatcher<op, /*is_silent*/ true, InputType, OutputType>>
-get_silent_mpfr_matcher(InputType input, OutputType output_unused,
+get_silent_mpfr_matcher(InputType input, OutputType /*output_unused*/,
                         double ulp_tolerance, RoundingMode rounding) {
   return internal::MPFRMatcher<op, /*is_silent*/ true, InputType, OutputType>(
       input, ulp_tolerance, rounding);

>From 1a2a90dd0d950a015152c7081892caa705b328c2 Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <32487576+vinay-deshmukh at users.noreply.github.com>
Date: Mon, 13 Jan 2025 19:48:17 -0500
Subject: [PATCH 05/10] -Wextra-semi

---
 libc/test/src/math/smoke/nan_test.cpp  | 2 +-
 libc/test/src/math/smoke/nanf_test.cpp | 2 +-
 libc/test/src/math/smoke/nanl_test.cpp | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libc/test/src/math/smoke/nan_test.cpp b/libc/test/src/math/smoke/nan_test.cpp
index 46b9e9aa9563ab..da6beb94c7f05d 100644
--- a/libc/test/src/math/smoke/nan_test.cpp
+++ b/libc/test/src/math/smoke/nan_test.cpp
@@ -23,7 +23,7 @@ class LlvmLibcNanTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     auto actual_fp = LIBC_NAMESPACE::fputil::FPBits<double>(result);
     auto expected_fp = LIBC_NAMESPACE::fputil::FPBits<double>(bits);
     EXPECT_EQ(actual_fp.uintval(), expected_fp.uintval());
-  };
+  }
 };
 
 TEST_F(LlvmLibcNanTest, NCharSeq) {
diff --git a/libc/test/src/math/smoke/nanf_test.cpp b/libc/test/src/math/smoke/nanf_test.cpp
index dd3124ee9c5112..19d94b40b5ffbd 100644
--- a/libc/test/src/math/smoke/nanf_test.cpp
+++ b/libc/test/src/math/smoke/nanf_test.cpp
@@ -23,7 +23,7 @@ class LlvmLibcNanfTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     auto actual_fp = LIBC_NAMESPACE::fputil::FPBits<float>(result);
     auto expected_fp = LIBC_NAMESPACE::fputil::FPBits<float>(bits);
     EXPECT_EQ(actual_fp.uintval(), expected_fp.uintval());
-  };
+  }
 };
 
 TEST_F(LlvmLibcNanfTest, NCharSeq) {
diff --git a/libc/test/src/math/smoke/nanl_test.cpp b/libc/test/src/math/smoke/nanl_test.cpp
index ef3f9c15dafd9f..c7217928e943b0 100644
--- a/libc/test/src/math/smoke/nanl_test.cpp
+++ b/libc/test/src/math/smoke/nanl_test.cpp
@@ -33,7 +33,7 @@ class LlvmLibcNanlTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     auto actual_fp = LIBC_NAMESPACE::fputil::FPBits<long double>(result);
     auto expected_fp = LIBC_NAMESPACE::fputil::FPBits<long double>(bits);
     EXPECT_EQ(actual_fp.uintval(), expected_fp.uintval());
-  };
+  }
 };
 
 TEST_F(LlvmLibcNanlTest, NCharSeq) {

>From f375ca56c95ea22a730e932b0418071d46c4ae43 Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <32487576+vinay-deshmukh at users.noreply.github.com>
Date: Mon, 13 Jan 2025 19:57:52 -0500
Subject: [PATCH 06/10] clang-format patch

---
 libc/test/UnitTest/LibcDeathTestExecutors.cpp         | 2 +-
 libc/test/include/stdbit_stub.h                       | 8 ++++----
 libc/test/src/__support/CPP/integer_sequence_test.cpp | 3 ++-
 libc/test/src/__support/arg_list_test.cpp             | 3 ++-
 libc/test/src/string/memory_utils/op_tests.cpp        | 3 ++-
 5 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/libc/test/UnitTest/LibcDeathTestExecutors.cpp b/libc/test/UnitTest/LibcDeathTestExecutors.cpp
index 18e23ba39057dd..f2b048864b556c 100644
--- a/libc/test/UnitTest/LibcDeathTestExecutors.cpp
+++ b/libc/test/UnitTest/LibcDeathTestExecutors.cpp
@@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
 namespace testing {
 
 bool Test::testProcessKilled(testutils::FunctionCaller *Func, int Signal,
-                             const char *LHSStr, const char */*RHSStr*/,
+                             const char *LHSStr, const char * /*RHSStr*/,
                              internal::Location Loc) {
   testutils::ProcessStatus Result =
       testutils::invoke_in_subprocess(Func, TIMEOUT_MS);
diff --git a/libc/test/include/stdbit_stub.h b/libc/test/include/stdbit_stub.h
index 58baf493d8adb8..e73a2117d6b575 100644
--- a/libc/test/include/stdbit_stub.h
+++ b/libc/test/include/stdbit_stub.h
@@ -17,10 +17,10 @@
 #include <stdbool.h> // bool in C
 
 #define STDBIT_STUB_FUNCTION(FUNC_NAME, LEADING_VAL)                           \
-  unsigned FUNC_NAME##_uc(unsigned char) { return LEADING_VAL##AU; }         \
-  unsigned FUNC_NAME##_us(unsigned short) { return LEADING_VAL##BU; }        \
-  unsigned FUNC_NAME##_ui(unsigned int) { return LEADING_VAL##CU; }          \
-  unsigned FUNC_NAME##_ul(unsigned long) { return LEADING_VAL##DU; }         \
+  unsigned FUNC_NAME##_uc(unsigned char) { return LEADING_VAL##AU; }           \
+  unsigned FUNC_NAME##_us(unsigned short) { return LEADING_VAL##BU; }          \
+  unsigned FUNC_NAME##_ui(unsigned int) { return LEADING_VAL##CU; }            \
+  unsigned FUNC_NAME##_ul(unsigned long) { return LEADING_VAL##DU; }           \
   unsigned FUNC_NAME##_ull(unsigned long long) { return LEADING_VAL##EU; }
 
 __BEGIN_C_DECLS
diff --git a/libc/test/src/__support/CPP/integer_sequence_test.cpp b/libc/test/src/__support/CPP/integer_sequence_test.cpp
index 3a5ad77c9e8747..56e75f496255f5 100644
--- a/libc/test/src/__support/CPP/integer_sequence_test.cpp
+++ b/libc/test/src/__support/CPP/integer_sequence_test.cpp
@@ -23,7 +23,8 @@ TEST(LlvmLibcIntegerSequencetTest, Basic) {
       (is_same_v<ULLSeq, make_integer_sequence<unsigned long long, 4>>));
 }
 
-template <typename T, T... Ts> bool checkArray(integer_sequence<T, Ts...> /*seq*/) {
+template <typename T, T... Ts>
+bool checkArray(integer_sequence<T, Ts...> /*seq*/) {
   T arr[sizeof...(Ts)]{Ts...};
 
   for (T i = 0; i < static_cast<T>(sizeof...(Ts)); i++)
diff --git a/libc/test/src/__support/arg_list_test.cpp b/libc/test/src/__support/arg_list_test.cpp
index cd6c5696953c81..57714050f05fca 100644
--- a/libc/test/src/__support/arg_list_test.cpp
+++ b/libc/test/src/__support/arg_list_test.cpp
@@ -112,7 +112,8 @@ long int check_struct_type(int first, ...) {
 
   S s = args.next_var<S>();
   int last = args.next_var<int>();
-  return s.c + s.s + s.i + s.l + static_cast<long>(s.f) + static_cast<long>(s.d) + last;
+  return s.c + s.s + s.i + s.l + static_cast<long>(s.f) +
+         static_cast<long>(s.d) + last;
 }
 
 TEST(LlvmLibcArgListTest, TestStructTypes) {
diff --git a/libc/test/src/string/memory_utils/op_tests.cpp b/libc/test/src/string/memory_utils/op_tests.cpp
index 0b12c7da003f3c..dd7619240417ef 100644
--- a/libc/test/src/string/memory_utils/op_tests.cpp
+++ b/libc/test/src/string/memory_utils/op_tests.cpp
@@ -72,7 +72,8 @@ void CopyAdaptor(cpp::span<char> dst, cpp::span<char> src, size_t size) {
   FnImpl(as_byte(dst), as_byte(src), size);
 }
 template <size_t Size, auto FnImpl>
-void CopyBlockAdaptor(cpp::span<char> dst, cpp::span<char> src, size_t /*size*/) {
+void CopyBlockAdaptor(cpp::span<char> dst, cpp::span<char> src,
+                      size_t /*size*/) {
   FnImpl(as_byte(dst), as_byte(src));
 }
 

>From ba19d9a01c10d77562614418620635a3a6167e83 Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <32487576+vinay-deshmukh at users.noreply.github.com>
Date: Mon, 13 Jan 2025 20:11:56 -0500
Subject: [PATCH 07/10] full build warnings from CI

---
 libc/test/UnitTest/HermeticTestUtils.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libc/test/UnitTest/HermeticTestUtils.cpp b/libc/test/UnitTest/HermeticTestUtils.cpp
index 47f813b0b7a4e1..b46070699b311d 100644
--- a/libc/test/UnitTest/HermeticTestUtils.cpp
+++ b/libc/test/UnitTest/HermeticTestUtils.cpp
@@ -29,7 +29,7 @@ int atexit(void (*func)(void));
 // add_libc_hermetic_test properly. Such that they won't get correct linkage
 // against the object containing this function. We create a dummy function that
 // always returns 0 to indicate a failure.
-[[gnu::weak]] unsigned long getauxval(unsigned long id) { return 0; }
+[[gnu::weak]] unsigned long getauxval(unsigned long /*id*/) { return 0; }
 
 } // namespace LIBC_NAMESPACE_DECL
 
@@ -124,7 +124,7 @@ unsigned long __getauxval(unsigned long id) {
 
 } // extern "C"
 
-void *operator new(size_t size, void *ptr) { return ptr; }
+void *operator new(size_t /*size*/, void *ptr) { return ptr; }
 
 void *operator new(size_t size) { return malloc(size); }
 
@@ -136,7 +136,7 @@ void operator delete(void *) {
   __builtin_trap();
 }
 
-void operator delete(void *ptr, size_t size) { __builtin_trap(); }
+void operator delete(void */*ptr*/, size_t /*size*/) { __builtin_trap(); }
 
 // Defining members in the std namespace is not preferred. But, we do it here
 // so that we can use it to define the operator new which takes std::align_val_t
@@ -145,8 +145,8 @@ namespace std {
 enum class align_val_t : size_t {};
 } // namespace std
 
-void operator delete(void *mem, std::align_val_t) noexcept { __builtin_trap(); }
+void operator delete(void *, std::align_val_t) noexcept { __builtin_trap(); }
 
-void operator delete(void *mem, unsigned int, std::align_val_t) noexcept {
+void operator delete(void *, unsigned int, std::align_val_t) noexcept {
   __builtin_trap();
 }

>From 90e7a0665da4f0f9ec974087471483f4e519ebca Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <32487576+vinay-deshmukh at users.noreply.github.com>
Date: Thu, 16 Jan 2025 06:47:38 -0500
Subject: [PATCH 08/10] Refactor CMake and temporarily disable warnings

These warnings will be enabled one by one in subsequent PRs.
---
 .../modules/LLVMLibCCompileOptionRules.cmake  | 27 ++++++++++++++-----
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
index 520b486c8baf93..ce68a77d2abdbf 100644
--- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
+++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
@@ -257,18 +257,31 @@ function(_get_common_test_compile_options output_var c_test flags)
       if(NOT c_test)
         list(APPEND compile_options "-fext-numeric-literals")
       endif()
-    else()
-      list(APPEND compile_options "-Wno-c99-extensions")
-      list(APPEND compile_options "-Wno-gnu-imaginary-constant")
-    endif()
-    list(APPEND compile_options "-Wno-pedantic")
-    if(NOT CMAKE_COMPILER_IS_GNUCXX)
+    elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
       list(APPEND compile_options "-Wnewline-eof")
       list(APPEND compile_options "-Wnonportable-system-include-path")
       list(APPEND compile_options "-Wstrict-prototypes")
       list(APPEND compile_options "-Wthread-safety")
-      list(APPEND compile_options "-Wglobal-constructors")
+      # TODO(https://github.com/llvm/llvm-project/issues/119281) triggered in TEST_F implementation
+      list(APPEND compile_options "-Wno-global-constructors") 
+
+      # TODO(https://github.com/llvm/llvm-project/issues/119281)
+      # These have been disabled for the time being to create explicit PRs for each change.
+      list(APPEND compile_options "-Wno-unused-parameter")
+      list(APPEND compile_options "-Wno-implicit-int-conversion")
+      list(APPEND compile_options "-Wno-shorten-64-to-32")
+      list(APPEND compile_options "-Wno-float-conversion")
+      list(APPEND compile_options "-Wno-implicit-float-conversion")
+      list(APPEND compile_options "-Wno-extra-semi")
+
+
+      list(APPEND compile_options "-Wno-c99-extensions")
+      list(APPEND compile_options "-Wno-gnu-imaginary-constant")
+
     endif()
+
+    list(APPEND compile_options "-Wno-pedantic")
+
   endif()
   set(${output_var} ${compile_options} PARENT_SCOPE)
 endfunction()

>From fb7d4bac4ec26133cacb3195284b0fd66df9af2d Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <32487576+vinay-deshmukh at users.noreply.github.com>
Date: Thu, 16 Jan 2025 06:55:59 -0500
Subject: [PATCH 09/10] whitespace

---
 libc/cmake/modules/LLVMLibCTestRules.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 11469d2f616a8d..a73aee68a9372a 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -47,7 +47,7 @@ function(_get_common_test_compile_options output_var c_test flags)
       list(APPEND compile_options "-Wstrict-prototypes")
       list(APPEND compile_options "-Wthread-safety")
       # TODO(https://github.com/llvm/llvm-project/issues/119281) triggered in TEST_F implementation
-      list(APPEND compile_options "-Wno-global-constructors") 
+      list(APPEND compile_options "-Wno-global-constructors")
 
       # TODO(https://github.com/llvm/llvm-project/issues/119281)
       # These have been disabled for the time being to create explicit PRs for each change.

>From 26d4b308f1b56d3950d7870ee16b316f6e0b8ebd Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <32487576+vinay-deshmukh at users.noreply.github.com>
Date: Thu, 16 Jan 2025 06:59:15 -0500
Subject: [PATCH 10/10] undo code changes

---
 libc/src/__support/CPP/bit.h                  |  4 +-
 libc/src/string/memory_utils/utils.h          |  2 +-
 libc/test/UnitTest/HermeticTestUtils.cpp      | 10 ++---
 libc/test/UnitTest/LibcDeathTestExecutors.cpp |  2 +-
 libc/test/UnitTest/LibcTest.h                 |  2 +-
 libc/test/include/stdbit_stub.h               | 42 +++++++++----------
 libc/test/src/__support/CPP/bit_test.cpp      |  2 +-
 .../__support/CPP/integer_sequence_test.cpp   |  3 +-
 libc/test/src/__support/arg_list_test.cpp     |  9 ++--
 libc/test/src/__support/big_int_test.cpp      |  2 +-
 libc/test/src/__support/hash_test.cpp         |  2 +-
 libc/test/src/__support/math_extras_test.cpp  |  8 ++--
 libc/test/src/math/FModTest.h                 |  8 ++--
 libc/test/src/math/smoke/nan_test.cpp         |  2 +-
 libc/test/src/math/smoke/nanf_test.cpp        |  2 +-
 libc/test/src/math/smoke/nanl_test.cpp        |  2 +-
 .../test/src/string/memory_utils/op_tests.cpp |  7 ++--
 libc/test/src/strings/bzero_test.cpp          |  2 +-
 libc/utils/MPFRWrapper/MPFRUtils.h            |  4 +-
 19 files changed, 56 insertions(+), 59 deletions(-)

diff --git a/libc/src/__support/CPP/bit.h b/libc/src/__support/CPP/bit.h
index 82b9eb51282625..adcd0472747d01 100644
--- a/libc/src/__support/CPP/bit.h
+++ b/libc/src/__support/CPP/bit.h
@@ -232,7 +232,7 @@ rotl(T value, int rotate) {
     return value;
   if (rotate < 0)
     return cpp::rotr<T>(value, -rotate);
-  return static_cast<T>((value << rotate) | (value >> (N - rotate)));
+  return (value << rotate) | (value >> (N - rotate));
 }
 
 template <typename T>
@@ -244,7 +244,7 @@ rotr(T value, int rotate) {
     return value;
   if (rotate < 0)
     return cpp::rotl<T>(value, -rotate);
-  return static_cast<T>((value >> rotate) | (value << (N - rotate)));
+  return (value >> rotate) | (value << (N - rotate));
 }
 
 // TODO: Do we need this function at all? How is it different from
diff --git a/libc/src/string/memory_utils/utils.h b/libc/src/string/memory_utils/utils.h
index eb44e856a1a718..cae65bddd92f6e 100644
--- a/libc/src/string/memory_utils/utils.h
+++ b/libc/src/string/memory_utils/utils.h
@@ -263,7 +263,7 @@ LIBC_INLINE void store_aligned(ValueType value, Ptr dst) {
   static_assert(sizeof(ValueType) >= (sizeof(T) + ... + sizeof(TS)));
   constexpr size_t SHIFT = sizeof(T) * 8;
   if constexpr (Endian::IS_LITTLE) {
-    store<T>(assume_aligned<sizeof(T)>(dst), static_cast<T>(value & ~T(0)));
+    store<T>(assume_aligned<sizeof(T)>(dst), value & ~T(0));
     if constexpr (sizeof...(TS) > 0)
       store_aligned<ValueType, TS...>(value >> SHIFT, dst + sizeof(T));
   } else if constexpr (Endian::IS_BIG) {
diff --git a/libc/test/UnitTest/HermeticTestUtils.cpp b/libc/test/UnitTest/HermeticTestUtils.cpp
index b46070699b311d..47f813b0b7a4e1 100644
--- a/libc/test/UnitTest/HermeticTestUtils.cpp
+++ b/libc/test/UnitTest/HermeticTestUtils.cpp
@@ -29,7 +29,7 @@ int atexit(void (*func)(void));
 // add_libc_hermetic_test properly. Such that they won't get correct linkage
 // against the object containing this function. We create a dummy function that
 // always returns 0 to indicate a failure.
-[[gnu::weak]] unsigned long getauxval(unsigned long /*id*/) { return 0; }
+[[gnu::weak]] unsigned long getauxval(unsigned long id) { return 0; }
 
 } // namespace LIBC_NAMESPACE_DECL
 
@@ -124,7 +124,7 @@ unsigned long __getauxval(unsigned long id) {
 
 } // extern "C"
 
-void *operator new(size_t /*size*/, void *ptr) { return ptr; }
+void *operator new(size_t size, void *ptr) { return ptr; }
 
 void *operator new(size_t size) { return malloc(size); }
 
@@ -136,7 +136,7 @@ void operator delete(void *) {
   __builtin_trap();
 }
 
-void operator delete(void */*ptr*/, size_t /*size*/) { __builtin_trap(); }
+void operator delete(void *ptr, size_t size) { __builtin_trap(); }
 
 // Defining members in the std namespace is not preferred. But, we do it here
 // so that we can use it to define the operator new which takes std::align_val_t
@@ -145,8 +145,8 @@ namespace std {
 enum class align_val_t : size_t {};
 } // namespace std
 
-void operator delete(void *, std::align_val_t) noexcept { __builtin_trap(); }
+void operator delete(void *mem, std::align_val_t) noexcept { __builtin_trap(); }
 
-void operator delete(void *, unsigned int, std::align_val_t) noexcept {
+void operator delete(void *mem, unsigned int, std::align_val_t) noexcept {
   __builtin_trap();
 }
diff --git a/libc/test/UnitTest/LibcDeathTestExecutors.cpp b/libc/test/UnitTest/LibcDeathTestExecutors.cpp
index f2b048864b556c..943e2c23c5fde9 100644
--- a/libc/test/UnitTest/LibcDeathTestExecutors.cpp
+++ b/libc/test/UnitTest/LibcDeathTestExecutors.cpp
@@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
 namespace testing {
 
 bool Test::testProcessKilled(testutils::FunctionCaller *Func, int Signal,
-                             const char *LHSStr, const char * /*RHSStr*/,
+                             const char *LHSStr, const char *RHSStr,
                              internal::Location Loc) {
   testutils::ProcessStatus Result =
       testutils::invoke_in_subprocess(Func, TIMEOUT_MS);
diff --git a/libc/test/UnitTest/LibcTest.h b/libc/test/UnitTest/LibcTest.h
index 124748ba343270..b4e3819ea958de 100644
--- a/libc/test/UnitTest/LibcTest.h
+++ b/libc/test/UnitTest/LibcTest.h
@@ -81,7 +81,7 @@ struct Message {
 // A trivial object to catch the Message, this enables custom logging and
 // returning from the test function, see LIBC_TEST_SCAFFOLDING_ below.
 struct Failure {
-  void operator=(Message /*msg*/) {}
+  void operator=(Message msg) {}
 };
 
 struct RunContext {
diff --git a/libc/test/include/stdbit_stub.h b/libc/test/include/stdbit_stub.h
index e7b887cf4f3734..3d2e0fb60334eb 100644
--- a/libc/test/include/stdbit_stub.h
+++ b/libc/test/include/stdbit_stub.h
@@ -17,11 +17,11 @@
 #include <stdbool.h> // bool in C
 
 #define STDBIT_STUB_FUNCTION(FUNC_NAME, LEADING_VAL)                           \
-  unsigned FUNC_NAME##_uc(unsigned char) { return LEADING_VAL##AU; }           \
-  unsigned FUNC_NAME##_us(unsigned short) { return LEADING_VAL##BU; }          \
-  unsigned FUNC_NAME##_ui(unsigned int) { return LEADING_VAL##CU; }            \
-  unsigned FUNC_NAME##_ul(unsigned long) { return LEADING_VAL##DU; }           \
-  unsigned FUNC_NAME##_ull(unsigned long long) { return LEADING_VAL##EU; }
+  unsigned FUNC_NAME##_uc(unsigned char x) { return LEADING_VAL##AU; }         \
+  unsigned FUNC_NAME##_us(unsigned short x) { return LEADING_VAL##BU; }        \
+  unsigned FUNC_NAME##_ui(unsigned int x) { return LEADING_VAL##CU; }          \
+  unsigned FUNC_NAME##_ul(unsigned long x) { return LEADING_VAL##DU; }         \
+  unsigned FUNC_NAME##_ull(unsigned long long x) { return LEADING_VAL##EU; }
 
 __BEGIN_C_DECLS
 
@@ -36,24 +36,24 @@ STDBIT_STUB_FUNCTION(stdc_first_trailing_one, 0x1)
 STDBIT_STUB_FUNCTION(stdc_count_zeros, 0x2)
 STDBIT_STUB_FUNCTION(stdc_count_ones, 0x3)
 
-bool stdc_has_single_bit_uc(unsigned char) { return false; }
-bool stdc_has_single_bit_us(unsigned short) { return false; }
-bool stdc_has_single_bit_ui(unsigned) { return false; }
-bool stdc_has_single_bit_ul(unsigned long) { return false; }
-bool stdc_has_single_bit_ull(unsigned long long) { return false; }
+bool stdc_has_single_bit_uc(unsigned char x) { return false; }
+bool stdc_has_single_bit_us(unsigned short x) { return false; }
+bool stdc_has_single_bit_ui(unsigned x) { return false; }
+bool stdc_has_single_bit_ul(unsigned long x) { return false; }
+bool stdc_has_single_bit_ull(unsigned long long x) { return false; }
 
 STDBIT_STUB_FUNCTION(stdc_bit_width, 0x4)
 
-unsigned char stdc_bit_floor_uc(unsigned char) { return 0x5AU; }
-unsigned short stdc_bit_floor_us(unsigned short) { return 0x5BU; }
-unsigned stdc_bit_floor_ui(unsigned) { return 0x5CU; }
-unsigned long stdc_bit_floor_ul(unsigned long) { return 0x5DUL; }
-unsigned long long stdc_bit_floor_ull(unsigned long long) { return 0x5EULL; }
-
-unsigned char stdc_bit_ceil_uc(unsigned char) { return 0x6AU; }
-unsigned short stdc_bit_ceil_us(unsigned short) { return 0x6BU; }
-unsigned stdc_bit_ceil_ui(unsigned) { return 0x6CU; }
-unsigned long stdc_bit_ceil_ul(unsigned long) { return 0x6DUL; }
-unsigned long long stdc_bit_ceil_ull(unsigned long long) { return 0x6EULL; }
+unsigned char stdc_bit_floor_uc(unsigned char x) { return 0x5AU; }
+unsigned short stdc_bit_floor_us(unsigned short x) { return 0x5BU; }
+unsigned stdc_bit_floor_ui(unsigned x) { return 0x5CU; }
+unsigned long stdc_bit_floor_ul(unsigned long x) { return 0x5DUL; }
+unsigned long long stdc_bit_floor_ull(unsigned long long x) { return 0x5EULL; }
+
+unsigned char stdc_bit_ceil_uc(unsigned char x) { return 0x6AU; }
+unsigned short stdc_bit_ceil_us(unsigned short x) { return 0x6BU; }
+unsigned stdc_bit_ceil_ui(unsigned x) { return 0x6CU; }
+unsigned long stdc_bit_ceil_ul(unsigned long x) { return 0x6DUL; }
+unsigned long long stdc_bit_ceil_ull(unsigned long long x) { return 0x6EULL; }
 
 __END_C_DECLS
diff --git a/libc/test/src/__support/CPP/bit_test.cpp b/libc/test/src/__support/CPP/bit_test.cpp
index 9389e96642d1ef..9429b66ad1f981 100644
--- a/libc/test/src/__support/CPP/bit_test.cpp
+++ b/libc/test/src/__support/CPP/bit_test.cpp
@@ -41,7 +41,7 @@ TYPED_TEST(LlvmLibcBitTest, HasSingleBit, UnsignedTypes) {
   constexpr auto LSB = T(1);
   constexpr auto MSB = T(~(ALL_ONES >> 1));
   for (T value = 1; value; value <<= 1) {
-    T two_bits_value = value | ((value <= MIDPOINT) ? MSB : LSB);
+    auto two_bits_value = value | ((value <= MIDPOINT) ? MSB : LSB);
     EXPECT_FALSE(has_single_bit<T>(two_bits_value));
   }
 }
diff --git a/libc/test/src/__support/CPP/integer_sequence_test.cpp b/libc/test/src/__support/CPP/integer_sequence_test.cpp
index 56e75f496255f5..fe378522b446b9 100644
--- a/libc/test/src/__support/CPP/integer_sequence_test.cpp
+++ b/libc/test/src/__support/CPP/integer_sequence_test.cpp
@@ -23,8 +23,7 @@ TEST(LlvmLibcIntegerSequencetTest, Basic) {
       (is_same_v<ULLSeq, make_integer_sequence<unsigned long long, 4>>));
 }
 
-template <typename T, T... Ts>
-bool checkArray(integer_sequence<T, Ts...> /*seq*/) {
+template <typename T, T... Ts> bool checkArray(integer_sequence<T, Ts...> seq) {
   T arr[sizeof...(Ts)]{Ts...};
 
   for (T i = 0; i < static_cast<T>(sizeof...(Ts)); i++)
diff --git a/libc/test/src/__support/arg_list_test.cpp b/libc/test/src/__support/arg_list_test.cpp
index 57714050f05fca..79a715e9106870 100644
--- a/libc/test/src/__support/arg_list_test.cpp
+++ b/libc/test/src/__support/arg_list_test.cpp
@@ -72,9 +72,9 @@ long int check_primitives(int first, ...) {
   count += args.next_var<unsigned long>();
   count += args.next_var<long long>();
   count += args.next_var<unsigned long long>();
-  count += static_cast<long>(args.next_var<double>());
-  count += static_cast<long>(args.next_var<double>());
-  count += static_cast<long>(args.next_var<long double>());
+  count += args.next_var<double>();
+  count += args.next_var<double>();
+  count += args.next_var<long double>();
   count += *args.next_var<int *>();
   return count;
 }
@@ -112,8 +112,7 @@ long int check_struct_type(int first, ...) {
 
   S s = args.next_var<S>();
   int last = args.next_var<int>();
-  return s.c + s.s + s.i + s.l + static_cast<long>(s.f) +
-         static_cast<long>(s.d) + last;
+  return s.c + s.s + s.i + s.l + s.f + s.d + last;
 }
 
 TEST(LlvmLibcArgListTest, TestStructTypes) {
diff --git a/libc/test/src/__support/big_int_test.cpp b/libc/test/src/__support/big_int_test.cpp
index 68afecb17057d3..2666ed978dad7a 100644
--- a/libc/test/src/__support/big_int_test.cpp
+++ b/libc/test/src/__support/big_int_test.cpp
@@ -197,7 +197,7 @@ TYPED_TEST(LlvmLibcUIntClassTest, CountBits, Types) {
     for (size_t i = 0; i < T::BITS; ++i) {
       const auto l_one = T::all_ones() << i; // 0b111...000
       const auto r_one = T::all_ones() >> i; // 0b000...111
-      const int zeros = static_cast<int>(i);
+      const int zeros = i;
       const int ones = T::BITS - zeros;
       ASSERT_EQ(cpp::countr_one(r_one), ones);
       ASSERT_EQ(cpp::countl_one(l_one), ones);
diff --git a/libc/test/src/__support/hash_test.cpp b/libc/test/src/__support/hash_test.cpp
index 94c884cc7fb17e..f23a43a3bc5e4d 100644
--- a/libc/test/src/__support/hash_test.cpp
+++ b/libc/test/src/__support/hash_test.cpp
@@ -78,7 +78,7 @@ TEST(LlvmLibcHashTest, Avalanche) {
       }
       for (size_t i = 0; i < sz; ++i) {
         for (size_t j = 0; j < 8; ++j) {
-          uint8_t mask = static_cast<uint8_t>(1 << j);
+          uint8_t mask = 1 << j;
           mem.data[i] ^= mask;
           {
             LIBC_NAMESPACE::internal::HashState state{0xabcdef1234567890};
diff --git a/libc/test/src/__support/math_extras_test.cpp b/libc/test/src/__support/math_extras_test.cpp
index 887164cfb398df..08c090017c1a19 100644
--- a/libc/test/src/__support/math_extras_test.cpp
+++ b/libc/test/src/__support/math_extras_test.cpp
@@ -73,27 +73,27 @@ TEST(LlvmLibcBlockMathExtrasTest, mask_trailing_ones) {
 TYPED_TEST(LlvmLibcBitTest, FirstLeadingZero, UnsignedTypesNoBigInt) {
   EXPECT_EQ(first_leading_zero<T>(cpp::numeric_limits<T>::max()), 0);
   for (int i = 0U; i != cpp::numeric_limits<T>::digits; ++i)
-    EXPECT_EQ(first_leading_zero<T>(static_cast<T>(~(T(1) << i))),
+    EXPECT_EQ(first_leading_zero<T>(~(T(1) << i)),
               cpp::numeric_limits<T>::digits - i);
 }
 
 TYPED_TEST(LlvmLibcBitTest, FirstLeadingOne, UnsignedTypesNoBigInt) {
   EXPECT_EQ(first_leading_one<T>(static_cast<T>(0)), 0);
   for (int i = 0U; i != cpp::numeric_limits<T>::digits; ++i)
-    EXPECT_EQ(first_leading_one<T>(static_cast<T>(T(1) << i)),
+    EXPECT_EQ(first_leading_one<T>(T(1) << i),
               cpp::numeric_limits<T>::digits - i);
 }
 
 TYPED_TEST(LlvmLibcBitTest, FirstTrailingZero, UnsignedTypesNoBigInt) {
   EXPECT_EQ(first_trailing_zero<T>(cpp::numeric_limits<T>::max()), 0);
   for (int i = 0U; i != cpp::numeric_limits<T>::digits; ++i)
-    EXPECT_EQ(first_trailing_zero<T>(static_cast<T>(~(T(1) << i))), i + 1);
+    EXPECT_EQ(first_trailing_zero<T>(~(T(1) << i)), i + 1);
 }
 
 TYPED_TEST(LlvmLibcBitTest, FirstTrailingOne, UnsignedTypesNoBigInt) {
   EXPECT_EQ(first_trailing_one<T>(cpp::numeric_limits<T>::max()), 0);
   for (int i = 0U; i != cpp::numeric_limits<T>::digits; ++i)
-    EXPECT_EQ(first_trailing_one<T>(static_cast<T>(T(1) << i)), i + 1);
+    EXPECT_EQ(first_trailing_one<T>(T(1) << i), i + 1);
 }
 
 TYPED_TEST(LlvmLibcBitTest, CountZeros, UnsignedTypesNoBigInt) {
diff --git a/libc/test/src/math/FModTest.h b/libc/test/src/math/FModTest.h
index c32328584582fc..32c009ab88286d 100644
--- a/libc/test/src/math/FModTest.h
+++ b/libc/test/src/math/FModTest.h
@@ -54,7 +54,7 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
 
     // fmod (+inf, y) == aNaN plus invalid exception.
     TEST_SPECIAL(inf, 3.0, aNaN, true, FE_INVALID);
-    TEST_SPECIAL(inf, static_cast<T>(-1.1L), aNaN, true, FE_INVALID);
+    TEST_SPECIAL(inf, -1.1L, aNaN, true, FE_INVALID);
     TEST_SPECIAL(inf, 0.0, aNaN, true, FE_INVALID);
     TEST_SPECIAL(inf, neg_zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(inf, min_denormal, aNaN, true, FE_INVALID);
@@ -65,7 +65,7 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
 
     // fmod (-inf, y) == aNaN plus invalid exception.
     TEST_SPECIAL(neg_inf, 3.0, aNaN, true, FE_INVALID);
-    TEST_SPECIAL(neg_inf, static_cast<T>(-1.1L), aNaN, true, FE_INVALID);
+    TEST_SPECIAL(neg_inf, -1.1L, aNaN, true, FE_INVALID);
     TEST_SPECIAL(neg_inf, 0.0, aNaN, true, FE_INVALID);
     TEST_SPECIAL(neg_inf, neg_zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(neg_inf, min_denormal, aNaN, true, FE_INVALID);
@@ -76,7 +76,7 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
 
     // fmod (x, +0) == aNaN plus invalid exception.
     TEST_SPECIAL(3.0, 0.0, aNaN, true, FE_INVALID);
-    TEST_SPECIAL(static_cast<T>(-1.1L), 0.0, aNaN, true, FE_INVALID);
+    TEST_SPECIAL(-1.1L, 0.0, aNaN, true, FE_INVALID);
     TEST_SPECIAL(0.0, 0.0, aNaN, true, FE_INVALID);
     TEST_SPECIAL(neg_zero, 0.0, aNaN, true, FE_INVALID);
     TEST_SPECIAL(min_denormal, 0.0, aNaN, true, FE_INVALID);
@@ -85,7 +85,7 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
 
     // fmod (x, -0) == aNaN plus invalid exception.
     TEST_SPECIAL(3.0, neg_zero, aNaN, true, FE_INVALID);
-    TEST_SPECIAL(static_cast<T>(-1.1L), neg_zero, aNaN, true, FE_INVALID);
+    TEST_SPECIAL(-1.1L, neg_zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(0.0, neg_zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(neg_zero, neg_zero, aNaN, true, FE_INVALID);
     TEST_SPECIAL(min_denormal, neg_zero, aNaN, true, FE_INVALID);
diff --git a/libc/test/src/math/smoke/nan_test.cpp b/libc/test/src/math/smoke/nan_test.cpp
index da6beb94c7f05d..46b9e9aa9563ab 100644
--- a/libc/test/src/math/smoke/nan_test.cpp
+++ b/libc/test/src/math/smoke/nan_test.cpp
@@ -23,7 +23,7 @@ class LlvmLibcNanTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     auto actual_fp = LIBC_NAMESPACE::fputil::FPBits<double>(result);
     auto expected_fp = LIBC_NAMESPACE::fputil::FPBits<double>(bits);
     EXPECT_EQ(actual_fp.uintval(), expected_fp.uintval());
-  }
+  };
 };
 
 TEST_F(LlvmLibcNanTest, NCharSeq) {
diff --git a/libc/test/src/math/smoke/nanf_test.cpp b/libc/test/src/math/smoke/nanf_test.cpp
index 19d94b40b5ffbd..dd3124ee9c5112 100644
--- a/libc/test/src/math/smoke/nanf_test.cpp
+++ b/libc/test/src/math/smoke/nanf_test.cpp
@@ -23,7 +23,7 @@ class LlvmLibcNanfTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     auto actual_fp = LIBC_NAMESPACE::fputil::FPBits<float>(result);
     auto expected_fp = LIBC_NAMESPACE::fputil::FPBits<float>(bits);
     EXPECT_EQ(actual_fp.uintval(), expected_fp.uintval());
-  }
+  };
 };
 
 TEST_F(LlvmLibcNanfTest, NCharSeq) {
diff --git a/libc/test/src/math/smoke/nanl_test.cpp b/libc/test/src/math/smoke/nanl_test.cpp
index c7217928e943b0..ef3f9c15dafd9f 100644
--- a/libc/test/src/math/smoke/nanl_test.cpp
+++ b/libc/test/src/math/smoke/nanl_test.cpp
@@ -33,7 +33,7 @@ class LlvmLibcNanlTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     auto actual_fp = LIBC_NAMESPACE::fputil::FPBits<long double>(result);
     auto expected_fp = LIBC_NAMESPACE::fputil::FPBits<long double>(bits);
     EXPECT_EQ(actual_fp.uintval(), expected_fp.uintval());
-  }
+  };
 };
 
 TEST_F(LlvmLibcNanlTest, NCharSeq) {
diff --git a/libc/test/src/string/memory_utils/op_tests.cpp b/libc/test/src/string/memory_utils/op_tests.cpp
index dd7619240417ef..c6197d1afa266b 100644
--- a/libc/test/src/string/memory_utils/op_tests.cpp
+++ b/libc/test/src/string/memory_utils/op_tests.cpp
@@ -72,8 +72,7 @@ void CopyAdaptor(cpp::span<char> dst, cpp::span<char> src, size_t size) {
   FnImpl(as_byte(dst), as_byte(src), size);
 }
 template <size_t Size, auto FnImpl>
-void CopyBlockAdaptor(cpp::span<char> dst, cpp::span<char> src,
-                      size_t /*size*/) {
+void CopyBlockAdaptor(cpp::span<char> dst, cpp::span<char> src, size_t size) {
   FnImpl(as_byte(dst), as_byte(src));
 }
 
@@ -154,7 +153,7 @@ void SetAdaptor(cpp::span<char> dst, uint8_t value, size_t size) {
   FnImpl(as_byte(dst), value, size);
 }
 template <size_t Size, auto FnImpl>
-void SetBlockAdaptor(cpp::span<char> dst, uint8_t value, size_t /*size*/) {
+void SetBlockAdaptor(cpp::span<char> dst, uint8_t value, size_t size) {
   FnImpl(as_byte(dst), value);
 }
 
@@ -243,7 +242,7 @@ int CmpAdaptor(cpp::span<char> p1, cpp::span<char> p2, size_t size) {
   return (int)FnImpl(as_byte(p1), as_byte(p2), size);
 }
 template <size_t Size, auto FnImpl>
-int CmpBlockAdaptor(cpp::span<char> p1, cpp::span<char> p2, size_t /*size*/) {
+int CmpBlockAdaptor(cpp::span<char> p1, cpp::span<char> p2, size_t size) {
   return (int)FnImpl(as_byte(p1), as_byte(p2));
 }
 
diff --git a/libc/test/src/strings/bzero_test.cpp b/libc/test/src/strings/bzero_test.cpp
index e3091556da2762..4d4112f4be8ee1 100644
--- a/libc/test/src/strings/bzero_test.cpp
+++ b/libc/test/src/strings/bzero_test.cpp
@@ -14,7 +14,7 @@
 namespace LIBC_NAMESPACE_DECL {
 
 // Adapt CheckMemset signature to bzero.
-static inline void Adaptor(cpp::span<char> p1, uint8_t /*value*/, size_t size) {
+static inline void Adaptor(cpp::span<char> p1, uint8_t value, size_t size) {
   LIBC_NAMESPACE::bzero(p1.begin(), size);
 }
 
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.h b/libc/utils/MPFRWrapper/MPFRUtils.h
index 791936d78cb67d..c7a57819f68b79 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.h
+++ b/libc/utils/MPFRWrapper/MPFRUtils.h
@@ -352,7 +352,7 @@ template <Operation op, typename InputType, typename OutputType>
 __attribute__((no_sanitize("address"))) cpp::enable_if_t<
     is_valid_operation<op, InputType, OutputType>(),
     internal::MPFRMatcher<op, /*is_silent*/ false, InputType, OutputType>>
-get_mpfr_matcher(InputType input, OutputType /*output_unused*/,
+get_mpfr_matcher(InputType input, OutputType output_unused,
                  double ulp_tolerance, RoundingMode rounding) {
   return internal::MPFRMatcher<op, /*is_silent*/ false, InputType, OutputType>(
       input, ulp_tolerance, rounding);
@@ -362,7 +362,7 @@ template <Operation op, typename InputType, typename OutputType>
 __attribute__((no_sanitize("address"))) cpp::enable_if_t<
     is_valid_operation<op, InputType, OutputType>(),
     internal::MPFRMatcher<op, /*is_silent*/ true, InputType, OutputType>>
-get_silent_mpfr_matcher(InputType input, OutputType /*output_unused*/,
+get_silent_mpfr_matcher(InputType input, OutputType output_unused,
                         double ulp_tolerance, RoundingMode rounding) {
   return internal::MPFRMatcher<op, /*is_silent*/ true, InputType, OutputType>(
       input, ulp_tolerance, rounding);



More information about the libc-commits mailing list