[libc-commits] [libc] e35c714 - [libc][NFC] Clean up clang-tidy warnings for `src/__support` and `src/math`.

Tue Ly via libc-commits libc-commits at lists.llvm.org
Wed Mar 15 15:47:47 PDT 2023


Author: Tue Ly
Date: 2023-03-15T18:47:31-04:00
New Revision: e35c71493b3a191b7a836d62feb0039b79b0b428

URL: https://github.com/llvm/llvm-project/commit/e35c71493b3a191b7a836d62feb0039b79b0b428
DIFF: https://github.com/llvm/llvm-project/commit/e35c71493b3a191b7a836d62feb0039b79b0b428.diff

LOG: [libc][NFC] Clean up clang-tidy warnings for `src/__support` and `src/math`.

Clean up some warnings from running libc-lint for these folders.

Reviewed By: michaelrj, sivachandra

Differential Revision: https://reviews.llvm.org/D146048

Added: 
    

Modified: 
    libc/.clang-tidy
    libc/src/__support/FPUtil/XFloat.h
    libc/src/__support/FPUtil/dyadic_float.h
    libc/src/__support/FPUtil/generic/FMod.h
    libc/src/__support/UInt.h
    libc/src/math/generic/exp2f.cpp
    libc/src/math/generic/log10.cpp

Removed: 
    libc/utils/HdrGen/PrototypeTestGen/.clang-tidy


################################################################################
diff  --git a/libc/.clang-tidy b/libc/.clang-tidy
index 741b63b18d6d5..5adada9a3f59a 100644
--- a/libc/.clang-tidy
+++ b/libc/.clang-tidy
@@ -9,17 +9,21 @@ CheckOptions:
   - key:             readability-identifier-naming.MemberCase
     value:           lower_case
   - key:             readability-identifier-naming.MemberIgnoredRegexp
-    value:           "^_[A-Za-z0-9_]+$"
+    value:           "_?(_[A-Za-z0-9]+)*"
   - key:             readability-identifier-naming.VariableCase
     value:           lower_case
   - key:             readability-identifier-naming.VariableIgnoredRegexp
-    value:           "^_[A-Za-z0-9_]+$"
+    value:           "_?(_[A-Za-z0-9]+)*"
   - key:             readability-identifier-naming.FunctionCase
     value:           lower_case
   - key:             readability-identifier-naming.FunctionIgnoredRegexp
-    value:           "^_[A-Za-z0-9_]+$"
+    value:           "_?(_[A-Za-z0-9]+)*"
   - key:             readability-identifier-naming.GlobalConstantCase
     value:           UPPER_CASE
+  - key:             readability-identifier-naming.LocalConstantIgnoredRegexp
+    value:           "[A-Z]+[A-Z0-9]*(_[A-Z0-9]+)*"
+  - key:             readability-identifier-naming.ClassConstantCase
+    value:           UPPER_CASE
   - key:             readability-identifier-naming.ConstexprVariableCase
     value:           UPPER_CASE
   - key:             readability-identifier-naming.GetConfigPerFile

diff  --git a/libc/src/__support/FPUtil/XFloat.h b/libc/src/__support/FPUtil/XFloat.h
index d76fc5b58dcde..b3f8f44badd33 100644
--- a/libc/src/__support/FPUtil/XFloat.h
+++ b/libc/src/__support/FPUtil/XFloat.h
@@ -19,7 +19,7 @@ namespace fputil {
 template <size_t Precision> class XFloat {
   static constexpr uint64_t OneMask = (uint64_t(1) << 63);
   UInt<Precision> man;
-  static constexpr uint64_t WordCount = Precision / 64;
+  static constexpr uint64_t WORDCOUNT = Precision / 64;
   int exp;
 
   size_t bit_width(uint64_t x) {
@@ -35,25 +35,25 @@ template <size_t Precision> class XFloat {
 
 public:
   XFloat() : exp(0) {
-    for (int i = 0; i < WordCount; ++i)
+    for (int i = 0; i < WORDCOUNT; ++i)
       man[i] = 0;
   }
 
   XFloat(const XFloat &other) : exp(other.exp) {
-    for (int i = 0; i < WordCount; ++i)
+    for (int i = 0; i < WORDCOUNT; ++i)
       man[i] = other.man[i];
   }
 
   explicit XFloat(double x) {
     auto xn = NormalFloat<double>(x);
     exp = xn.exponent;
-    man[WordCount - 1] = xn.mantissa << 11;
-    for (int i = 0; i < WordCount - 1; ++i)
+    man[WORDCOUNT - 1] = xn.mantissa << 11;
+    for (int i = 0; i < WORDCOUNT - 1; ++i)
       man[i] = 0;
   }
 
   XFloat(int e, const UInt<Precision> &bits) : exp(e) {
-    for (size_t i = 0; i < WordCount; ++i)
+    for (size_t i = 0; i < WORDCOUNT; ++i)
       man[i] = bits[i];
   }
 
@@ -65,7 +65,7 @@ template <size_t Precision> class XFloat {
     size_t carry_width = bit_width(carry);
     carry_width = (carry_width == 64 ? 64 : 63);
     man.shift_right(carry_width);
-    man[WordCount - 1] = man[WordCount - 1] + (carry << (64 - carry_width));
+    man[WORDCOUNT - 1] = man[WORDCOUNT - 1] + (carry << (64 - carry_width));
     exp += carry_width == 64 ? 1 : 0;
     normalize();
   }
@@ -74,7 +74,7 @@ template <size_t Precision> class XFloat {
     if (exp < 0)
       return;
     if (exp > int(Precision - 1)) {
-      for (size_t i = 0; i < WordCount; ++i)
+      for (size_t i = 0; i < WORDCOUNT; ++i)
         man[i] = 0;
       return;
     }
@@ -86,14 +86,14 @@ template <size_t Precision> class XFloat {
   }
 
   double mul(const XFloat<Precision> &other) {
-    constexpr size_t row_words = 2 * WordCount + 1;
+    constexpr size_t row_words = 2 * WORDCOUNT + 1;
     constexpr size_t row_precision = row_words * 64;
     constexpr size_t result_bits = 2 * Precision;
-    UInt<row_precision> rows[WordCount];
+    UInt<row_precision> rows[WORDCOUNT];
 
-    for (size_t r = 0; r < WordCount; ++r) {
+    for (size_t r = 0; r < WORDCOUNT; ++r) {
       for (size_t i = 0; i < row_words; ++i) {
-        if (i < WordCount)
+        if (i < WORDCOUNT)
           rows[r][i] = man[i];
         else
           rows[r][i] = 0;
@@ -102,7 +102,7 @@ template <size_t Precision> class XFloat {
       rows[r].shift_left(r * 64);
     }
 
-    for (size_t r = 1; r < WordCount; ++r) {
+    for (size_t r = 1; r < WORDCOUNT; ++r) {
       rows[0].add(rows[r]);
     }
     int result_exp = exp + other.exp;
@@ -134,14 +134,14 @@ template <size_t Precision> class XFloat {
 
     constexpr uint64_t one = uint64_t(1) << 10;
     constexpr uint64_t excess_mask = (one << 1) - 1;
-    uint64_t excess = man[WordCount - 1] & excess_mask;
-    uint64_t new_man = man[WordCount - 1] >> 11;
+    uint64_t excess = man[WORDCOUNT - 1] & excess_mask;
+    uint64_t new_man = man[WORDCOUNT - 1] >> 11;
     if (excess > one) {
       // We have to round up.
       ++new_man;
     } else if (excess == one) {
       bool greater_than_one = false;
-      for (size_t i = 0; i < WordCount - 1; ++i) {
+      for (size_t i = 0; i < WORDCOUNT - 1; ++i) {
         greater_than_one = (man[i] != 0);
         if (greater_than_one)
           break;
@@ -163,13 +163,13 @@ template <size_t Precision> class XFloat {
   // Normalizes this number.
   void normalize() {
     uint64_t man_bits = 0;
-    for (size_t i = 0; i < WordCount; ++i)
+    for (size_t i = 0; i < WORDCOUNT; ++i)
       man_bits |= man[i];
 
     if (man_bits == 0)
       return;
 
-    while ((man[WordCount - 1] & OneMask) == 0) {
+    while ((man[WORDCOUNT - 1] & OneMask) == 0) {
       man.shift_left(1);
       --exp;
     }

diff  --git a/libc/src/__support/FPUtil/dyadic_float.h b/libc/src/__support/FPUtil/dyadic_float.h
index 86c41df18bc6f..a1dc8a5cc36ab 100644
--- a/libc/src/__support/FPUtil/dyadic_float.h
+++ b/libc/src/__support/FPUtil/dyadic_float.h
@@ -104,11 +104,11 @@ template <size_t Bits> struct DyadicFloat {
         sign, exponent + (Bits - 1) + FloatProperties<T>::EXPONENT_BIAS,
         output_bits_t(m_hi) & FloatProperties<T>::MANTISSA_MASK);
 
-    const MantissaType ROUND_MASK = MantissaType(1) << (Bits - PRECISION - 1);
-    const MantissaType STICKY_MASK = ROUND_MASK - MantissaType(1);
+    const MantissaType round_mask = MantissaType(1) << (Bits - PRECISION - 1);
+    const MantissaType sticky_mask = round_mask - MantissaType(1);
 
-    bool round_bit = !(mantissa & ROUND_MASK).is_zero();
-    bool sticky_bit = !(mantissa & STICKY_MASK).is_zero();
+    bool round_bit = !(mantissa & round_mask).is_zero();
+    bool sticky_bit = !(mantissa & sticky_mask).is_zero();
     int round_and_sticky = int(round_bit) * 2 + int(sticky_bit);
     auto d_lo = FPBits<T>::create_value(sign,
                                         exponent + (Bits - PRECISION - 2) +
@@ -156,7 +156,7 @@ constexpr DyadicFloat<Bits> quick_add(DyadicFloat<Bits> a,
     if (result.mantissa.add(b.mantissa)) {
       // Mantissa addition overflow.
       result.shift_right(1);
-      result.mantissa.val[DyadicFloat<Bits>::MantissaType::WordCount - 1] |=
+      result.mantissa.val[DyadicFloat<Bits>::MantissaType::WORDCOUNT - 1] |=
           (uint64_t(1) << 63);
     }
     // Result is already normalized.
@@ -183,7 +183,7 @@ constexpr DyadicFloat<Bits> quick_add(DyadicFloat<Bits> a,
 //   result.mantissa = quick_mul_hi(a.mantissa + b.mantissa)
 //                   ~ (full product a.mantissa * b.mantissa) >> Bits.
 // The errors compared to the mathematical product is bounded by:
-//   2 * errors of quick_mul_hi = 2 * (UInt<Bits>::WordCount - 1) in ULPs.
+//   2 * errors of quick_mul_hi = 2 * (UInt<Bits>::WORDCOUNT - 1) in ULPs.
 // Assume inputs are normalized (by constructors or other functions) so that we
 // don't need to normalize the inputs again in this function.  If the inputs are
 // not normalized, the results might lose precision significantly.
@@ -198,7 +198,7 @@ constexpr DyadicFloat<Bits> quick_mul(DyadicFloat<Bits> a,
     result.mantissa = a.mantissa.quick_mul_hi(b.mantissa);
     // Check the leading bit directly, should be faster than using clz in
     // normalize().
-    if (result.mantissa.val[DyadicFloat<Bits>::MantissaType::WordCount - 1] >>
+    if (result.mantissa.val[DyadicFloat<Bits>::MantissaType::WORDCOUNT - 1] >>
             63 ==
         0)
       result.shift_left(1);

diff  --git a/libc/src/__support/FPUtil/generic/FMod.h b/libc/src/__support/FPUtil/generic/FMod.h
index 1879c0ad2c510..fd40d87132922 100644
--- a/libc/src/__support/FPUtil/generic/FMod.h
+++ b/libc/src/__support/FPUtil/generic/FMod.h
@@ -122,9 +122,9 @@ template <typename T> struct FModExceptionalInputHandler {
   static_assert(cpp::is_floating_point_v<T>,
                 "FModCStandardWrapper instantiated with invalid type.");
 
-  LIBC_INLINE static bool PreCheck(T x, T y, T &out) {
+  LIBC_INLINE static bool pre_check(T x, T y, T &out) {
     using FPB = fputil::FPBits<T>;
-    const T quiet_NaN = FPB::build_quiet_nan(0);
+    const T quiet_nan = FPB::build_quiet_nan(0);
     FPB sx(x), sy(y);
     if (LIBC_LIKELY(!sy.is_zero() && !sy.is_inf_or_nan() &&
                     !sx.is_inf_or_nan())) {
@@ -134,14 +134,15 @@ template <typename T> struct FModExceptionalInputHandler {
     if (sx.is_nan() || sy.is_nan()) {
       if ((sx.is_nan() && !sx.is_quiet_nan()) ||
           (sy.is_nan() && !sy.is_quiet_nan()))
-        fputil::set_except(FE_INVALID);
-      out = quiet_NaN;
+        fputil::raise_except_if_required(FE_INVALID);
+      out = quiet_nan;
       return true;
     }
 
     if (sx.is_inf() || sy.is_zero()) {
-      fputil::set_except(FE_INVALID);
-      out = with_errno(quiet_NaN, EDOM);
+      fputil::raise_except_if_required(FE_INVALID);
+      fputil::set_errno_if_required(EDOM);
+      out = quiet_nan;
       return true;
     }
 
@@ -161,7 +162,7 @@ template <typename T> struct FModFastMathWrapper {
   static_assert(cpp::is_floating_point_v<T>,
                 "FModFastMathWrapper instantiated with invalid type.");
 
-  static bool PreCheck(T, T, T &) { return false; }
+  static bool pre_check(T, T, T &) { return false; }
 };
 
 template <typename T> class FModDivisionSimpleHelper {
@@ -302,7 +303,7 @@ class FMod {
 
 public:
   LIBC_INLINE static T eval(T x, T y) {
-    if (T out; Wrapper::PreCheck(x, y, out))
+    if (T out; Wrapper::pre_check(x, y, out))
       return out;
     FPB sx(x), sy(y);
     bool sign = sx.get_sign();

diff  --git a/libc/src/__support/UInt.h b/libc/src/__support/UInt.h
index 85de5b77bb22d..2cbd3dfea6fb8 100644
--- a/libc/src/__support/UInt.h
+++ b/libc/src/__support/UInt.h
@@ -27,8 +27,8 @@ template <size_t Bits> struct UInt {
 
   static_assert(Bits > 0 && Bits % 64 == 0,
                 "Number of bits in UInt should be a multiple of 64.");
-  static constexpr size_t WordCount = Bits / 64;
-  uint64_t val[WordCount];
+  static constexpr size_t WORDCOUNT = Bits / 64;
+  uint64_t val[WORDCOUNT];
 
   static constexpr uint64_t MASK32 = 0xFFFFFFFFu;
 
@@ -38,45 +38,45 @@ template <size_t Bits> struct UInt {
   constexpr UInt() {}
 
   constexpr UInt(const UInt<Bits> &other) {
-    for (size_t i = 0; i < WordCount; ++i)
+    for (size_t i = 0; i < WORDCOUNT; ++i)
       val[i] = other.val[i];
   }
 
   template <size_t OtherBits> constexpr UInt(const UInt<OtherBits> &other) {
     if (OtherBits >= Bits) {
-      for (size_t i = 0; i < WordCount; ++i)
+      for (size_t i = 0; i < WORDCOUNT; ++i)
         val[i] = other[i];
     } else {
       size_t i = 0;
       for (; i < OtherBits / 64; ++i)
         val[i] = other[i];
-      for (; i < WordCount; ++i)
+      for (; i < WORDCOUNT; ++i)
         val[i] = 0;
     }
   }
 
   // Construct a UInt from a C array.
-  template <size_t N, enable_if_t<N <= WordCount, int> = 0>
+  template <size_t N, enable_if_t<N <= WORDCOUNT, int> = 0>
   constexpr UInt(const uint64_t (&nums)[N]) {
-    size_t min_wordcount = N < WordCount ? N : WordCount;
+    size_t min_wordcount = N < WORDCOUNT ? N : WORDCOUNT;
     size_t i = 0;
     for (; i < min_wordcount; ++i)
       val[i] = nums[i];
 
     // If nums doesn't completely fill val, then fill the rest with zeroes.
-    for (; i < WordCount; ++i)
+    for (; i < WORDCOUNT; ++i)
       val[i] = 0;
   }
 
   // Initialize the first word to |v| and the rest to 0.
   constexpr UInt(uint64_t v) {
     val[0] = v;
-    for (size_t i = 1; i < WordCount; ++i) {
+    for (size_t i = 1; i < WORDCOUNT; ++i) {
       val[i] = 0;
     }
   }
-  constexpr explicit UInt(const cpp::array<uint64_t, WordCount> &words) {
-    for (size_t i = 0; i < WordCount; ++i)
+  constexpr explicit UInt(const cpp::array<uint64_t, WORDCOUNT> &words) {
+    for (size_t i = 0; i < WORDCOUNT; ++i)
       val[i] = words[i];
   }
 
@@ -91,13 +91,13 @@ template <size_t Bits> struct UInt {
   }
 
   UInt<Bits> &operator=(const UInt<Bits> &other) {
-    for (size_t i = 0; i < WordCount; ++i)
+    for (size_t i = 0; i < WORDCOUNT; ++i)
       val[i] = other.val[i];
     return *this;
   }
 
   constexpr bool is_zero() const {
-    for (size_t i = 0; i < WordCount; ++i) {
+    for (size_t i = 0; i < WORDCOUNT; ++i) {
       if (val[i] != 0)
         return false;
     }
@@ -108,7 +108,7 @@ template <size_t Bits> struct UInt {
   // Returns the carry value produced by the addition operation.
   constexpr uint64_t add(const UInt<Bits> &x) {
     SumCarry<uint64_t> s{0, 0};
-    for (size_t i = 0; i < WordCount; ++i) {
+    for (size_t i = 0; i < WORDCOUNT; ++i) {
       s = add_with_carry(val[i], x.val[i], s.carry);
       val[i] = s.sum;
     }
@@ -118,7 +118,7 @@ template <size_t Bits> struct UInt {
   constexpr UInt<Bits> operator+(const UInt<Bits> &other) const {
     UInt<Bits> result;
     SumCarry<uint64_t> s{0, 0};
-    for (size_t i = 0; i < WordCount; ++i) {
+    for (size_t i = 0; i < WORDCOUNT; ++i) {
       s = add_with_carry(val[i], other.val[i], s.carry);
       result.val[i] = s.sum;
     }
@@ -134,7 +134,7 @@ template <size_t Bits> struct UInt {
   // Returns the carry value produced by the subtraction operation.
   constexpr uint64_t sub(const UInt<Bits> &x) {
     DiffBorrow<uint64_t> d{0, 0};
-    for (size_t i = 0; i < WordCount; ++i) {
+    for (size_t i = 0; i < WORDCOUNT; ++i) {
       d = sub_with_borrow(val[i], x.val[i], d.borrow);
       val[i] = d.
diff ;
     }
@@ -144,7 +144,7 @@ template <size_t Bits> struct UInt {
   constexpr UInt<Bits> operator-(const UInt<Bits> &other) const {
     UInt<Bits> result;
     DiffBorrow<uint64_t> d{0, 0};
-    for (size_t i = 0; i < WordCount; ++i) {
+    for (size_t i = 0; i < WORDCOUNT; ++i) {
       d = sub_with_borrow(val[i], other.val[i], d.borrow);
       result.val[i] = d.
diff ;
     }
@@ -166,7 +166,7 @@ template <size_t Bits> struct UInt {
   constexpr uint64_t mul(uint64_t x) {
     UInt<128> partial_sum(0);
     uint64_t carry = 0;
-    for (size_t i = 0; i < WordCount; ++i) {
+    for (size_t i = 0; i < WORDCOUNT; ++i) {
       NumberPair<uint64_t> prod = full_mul(val[i], x);
       UInt<128> tmp({prod.lo, prod.hi});
       carry += partial_sum.add(tmp);
@@ -179,13 +179,13 @@ template <size_t Bits> struct UInt {
   }
 
   constexpr UInt<Bits> operator*(const UInt<Bits> &other) const {
-    if constexpr (WordCount == 1) {
+    if constexpr (WORDCOUNT == 1) {
       return {val[0] * other.val[0]};
     } else {
       UInt<Bits> result(0);
       UInt<128> partial_sum(0);
       uint64_t carry = 0;
-      for (size_t i = 0; i < WordCount; ++i) {
+      for (size_t i = 0; i < WORDCOUNT; ++i) {
         for (size_t j = 0; j <= i; j++) {
           NumberPair<uint64_t> prod = full_mul(val[j], other.val[i - j]);
           UInt<128> tmp({prod.lo, prod.hi});
@@ -206,10 +206,11 @@ template <size_t Bits> struct UInt {
     UInt<Bits + OtherBits> result(0);
     UInt<128> partial_sum(0);
     uint64_t carry = 0;
-    constexpr size_t OtherWordCount = UInt<OtherBits>::WordCount;
-    for (size_t i = 0; i <= WordCount + OtherWordCount - 2; ++i) {
-      const size_t lower_idx = i < OtherWordCount ? 0 : i - OtherWordCount + 1;
-      const size_t upper_idx = i < WordCount ? i : WordCount - 1;
+    constexpr size_t OTHER_WORDCOUNT = UInt<OtherBits>::WORDCOUNT;
+    for (size_t i = 0; i <= WORDCOUNT + OTHER_WORDCOUNT - 2; ++i) {
+      const size_t lower_idx =
+          i < OTHER_WORDCOUNT ? 0 : i - OTHER_WORDCOUNT + 1;
+      const size_t upper_idx = i < WORDCOUNT ? i : WORDCOUNT - 1;
       for (size_t j = lower_idx; j <= upper_idx; ++j) {
         NumberPair<uint64_t> prod = full_mul(val[j], other.val[i - j]);
         UInt<128> tmp({prod.lo, prod.hi});
@@ -220,7 +221,7 @@ template <size_t Bits> struct UInt {
       partial_sum.val[1] = carry;
       carry = 0;
     }
-    result.val[WordCount + OtherWordCount - 1] = partial_sum.val[0];
+    result.val[WORDCOUNT + OTHER_WORDCOUNT - 1] = partial_sum.val[0];
     return result;
   }
 
@@ -228,7 +229,7 @@ template <size_t Bits> struct UInt {
   // `Bits` least significant bits of the full product, while this function will
   // approximate `Bits` most significant bits of the full product with errors
   // bounded by:
-  //   0 <= (a.full_mul(b) >> Bits) - a.quick_mul_hi(b)) <= WordCount - 1.
+  //   0 <= (a.full_mul(b) >> Bits) - a.quick_mul_hi(b)) <= WORDCOUNT - 1.
   //
   // An example usage of this is to quickly (but less accurately) compute the
   // product of (normalized) mantissas of floating point numbers:
@@ -240,7 +241,7 @@ template <size_t Bits> struct UInt {
   //
   // Performance summary:
   //   Number of 64-bit x 64-bit -> 128-bit multiplications performed.
-  //   Bits  WordCount  ful_mul  quick_mul_hi  Error bound
+  //   Bits  WORDCOUNT  ful_mul  quick_mul_hi  Error bound
   //    128      2         4           3            1
   //    196      3         9           6            2
   //    256      4        16          10            3
@@ -249,26 +250,26 @@ template <size_t Bits> struct UInt {
     UInt<Bits> result(0);
     UInt<128> partial_sum(0);
     uint64_t carry = 0;
-    // First round of accumulation for those at WordCount - 1 in the full
+    // First round of accumulation for those at WORDCOUNT - 1 in the full
     // product.
-    for (size_t i = 0; i < WordCount; ++i) {
+    for (size_t i = 0; i < WORDCOUNT; ++i) {
       NumberPair<uint64_t> prod =
-          full_mul(val[i], other.val[WordCount - 1 - i]);
+          full_mul(val[i], other.val[WORDCOUNT - 1 - i]);
       UInt<128> tmp({prod.lo, prod.hi});
       carry += partial_sum.add(tmp);
     }
-    for (size_t i = WordCount; i < 2 * WordCount - 1; ++i) {
+    for (size_t i = WORDCOUNT; i < 2 * WORDCOUNT - 1; ++i) {
       partial_sum.val[0] = partial_sum.val[1];
       partial_sum.val[1] = carry;
       carry = 0;
-      for (size_t j = i - WordCount + 1; j < WordCount; ++j) {
+      for (size_t j = i - WORDCOUNT + 1; j < WORDCOUNT; ++j) {
         NumberPair<uint64_t> prod = full_mul(val[j], other.val[i - j]);
         UInt<128> tmp({prod.lo, prod.hi});
         carry += partial_sum.add(tmp);
       }
-      result.val[i - WordCount] = partial_sum.val[0];
+      result.val[i - WORDCOUNT] = partial_sum.val[0];
     }
-    result.val[WordCount - 1] = partial_sum.val[1];
+    result.val[WORDCOUNT - 1] = partial_sum.val[1];
     return result;
   }
 
@@ -338,7 +339,7 @@ template <size_t Bits> struct UInt {
 
   constexpr uint64_t clz() {
     uint64_t leading_zeroes = 0;
-    for (size_t i = WordCount; i > 0; --i) {
+    for (size_t i = WORDCOUNT; i > 0; --i) {
       if (val[i - 1] == 0) {
         leading_zeroes += sizeof(uint64_t) * 8;
       } else {
@@ -370,17 +371,17 @@ template <size_t Bits> struct UInt {
 
     const size_t drop = s / 64;  // Number of words to drop
     const size_t shift = s % 64; // Bits to shift in the remaining words.
-    size_t i = WordCount;
+    size_t i = WORDCOUNT;
 
-    if (drop < WordCount) {
-      i = WordCount - 1;
+    if (drop < WORDCOUNT) {
+      i = WORDCOUNT - 1;
       if (shift > 0) {
-        for (size_t j = WordCount - 1 - drop; j > 0; --i, --j) {
+        for (size_t j = WORDCOUNT - 1 - drop; j > 0; --i, --j) {
           val[i] = (val[j] << shift) | (val[j - 1] >> (64 - shift));
         }
         val[i] = val[0] << shift;
       } else {
-        for (size_t j = WordCount - 1 - drop; j > 0; --i, --j) {
+        for (size_t j = WORDCOUNT - 1 - drop; j > 0; --i, --j) {
           val[i] = val[j];
         }
         val[i] = val[0];
@@ -427,21 +428,21 @@ template <size_t Bits> struct UInt {
 
     size_t i = 0;
 
-    if (drop < WordCount) {
+    if (drop < WORDCOUNT) {
       if (shift > 0) {
-        for (size_t j = drop; j < WordCount - 1; ++i, ++j) {
+        for (size_t j = drop; j < WORDCOUNT - 1; ++i, ++j) {
           val[i] = (val[j] >> shift) | (val[j + 1] << (64 - shift));
         }
-        val[i] = val[WordCount - 1] >> shift;
+        val[i] = val[WORDCOUNT - 1] >> shift;
         ++i;
       } else {
-        for (size_t j = drop; j < WordCount; ++i, ++j) {
+        for (size_t j = drop; j < WORDCOUNT; ++i, ++j) {
           val[i] = val[j];
         }
       }
     }
 
-    for (; i < WordCount; ++i) {
+    for (; i < WORDCOUNT; ++i) {
       val[i] = 0;
     }
   }
@@ -459,52 +460,52 @@ template <size_t Bits> struct UInt {
 
   constexpr UInt<Bits> operator&(const UInt<Bits> &other) const {
     UInt<Bits> result;
-    for (size_t i = 0; i < WordCount; ++i)
+    for (size_t i = 0; i < WORDCOUNT; ++i)
       result.val[i] = val[i] & other.val[i];
     return result;
   }
 
   constexpr UInt<Bits> &operator&=(const UInt<Bits> &other) {
-    for (size_t i = 0; i < WordCount; ++i)
+    for (size_t i = 0; i < WORDCOUNT; ++i)
       val[i] &= other.val[i];
     return *this;
   }
 
   constexpr UInt<Bits> operator|(const UInt<Bits> &other) const {
     UInt<Bits> result;
-    for (size_t i = 0; i < WordCount; ++i)
+    for (size_t i = 0; i < WORDCOUNT; ++i)
       result.val[i] = val[i] | other.val[i];
     return result;
   }
 
   constexpr UInt<Bits> &operator|=(const UInt<Bits> &other) {
-    for (size_t i = 0; i < WordCount; ++i)
+    for (size_t i = 0; i < WORDCOUNT; ++i)
       val[i] |= other.val[i];
     return *this;
   }
 
   constexpr UInt<Bits> operator^(const UInt<Bits> &other) const {
     UInt<Bits> result;
-    for (size_t i = 0; i < WordCount; ++i)
+    for (size_t i = 0; i < WORDCOUNT; ++i)
       result.val[i] = val[i] ^ other.val[i];
     return result;
   }
 
   constexpr UInt<Bits> &operator^=(const UInt<Bits> &other) {
-    for (size_t i = 0; i < WordCount; ++i)
+    for (size_t i = 0; i < WORDCOUNT; ++i)
       val[i] ^= other.val[i];
     return *this;
   }
 
   constexpr UInt<Bits> operator~() const {
     UInt<Bits> result;
-    for (size_t i = 0; i < WordCount; ++i)
+    for (size_t i = 0; i < WORDCOUNT; ++i)
       result.val[i] = ~val[i];
     return result;
   }
 
   constexpr bool operator==(const UInt<Bits> &other) const {
-    for (size_t i = 0; i < WordCount; ++i) {
+    for (size_t i = 0; i < WORDCOUNT; ++i) {
       if (val[i] != other.val[i])
         return false;
     }
@@ -512,7 +513,7 @@ template <size_t Bits> struct UInt {
   }
 
   constexpr bool operator!=(const UInt<Bits> &other) const {
-    for (size_t i = 0; i < WordCount; ++i) {
+    for (size_t i = 0; i < WORDCOUNT; ++i) {
       if (val[i] != other.val[i])
         return true;
     }
@@ -520,7 +521,7 @@ template <size_t Bits> struct UInt {
   }
 
   constexpr bool operator>(const UInt<Bits> &other) const {
-    for (size_t i = WordCount; i > 0; --i) {
+    for (size_t i = WORDCOUNT; i > 0; --i) {
       uint64_t word = val[i - 1];
       uint64_t other_word = other.val[i - 1];
       if (word > other_word)
@@ -533,7 +534,7 @@ template <size_t Bits> struct UInt {
   }
 
   constexpr bool operator>=(const UInt<Bits> &other) const {
-    for (size_t i = WordCount; i > 0; --i) {
+    for (size_t i = WORDCOUNT; i > 0; --i) {
       uint64_t word = val[i - 1];
       uint64_t other_word = other.val[i - 1];
       if (word > other_word)
@@ -546,7 +547,7 @@ template <size_t Bits> struct UInt {
   }
 
   constexpr bool operator<(const UInt<Bits> &other) const {
-    for (size_t i = WordCount; i > 0; --i) {
+    for (size_t i = WORDCOUNT; i > 0; --i) {
       uint64_t word = val[i - 1];
       uint64_t other_word = other.val[i - 1];
       if (word > other_word)
@@ -559,7 +560,7 @@ template <size_t Bits> struct UInt {
   }
 
   constexpr bool operator<=(const UInt<Bits> &other) const {
-    for (size_t i = WordCount; i > 0; --i) {
+    for (size_t i = WORDCOUNT; i > 0; --i) {
       uint64_t word = val[i - 1];
       uint64_t other_word = other.val[i - 1];
       if (word > other_word)

diff  --git a/libc/src/math/generic/exp2f.cpp b/libc/src/math/generic/exp2f.cpp
index 116f40fc0a178..3c319d288e1c9 100644
--- a/libc/src/math/generic/exp2f.cpp
+++ b/libc/src/math/generic/exp2f.cpp
@@ -21,9 +21,9 @@
 
 namespace __llvm_libc {
 
-constexpr uint32_t exval1 = 0x3b42'9d37U;
-constexpr uint32_t exval2 = 0xbcf3'a937U;
-constexpr uint32_t exval_mask = exval1 & exval2;
+constexpr uint32_t EXVAL1 = 0x3b42'9d37U;
+constexpr uint32_t EXVAL2 = 0xbcf3'a937U;
+constexpr uint32_t EXVAL_MASK = EXVAL1 & EXVAL2;
 
 LLVM_LIBC_FUNCTION(float, exp2f, (float x)) {
   using FPBits = typename fputil::FPBits<float>;
@@ -73,11 +73,11 @@ LLVM_LIBC_FUNCTION(float, exp2f, (float x)) {
   }
 
   // Check exceptional values.
-  if (LIBC_UNLIKELY((x_u & exval_mask) == exval_mask)) {
-    if (LIBC_UNLIKELY(x_u == exval1)) { // x = 0x1.853a6ep-9f
+  if (LIBC_UNLIKELY((x_u & EXVAL_MASK) == EXVAL_MASK)) {
+    if (LIBC_UNLIKELY(x_u == EXVAL1)) { // x = 0x1.853a6ep-9f
       if (fputil::get_round() == FE_TONEAREST)
         return 0x1.00870ap+0f;
-    } else if (LIBC_UNLIKELY(x_u == exval2)) { // x = -0x1.e7526ep-6f
+    } else if (LIBC_UNLIKELY(x_u == EXVAL2)) { // x = -0x1.e7526ep-6f
       if (fputil::get_round() == FE_TONEAREST)
         return 0x1.f58d62p-1f;
     }

diff  --git a/libc/src/math/generic/log10.cpp b/libc/src/math/generic/log10.cpp
index 8eca77379c5e9..b2dd29f5f74d1 100644
--- a/libc/src/math/generic/log10.cpp
+++ b/libc/src/math/generic/log10.cpp
@@ -917,7 +917,6 @@ double log10_accurate(int e_x, int index, double m_x) {
 
   // Further range reductions.
   double scale = 0x1.0p+7;
-  const fputil::DyadicFloat<128> NEG_ONE(-1.0);
   for (size_t i = 0; i < R_STEPS; ++i) {
     scale *= 0x1.0p+4;
     int id = static_cast<int>(fputil::multiply_add(mx.hi, scale, 0x1.0p+4));

diff  --git a/libc/utils/HdrGen/PrototypeTestGen/.clang-tidy b/libc/utils/HdrGen/PrototypeTestGen/.clang-tidy
deleted file mode 100644
index d404f83828f7c..0000000000000
--- a/libc/utils/HdrGen/PrototypeTestGen/.clang-tidy
+++ /dev/null
@@ -1,3 +0,0 @@
-CheckOptions:
-  - key:             readability-identifier-naming.VariableCase
-    value:           camelBack


        


More information about the libc-commits mailing list