From eef2976dfa3f6b07e746ec3885ad5b9e61252b7d Mon Sep 17 00:00:00 2001 From: Laurynas Biveinis Date: Tue, 24 Sep 2024 11:34:03 +0300 Subject: [PATCH] Add LLVM 19 support - Add missing template arguments to make_db_inode_reclaimable_ptr calls - Suppress what appears to be false positive diagnostics about C-style casts - Suppress -Wpedantic warning in TYPED_TEST_SUITE definition in Google Test - include-what-you-use pragma tweaks - Bump main GitHub Actions and CircleCI jobs to LLVM 19 - Add LLVM 18 to old-compilers.yml GitHub Action --- .circleci/config.yml | 28 +++++++-------- .clang-tidy | 4 ++- .github/workflows/build.yml | 34 +++++++++--------- .github/workflows/old-compilers.yml | 54 +++++++++++++++++++++++++++++ art.cpp | 1 + art_internal.hpp | 1 + art_internal_impl.hpp | 26 +++++++------- olc_art.cpp | 1 + test/gtest_utils.hpp | 4 ++- 9 files changed, 107 insertions(+), 46 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 305b4b49..c28734d7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,11 +51,11 @@ jobs: curl 'https://apt.llvm.org/llvm-snapshot.gpg.key' \ | sudo apt-key add - echo \ - 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' \ + 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main' \ | sudo tee -a /etc/apt/sources.list sudo apt-get update - sudo NEEDRESTART_MODE=a apt-get install -y clang-18 \ - clang-tidy-18 iwyu + sudo NEEDRESTART_MODE=a apt-get install -y clang-19 \ + clang-tidy-19 iwyu - when: condition: and: @@ -65,8 +65,8 @@ jobs: - run: name: Installing dependencies (LLVM Release) command: | - sudo NEEDRESTART_MODE=a apt-get install -y libomp5-18 \ - llvm-18 lld-18 + sudo NEEDRESTART_MODE=a apt-get install -y libomp5-19 \ + llvm-19 lld-19 - run: name: Create build environment command: mkdir build @@ -85,7 +85,7 @@ jobs: export CXX=g++-$V EXTRA_CMAKE_ARGS=() elif [[ $COMPILER == "clang" ]]; then - V=18 + V=19 export CC=clang-$V export CXX=clang++-$V if [[ $BUILD_TYPE == "Release" ]]; then @@ -179,40 +179,40 @@ workflows: compiler: gcc ubsan: true - build: - name: clang 18 Debug + name: clang 19 Debug build_type: Debug compiler: clang - build: - name: clang 18 Debug with ASan + name: clang 19 Debug with ASan build_type: Debug compiler: clang asan: true - build: - name: clang 18 Debug with TSan + name: clang 19 Debug with TSan build_type: Debug compiler: clang tsan: true - build: - name: clang 18 Debug with UBSan + name: clang 19 Debug with UBSan build_type: Debug compiler: clang ubsan: true - build: - name: clang 18 Release + name: clang 19 Release build_type: Release compiler: clang - build: - name: clang 18 Release with ASan + name: clang 19 Release with ASan build_type: Release compiler: clang asan: true - build: - name: clang 18 Release with TSan + name: clang 19 Release with TSan build_type: Release compiler: clang tsan: true - build: - name: clang 18 Release with UBSan + name: clang 19 Release with UBSan build_type: Release compiler: clang ubsan: true diff --git a/.clang-tidy b/.clang-tidy index 5eecbcf4..4974d1e0 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,6 +3,8 @@ # clang-analyzer-unix.Malloc: # clang static analysis is run separately from clang-tidy, and this one gives # false positives under clang-tidy. +# - boost-use-ranges: will switch to C++ standard ranges instead, no need to +# deepen the Boost dependency meanwhile. # - bugprone-easily-swappable-parameters: too many suppressions for otherwise # unfixable signatures # - cppcoreguidelines-avoid-c-arrays: duplicated by modernize-avoid-c-arrays @@ -16,7 +18,7 @@ # - hicpp-no-assembler: Valgrind client requests # - modernize-use-equals-default: until foo() noexcept = default is accepted by # clang -Checks: '*,-altera-id-dependent-backward-branch,-altera-struct-pack-align,-altera-unroll-loops,-bugprone-easily-swappable-parameters,-bugprone-use-after-move,-clang-diagnostic-error,-clang-analyzer-core.CallAndMessage,-clang-analyzer-core.NonNullParamChecker,-clang-analyzer-cplusplus.Move,-clang-analyzer-unix.Malloc,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-init-variables,-cppcoreguidelines-macro-usage,-cppcoreguidelines-non-private-member-variables-in-classes,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-cstyle-cast,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-union-access,-fuchsia-default-arguments-calls,-fuchsia-default-arguments-declarations,-fuchsia-overloaded-operator,-google-readability-braces-around-statements,-google-runtime-references,-hicpp-avoid-c-arrays,-hicpp-braces-around-statements,-hicpp-explicit-conversions,-hicpp-invalid-access-moved,-hicpp-member-init,-hicpp-named-parameter,-hicpp-no-array-decay,-hicpp-no-assembler,-hicpp-use-equals-default,-llvm-include-order,-llvmlibc*,-misc-no-recursion,-misc-non-private-member-variables-in-classes,-modernize-use-equals-default,-modernize-use-trailing-return-type,-portability-simd-intrinsics,-readability-braces-around-statements,-readability-function-cognitive-complexity,-readability-identifier-length,-readability-named-parameter,-readability-magic-numbers' +Checks: '*,-altera-id-dependent-backward-branch,-altera-struct-pack-align,-altera-unroll-loops,-boost-use-ranges,-bugprone-easily-swappable-parameters,-bugprone-use-after-move,-clang-diagnostic-error,-clang-analyzer-core.CallAndMessage,-clang-analyzer-core.NonNullParamChecker,-clang-analyzer-cplusplus.Move,-clang-analyzer-unix.Malloc,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-init-variables,-cppcoreguidelines-macro-usage,-cppcoreguidelines-non-private-member-variables-in-classes,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-cstyle-cast,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-union-access,-fuchsia-default-arguments-calls,-fuchsia-default-arguments-declarations,-fuchsia-overloaded-operator,-google-readability-braces-around-statements,-google-runtime-references,-hicpp-avoid-c-arrays,-hicpp-braces-around-statements,-hicpp-explicit-conversions,-hicpp-invalid-access-moved,-hicpp-member-init,-hicpp-named-parameter,-hicpp-no-array-decay,-hicpp-no-assembler,-hicpp-use-equals-default,-llvm-include-order,-llvmlibc*,-misc-no-recursion,-misc-non-private-member-variables-in-classes,-modernize-use-equals-default,-modernize-use-trailing-return-type,-portability-simd-intrinsics,-readability-braces-around-statements,-readability-function-cognitive-complexity,-readability-identifier-length,-readability-named-parameter,-readability-magic-numbers' WarningsAsErrors: '*' CheckOptions: - key: performance-unnecessary-value-param.AllowedTypes diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db0be124..ecb2faff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -97,59 +97,59 @@ jobs: os: ubuntu-22.04 COMPILER: gcc - - name: clang 18 Release + - name: clang 19 Release os: ubuntu-22.04 BUILD_TYPE: Release COMPILER: clang - - name: clang 18 Release with ASan + - name: clang 19 Release with ASan os: ubuntu-22.04 BUILD_TYPE: Release SANITIZE_ADDRESS: ON COMPILER: clang - - name: clang 18 Release with TSan + - name: clang 19 Release with TSan os: ubuntu-22.04 BUILD_TYPE: Release SANITIZE_THREAD: ON COMPILER: clang - - name: clang 18 Release with UBSan + - name: clang 19 Release with UBSan os: ubuntu-22.04 BUILD_TYPE: Release SANITIZE_UB: ON COMPILER: clang - - name: clang 18 Debug + - name: clang 19 Debug os: ubuntu-22.04 BUILD_TYPE: Debug COMPILER: clang - - name: clang 18 Debug with ASan + - name: clang 19 Debug with ASan os: ubuntu-22.04 BUILD_TYPE: Debug SANITIZE_ADDRESS: ON COMPILER: clang - - name: clang 18 Debug with TSan + - name: clang 19 Debug with TSan os: ubuntu-22.04 BUILD_TYPE: Debug SANITIZE_THREAD: ON COMPILER: clang - - name: clang 18 Debug with UBSan + - name: clang 19 Debug with UBSan os: ubuntu-22.04 BUILD_TYPE: Debug SANITIZE_UB: ON COMPILER: clang - - name: clang 18 Release static analysis + - name: clang 19 Release static analysis os: ubuntu-22.04 BUILD_TYPE: Release COMPILER: clang STATIC_ANALYSIS: ON - - name: clang 18 Debug static analysis + - name: clang 19 Debug static analysis os: ubuntu-22.04 BUILD_TYPE: Debug COMPILER: clang @@ -306,26 +306,26 @@ jobs: run: | curl 'https://apt.llvm.org/llvm-snapshot.gpg.key' \ | sudo apt-key add - - echo 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' \ + echo 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main' \ | sudo tee -a /etc/apt/sources.list sudo apt-get update - sudo apt-get install -y clang-18 iwyu + sudo apt-get install -y clang-19 iwyu if: runner.os == 'Linux' && env.COMPILER == 'clang' - name: Setup dependencies for Linux LLVM (Release) - run: sudo apt-get install -y libomp5-18 llvm-18 lld-18 + run: sudo apt-get install -y libomp5-19 llvm-19 lld-19 if: > runner.os == 'Linux' && env.COMPILER == 'clang' && env.BUILD_TYPE == 'Release' - name: Setup dependencies for Linux LLVM (static analysis) - run: sudo apt-get install -y clang-tools-18 + run: sudo apt-get install -y clang-tools-19 if: > runner.os == 'Linux' && env.COMPILER == 'clang' && env.STATIC_ANALYSIS == 'ON' - name: Setup dependencies for Linux LLVM (not static analysis) - run: sudo apt-get install -y clang-tidy-18 + run: sudo apt-get install -y clang-tidy-19 if: > runner.os == 'Linux' && env.COMPILER == 'clang' && env.STATIC_ANALYSIS != 'ON' @@ -377,7 +377,7 @@ jobs: export CC=gcc-$V export CXX=g++-$V elif [[ $COMPILER == "clang" ]]; then - V=18 + V=19 export CC=clang-$V export CXX=clang++-$V if [[ $BUILD_TYPE == "Release" ]]; then @@ -418,7 +418,7 @@ jobs: - name: clang static analysis working-directory: ${{github.workspace}}/build run: | - /usr/bin/scan-build-18 --status-bugs -stats -analyze-headers \ + /usr/bin/scan-build-19 --status-bugs -stats -analyze-headers \ --force-analyze-debug-code make -j3; if: env.STATIC_ANALYSIS == 'ON' && env.COMPILER == 'clang' diff --git a/.github/workflows/old-compilers.yml b/.github/workflows/old-compilers.yml index a9a44a16..29807289 100644 --- a/.github/workflows/old-compilers.yml +++ b/.github/workflows/old-compilers.yml @@ -404,6 +404,60 @@ jobs: COMPILER: clang VERSION: 17 + - name: clang 18 Release + os: ubuntu-22.04 + BUILD_TYPE: Release + COMPILER: clang + VERSION: 18 + + - name: clang 18 Release with ASan + os: ubuntu-22.04 + BUILD_TYPE: Release + SANITIZE_ADDRESS: ON + COMPILER: clang + VERSION: 18 + + - name: clang 18 Release with TSan + os: ubuntu-22.04 + BUILD_TYPE: Release + SANITIZE_THREAD: ON + COMPILER: clang + VERSION: 18 + + - name: clang 18 Release with UBSan + os: ubuntu-22.04 + BUILD_TYPE: Release + SANITIZE_UB: ON + COMPILER: clang + VERSION: 18 + + - name: clang 18 Debug + os: ubuntu-22.04 + BUILD_TYPE: Debug + COMPILER: clang + VERSION: 18 + + - name: clang 18 Debug with ASan + os: ubuntu-22.04 + BUILD_TYPE: Debug + SANITIZE_ADDRESS: ON + COMPILER: clang + VERSION: 18 + + - name: clang 18 Debug with TSan + os: ubuntu-22.04 + BUILD_TYPE: Debug + SANITIZE_THREAD: ON + COMPILER: clang + VERSION: 18 + + - name: clang 18 Debug with UBSan + os: ubuntu-22.04 + BUILD_TYPE: Debug + SANITIZE_UB: ON + COMPILER: clang + VERSION: 18 + - name: GCC 10 Release os: ubuntu-22.04 BUILD_TYPE: Release diff --git a/art.cpp b/art.cpp index 8fc8e406..b9371eb9 100644 --- a/art.cpp +++ b/art.cpp @@ -273,6 +273,7 @@ template constexpr void db::account_growing_inode() noexcept { static_assert(NodeType != node_type::LEAF); + // NOLINTNEXTLINE(google-readability-casting) ++growing_inode_counts[internal_as_i]; UNODB_DETAIL_ASSERT(growing_inode_counts[internal_as_i] >= node_counts[as_i]); diff --git a/art_internal.hpp b/art_internal.hpp index bf86b0c8..805736a2 100644 --- a/art_internal.hpp +++ b/art_internal.hpp @@ -5,6 +5,7 @@ #include "global.hpp" // IWYU pragma: no_include <__fwd/ostream.h> +// IWYU pragma: no_include <_string.h> #include #include diff --git a/art_internal_impl.hpp b/art_internal_impl.hpp index e10f9600..9cb9a5db 100644 --- a/art_internal_impl.hpp +++ b/art_internal_impl.hpp @@ -1,4 +1,4 @@ -// Copyright 2019-2023 Laurynas Biveinis +// Copyright 2019-2024 Laurynas Biveinis #ifndef UNODB_DETAIL_ART_INTERNAL_IMPL_HPP #define UNODB_DETAIL_ART_INTERNAL_IMPL_HPP @@ -855,8 +855,8 @@ class basic_inode_4 : public basic_inode_4_parent { constexpr void init(db &db_instance, inode16_type &source_node, std::uint8_t child_to_delete) { const auto reclaim_source_node{ - ArtPolicy::template make_db_inode_reclaimable_ptr(&source_node, - db_instance)}; + ArtPolicy::template make_db_inode_reclaimable_ptr( + &source_node, db_instance)}; auto source_keys_itr = source_node.keys.byte_array.cbegin(); auto keys_itr = keys.byte_array.begin(); auto source_children_itr = source_node.children.cbegin(); @@ -1188,8 +1188,8 @@ class basic_inode_16 : public basic_inode_16_parent { constexpr void init(db &db_instance, inode4_type &source_node, db_leaf_unique_ptr child, tree_depth depth) noexcept { const auto reclaim_source_node{ - ArtPolicy::template make_db_inode_reclaimable_ptr(&source_node, - db_instance)}; + ArtPolicy::template make_db_inode_reclaimable_ptr( + &source_node, db_instance)}; const auto key_byte = static_cast(child->get_key()[depth]); #ifdef UNODB_DETAIL_X86_64 @@ -1225,8 +1225,8 @@ class basic_inode_16 : public basic_inode_16_parent { constexpr void init(db &db_instance, inode48_type &source_node, std::uint8_t child_to_delete) noexcept { const auto reclaim_source_node{ - ArtPolicy::template make_db_inode_reclaimable_ptr(&source_node, - db_instance)}; + ArtPolicy::template make_db_inode_reclaimable_ptr( + &source_node, db_instance)}; source_node.remove_child_pointer(child_to_delete, db_instance); source_node.child_indexes[child_to_delete] = inode48_type::empty_child; @@ -1485,8 +1485,8 @@ class basic_inode_48 : public basic_inode_48_parent { constexpr void init(db &db_instance, inode16_type &__restrict source_node, db_leaf_unique_ptr child, tree_depth depth) noexcept { const auto reclaim_source_node{ - ArtPolicy::template make_db_inode_reclaimable_ptr(&source_node, - db_instance)}; + ArtPolicy::template make_db_inode_reclaimable_ptr( + &source_node, db_instance)}; auto *const __restrict child_ptr = child.release(); // TODO(laurynas): consider AVX512 scatter? @@ -1517,8 +1517,8 @@ class basic_inode_48 : public basic_inode_48_parent { constexpr void init(db &db_instance, inode256_type &__restrict source_node, std::uint8_t child_to_delete) noexcept { const auto reclaim_source_node{ - ArtPolicy::template make_db_inode_reclaimable_ptr(&source_node, - db_instance)}; + ArtPolicy::template make_db_inode_reclaimable_ptr( + &source_node, db_instance)}; const auto r{ArtPolicy::reclaim_leaf_on_scope_exit( source_node.children[child_to_delete] .load() @@ -1875,8 +1875,8 @@ class basic_inode_256 : public basic_inode_256_parent { constexpr void init(db &db_instance, inode48_type &__restrict source_node, db_leaf_unique_ptr child, tree_depth depth) noexcept { const auto reclaim_source_node{ - ArtPolicy::template make_db_inode_reclaimable_ptr(&source_node, - db_instance)}; + ArtPolicy::template make_db_inode_reclaimable_ptr( + &source_node, db_instance)}; unsigned children_copied = 0; unsigned i = 0; while (true) { diff --git a/olc_art.cpp b/olc_art.cpp index 4b7305fd..45a0ec91 100644 --- a/olc_art.cpp +++ b/olc_art.cpp @@ -796,6 +796,7 @@ template constexpr void olc_db::account_growing_inode() noexcept { static_assert(NodeType != node_type::LEAF); + // NOLINTNEXTLINE(google-readability-casting) growing_inode_counts[internal_as_i].fetch_add( 1, std::memory_order_relaxed); } diff --git a/test/gtest_utils.hpp b/test/gtest_utils.hpp index e13b2206..136758ee 100644 --- a/test/gtest_utils.hpp +++ b/test/gtest_utils.hpp @@ -1,4 +1,4 @@ -// Copyright 2021-2022 Laurynas Biveinis +// Copyright 2021-2024 Laurynas Biveinis #ifndef UNODB_DETAIL_GTEST_UTILS_HPP #define UNODB_DETAIL_GTEST_UTILS_HPP @@ -15,7 +15,9 @@ // is not a bug: https://github.com/google/googletest/issues/2271 #define UNODB_TYPED_TEST_SUITE(Suite, Types) \ UNODB_DETAIL_DISABLE_CLANG_WARNING("-Wgnu-zero-variadic-macro-arguments") \ + UNODB_DETAIL_DISABLE_CLANG_WARNING("-Wpedantic") \ TYPED_TEST_SUITE(Suite, Types); \ + UNODB_DETAIL_RESTORE_CLANG_WARNINGS() \ UNODB_DETAIL_RESTORE_CLANG_WARNINGS() #define UNODB_START_TESTS() \