From c1360709b1c822cd532da710bc47bcf226156591 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Sun, 19 Apr 2026 10:17:53 +0200 Subject: [PATCH 1/5] [ci] Prevent clang-tidy regression --- .clang-tidy | 4 ++++ .github/workflows/style-check.yml | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..2d173401f --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,4 @@ +--- +Checks: '-*,modernize-type-traits' +WarningsAsErrors: true +HeaderFilterRegex: '.*' diff --git a/.github/workflows/style-check.yml b/.github/workflows/style-check.yml index 478d97183..5fa1007b1 100644 --- a/.github/workflows/style-check.yml +++ b/.github/workflows/style-check.yml @@ -30,3 +30,19 @@ jobs: - uses: actions/checkout@v6 - run: pip install diskarzhan - run: diskarzhan `find -name '*.[ch]pp'` + + clang-tidy-check: + name: Clang-tidy check (x86_64) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - run: sudo apt install clang-tidy + - name: Configure + run: cmake -B _build \ + -DCMAKE_CXX_COMPILER=clang++ \ + -DBUILD_TESTS=ON \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_CXX_FLAGS='-march=tigerlake' + - name: Check + run: run-clang-tidy -p _build From 7c698a015755ffb4cfa02296beaf49e9b02d3b8a Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Mon, 20 Apr 2026 11:46:35 +0200 Subject: [PATCH 2/5] Apply clang-tidy's current rules to xsimd --- include/xsimd/arch/xsimd_avx.hpp | 2 +- include/xsimd/arch/xsimd_avx2.hpp | 4 ++-- include/xsimd/arch/xsimd_avx512f.hpp | 6 ++--- include/xsimd/arch/xsimd_sse2.hpp | 4 ++-- include/xsimd/arch/xsimd_sse4_1.hpp | 2 +- include/xsimd/config/xsimd_arch.hpp | 4 ++-- .../xsimd/config/xsimd_cpu_features_x86.hpp | 24 +++++++++---------- test/test_xsimd_api.cpp | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/xsimd/arch/xsimd_avx.hpp b/include/xsimd/arch/xsimd_avx.hpp index 441371643..bc0d9c672 100644 --- a/include/xsimd/arch/xsimd_avx.hpp +++ b/include/xsimd/arch/xsimd_avx.hpp @@ -1526,7 +1526,7 @@ namespace xsimd { _mm256_stream_pd(mem, self); } - template ::value, void>::type> + template ::value, void>> XSIMD_INLINE void store_stream(T* mem, batch const& self, requires_arch) noexcept { _mm256_stream_si256((__m256i*)mem, self); diff --git a/include/xsimd/arch/xsimd_avx2.hpp b/include/xsimd/arch/xsimd_avx2.hpp index cfa22d18b..ebffd910b 100644 --- a/include/xsimd/arch/xsimd_avx2.hpp +++ b/include/xsimd/arch/xsimd_avx2.hpp @@ -231,7 +231,7 @@ namespace xsimd } // load_stream - template ::value, void>::type> + template ::value, void>> XSIMD_INLINE batch load_stream(T const* mem, convert, requires_arch) noexcept { return _mm256_stream_load_si256((__m256i const*)mem); @@ -359,7 +359,7 @@ namespace xsimd XSIMD_INLINE batch bitwise_lshift( batch const& self, batch_constant shifts, requires_arch req) noexcept { - using uint_t = typename std::make_unsigned::type; + using uint_t = std::make_unsigned_t; // AVX2 only supports 16-bit shifts with a uniform bitshift value, // otherwise emulate using 32-bit shifts. diff --git a/include/xsimd/arch/xsimd_avx512f.hpp b/include/xsimd/arch/xsimd_avx512f.hpp index fe8d33d99..dcc85b983 100644 --- a/include/xsimd/arch/xsimd_avx512f.hpp +++ b/include/xsimd/arch/xsimd_avx512f.hpp @@ -1514,7 +1514,7 @@ namespace xsimd } // load_stream - template ::value, void>::type> + template ::value, void>> XSIMD_INLINE batch load_stream(T const* mem, convert, requires_arch) noexcept { return _mm512_stream_load_si512((__m512i*)mem); @@ -2303,7 +2303,7 @@ namespace xsimd } // store_stream - template ::value, void>::type> + template ::value, void>> XSIMD_INLINE void store_stream(T* mem, batch const& self, requires_arch) noexcept { _mm512_stream_si512((__m512i*)mem, self); @@ -2483,7 +2483,7 @@ namespace xsimd }; template - struct is_pair_of_contiguous_indices : std::conditional<(Idx0 % 2 == 0) && (Idx0 + 1 == Idx1), is_pair_of_contiguous_indices, std::false_type>::type + struct is_pair_of_contiguous_indices : std::conditional_t<(Idx0 % 2 == 0) && (Idx0 + 1 == Idx1), is_pair_of_contiguous_indices, std::false_type> { }; diff --git a/include/xsimd/arch/xsimd_sse2.hpp b/include/xsimd/arch/xsimd_sse2.hpp index 7e00b2b74..f043eda70 100644 --- a/include/xsimd/arch/xsimd_sse2.hpp +++ b/include/xsimd/arch/xsimd_sse2.hpp @@ -345,7 +345,7 @@ namespace xsimd XSIMD_INLINE batch bitwise_lshift( batch const& self, batch_constant shifts, requires_arch req) noexcept { - using uint_t = typename std::make_unsigned::type; + using uint_t = std::make_unsigned_t; XSIMD_IF_CONSTEXPR(utils::all_equals(shifts)) { @@ -1966,7 +1966,7 @@ namespace xsimd { _mm_stream_ps(mem, self); } - template ::value, void>::type> + template ::value, void>> XSIMD_INLINE void store_stream(T* mem, batch const& self, requires_arch) noexcept { _mm_stream_si128((__m128i*)mem, self); diff --git a/include/xsimd/arch/xsimd_sse4_1.hpp b/include/xsimd/arch/xsimd_sse4_1.hpp index bb3a6ca2c..b13d75741 100644 --- a/include/xsimd/arch/xsimd_sse4_1.hpp +++ b/include/xsimd/arch/xsimd_sse4_1.hpp @@ -229,7 +229,7 @@ namespace xsimd } // load_stream - template ::value, void>::type> + template ::value, void>> XSIMD_INLINE batch load_stream(T const* mem, convert, requires_arch) noexcept { return _mm_stream_load_si128((__m128i*)mem); diff --git a/include/xsimd/config/xsimd_arch.hpp b/include/xsimd/config/xsimd_arch.hpp index d69ff7560..9084d2d34 100644 --- a/include/xsimd/config/xsimd_arch.hpp +++ b/include/xsimd/config/xsimd_arch.hpp @@ -51,8 +51,8 @@ namespace xsimd template struct contains - : std::conditional::value, std::true_type, - contains>::type + : std::conditional_t::value, std::true_type, + contains> { }; diff --git a/include/xsimd/config/xsimd_cpu_features_x86.hpp b/include/xsimd/config/xsimd_cpu_features_x86.hpp index b98e0e7dc..439cc6b5e 100644 --- a/include/xsimd/config/xsimd_cpu_features_x86.hpp +++ b/include/xsimd/config/xsimd_cpu_features_x86.hpp @@ -138,55 +138,55 @@ namespace xsimd enum class type {}; }; - using eax_or_empty = typename std::conditional::value, typename m_empty_reg<0>::type, eax>::type; - using ebx_or_empty = typename std::conditional::value, typename m_empty_reg<1>::type, ebx>::type; - using ecx_or_empty = typename std::conditional::value, typename m_empty_reg<2>::type, ecx>::type; - using edx_or_empty = typename std::conditional::value, typename m_empty_reg<3>::type, edx>::type; + using eax_or_empty = std::conditional_t::value, typename m_empty_reg<0>::type, eax>; + using ebx_or_empty = std::conditional_t::value, typename m_empty_reg<1>::type, ebx>; + using ecx_or_empty = std::conditional_t::value, typename m_empty_reg<2>::type, ecx>; + using edx_or_empty = std::conditional_t::value, typename m_empty_reg<3>::type, edx>; public: - template ::value, int>::type = 0> + template ::value, int> = 0> constexpr bool all_bits_set() const noexcept { return x86_reg32_bitset::template all_bits_set(); } - template ::value, int>::type = 0> + template ::value, int> = 0> constexpr x86_reg32_t get_range() const noexcept { return x86_reg32_bitset::template get_range(); } - template ::value, int>::type = 0> + template ::value, int> = 0> constexpr bool all_bits_set() const noexcept { return x86_reg32_bitset::template all_bits_set(); } - template ::value, int>::type = 0> + template ::value, int> = 0> constexpr x86_reg32_t get_range() const noexcept { return x86_reg32_bitset::template get_range(); } - template ::value, int>::type = 0> + template ::value, int> = 0> constexpr bool all_bits_set() const noexcept { return x86_reg32_bitset::template all_bits_set(); } - template ::value, int>::type = 0> + template ::value, int> = 0> constexpr x86_reg32_t get_range() const noexcept { return x86_reg32_bitset::template get_range(); } - template ::value, int>::type = 0> + template ::value, int> = 0> constexpr bool all_bits_set() const noexcept { return x86_reg32_bitset::template all_bits_set(); } - template ::value, int>::type = 0> + template ::value, int> = 0> constexpr x86_reg32_t get_range() const noexcept { return x86_reg32_bitset::template get_range(); diff --git a/test/test_xsimd_api.cpp b/test/test_xsimd_api.cpp index 70ac61f25..ad72fbd67 100644 --- a/test/test_xsimd_api.cpp +++ b/test/test_xsimd_api.cpp @@ -366,7 +366,7 @@ struct xsimd_api_integral_types_functions /* Test when T is a batch_constant only, not a scalar. */ template - void test_bitwise_lshift_multiple(T const& vals, typename std::enable_if::value, int>::type = 0) + void test_bitwise_lshift_multiple(T const& vals, std::enable_if_t::value, int> = 0) { #ifndef XSIMD_NO_SUPPORTED_ARCHITECTURE constexpr auto Max = static_cast(std::numeric_limits::digits); @@ -389,7 +389,7 @@ struct xsimd_api_integral_types_functions /* Test multiple does not make sense when T is scalar. */ template - void test_bitwise_lshift_multiple(T const&, typename std::enable_if::value, int>::type = 0) + void test_bitwise_lshift_multiple(T const&, std::enable_if_t::value, int> = 0) { } From f4b160b076c93e77e01c8b865daeb2f54348c2b0 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Mon, 20 Apr 2026 12:01:17 +0200 Subject: [PATCH 3/5] WIP --- .github/workflows/style-check.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/style-check.yml b/.github/workflows/style-check.yml index 5fa1007b1..4cccce17d 100644 --- a/.github/workflows/style-check.yml +++ b/.github/workflows/style-check.yml @@ -43,6 +43,7 @@ jobs: -DBUILD_TESTS=ON \ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ - -DCMAKE_CXX_FLAGS='-march=tigerlake' + -DCMAKE_CXX_FLAGS='-march=tigerlake' \ + . - name: Check run: run-clang-tidy -p _build From 3885e64789fea09614096ebb28a353190b723f51 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Mon, 20 Apr 2026 12:17:07 +0200 Subject: [PATCH 4/5] WIP --- include/xsimd/config/xsimd_arch.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/xsimd/config/xsimd_arch.hpp b/include/xsimd/config/xsimd_arch.hpp index 9084d2d34..a4013b86c 100644 --- a/include/xsimd/config/xsimd_arch.hpp +++ b/include/xsimd/config/xsimd_arch.hpp @@ -52,7 +52,7 @@ namespace xsimd template struct contains : std::conditional_t::value, std::true_type, - contains> + contains> { }; From c2174fed151545d87cc7995ee9f6d4adc0fcfb1a Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Mon, 20 Apr 2026 12:52:01 +0200 Subject: [PATCH 5/5] WIP --- .github/workflows/style-check.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/style-check.yml b/.github/workflows/style-check.yml index 4cccce17d..f308b99eb 100644 --- a/.github/workflows/style-check.yml +++ b/.github/workflows/style-check.yml @@ -38,12 +38,13 @@ jobs: - uses: actions/checkout@v6 - run: sudo apt install clang-tidy - name: Configure - run: cmake -B _build \ - -DCMAKE_CXX_COMPILER=clang++ \ - -DBUILD_TESTS=ON \ - -DCMAKE_BUILD_TYPE=Debug \ - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ - -DCMAKE_CXX_FLAGS='-march=tigerlake' \ + run: cmake -B _build + -DCMAKE_CXX_COMPILER=clang++ + -DBUILD_TESTS=ON + -DDOWNLOAD_DOCTEST=ON + -DCMAKE_BUILD_TYPE=Debug + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON + -DCMAKE_CXX_FLAGS='-march=tigerlake' . - name: Check run: run-clang-tidy -p _build