Skip to content

Commit 8a0abf1

Browse files
committed
General: Upgrade to clang-format 18 style
1 parent 7c47c7a commit 8a0abf1

11 files changed

+36
-30
lines changed

.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ BasedOnStyle: Mozilla
55
Standard: c++17
66
AccessModifierOffset: -4
77
AllowAllArgumentsOnNextLine: false
8-
AllowAllConstructorInitializersOnNextLine: false
98
AlwaysBreakAfterReturnType: All
109
BreakBeforeBraces: Allman
1110
ColumnLimit: 120
1211
ContinuationIndentWidth: 8
1312
FixNamespaceComments: true
1413
IndentPPDirectives: BeforeHash
1514
IndentWidth: 4
15+
PackConstructorInitializers: Never
1616
ReflowComments: true
1717
SpaceAfterTemplateKeyword: true
1818
SpaceInEmptyBlock: true

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ concurrency:
1515
jobs:
1616
clangformat:
1717
name: "Clang-Format"
18-
runs-on: ubuntu-20.04 # Keep Ubuntu 20.04 until raising the requirements to clang-format > 10
18+
runs-on: ubuntu-24.04
1919

2020
steps:
2121
- uses: actions/checkout@v4

benchmarks/stdgpu/unordered_datastructure.inc

+16-11
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ create_values(const stdgpu::index_t N)
8080
benchmark_unordered_datastructure::key_type* host_keys =
8181
createHostArray<benchmark_unordered_datastructure::key_type>(N);
8282

83-
std::generate(host_keys, host_keys + N, [&dist, &rng]() {
84-
return benchmark_unordered_datastructure::key_type(dist(rng), dist(rng), dist(rng));
85-
});
83+
std::generate(host_keys,
84+
host_keys + N,
85+
[&dist, &rng]()
86+
{ return benchmark_unordered_datastructure::key_type(dist(rng), dist(rng), dist(rng)); });
8687

8788
benchmark_unordered_datastructure::key_type* keys =
8889
copyCreateHost2DeviceArray<benchmark_unordered_datastructure::key_type>(host_keys, N);
@@ -131,8 +132,9 @@ extract_keys(benchmark_unordered_datastructure::value_type* values, const stdgpu
131132
}
132133
} // namespace
133134

134-
void STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _insert)(benchmark::State& state,
135-
const stdgpu::index_t unordered_size)
135+
void
136+
STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _insert)(benchmark::State& state,
137+
const stdgpu::index_t unordered_size)
136138
{
137139
// Use larger container to avoid unlikely but possible overflow of excess list
138140
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)
154156
destroyDeviceArray<benchmark_unordered_datastructure::value_type>(values);
155157
}
156158

157-
void STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _erase)(benchmark::State& state,
158-
const stdgpu::index_t unordered_size)
159+
void
160+
STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _erase)(benchmark::State& state,
161+
const stdgpu::index_t unordered_size)
159162
{
160163
// Use larger container to avoid unlikely but possible overflow of excess list
161164
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)(
178181
destroyDeviceArray<benchmark_unordered_datastructure::key_type>(keys);
179182
}
180183

181-
void STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _clear)(benchmark::State& state,
182-
const stdgpu::index_t unordered_size)
184+
void
185+
STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _clear)(benchmark::State& state,
186+
const stdgpu::index_t unordered_size)
183187
{
184188
// Use larger container to avoid unlikely but possible overflow of excess list
185189
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)(
200204
destroyDeviceArray<benchmark_unordered_datastructure::value_type>(values);
201205
}
202206

203-
void STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _valid)(benchmark::State& state,
204-
const stdgpu::index_t vector_size)
207+
void
208+
STDGPU_DETAIL_CAT2(STDGPU_UNORDERED_DATASTRUCTURE_BENCHMARK_CLASS, _valid)(benchmark::State& state,
209+
const stdgpu::index_t vector_size)
205210
{
206211
benchmark_unordered_datastructure u = benchmark_unordered_datastructure::createDeviceObject(vector_size);
207212

cmake/FindClangFormat.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
find_program(CLANG_FORMAT_EXECUTABLE
33
NAMES
4-
"clang-format-10" # Prefer exact version
4+
"clang-format-18" # Prefer exact version
55
"clang-format")
66

77
if(CLANG_FORMAT_EXECUTABLE)

cmake/setup_clang_format.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
function(stdgpu_setup_clang_format)
22
if(STDGPU_ALLOW_NEWER_CLANG_FORMAT_VERSIONS)
3-
find_package(ClangFormat 10)
3+
find_package(ClangFormat 18)
44
else()
5-
find_package(ClangFormat 10 EXACT)
5+
find_package(ClangFormat 18 EXACT)
66
endif()
77

88
if (NOT ClangFormat_FOUND)

src/stdgpu/bitset.cuh

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public:
9595
* \return The old value of the bit
9696
*/
9797
STDGPU_DEVICE_ONLY bool // NOLINT(misc-unconventional-assign-operator,cppcoreguidelines-c-copy-assignment-signature)
98-
operator=(const reference& x) noexcept;
98+
operator=(const reference & x) noexcept;
9999

100100
/**
101101
* \brief Deleted move constructor

src/stdgpu/impl/functional_detail.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ identity::operator()(T&& t) const noexcept
115115
\
116116
template <typename T, typename U> /* NOLINTNEXTLINE(bugprone-macro-parentheses,misc-macro-parentheses) */ \
117117
inline STDGPU_HOST_DEVICE auto NAME<void>::operator()(T&& lhs, U&& rhs) \
118-
const->decltype(forward<T>(lhs) OP forward<U>(rhs)) \
118+
const -> decltype(forward<T>(lhs) OP forward<U>(rhs)) \
119119
{ \
120120
return forward<T>(lhs) OP forward<U>(rhs); \
121121
}

src/stdgpu/impl/memory_detail.h

+8-5
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,12 @@ device_unique_object<T>::device_unique_object(null_object_t /*null_object*/)
454454
template <typename T>
455455
template <typename... Args>
456456
device_unique_object<T>::device_unique_object(Args&&... args)
457-
: _object(new T(T::createDeviceObject(std::forward<Args>(args)...)), [](T* ptr) {
458-
T::destroyDeviceObject(*ptr);
459-
delete ptr;
460-
})
457+
: _object(new T(T::createDeviceObject(std::forward<Args>(args)...)),
458+
[](T* ptr)
459+
{
460+
T::destroyDeviceObject(*ptr);
461+
delete ptr;
462+
})
461463
{
462464
}
463465

@@ -467,7 +469,8 @@ template <typename ExecutionPolicy,
467469
STDGPU_DETAIL_OVERLOAD_DEFINITION_IF(is_execution_policy_v<remove_cvref_t<ExecutionPolicy>>)>
468470
device_unique_object<T>::device_unique_object(ExecutionPolicy&& policy, Args&&... args)
469471
: _object(new T(T::createDeviceObject(std::forward<ExecutionPolicy>(policy), std::forward<Args>(args)...)),
470-
[_policy = std::forward<ExecutionPolicy>(policy)](T* ptr) {
472+
[_policy = std::forward<ExecutionPolicy>(policy)](T* ptr)
473+
{
471474
T::destroyDeviceObject(_policy, *ptr);
472475
delete ptr;
473476
})

src/stdgpu/impl/type_traits_detail.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ STDGPU_DETAIL_DEFINE_TRAIT(is_iterator,
6464
STDGPU_DETAIL_DEFINE_TRAIT(is_transparent, typename T::is_transparent)
6565

6666
STDGPU_DETAIL_DEFINE_TRAIT(has_get, decltype(std::declval<T>().get()))
67-
STDGPU_DETAIL_DEFINE_TRAIT(has_arrow_operator,
68-
decltype(std::declval<T>()
69-
.
70-
operator->()))
67+
STDGPU_DETAIL_DEFINE_TRAIT(has_arrow_operator, decltype(std::declval<T>().operator->()))
7168

7269
STDGPU_DETAIL_DEFINE_TRAIT(is_disabled, typename T::is_disabled)
7370

src/stdgpu/memory.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ class device_unique_object
347347
* \brief Checks whether the unique object is not empty
348348
* \return True if the unique object is not empty, false otherwise
349349
*/
350-
explicit operator bool() const;
350+
explicit
351+
operator bool() const;
351352

352353
private:
353354
std::unique_ptr<T, std::function<void(T*)>> _object;

tools/ubuntu/install_clang_format.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -e
33

4-
# Install clang-format version 10
4+
# Install clang-format version 18
55
sudo apt-get update
6-
sudo apt-get install clang-format-10
6+
sudo apt-get install clang-format-18

0 commit comments

Comments
 (0)