From a68384f9845201fe0123320d45bcf076b0a14c5d Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Wed, 23 Oct 2024 14:45:28 -0600 Subject: [PATCH] :rotating_light: Updates for fixed clang-tidy --- .github/workflows/unit_tests.yml | 60 ++++++++++++++++++++------------ .gitignore | 3 +- include/stdx/atomic.hpp | 5 ++- include/stdx/atomic_bitset.hpp | 1 + include/stdx/bit.hpp | 9 ++--- include/stdx/compiler.hpp | 4 +++ include/stdx/panic.hpp | 4 +++ include/stdx/udls.hpp | 4 +++ include/stdx/utility.hpp | 6 +++- requirements.txt | 11 ------ 10 files changed, 66 insertions(+), 41 deletions(-) delete mode 100644 requirements.txt diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 2e6e771..9384176 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -100,11 +100,6 @@ jobs: run: | ${{ matrix.install }} sudo apt install -y ninja-build python3-venv python3-pip - python3 -m venv ${{github.workspace}}/test_venv - source ${{github.workspace}}/test_venv/bin/activate - pip install -r ${{github.workspace}}/requirements.txt - echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH - - name: Restore CPM cache env: @@ -132,6 +127,13 @@ jobs: path: ~/cpm-cache key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} + - name: Install python test requirements + run: | + python3 -m venv ${{github.workspace}}/test_venv + source ${{github.workspace}}/test_venv/bin/activate + pip install -r ${{github.workspace}}/requirements.txt + echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH + - name: Build Unit Tests run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -v -t build_unit_tests @@ -184,10 +186,6 @@ jobs: run: | ${{ matrix.install }} sudo apt install -y ninja-build python3-venv python3-pip - python3 -m venv ${{github.workspace}}/test_venv - source ${{github.workspace}}/test_venv/bin/activate - pip install -r ${{github.workspace}}/requirements.txt - echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH - name: Restore CPM cache env: @@ -215,6 +213,13 @@ jobs: path: ~/cpm-cache key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} + - name: Install python test requirements + run: | + python3 -m venv ${{github.workspace}}/test_venv + source ${{github.workspace}}/test_venv/bin/activate + pip install -r ${{github.workspace}}/requirements.txt + echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH + - name: Build Unit Tests run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -v -t build_unit_tests @@ -263,7 +268,7 @@ jobs: CC: "/usr/lib/llvm-${{env.DEFAULT_LLVM_VERSION}}/bin/clang" CXX: "/usr/lib/llvm-${{env.DEFAULT_LLVM_VERSION}}/bin/clang++" PR_TARGET_BRANCH: ${{ steps.target_branch.outputs.branch }} - run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=${{env.DEFAULT_CXX_STANDARD}} -DCPM_SOURCE_CACHE=~/cpm-cache + run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=17 -DCPM_SOURCE_CACHE=~/cpm-cache - name: Save CPM cache env: @@ -303,10 +308,6 @@ jobs: run: | ${{ matrix.install }} sudo apt install -y ninja-build python3-venv python3-pip - python3 -m venv ${{github.workspace}}/test_venv - source ${{github.workspace}}/test_venv/bin/activate - pip install -r ${{github.workspace}}/requirements.txt - echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH - name: Restore CPM cache env: @@ -335,6 +336,13 @@ jobs: path: ~/cpm-cache key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} + - name: Install python test requirements + run: | + python3 -m venv ${{github.workspace}}/test_venv + source ${{github.workspace}}/test_venv/bin/activate + pip install -r ${{github.workspace}}/requirements.txt + echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH + # https://github.com/actions/runner-images/issues/9524 - name: Fix kernel mmap rnd bits # Asan in llvm 14 provided in ubuntu 22.04 is incompatible with @@ -353,10 +361,6 @@ jobs: - name: Install build tools run: | sudo apt update && sudo apt install -y gcc-${{env.DEFAULT_GCC_VERSION}} g++-${{env.DEFAULT_GCC_VERSION}} ninja-build valgrind python3-venv python3-pip - python3 -m venv ${{github.workspace}}/test_venv - source ${{github.workspace}}/test_venv/bin/activate - pip install -r ${{github.workspace}}/requirements.txt - echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH - name: Restore CPM cache env: @@ -384,6 +388,13 @@ jobs: path: ~/cpm-cache key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} + - name: Install python test requirements + run: | + python3 -m venv ${{github.workspace}}/test_venv + source ${{github.workspace}}/test_venv/bin/activate + pip install -r ${{github.workspace}}/requirements.txt + echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH + - name: Build Unit Tests run: cmake --build ${{github.workspace}}/build -t build_unit_tests @@ -428,10 +439,6 @@ jobs: - name: Install build tools run: | sudo apt update && sudo apt install -y clang-${{env.MULL_LLVM_VERSION}} ninja-build python3-venv python3-pip - python3 -m venv ${{github.workspace}}/test_venv - source ${{github.workspace}}/test_venv/bin/activate - pip install -r ${{github.workspace}}/requirements.txt - echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH - name: Install mull env: @@ -466,12 +473,19 @@ jobs: path: ~/cpm-cache key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} + - name: Install python test requirements + run: | + python3 -m venv ${{github.workspace}}/test_venv + source ${{github.workspace}}/test_venv/bin/activate + pip install -r ${{github.workspace}}/requirements.txt + echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH + - name: Build and run mull tests run: cmake --build build -t mull_tests merge_ok: runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04 - needs: [build_and_test_24, build_and_test_22, quality_checks_pass, sanitize, valgrind] + needs: [build_and_test_24, build_and_test_22, mutate, quality_checks_pass, sanitize, valgrind] if: ${{ !cancelled() }} steps: - name: Enable merge diff --git a/.gitignore b/.gitignore index 29c2d78..150fbd2 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ CMakePresets.json __pycache__ .mypy_cache .pytest_cache -.hypothesis \ No newline at end of file +.hypothesis +requirements.txt diff --git a/include/stdx/atomic.hpp b/include/stdx/atomic.hpp index dc81f64..76f3835 100644 --- a/include/stdx/atomic.hpp +++ b/include/stdx/atomic.hpp @@ -13,6 +13,7 @@ namespace stdx { inline namespace v1 { +// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) template class atomic { static_assert(std::is_trivially_copyable_v and std::is_copy_constructible_v and @@ -39,7 +40,7 @@ template class atomic { constexpr atomic() CPP20(requires std::is_default_constructible_v) : value{} {} - constexpr atomic(T t) : value{static_cast(t)} {} + constexpr explicit atomic(T t) : value{static_cast(t)} {} atomic(atomic const &) = delete; auto operator=(atomic const &) -> atomic & = delete; @@ -52,7 +53,9 @@ template class atomic { ::atomic::store(value, static_cast(t), mo); } + // NOLINTNEXTLINE(google-explicit-constructor) [[nodiscard]] operator T() const { return load(); } + // NOLINTNEXTLINE(misc-unconventional-assign-operator) auto operator=(T t) -> T { store(t); return t; diff --git a/include/stdx/atomic_bitset.hpp b/include/stdx/atomic_bitset.hpp index b4280b8..139c7c1 100644 --- a/include/stdx/atomic_bitset.hpp +++ b/include/stdx/atomic_bitset.hpp @@ -102,6 +102,7 @@ class atomic_bitset { return static_cast(salient_value(order)); } + // NOLINTNEXTLINE(google-explicit-constructor) operator bitset_t() const { return bitset_t{salient_value(std::memory_order_seq_cst)}; } diff --git a/include/stdx/bit.hpp b/include/stdx/bit.hpp index b792e83..8248194 100644 --- a/include/stdx/bit.hpp +++ b/include/stdx/bit.hpp @@ -19,7 +19,8 @@ inline namespace v1 { // endian #if __cpp_lib_endian < 201907L -enum struct endian { +// NOLINTNEXTLINE(performance-enum-size) +enum struct endian : underlying_type_t { little = __ORDER_LITTLE_ENDIAN__, big = __ORDER_BIG_ENDIAN__, native = __BYTE_ORDER__ @@ -262,14 +263,14 @@ constexpr auto bit_pack = [](auto... args) { }; template <> -constexpr auto bit_pack = +constexpr inline auto bit_pack = [](std::uint8_t hi, std::uint8_t lo) -> std::uint16_t { return static_cast((static_cast(hi) << 8u) | lo); }; template <> -constexpr auto bit_pack = +constexpr inline auto bit_pack = stdx::overload{[](std::uint16_t hi, std::uint16_t lo) -> std::uint32_t { return (static_cast(hi) << 16u) | lo; }, @@ -281,7 +282,7 @@ constexpr auto bit_pack = }}; template <> -constexpr auto bit_pack = +constexpr inline auto bit_pack = stdx::overload{[](std::uint32_t hi, std::uint32_t lo) -> std::uint64_t { return (static_cast(hi) << 32u) | lo; }, diff --git a/include/stdx/compiler.hpp b/include/stdx/compiler.hpp index 4b08cb6..80760d7 100644 --- a/include/stdx/compiler.hpp +++ b/include/stdx/compiler.hpp @@ -1,5 +1,7 @@ #pragma once +// NOLINTBEGIN(cppcoreguidelines-macro-usage) + #ifndef CONSTINIT #ifndef __cpp_constinit #if defined(__clang__) @@ -50,3 +52,5 @@ #else #define STDX_PRAGMA(X) STDX_DO_PRAGMA(GCC X) #endif + +// NOLINTEND(cppcoreguidelines-macro-usage) diff --git a/include/stdx/panic.hpp b/include/stdx/panic.hpp index f305891..c0ca44d 100644 --- a/include/stdx/panic.hpp +++ b/include/stdx/panic.hpp @@ -31,6 +31,8 @@ auto panic(Args &&...args) -> void { } // namespace v1 } // namespace stdx +// NOLINTBEGIN(cppcoreguidelines-macro-usage) + #if __cplusplus >= 202002L #define STDX_PANIC(MSG, ...) \ [] { \ @@ -40,3 +42,5 @@ auto panic(Args &&...args) -> void { #else #define STDX_PANIC(...) stdx::panic(__VA_ARGS__) #endif + +// NOLINTEND(cppcoreguidelines-macro-usage) diff --git a/include/stdx/udls.hpp b/include/stdx/udls.hpp index f108784..c4c76fb 100644 --- a/include/stdx/udls.hpp +++ b/include/stdx/udls.hpp @@ -84,6 +84,8 @@ operator""_Gi(unsigned long long int n) -> unsigned long long int { return n * 1'024ull * 1'024ull * 1'024ull; } +// NOLINTBEGIN(cppcoreguidelines-macro-usage) + #define STDX_SMALL_INT_LITERAL_DEF(x) \ CONSTEVAL auto operator""_##x(char const *, std::size_t) \ ->std::integral_constant { \ @@ -103,6 +105,8 @@ STDX_SMALL_INT_LITERAL_DEF(9) #undef STDX_SMALL_INT_LITERAL_DEF +// NOLINTEND(cppcoreguidelines-macro-usage) + // NOLINTEND(google-runtime-int) } // namespace literals diff --git a/include/stdx/utility.hpp b/include/stdx/utility.hpp index 66b9cab..9f73c61 100644 --- a/include/stdx/utility.hpp +++ b/include/stdx/utility.hpp @@ -78,7 +78,7 @@ template if constexpr (t_is_const) { return std::as_const(u); } else { - return static_cast(u); + return (u); } } else { if constexpr (t_is_const) { @@ -182,6 +182,8 @@ constexpr auto is_aligned_with = [](auto v) -> bool { } // namespace v1 } // namespace stdx +// NOLINTBEGIN(cppcoreguidelines-macro-usage) + #ifndef FWD #define FWD(x) std::forward(x) #endif @@ -217,3 +219,5 @@ constexpr auto is_aligned_with = [](auto v) -> bool { STDX_PRAGMA(diagnostic pop) \ }() #endif + +// NOLINTEND(cppcoreguidelines-macro-usage) diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 19a90b9..0000000 --- a/requirements.txt +++ /dev/null @@ -1,11 +0,0 @@ -pytest==8.3.3 -pytest-forked==1.6.0 -pytest-xdist==3.6.1 -hypothesis==6.112.5 -attrs==24.2.0 -execnet==2.1.1 -pluggy==1.5.0 -sortedcontainers==2.4.0 -iniconfig==2.0.0 -packaging==24.1 -py==1.11.0 \ No newline at end of file