Skip to content

Commit acbdae5

Browse files
committed
more clang-tidy fixes
1 parent fcb61df commit acbdae5

23 files changed

+116
-59
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,12 @@ clang-tidy: build/$(SANITIZER)/compile_commands.json
8989
codespell:
9090
codespell -L statics,snd,copyable,cancelled
9191

92-
format:
92+
format: cmake-format clang-format
93+
94+
cmake-format:
9395
cmake-format -i `git diff --name-only main | egrep '(CMakeLists.txt|\.cmake)'`
96+
97+
clang-format:
9498
git clang-format main
9599

96100
todo:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// include/beman/execution26/detail/immovable.hpp -*-C++-*-
2+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
#ifndef INCLUDED_BEMAN_EXECUTION26_DETAIL_IMMOVABLE
5+
#define INCLUDED_BEMAN_EXECUTION26_DETAIL_IMMOVABLE
6+
7+
// ----------------------------------------------------------------------------
8+
9+
namespace beman::execution26::detail {
10+
struct immovable {
11+
constexpr immovable() = default;
12+
immovable(immovable&&) = delete;
13+
immovable(const immovable&) = delete;
14+
~immovable() = default;
15+
auto operator=(immovable&&) -> immovable& = delete;
16+
auto operator=(const immovable&) -> immovable& = delete;
17+
};
18+
} // namespace beman::execution26::detail
19+
20+
// ----------------------------------------------------------------------------
21+
22+
#endif

include/beman/execution26/detail/inplace_stop_source.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,15 @@ class beman::execution26::inplace_stop_callback final
8383

8484
template <typename Init>
8585
inplace_stop_callback(::beman::execution26::inplace_stop_token, Init&&);
86+
inplace_stop_callback(const inplace_stop_callback&) = delete;
8687
inplace_stop_callback(inplace_stop_callback&&) = delete;
8788
~inplace_stop_callback() {
8889
if (this->source) {
8990
this->source->deregister(this);
9091
}
9192
}
93+
auto operator=(const inplace_stop_callback&) -> inplace_stop_callback& = delete;
94+
auto operator=(inplace_stop_callback&&) -> inplace_stop_callback& = delete;
9295

9396
private:
9497
auto call() -> void override;

include/beman/execution26/detail/operation_state_task.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,14 @@ struct beman::execution26::detail::operation_state_task {
5757
using promise_type = ::beman::execution26::detail::connect_awaitable_promise<Receiver>;
5858

5959
explicit operation_state_task(::std::coroutine_handle<> handle) noexcept : handle(handle) {}
60+
operation_state_task(const operation_state_task&) = delete;
6061
operation_state_task(operation_state_task&& other) noexcept : handle(::std::exchange(other.handle, {})) {}
6162
~operation_state_task() {
6263
if (this->handle)
6364
this->handle.destroy();
6465
}
66+
auto operator=(operation_state_task&&) -> operation_state_task& = delete;
67+
auto operator=(const operation_state_task&) -> operation_state_task& = delete;
6568

6669
auto start() & noexcept -> void { this->handle.resume(); }
6770

include/beman/execution26/detail/run_loop.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <beman/execution26/detail/get_completion_scheduler.hpp>
99
#include <beman/execution26/detail/get_env.hpp>
1010
#include <beman/execution26/detail/get_stop_token.hpp>
11+
#include <beman/execution26/detail/immovable.hpp>
1112
#include <beman/execution26/detail/operation_state.hpp>
1213
#include <beman/execution26/detail/scheduler.hpp>
1314
#include <beman/execution26/detail/sender.hpp>
@@ -36,7 +37,7 @@ class run_loop {
3637
return {this->loop};
3738
}
3839
};
39-
struct opstate_base {
40+
struct opstate_base : ::beman::execution26::detail::immovable {
4041
opstate_base* next{};
4142
virtual auto execute() noexcept -> void = 0;
4243
};
@@ -49,7 +50,6 @@ class run_loop {
4950

5051
template <typename R>
5152
opstate(run_loop* loop, R&& receiver) : loop(loop), receiver(::std::forward<Receiver>(receiver)) {}
52-
opstate(opstate&&) = delete;
5353
auto start() & noexcept -> void {
5454
try {
5555
this->loop->push_back(this);
@@ -88,7 +88,7 @@ class run_loop {
8888
auto operator==(const scheduler&) const -> bool = default;
8989
};
9090

91-
enum class state { starting, running, finishing };
91+
enum class state : unsigned char { starting, running, finishing };
9292

9393
state current_state{state::starting};
9494
::std::mutex mutex{};
@@ -115,12 +115,15 @@ class run_loop {
115115

116116
public:
117117
run_loop() noexcept = default;
118+
run_loop(const run_loop&) = delete;
118119
run_loop(run_loop&&) = delete;
119120
~run_loop() {
120121
::std::lock_guard guard(this->mutex);
121122
if (this->front != nullptr || this->current_state == state::running)
122123
::std::terminate();
123124
}
125+
auto operator=(const run_loop&) -> run_loop& = delete;
126+
auto operator=(run_loop&&) -> run_loop& = delete;
124127

125128
auto get_scheduler() -> scheduler { return {this}; }
126129

include/beman/execution26/detail/sched_attrs.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ class sched_attrs {
2323
Scheduler sched;
2424

2525
public:
26+
sched_attrs(const sched_attrs&) = default;
27+
sched_attrs(sched_attrs&&) = default;
2628
template <typename S>
27-
sched_attrs(S&& sched) : sched(::std::forward<S>(sched)) {}
29+
explicit sched_attrs(S&& sched) : sched(::std::forward<S>(sched)) {}
2830

2931
template <typename Tag>
3032
auto query(const ::beman::execution26::get_completion_scheduler_t<Tag>&) const noexcept {

include/beman/execution26/detail/sched_env.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class sched_env {
1919
Scheduler sched;
2020

2121
public:
22+
sched_env(const sched_env&) = default;
23+
sched_env(sched_env&&) = default;
2224
template <typename S>
2325
explicit sched_env(S&& sch) : sched(::std::forward<S>(sch)) {}
2426

include/beman/execution26/detail/sender_adaptor_closure.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ struct sender_adaptor_closure_base {};
1616
} // namespace beman::execution26::detail::pipeable
1717

1818
namespace beman::execution26 {
19+
// NOLINTBEGIN(bugprone-crtp-constructor-accessibility)
1920
template <typename>
2021
struct sender_adaptor_closure : ::beman::execution26::detail::pipeable::sender_adaptor_closure_base {};
22+
// NOLINTEND(bugprone-crtp-constructor-accessibility)
2123
} // namespace beman::execution26
2224

2325
namespace beman::execution26::detail::pipeable {

include/beman/execution26/detail/sender_decompose.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace beman::execution26::detail {
1414
struct sender_convert_to_any_t {
1515
template <typename T>
16-
constexpr operator T() const;
16+
constexpr operator T() const; // NOLINT(hicpp-explicit-conversions)
1717
};
1818

1919
template <typename Tag, typename Data, typename Children>

include/beman/execution26/detail/stop_source.hpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ struct beman::execution26::detail::stop_callback_base {
4949
virtual auto do_call() -> void = 0;
5050

5151
protected:
52-
stop_callback_base(const ::beman::execution26::stop_token&);
52+
explicit stop_callback_base(const ::beman::execution26::stop_token&);
5353
~stop_callback_base();
5454

5555
public:
56+
stop_callback_base(stop_callback_base&&) = delete;
57+
stop_callback_base(const stop_callback_base&) = delete;
58+
auto operator=(stop_callback_base&&) -> stop_callback_base& = delete;
59+
auto operator=(const stop_callback_base&) -> stop_callback_base& = delete;
5660
auto call() -> void;
5761
auto setup() -> void;
5862
auto deregister() -> void;
@@ -75,7 +79,9 @@ class beman::execution26::stop_source {
7579
stop_source();
7680
explicit stop_source(::beman::execution26::nostopstate_t) noexcept;
7781
stop_source(const stop_source&);
82+
stop_source(stop_source&&) = default;
7883
auto operator=(const stop_source&) -> stop_source&;
84+
auto operator=(stop_source&&) -> stop_source& = default;
7985
~stop_source();
8086

8187
auto swap(stop_source&) noexcept -> void;
@@ -93,7 +99,7 @@ class beman::execution26::stop_token {
9399
friend ::beman::execution26::detail::stop_callback_base;
94100
::std::shared_ptr<::beman::execution26::detail::stop_state> state;
95101

96-
stop_token(::std::shared_ptr<::beman::execution26::detail::stop_state>);
102+
explicit stop_token(::std::shared_ptr<::beman::execution26::detail::stop_state>);
97103

98104
public:
99105
template <typename Fun>
@@ -137,8 +143,11 @@ class beman::execution26::stop_callback final : private CallbackFun, beman::exec
137143
: CallbackFun(::std::forward<Initializer>(init)), stop_callback_base(::std::move(token)) {
138144
this->setup();
139145
}
140-
~stop_callback() { this->deregister(); }
146+
stop_callback(const stop_callback&) = delete;
141147
stop_callback(stop_callback&&) = delete;
148+
~stop_callback() { this->deregister(); }
149+
auto operator=(stop_callback&&) -> stop_callback& = delete;
150+
auto operator=(const stop_callback&) -> stop_callback& = delete;
142151
};
143152

144153
// ----------------------------------------------------------------------------
@@ -207,9 +216,7 @@ inline beman::execution26::stop_source::stop_source(const stop_source& other) :
207216
}
208217

209218
inline auto beman::execution26::stop_source::operator=(const stop_source& other) -> stop_source& {
210-
--this->state->sources;
211-
this->state = other.state;
212-
++this->state->sources;
219+
stop_source(other).swap(*this);
213220
return *this;
214221
}
215222

0 commit comments

Comments
 (0)