From 2aa22ca2ca4c7cd709665624ccc51be4676c6fd3 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Tue, 5 Mar 2024 08:17:27 -0800 Subject: [PATCH] [libc] suppress readability-identifier-naming for std::numeric_limits interfaces (#83921) These templates are made to match the ergonomics of std::numeric_limits. Because our style for constexpr variables is ALL_CAPS, we must silence the linter for these manually. Link: https://clang.llvm.org/extra/clang-tidy/#suppressing-undesired-diagnostics --- libc/src/__support/UInt.h | 4 ++++ libc/src/string/memory_utils/op_generic.h | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/libc/src/__support/UInt.h b/libc/src/__support/UInt.h index ae1fe7aaa182..5973e6fab1d7 100644 --- a/libc/src/__support/UInt.h +++ b/libc/src/__support/UInt.h @@ -898,6 +898,8 @@ public: return UInt<128>({0xffff'ffff'ffff'ffff, 0xffff'ffff'ffff'ffff}); } LIBC_INLINE static constexpr UInt<128> min() { return UInt<128>(0); } + // Meant to match std::numeric_limits interface. + // NOLINTNEXTLINE(readability-identifier-naming) LIBC_INLINE_VAR static constexpr int digits = 128; }; @@ -909,6 +911,8 @@ public: LIBC_INLINE static constexpr Int<128> min() { return Int<128>({0, 0x8000'0000'0000'0000}); } + // Meant to match std::numeric_limits interface. + // NOLINTNEXTLINE(readability-identifier-naming) LIBC_INLINE_VAR static constexpr int digits = 128; }; diff --git a/libc/src/string/memory_utils/op_generic.h b/libc/src/string/memory_utils/op_generic.h index 90269c0fa803..41fc1fa0f1ff 100644 --- a/libc/src/string/memory_utils/op_generic.h +++ b/libc/src/string/memory_utils/op_generic.h @@ -63,28 +63,41 @@ template <> struct is_scalar : cpp::true_type {}; #ifdef LLVM_LIBC_HAS_UINT64 template <> struct is_scalar : cpp::true_type {}; #endif // LLVM_LIBC_HAS_UINT64 +// Meant to match std::numeric_limits interface. +// NOLINTNEXTLINE(readability-identifier-naming) template constexpr bool is_scalar_v = is_scalar::value; template struct is_vector : cpp::false_type {}; template <> struct is_vector : cpp::true_type {}; template <> struct is_vector : cpp::true_type {}; template <> struct is_vector : cpp::true_type {}; +// Meant to match std::numeric_limits interface. +// NOLINTNEXTLINE(readability-identifier-naming) template constexpr bool is_vector_v = is_vector::value; template struct is_array : cpp::false_type {}; template struct is_array> { + // Meant to match std::numeric_limits interface. + // NOLINTNEXTLINE(readability-identifier-naming) static constexpr bool value = is_scalar_v || is_vector_v; }; +// Meant to match std::numeric_limits interface. +// NOLINTNEXTLINE(readability-identifier-naming) template constexpr bool is_array_v = is_array::value; +// Meant to match std::numeric_limits interface. +// NOLINTBEGIN(readability-identifier-naming) template constexpr bool is_element_type_v = is_scalar_v || is_vector_v || is_array_v; +// NOLINTEND(readability-identifier-naming) // Helper struct to retrieve the number of elements of an array. template struct array_size {}; template struct array_size> : cpp::integral_constant {}; +// Meant to match std::numeric_limits interface. +// NOLINTNEXTLINE(readability-identifier-naming) template constexpr size_t array_size_v = array_size::value; // Generic operations for the above type categories.