diff --git a/libc/benchmarks/LibcMemoryBenchmark.cpp b/libc/benchmarks/LibcMemoryBenchmark.cpp index 3ced306584d15..9307ee45b2853 100644 --- a/libc/benchmarks/LibcMemoryBenchmark.cpp +++ b/libc/benchmarks/LibcMemoryBenchmark.cpp @@ -53,8 +53,8 @@ MismatchOffsetDistribution::MismatchOffsetDistribution(size_t BufferSize, : MismatchAt(MismatchAt) { if (MismatchAt <= 1) return; - for (size_t I = MaxSizeValue + 1; I < BufferSize; I += MaxSizeValue) - MismatchIndices.push_back(I); + for (size_t i = MaxSizeValue + 1; i < BufferSize; i += MaxSizeValue) + MismatchIndices.push_back(i); if (MismatchIndices.empty()) report_fatal_error("Unable to generate mismatch"); MismatchIndexSelector = diff --git a/libc/benchmarks/LibcMemoryBenchmarkMain.cpp b/libc/benchmarks/LibcMemoryBenchmarkMain.cpp index c042b29cad98e..613160d72c17f 100644 --- a/libc/benchmarks/LibcMemoryBenchmarkMain.cpp +++ b/libc/benchmarks/LibcMemoryBenchmarkMain.cpp @@ -161,11 +161,11 @@ struct MemfunctionBenchmarkBase : public BenchmarkSetup { if (Percent == LastPercent) return; LastPercent = Percent; - size_t I = 0; + size_t i = 0; errs() << '['; - for (; I <= Percent; ++I) + for (; i <= Percent; ++i) errs() << '#'; - for (; I <= 100; ++I) + for (; i <= 100; ++i) errs() << '_'; errs() << "] " << Percent << '%' << '\r'; } diff --git a/libc/benchmarks/LibcMemoryBenchmarkTest.cpp b/libc/benchmarks/LibcMemoryBenchmarkTest.cpp index 00866e5a65c27..3c796c8ecc284 100644 --- a/libc/benchmarks/LibcMemoryBenchmarkTest.cpp +++ b/libc/benchmarks/LibcMemoryBenchmarkTest.cpp @@ -38,7 +38,7 @@ TEST(OffsetDistribution, AlignToBegin) { const size_t BufferSize = 8192; OffsetDistribution OD(BufferSize, 1024, std::nullopt); std::default_random_engine Gen; - for (size_t I = 0; I <= 10; ++I) + for (size_t i = 0; i <= 10; ++i) EXPECT_EQ(OD(Gen), 0U); } @@ -46,7 +46,7 @@ TEST(OffsetDistribution, NoAlignment) { const size_t BufferSize = 8192; OffsetDistribution OD(BufferSize, 1, Align(1)); std::default_random_engine Gen; - for (size_t I = 0; I <= 10; ++I) + for (size_t i = 0; i <= 10; ++i) EXPECT_THAT(OD(Gen), AllOf(Ge(0U), Lt(8192U))); } @@ -59,7 +59,7 @@ TEST(OffsetDistribution, Aligned) { const size_t BufferSize = 8192; OffsetDistribution OD(BufferSize, 1, Align(16)); std::default_random_engine Gen; - for (size_t I = 0; I <= 10; ++I) + for (size_t i = 0; i <= 10; ++i) EXPECT_THAT(OD(Gen), AllOf(Ge(0U), Lt(8192U), IsDivisibleBy(16U))); } diff --git a/libc/src/__support/CPP/tuple.h b/libc/src/__support/CPP/tuple.h index cce8e0ef2bfae..fa4fcd08cc04f 100644 --- a/libc/src/__support/CPP/tuple.h +++ b/libc/src/__support/CPP/tuple.h @@ -48,33 +48,33 @@ template LIBC_INLINE constexpr auto tie(Ts &...args) { return tuple(args...); } -template +template LIBC_INLINE constexpr auto &get(tuple &t) { - if constexpr (I == 0) + if constexpr (Idx == 0) return t.get_head(); else - return get(t.get_tail()); + return get(t.get_tail()); } -template +template LIBC_INLINE constexpr const auto &get(const tuple &t) { - if constexpr (I == 0) + if constexpr (Idx == 0) return t.get_head(); else - return get(t.get_tail()); + return get(t.get_tail()); } -template +template LIBC_INLINE constexpr auto &&get(tuple &&t) { - if constexpr (I == 0) + if constexpr (Idx == 0) return static_cast(t.get_head()); else - return get(static_cast &&>(t.get_tail())); + return get(static_cast &&>(t.get_tail())); } -template +template LIBC_INLINE constexpr const auto &&get(const tuple &&t) { - if constexpr (I == 0) + if constexpr (Idx == 0) return static_cast(t.get_head()); else - return get(static_cast &&>(t.get_tail())); + return get(static_cast &&>(t.get_tail())); } template struct tuple_size; @@ -82,21 +82,21 @@ template struct tuple_size> { static constexpr size_t value = sizeof...(Ts); }; -template struct tuple_element; -template -struct tuple_element> - : tuple_element> {}; +template struct tuple_element; +template +struct tuple_element> + : tuple_element> {}; template struct tuple_element<0, tuple> { using type = cpp::remove_cv_t>; }; namespace internal { -template +template LIBC_INLINE constexpr auto tuple_cat(const tuple &a, const tuple &b, - cpp::index_sequence, cpp::index_sequence) { - return tuple(get(a)..., get(b)...); + cpp::index_sequence, cpp::index_sequence) { + return tuple(get(a)..., get(b)...); } template @@ -128,16 +128,16 @@ LIBC_INLINE constexpr auto tuple_cat(const Tuples &...tuples) { namespace std { template struct tuple_size; -template struct tuple_element; +template struct tuple_element; template struct tuple_size> : LIBC_NAMESPACE::cpp::tuple_size> {}; -template -struct tuple_element> - : LIBC_NAMESPACE::cpp::tuple_element> { -}; +template +struct tuple_element> + : LIBC_NAMESPACE::cpp::tuple_element> {}; } // namespace std diff --git a/libc/test/UnitTest/MemoryMatcher.cpp b/libc/test/UnitTest/MemoryMatcher.cpp index 3cd5174fd7f75..6e375768e9333 100644 --- a/libc/test/UnitTest/MemoryMatcher.cpp +++ b/libc/test/UnitTest/MemoryMatcher.cpp @@ -40,9 +40,9 @@ bool MemoryMatcher::match(MemoryView actualValue) { } static void display(char C) { - const auto print = [](unsigned char I) { + const auto print = [](unsigned char i) { tlog << static_cast(LIBC_NAMESPACE::internal::toupper( - LIBC_NAMESPACE::internal::int_to_b36_char(I))); + LIBC_NAMESPACE::internal::int_to_b36_char(i))); }; print(static_cast(C) / 16); print(static_cast(C) & 15); diff --git a/libc/test/integration/src/pthread/pthread_create_test.cpp b/libc/test/integration/src/pthread/pthread_create_test.cpp index abd348e707c09..d436cc3270d9c 100644 --- a/libc/test/integration/src/pthread/pthread_create_test.cpp +++ b/libc/test/integration/src/pthread/pthread_create_test.cpp @@ -108,14 +108,14 @@ static void *successThread(void *Arg) { volatile uint8_t *bytes_on_stack = (volatile uint8_t *)__builtin_alloca(test_stacksize); - for (size_t I = 0; I < test_stacksize; ++I) { + for (size_t i = 0; i < test_stacksize; ++i) { // Write permissions - bytes_on_stack[I] = static_cast(I); + bytes_on_stack[i] = static_cast(i); } - for (size_t I = 0; I < test_stacksize; ++I) { + for (size_t i = 0; i < test_stacksize; ++i) { // Read/write permissions - bytes_on_stack[I] += static_cast(I); + bytes_on_stack[i] += static_cast(i); } } diff --git a/libc/test/src/math/smoke/RoundToIntegerTest.h b/libc/test/src/math/smoke/RoundToIntegerTest.h index f8be5a5bcc737..c0b326e5dcbb0 100644 --- a/libc/test/src/math/smoke/RoundToIntegerTest.h +++ b/libc/test/src/math/smoke/RoundToIntegerTest.h @@ -22,25 +22,26 @@ static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO, FE_TONEAREST}; -template +template class RoundToIntegerTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest { public: - typedef I (*RoundToIntegerFunc)(F); + typedef IntType (*RoundToIntegerFunc)(FloatType); private: - DECLARE_SPECIAL_CONSTANTS(F) + DECLARE_SPECIAL_CONSTANTS(FloatType) static constexpr StorageType MAX_SUBNORMAL = FPBits::max_subnormal().uintval(); static constexpr StorageType MIN_SUBNORMAL = FPBits::min_subnormal().uintval(); - static constexpr I INTEGER_MIN = I(1) << (sizeof(I) * 8 - 1); - static constexpr I INTEGER_MAX = -(INTEGER_MIN + 1); + static constexpr IntType INTEGER_MIN = IntType(1) + << (sizeof(IntType) * 8 - 1); + static constexpr IntType INTEGER_MAX = -(INTEGER_MIN + 1); - void test_one_input(RoundToIntegerFunc func, F input, I expected, - bool expectError) { + void test_one_input(RoundToIntegerFunc func, FloatType input, + IntType expected, bool expectError) { libc_errno = 0; LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); @@ -92,14 +93,14 @@ class RoundToIntegerTestTemplate } void do_round_numbers_test(RoundToIntegerFunc func) { - test_one_input(func, zero, I(0), false); - test_one_input(func, neg_zero, I(0), false); - test_one_input(func, F(1.0), I(1), false); - test_one_input(func, F(-1.0), I(-1), false); - test_one_input(func, F(10.0), I(10), false); - test_one_input(func, F(-10.0), I(-10), false); - test_one_input(func, F(1232.0), I(1232), false); - test_one_input(func, F(-1232.0), I(-1232), false); + test_one_input(func, zero, IntType(0), false); + test_one_input(func, neg_zero, IntType(0), false); + test_one_input(func, FloatType(1.0), IntType(1), false); + test_one_input(func, FloatType(-1.0), IntType(-1), false); + test_one_input(func, FloatType(10.0), IntType(10), false); + test_one_input(func, FloatType(-10.0), IntType(-10), false); + test_one_input(func, FloatType(1232.0), IntType(1232), false); + test_one_input(func, FloatType(-1232.0), IntType(-1232), false); } void testRoundNumbers(RoundToIntegerFunc func) { @@ -120,29 +121,29 @@ class RoundToIntegerTestTemplate static_cast((MAX_SUBNORMAL - MIN_SUBNORMAL) / COUNT), StorageType(1)); for (StorageType i = MIN_SUBNORMAL; i <= MAX_SUBNORMAL; i += STEP) { - F x = FPBits(i).get_val(); - if (x == F(0.0)) + FloatType x = FPBits(i).get_val(); + if (x == FloatType(0.0)) continue; // All subnormal numbers should round to zero. if (TestModes) { if (x > zero) { LIBC_NAMESPACE::fputil::set_round(FE_UPWARD); - test_one_input(func, x, I(1), false); + test_one_input(func, x, IntType(1), false); LIBC_NAMESPACE::fputil::set_round(FE_DOWNWARD); - test_one_input(func, x, I(0), false); + test_one_input(func, x, IntType(0), false); LIBC_NAMESPACE::fputil::set_round(FE_TOWARDZERO); - test_one_input(func, x, I(0), false); + test_one_input(func, x, IntType(0), false); LIBC_NAMESPACE::fputil::set_round(FE_TONEAREST); - test_one_input(func, x, I(0), false); + test_one_input(func, x, IntType(0), false); } else { LIBC_NAMESPACE::fputil::set_round(FE_UPWARD); - test_one_input(func, x, I(0), false); + test_one_input(func, x, IntType(0), false); LIBC_NAMESPACE::fputil::set_round(FE_DOWNWARD); - test_one_input(func, x, I(-1), false); + test_one_input(func, x, IntType(-1), false); LIBC_NAMESPACE::fputil::set_round(FE_TOWARDZERO); - test_one_input(func, x, I(0), false); + test_one_input(func, x, IntType(0), false); LIBC_NAMESPACE::fputil::set_round(FE_TONEAREST); - test_one_input(func, x, I(0), false); + test_one_input(func, x, IntType(0), false); } } else { test_one_input(func, x, 0L, false); @@ -151,9 +152,10 @@ class RoundToIntegerTestTemplate } }; -#define LIST_ROUND_TO_INTEGER_TESTS_HELPER(F, I, func, TestModes) \ +#define LIST_ROUND_TO_INTEGER_TESTS_HELPER(FloatType, IntType, func, \ + TestModes) \ using LlvmLibcRoundToIntegerTest = \ - RoundToIntegerTestTemplate; \ + RoundToIntegerTestTemplate; \ TEST_F(LlvmLibcRoundToIntegerTest, InfinityAndNaN) { \ testInfinityAndNaN(&func); \ } \ @@ -164,16 +166,16 @@ class RoundToIntegerTestTemplate testSubnormalRange(&func); \ } -#define LIST_ROUND_TO_INTEGER_TESTS(F, I, func) \ - LIST_ROUND_TO_INTEGER_TESTS_HELPER(F, I, func, false) +#define LIST_ROUND_TO_INTEGER_TESTS(FloatType, IntType, func) \ + LIST_ROUND_TO_INTEGER_TESTS_HELPER(FloatType, IntType, func, false) // The GPU target does not support different rounding modes. #ifdef LIBC_TARGET_ARCH_IS_GPU -#define LIST_ROUND_TO_INTEGER_TESTS_WITH_MODES(F, I, func) \ - LIST_ROUND_TO_INTEGER_TESTS_HELPER(F, I, func, false) +#define LIST_ROUND_TO_INTEGER_TESTS_WITH_MODES(FloatType, IntType, func) \ + LIST_ROUND_TO_INTEGER_TESTS_HELPER(FloatType, IntType, func, false) #else -#define LIST_ROUND_TO_INTEGER_TESTS_WITH_MODES(F, I, func) \ - LIST_ROUND_TO_INTEGER_TESTS_HELPER(F, I, func, true) +#define LIST_ROUND_TO_INTEGER_TESTS_WITH_MODES(FloatType, IntType, func) \ + LIST_ROUND_TO_INTEGER_TESTS_HELPER(FloatType, IntType, func, true) #endif #endif // LLVM_LIBC_TEST_SRC_MATH_SMOKE_ROUNDTOINTEGERTEST_H diff --git a/libc/test/src/string/memory_utils/utils_test.cpp b/libc/test/src/string/memory_utils/utils_test.cpp index 4dff0684b9111..2ab2e8d3ad867 100644 --- a/libc/test/src/string/memory_utils/utils_test.cpp +++ b/libc/test/src/string/memory_utils/utils_test.cpp @@ -47,14 +47,14 @@ TEST(LlvmLibcUtilsTest, DistanceToAlignDown) { TEST(LlvmLibcUtilsTest, Adjust2) { char a, b; const size_t base_size = 10; - for (uintptr_t I = 0; I < 4; ++I) { + for (uintptr_t i = 0; i < 4; ++i) { auto *p1 = &a; auto *p2 = &b; size_t size = base_size; - adjust(static_cast(I), p1, p2, size); - EXPECT_EQ(intptr_t(p1), intptr_t(&a + I)); - EXPECT_EQ(intptr_t(p2), intptr_t(&b + I)); - EXPECT_EQ(size, base_size - I); + adjust(static_cast(i), p1, p2, size); + EXPECT_EQ(intptr_t(p1), intptr_t(&a + i)); + EXPECT_EQ(intptr_t(p2), intptr_t(&b + i)); + EXPECT_EQ(size, base_size - i); } }