Skip to content

Commit e90f539

Browse files
committed
apply clang-tidy and clang-format
1 parent 16a9f13 commit e90f539

File tree

158 files changed

+1396
-1212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+1396
-1212
lines changed

.clang-tidy

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
---
2-
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,bugprone-*,modernize-*,-bugprone-reserved-identifier,-bugprone-unchecked-optional-access,-bugprone-macro-parentheses,-bugprone-easily-swappable-parameters'
2+
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,bugprone-*,modernize-*,-bugprone-reserved-identifier,-bugprone-unchecked-optional-access,-bugprone-macro-parentheses,-bugprone-easily-swappable-parameters,-bugprone-dynamic-static-initializers,-modernize-avoid-c-arrays'
33
WarningsAsErrors: ''
44
HeaderFileExtensions:
55
- ''
66
- h
7-
- hh
87
- hpp
9-
- hxx
108
- cuh
119
ImplementationFileExtensions:
1210
- c
13-
- cc
1411
- cpp
15-
- cxx
16-
HeaderFilterRegex: ''
12+
- cu
13+
HeaderFilterRegex: '^.*[.](h|hpp|cuh)$'
14+
ExcludeHeaderFilterRegex: '^.*__system_context_default_impl_entry[.]hpp$'
1715
FormatStyle: none
1816
User: eniebler
17+
ExtraArgsBefore: [
18+
'-DSTDEXEC_SYSTEM_CONTEXT_HEADER_ONLY=1',
19+
'-DSTDEXEC_CLANG_TIDY_INVOKED=1',
20+
]
1921
CheckOptions:
2022
bugprone-argument-comment.CommentFloatLiterals: '0'
2123
bugprone-argument-comment.CommentUserDefinedLiterals: '0'

.clangd

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ CompileFlags:
5252
- "-fmacro-backtrace-limit=0"
5353
- "-ftemplate-backtrace-limit=0"
5454
- "-std=gnu++20"
55+
- "-DSTDEXEC_CLANGD_INVOKED"
5556
Remove:
5657
- "-stdpar*"
5758
# strip CUDA fatbin args

examples/_clangd_helper_file.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@
2828
// than those in the parent (for example, if the subdirectory has a CMakeList.txt that defines additional executables).
2929
// This ensures clangd provides useful intellisense for headers in any subdirectory with a CMakeList.txt.
3030

31-
int main(void) {
31+
auto main() -> int {
3232
}

examples/algorithms/retry.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ template <class S, class R>
5252
struct _retry_receiver : stdexec::receiver_adaptor<_retry_receiver<S, R>> {
5353
_op<S, R>* o_;
5454

55-
R&& base() && noexcept {
55+
auto base() && noexcept -> R&& {
5656
return static_cast<R&&>(o_->r_);
5757
}
5858

59-
const R& base() const & noexcept {
59+
auto base() const & noexcept -> const R& {
6060
return o_->r_;
6161
}
6262

@@ -141,6 +141,6 @@ struct _retry_sender {
141141
};
142142

143143
template <stdexec::sender S>
144-
stdexec::sender auto retry(S s) {
144+
auto retry(S s) -> stdexec::sender auto {
145145
return _retry_sender{static_cast<S&&>(s)};
146146
}

examples/algorithms/then.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,6 @@ struct _then_sender {
9292
};
9393

9494
template <stdexec::sender S, class F>
95-
stdexec::sender auto then(S s, F f) {
95+
auto then(S s, F f) -> stdexec::sender auto {
9696
return _then_sender<S, F>{static_cast<S&&>(s), static_cast<F&&>(f)};
9797
}

examples/benchmark/asio_thread_pool.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ struct RunThread {
8484
}
8585
};
8686

87-
int main(int argc, char** argv) {
87+
auto main(int argc, char** argv) -> int {
8888
my_main<execpools::asio_thread_pool, RunThread>(argc, argv);
8989
}

examples/benchmark/common.hpp

+17-10
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727
#include <memory>
2828
#include <span>
2929
#include <thread>
30+
#include <utility>
3031
#include <vector>
3132

3233
#if __has_include(<memory_resource>)
33-
# include <memory_resource>
34+
# include <memory_resource> // IWYU pragma: keep
3435
namespace pmr = std::pmr;
3536
#else
3637
# define STDEXEC_NO_MONOTONIC_BUFFER_RESOURCE 1
@@ -41,15 +42,15 @@ struct statistics {
4142
double ops_per_sec;
4243
};
4344

44-
statistics compute_perf(
45+
auto compute_perf(
4546
std::chrono::steady_clock::time_point start,
4647
std::chrono::steady_clock::time_point end,
47-
std::size_t total_scheds) {
48+
std::size_t total_scheds) -> statistics {
4849
auto dur = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start);
4950
auto dur_ms = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
5051
auto dur_dbl = std::chrono::duration_cast<std::chrono::duration<double>>(dur);
5152
double ops_per_sec = static_cast<double>(total_scheds) / dur_dbl.count();
52-
return {dur_ms, ops_per_sec};
53+
return {.total_time_ms = dur_ms, .ops_per_sec = ops_per_sec};
5354
}
5455

5556
struct statistics_all {
@@ -61,12 +62,12 @@ struct statistics_all {
6162
double stddev;
6263
};
6364

64-
statistics_all compute_perf(
65+
auto compute_perf(
6566
std::span<const std::chrono::steady_clock::time_point> start,
6667
std::span<const std::chrono::steady_clock::time_point> end,
6768
std::size_t i0,
6869
std::size_t i,
69-
std::size_t total_scheds) {
70+
std::size_t total_scheds) -> statistics_all {
7071
double average = 0.0;
7172
double max = 0.0;
7273
double min = std::numeric_limits<double>::max();
@@ -85,7 +86,13 @@ statistics_all compute_perf(
8586
variance /= static_cast<double>(i + 1 - i0);
8687
double stddev = std::sqrt(variance);
8788
auto stats = compute_perf(start[i], end[i], total_scheds);
88-
statistics_all all{stats.total_time_ms, stats.ops_per_sec, average, max, min, stddev};
89+
statistics_all all{
90+
.total_time_ms = stats.total_time_ms,
91+
.ops_per_sec = stats.ops_per_sec,
92+
.average = average,
93+
.max = max,
94+
.min = min,
95+
.stddev = stddev};
8996
return all;
9097
}
9198

@@ -119,15 +126,15 @@ void my_main(int argc, char** argv, exec::numa_policy policy = exec::get_numa_po
119126
std::atomic<bool> stop{false};
120127
#ifndef STDEXEC_NO_MONOTONIC_BUFFER_RESOURCE
121128
std::size_t buffer_size = 2000 << 20;
122-
for (std::size_t i = 0; i < static_cast<std::size_t>(nthreads); ++i) {
129+
for (std::size_t i = 0; std::cmp_less(i, nthreads); ++i) {
123130
exec::numa_allocator<char> alloc(policy.thread_index_to_node(i));
124131
buffers.push_back(
125132
std::unique_ptr<char, numa_deleter>{
126-
alloc.allocate(buffer_size), numa_deleter{buffer_size, alloc}
133+
alloc.allocate(buffer_size), numa_deleter{.size_ = buffer_size, .allocator_ = alloc}
127134
});
128135
}
129136
#endif
130-
for (std::size_t i = 0; i < static_cast<std::size_t>(nthreads); ++i) {
137+
for (std::size_t i = 0; std::cmp_less(i, nthreads); ++i) {
131138
threads.emplace_back(
132139
RunThread{},
133140
std::ref(*pool),

examples/benchmark/fibonacci.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <exec/any_sender_of.hpp>
2424
#include <stdexec/execution.hpp>
2525

26-
long serial_fib(long n) {
26+
auto serial_fib(long n) -> long {
2727
return n < 2 ? n : serial_fib(n - 1) + serial_fib(n - 2);
2828
}
2929

@@ -67,7 +67,7 @@ struct fib_s {
6767
};
6868

6969
template <stdexec::receiver_of<completion_signatures> Receiver>
70-
friend operation<Receiver> tag_invoke(stdexec::connect_t, fib_s self, Receiver rcvr) {
70+
friend auto tag_invoke(stdexec::connect_t, fib_s self, Receiver rcvr) -> operation<Receiver> {
7171
return {static_cast<Receiver&&>(rcvr), self.cutoff, self.n, self.sched};
7272
}
7373
};
@@ -82,7 +82,7 @@ auto measure(F&& f) {
8282
return std::chrono::duration_cast<duration>(std::chrono::steady_clock::now() - start).count();
8383
}
8484

85-
int main(int argc, char** argv) {
85+
auto main(int argc, char** argv) -> int {
8686
if (argc < 5) {
8787
std::cerr << "Usage: example.benchmark.fibonacci cutoff n nruns {tbb|static}" << std::endl;
8888
return -1;

examples/benchmark/static_thread_pool.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,13 @@ struct RunThread {
8787
};
8888

8989
struct my_numa_distribution : public exec::default_numa_policy {
90-
int thread_index_to_node(std::size_t index) const noexcept {
90+
[[nodiscard]]
91+
auto thread_index_to_node(std::size_t index) const noexcept -> int {
9192
return exec::default_numa_policy::thread_index_to_node(2 * index);
9293
}
9394
};
9495

95-
int main(int argc, char** argv) {
96+
auto main(int argc, char** argv) -> int {
9697
my_numa_distribution numa{};
9798
my_main<exec::static_thread_pool, RunThread>(argc, argv, numa);
9899
}

examples/benchmark/static_thread_pool_bulk_enqueue.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ struct RunThread {
5858
};
5959

6060
struct my_numa_distribution : public exec::default_numa_policy {
61-
int thread_index_to_node(std::size_t index) const noexcept {
61+
[[nodiscard]]
62+
auto thread_index_to_node(std::size_t index) const noexcept -> int {
6263
return exec::default_numa_policy::thread_index_to_node(2 * index);
6364
}
6465
};
6566

66-
int main(int argc, char** argv) {
67+
auto main(int argc, char** argv) -> int {
6768
exec::numa_policy numa{my_numa_distribution{}};
6869
my_main<exec::static_thread_pool, RunThread>(argc, argv, std::move(numa));
6970
}

examples/benchmark/static_thread_pool_bulk_enqueue_nested.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct RunThread {
5757
}
5858
};
5959

60-
int main(int argc, char** argv) {
60+
auto main(int argc, char** argv) -> int {
6161
my_main<exec::static_thread_pool, RunThread>(argc, argv);
6262
}
6363
#else

examples/benchmark/static_thread_pool_nested.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@ struct RunThread {
9494
}
9595
};
9696

97-
int main(int argc, char** argv) {
97+
auto main(int argc, char** argv) -> int {
9898
my_main<exec::static_thread_pool, RunThread>(argc, argv);
9999
}

examples/benchmark/static_thread_pool_nested_old.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,6 @@ struct RunThread {
9292
}
9393
};
9494

95-
int main(int argc, char** argv) {
95+
auto main(int argc, char** argv) -> int {
9696
my_main<exec_old::static_thread_pool, RunThread>(argc, argv);
9797
}

examples/benchmark/static_thread_pool_old.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ struct RunThread {
8484
}
8585
};
8686

87-
int main(int argc, char** argv) {
87+
auto main(int argc, char** argv) -> int {
8888
my_main<exec_old::static_thread_pool, RunThread>(argc, argv);
8989
}

0 commit comments

Comments
 (0)