diff --git a/.clang-format b/.clang-format index 757abe0b1..3437c0e6e 100644 --- a/.clang-format +++ b/.clang-format @@ -5,7 +5,6 @@ BasedOnStyle: Mozilla Standard: c++17 AccessModifierOffset: -4 AllowAllArgumentsOnNextLine: false -AllowAllConstructorInitializersOnNextLine: false AlwaysBreakAfterReturnType: All BreakBeforeBraces: Allman ColumnLimit: 120 @@ -13,6 +12,7 @@ ContinuationIndentWidth: 8 FixNamespaceComments: true IndentPPDirectives: BeforeHash IndentWidth: 4 +PackConstructorInitializers: Never ReflowComments: true SpaceAfterTemplateKeyword: true SpaceInEmptyBlock: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a096f4906..12eb17f2a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,7 +15,7 @@ concurrency: jobs: clangformat: name: "Clang-Format" - runs-on: ubuntu-20.04 # Keep Ubuntu 20.04 until raising the requirements to clang-format > 10 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 diff --git a/benchmarks/stdgpu/unordered_datastructure.inc b/benchmarks/stdgpu/unordered_datastructure.inc index a6f86cf93..371d08bf8 100644 --- a/benchmarks/stdgpu/unordered_datastructure.inc +++ b/benchmarks/stdgpu/unordered_datastructure.inc @@ -80,9 +80,10 @@ create_values(const stdgpu::index_t N) benchmark_unordered_datastructure::key_type* host_keys = createHostArray(N); - std::generate(host_keys, host_keys + N, [&dist, &rng]() { - return benchmark_unordered_datastructure::key_type(dist(rng), dist(rng), dist(rng)); - }); + std::generate(host_keys, + host_keys + N, + [&dist, &rng]() + { return benchmark_unordered_datastructure::key_type(dist(rng), dist(rng), dist(rng)); }); benchmark_unordered_datastructure::key_type* keys = copyCreateHost2DeviceArray(host_keys, N); @@ -131,8 +132,9 @@ extract_keys(benchmark_unordered_datastructure::value_type* values, const stdgpu } } // namespace -void STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _insert)(benchmark::State& state, - const stdgpu::index_t unordered_size) +void +STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _insert)(benchmark::State& state, + const stdgpu::index_t unordered_size) { // Use larger container to avoid unlikely but possible overflow of excess list benchmark_unordered_datastructure u = benchmark_unordered_datastructure::createDeviceObject(2 * unordered_size); @@ -154,8 +156,9 @@ void STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _insert) destroyDeviceArray(values); } -void STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _erase)(benchmark::State& state, - const stdgpu::index_t unordered_size) +void +STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _erase)(benchmark::State& state, + const stdgpu::index_t unordered_size) { // Use larger container to avoid unlikely but possible overflow of excess list benchmark_unordered_datastructure u = benchmark_unordered_datastructure::createDeviceObject(2 * unordered_size); @@ -178,8 +181,9 @@ void STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _erase)( destroyDeviceArray(keys); } -void STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _clear)(benchmark::State& state, - const stdgpu::index_t unordered_size) +void +STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _clear)(benchmark::State& state, + const stdgpu::index_t unordered_size) { // Use larger container to avoid unlikely but possible overflow of excess list benchmark_unordered_datastructure u = benchmark_unordered_datastructure::createDeviceObject(2 * unordered_size); @@ -200,8 +204,9 @@ void STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _clear)( destroyDeviceArray(values); } -void STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _valid)(benchmark::State& state, - const stdgpu::index_t vector_size) +void +STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _valid)(benchmark::State& state, + const stdgpu::index_t vector_size) { benchmark_unordered_datastructure u = benchmark_unordered_datastructure::createDeviceObject(vector_size); diff --git a/cmake/FindClangFormat.cmake b/cmake/FindClangFormat.cmake index 7d62a47d5..d763ead74 100644 --- a/cmake/FindClangFormat.cmake +++ b/cmake/FindClangFormat.cmake @@ -1,7 +1,7 @@ find_program(CLANG_FORMAT_EXECUTABLE NAMES - "clang-format-10" # Prefer exact version + "clang-format-18" # Prefer exact version "clang-format") if(CLANG_FORMAT_EXECUTABLE) diff --git a/cmake/setup_clang_format.cmake b/cmake/setup_clang_format.cmake index 2bca86baf..f7344937a 100644 --- a/cmake/setup_clang_format.cmake +++ b/cmake/setup_clang_format.cmake @@ -1,8 +1,8 @@ function(stdgpu_setup_clang_format) if(STDGPU_ALLOW_NEWER_CLANG_FORMAT_VERSIONS) - find_package(ClangFormat 10) + find_package(ClangFormat 18) else() - find_package(ClangFormat 10 EXACT) + find_package(ClangFormat 18 EXACT) endif() if (NOT ClangFormat_FOUND) diff --git a/src/stdgpu/bitset.cuh b/src/stdgpu/bitset.cuh index 239e0db9d..4bea95cd2 100644 --- a/src/stdgpu/bitset.cuh +++ b/src/stdgpu/bitset.cuh @@ -95,7 +95,7 @@ public: * \return The old value of the bit */ STDGPU_DEVICE_ONLY bool // NOLINT(misc-unconventional-assign-operator,cppcoreguidelines-c-copy-assignment-signature) - operator=(const reference& x) noexcept; + operator=(const reference & x) noexcept; /** * \brief Deleted move constructor diff --git a/src/stdgpu/impl/functional_detail.h b/src/stdgpu/impl/functional_detail.h index fcb733a2c..f43802528 100644 --- a/src/stdgpu/impl/functional_detail.h +++ b/src/stdgpu/impl/functional_detail.h @@ -115,7 +115,7 @@ identity::operator()(T&& t) const noexcept \ template /* NOLINTNEXTLINE(bugprone-macro-parentheses,misc-macro-parentheses) */ \ inline STDGPU_HOST_DEVICE auto NAME::operator()(T&& lhs, U&& rhs) \ - const->decltype(forward(lhs) OP forward(rhs)) \ + const -> decltype(forward(lhs) OP forward(rhs)) \ { \ return forward(lhs) OP forward(rhs); \ } diff --git a/src/stdgpu/impl/memory_detail.h b/src/stdgpu/impl/memory_detail.h index 4dca683e1..d2f7b6723 100644 --- a/src/stdgpu/impl/memory_detail.h +++ b/src/stdgpu/impl/memory_detail.h @@ -454,10 +454,12 @@ device_unique_object::device_unique_object(null_object_t /*null_object*/) template template device_unique_object::device_unique_object(Args&&... args) - : _object(new T(T::createDeviceObject(std::forward(args)...)), [](T* ptr) { - T::destroyDeviceObject(*ptr); - delete ptr; - }) + : _object(new T(T::createDeviceObject(std::forward(args)...)), + [](T* ptr) + { + T::destroyDeviceObject(*ptr); + delete ptr; + }) { } @@ -467,7 +469,8 @@ template >)> device_unique_object::device_unique_object(ExecutionPolicy&& policy, Args&&... args) : _object(new T(T::createDeviceObject(std::forward(policy), std::forward(args)...)), - [_policy = std::forward(policy)](T* ptr) { + [_policy = std::forward(policy)](T* ptr) + { T::destroyDeviceObject(_policy, *ptr); delete ptr; }) diff --git a/src/stdgpu/impl/type_traits_detail.h b/src/stdgpu/impl/type_traits_detail.h index 40f0711f4..57e103360 100644 --- a/src/stdgpu/impl/type_traits_detail.h +++ b/src/stdgpu/impl/type_traits_detail.h @@ -64,10 +64,7 @@ STDGPU_DETAIL_DEFINE_TRAIT(is_iterator, STDGPU_DETAIL_DEFINE_TRAIT(is_transparent, typename T::is_transparent) STDGPU_DETAIL_DEFINE_TRAIT(has_get, decltype(std::declval().get())) -STDGPU_DETAIL_DEFINE_TRAIT(has_arrow_operator, - decltype(std::declval() - . - operator->())) +STDGPU_DETAIL_DEFINE_TRAIT(has_arrow_operator, decltype(std::declval().operator->())) STDGPU_DETAIL_DEFINE_TRAIT(is_disabled, typename T::is_disabled) diff --git a/src/stdgpu/memory.h b/src/stdgpu/memory.h index 489cc6542..8f8260eba 100644 --- a/src/stdgpu/memory.h +++ b/src/stdgpu/memory.h @@ -347,7 +347,8 @@ class device_unique_object * \brief Checks whether the unique object is not empty * \return True if the unique object is not empty, false otherwise */ - explicit operator bool() const; + explicit + operator bool() const; private: std::unique_ptr> _object; diff --git a/tools/ubuntu/install_clang_format.sh b/tools/ubuntu/install_clang_format.sh index b438bbf02..46a4dcde7 100644 --- a/tools/ubuntu/install_clang_format.sh +++ b/tools/ubuntu/install_clang_format.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e -# Install clang-format version 10 +# Install clang-format version 18 sudo apt-get update -sudo apt-get install clang-format-10 +sudo apt-get install clang-format-18