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..f308b99eb 100644 --- a/.github/workflows/style-check.yml +++ b/.github/workflows/style-check.yml @@ -30,3 +30,21 @@ 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 + -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 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..a4013b86c 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) { }