Skip to content

Commit

Permalink
Merge pull request #1417 from NVIDIA/clang-format-18
Browse files Browse the repository at this point in the history
reformat everything with clang-format-18
  • Loading branch information
ericniebler authored Sep 20, 2024
2 parents 0ce265a + 56df64c commit 519f931
Show file tree
Hide file tree
Showing 66 changed files with 368 additions and 365 deletions.
5 changes: 4 additions & 1 deletion .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ ab2a3baef655db23fb7ec11ce7ec49575bbd2807
4410452fed3acda19d7b75b20ec2d3a3c92c9c38

# clang-modernize
3eaba4111bc8e8516ed1a4f516d753503b87e504
3eaba4111bc8e8516ed1a4f516d753503b87e504

# Reformat everything with clang-format-18
413749037ac3cd2f66a476fdd593e54e3b4b60b7
13 changes: 7 additions & 6 deletions examples/algorithms/retry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,13 @@ struct _retry_sender {
using _value = stdexec::completion_signatures<stdexec::set_value_t(Ts...)>;

template <class Env>
auto get_completion_signatures(Env&&) const -> stdexec::transform_completion_signatures_of<
S&,
Env,
stdexec::completion_signatures<stdexec::set_error_t(std::exception_ptr)>,
_value,
_error> {
auto get_completion_signatures(Env&&) const
-> stdexec::transform_completion_signatures_of<
S&,
Env,
stdexec::completion_signatures<stdexec::set_error_t(std::exception_ptr)>,
_value,
_error> {
return {};
}

Expand Down
5 changes: 1 addition & 4 deletions examples/benchmark/fibonacci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ int main(int argc, char** argv) {
long result;
for (unsigned long i = 0; i < nruns; ++i) {
auto snd = std::visit(
[&](auto&& pool) {
return fib_sender(fib_s{cutoff, n, pool.get_scheduler()});
},
pool);
[&](auto&& pool) { return fib_sender(fib_s{cutoff, n, pool.get_scheduler()}); }, pool);

auto time = measure<std::chrono::milliseconds>([&] {
std::tie(result) = stdexec::sync_wait(std::move(snd)).value();
Expand Down
6 changes: 3 additions & 3 deletions include/exec/__detail/__basic_sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ namespace exec {
STDEXEC_ATTRIBUTE((host, device))
explicit __seqexpr(_Tag, _Data&& __data, _Child&&... __child)
: __impl_(stdexec::__detail::__captures(
_Tag(),
static_cast<_Data&&>(__data),
static_cast<_Child&&>(__child)...)) {
_Tag(),
static_cast<_Data&&>(__data),
static_cast<_Child&&>(__child)...)) {
}

template <stdexec::same_as<__seqexpr> _Self = __seqexpr>
Expand Down
6 changes: 3 additions & 3 deletions include/exec/__detail/__bwos_lifo_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ namespace exec::bwos {
std::size_t block_size,
Allocator allocator)
: blocks_(
std::max(static_cast<size_t>(2), std::bit_ceil(num_blocks)),
block_type(block_size, allocator),
allocator_of_t<block_type>(allocator))
std::max(static_cast<size_t>(2), std::bit_ceil(num_blocks)),
block_type(block_size, allocator),
allocator_of_t<block_type>(allocator))
, mask_(blocks_.size() - 1) {
blocks_[owner_block_.load()].reclaim();
}
Expand Down
6 changes: 6 additions & 0 deletions include/exec/__detail/__numa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ namespace exec {
T{static_cast<T&&>(*reinterpret_cast<T*>(other->buf))};
}
}

// copy
static auto _copy(_storage* self, const _storage* other) noexcept -> void {
if constexpr (!_is_small<T>::value) {
Expand All @@ -91,6 +92,7 @@ namespace exec {
::new (static_cast<void*>(self->buf)) T{*reinterpret_cast<const T*>(other->buf)};
}
}

// destroy
static auto _destroy(_storage* self) noexcept -> void {
if constexpr (!_is_small<T>::value) {
Expand All @@ -99,6 +101,7 @@ namespace exec {
std::destroy_at(reinterpret_cast<T*>(self->buf));
}
}

// num_nodes
static auto _num_nodes(const _storage* self) noexcept -> std::size_t {
if constexpr (!_is_small<T>::value) {
Expand All @@ -107,6 +110,7 @@ namespace exec {
return reinterpret_cast<const T*>(self->buf)->num_nodes();
}
}

// num_cpus
static auto _num_cpus(const _storage* self, int node) noexcept -> std::size_t {
if constexpr (!_is_small<T>::value) {
Expand All @@ -115,6 +119,7 @@ namespace exec {
return reinterpret_cast<const T*>(self->buf)->num_cpus(node);
}
}

// bind_to_node
static auto _bind_to_node(const _storage* self, int node) noexcept -> int {
if constexpr (!_is_small<T>::value) {
Expand All @@ -123,6 +128,7 @@ namespace exec {
return reinterpret_cast<const T*>(self->buf)->bind_to_node(node);
}
}

// thread_index_to_node
static auto _thread_index_to_node(const _storage* self, std::size_t index) noexcept -> int {
if constexpr (!_is_small<T>::value) {
Expand Down
12 changes: 6 additions & 6 deletions include/exec/any_sender_of.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ namespace exec {
private:
template <class _Rcvr>
requires receiver_of<_Rcvr, completion_signatures<_Sigs...>>
&& (__callable<__query_vfun_fn<_Rcvr>, _Queries> && ...)
&& (__callable<__query_vfun_fn<_Rcvr>, _Queries> && ...)
STDEXEC_MEMFN_DECL(
auto __create_vtable)(this __mtype<__t>, __mtype<_Rcvr>) noexcept -> const __t* {
static const __t __vtable_{
Expand Down Expand Up @@ -669,9 +669,9 @@ namespace exec {
&& (__callable<__query_vfun_fn<_Rcvr>, _Queries> && ...)
__ref(_Rcvr& __rcvr) noexcept
: __env_{
__create_vtable(__mtype<__vtable_t>{}, __mtype<_Rcvr>{}),
&__rcvr,
stdexec::get_stop_token(stdexec::get_env(__rcvr))} {
__create_vtable(__mtype<__vtable_t>{}, __mtype<_Rcvr>{}),
&__rcvr,
stdexec::get_stop_token(stdexec::get_env(__rcvr))} {
}

template <class... _As>
Expand Down Expand Up @@ -700,8 +700,8 @@ namespace exec {
}
};

auto __test_never_stop_token(get_stop_token_t (*)(never_stop_token (*)() noexcept))
-> __mbool<true>;
auto __test_never_stop_token(
get_stop_token_t (*)(never_stop_token (*)() noexcept)) -> __mbool<true>;

template <class _Tag, class _Ret, class... _As>
auto __test_never_stop_token(_Tag (*)(_Ret (*)(_As...) noexcept)) -> __mbool<false>;
Expand Down
17 changes: 10 additions & 7 deletions include/exec/async_scope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ namespace exec {
stdexec::start(static_cast<__t*>(__self)->__op_);
}

STDEXEC_IMMOVABLE_NO_UNIQUE_ADDRESS connect_result_t<_Constrained, _Receiver> __op_;
STDEXEC_IMMOVABLE_NO_UNIQUE_ADDRESS
connect_result_t<_Constrained, _Receiver> __op_;
};
};

Expand Down Expand Up @@ -214,7 +215,8 @@ namespace exec {
struct __t : __nest_op_base<_ReceiverId> {
using __id = __nest_op;
using __nest_rcvr_t = stdexec::__t<__nest_rcvr<_ReceiverId>>;
STDEXEC_IMMOVABLE_NO_UNIQUE_ADDRESS connect_result_t<_Constrained, __nest_rcvr_t> __op_;
STDEXEC_IMMOVABLE_NO_UNIQUE_ADDRESS
connect_result_t<_Constrained, __nest_rcvr_t> __op_;

template <__decays_to<_Constrained> _Sender, __decays_to<_Receiver> _Rcvr>
explicit __t(const __impl* __scope, _Sender&& __c, _Rcvr&& __rcvr)
Expand Down Expand Up @@ -356,7 +358,8 @@ namespace exec {
_Receiver __rcvr_;
std::unique_ptr<__future_state<_Sender, _Env>> __state_;
STDEXEC_ATTRIBUTE((no_unique_address))
stdexec::__optional<__forward_consumer> __forward_consumer_;
stdexec::__optional<__forward_consumer>
__forward_consumer_;

public:
using __id = __future_op;
Expand All @@ -381,7 +384,7 @@ namespace exec {
_Receiver2&& __rcvr, std::unique_ptr<__future_state<_Sender, _Env>> __state)
: __subscription{{},
[](__subscription* __self) noexcept -> void {
static_cast<__t*>(__self)->__complete_();
static_cast<__t*>(__self)->__complete_();
}}
, __rcvr_(static_cast<_Receiver2&&>(__rcvr))
, __state_(std::move(__state))
Expand Down Expand Up @@ -733,7 +736,7 @@ namespace exec {
: __spawn_op_base<_EnvId>{__env::__join(static_cast<_Env&&>(__env),
__spawn_env_{__scope->__stop_source_.get_token()}),
[](__spawn_op_base<_EnvId>* __op) {
delete static_cast<__t*>(__op);
delete static_cast<__t*>(__op);
}}
, __op_(stdexec::connect(static_cast<_Sndr&&>(__sndr), __spawn_receiver_t<_Env>{this})) {
}
Expand Down Expand Up @@ -781,8 +784,8 @@ namespace exec {
// start is noexcept so we can assume that the operation will complete
// after this, which means we can rely on its self-ownership to ensure
// that it is eventually deleted
stdexec::start(
*(new __op_t{nest(static_cast<_Sender&&>(__sndr)), static_cast<_Env&&>(__env), &__impl_}));
stdexec::start(*(
new __op_t{nest(static_cast<_Sender&&>(__sndr)), static_cast<_Env&&>(__env), &__impl_}));
}

template <__movable_value _Env = empty_env, sender_in<__env_t<_Env>> _Sender>
Expand Down
8 changes: 4 additions & 4 deletions include/exec/at_coroutine_exit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ namespace exec {
using __sender = __t<__sender_id<__decay_t<_Sender>>>;

template <sender _Sender>
auto operator()(_Sender&& __sndr) const noexcept(__nothrow_decay_copyable<_Sender>)
-> __sender<_Sender> {
auto operator()(_Sender&& __sndr) const
noexcept(__nothrow_decay_copyable<_Sender>) -> __sender<_Sender> {
return __sender<_Sender>{static_cast<_Sender&&>(__sndr)};
}

Expand Down Expand Up @@ -163,8 +163,8 @@ namespace exec {
return false;
}

static auto await_suspend(__coro::coroutine_handle<__promise> __h) noexcept
-> __coro::coroutine_handle<> {
static auto await_suspend(
__coro::coroutine_handle<__promise> __h) noexcept -> __coro::coroutine_handle<> {
__promise& __p = __h.promise();
auto __coro = __p.__is_unhandled_stopped_ ? __p.continuation().unhandled_stopped()
: __p.continuation().handle();
Expand Down
2 changes: 1 addition & 1 deletion include/exec/create.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace exec {
struct __create_t {
template <class _Fun, class... _Args>
requires move_constructible<_Fun>
&& constructible_from<__decayed_std_tuple<_Args...>, _Args...>
&& constructible_from<__decayed_std_tuple<_Args...>, _Args...>
auto operator()(_Fun __fun, _Args&&... __args) const
-> __t<__sender<_Fun, __id<__decayed_std_tuple<_Args...>>, _Sigs...>> {
return {static_cast<_Fun&&>(__fun), {static_cast<_Args&&>(__args)...}};
Expand Down
4 changes: 2 additions & 2 deletions include/exec/linux/__detail/memory_mapped_region.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ namespace exec {
, __size_(std::exchange(__other.__size_, 0)) {
}

inline auto memory_mapped_region::operator=(memory_mapped_region&& __other) noexcept
-> memory_mapped_region& {
inline auto memory_mapped_region::operator=(
memory_mapped_region&& __other) noexcept -> memory_mapped_region& {
if (this != &__other) {
if (__ptr_) {
::munmap(__ptr_, __size_);
Expand Down
4 changes: 2 additions & 2 deletions include/exec/linux/__detail/safe_file_descriptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ namespace exec {
: __fd_(std::exchange(__other.__fd_, -1)) {
}

inline auto safe_file_descriptor::operator=(safe_file_descriptor&& __other) noexcept
-> safe_file_descriptor& {
inline auto safe_file_descriptor::operator=(
safe_file_descriptor&& __other) noexcept -> safe_file_descriptor& {
if (this != &__other) {
if (__fd_ != -1) {
::close(__fd_);
Expand Down
14 changes: 7 additions & 7 deletions include/exec/linux/io_uring_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ namespace exec {
// This function first completes all tasks that are ready in the completion queue of the io_uring.
// Then it completes all tasks that are ready in the given queue of ready tasks.
// The function returns the number of previously submitted completed tasks.
auto complete(stdexec::__intrusive_queue<&__task::__next_> __ready = __task_queue{}) noexcept
-> int {
auto complete(
stdexec::__intrusive_queue<&__task::__next_> __ready = __task_queue{}) noexcept -> int {
__u32 __head = __head_.load(std::memory_order_relaxed);
__u32 __tail = __tail_.load(std::memory_order_acquire);
int __count = 0;
Expand Down Expand Up @@ -419,8 +419,8 @@ namespace exec {
return false;
} else {
__requests_.push_front(__op);
[[maybe_unused]] int __prev =
__n_submissions_in_flight_.fetch_sub(1, std::memory_order_relaxed);
[[maybe_unused]]
int __prev = __n_submissions_in_flight_.fetch_sub(1, std::memory_order_relaxed);
STDEXEC_ASSERT(__prev > 0);
return true;
}
Expand Down Expand Up @@ -654,8 +654,7 @@ namespace exec {
requires(_Op& __op) {
{
static_cast<_Op&&>(__op).receiver()
} noexcept
-> stdexec::receiver_of<stdexec::completion_signatures<stdexec::set_stopped_t()>>;
} noexcept -> stdexec::receiver_of<stdexec::completion_signatures<stdexec::set_stopped_t()>>;
};

template <__stoppable_task _Op>
Expand Down Expand Up @@ -896,7 +895,8 @@ namespace exec {
}

void submit(::io_uring_sqe& __sqe) noexcept {
[[maybe_unused]] int prev = __n_ops_.fetch_add(1, std::memory_order_relaxed);
[[maybe_unused]]
int prev = __n_ops_.fetch_add(1, std::memory_order_relaxed);
STDEXEC_ASSERT(prev == 0);
__context& __context_ = this->__base_.context();
_Receiver& __receiver = this->__base_.receiver();
Expand Down
4 changes: 2 additions & 2 deletions include/exec/materialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ namespace exec {
using __sender_t = __t<__sender<__id<_Sender>>>;

template <sender _Sender>
auto operator()(_Sender&& __sndr) const noexcept(__nothrow_decay_copyable<_Sender>)
-> __sender_t<_Sender> {
auto operator()(_Sender&& __sndr) const
noexcept(__nothrow_decay_copyable<_Sender>) -> __sender_t<_Sender> {
return __sender_t<_Sender>(static_cast<_Sender&&>(__sndr));
}

Expand Down
4 changes: 2 additions & 2 deletions include/exec/on_coro_disposition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ namespace exec {
return false;
}

static auto await_suspend(__coro::coroutine_handle<__promise> __h) noexcept
-> __coro::coroutine_handle<> {
static auto await_suspend(
__coro::coroutine_handle<__promise> __h) noexcept -> __coro::coroutine_handle<> {
__promise& __p = __h.promise();
auto __coro = __p.__is_unhandled_stopped_ ? __p.continuation().unhandled_stopped()
: __p.continuation().handle();
Expand Down
6 changes: 3 additions & 3 deletions include/exec/repeat_effect_until.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ namespace exec {
}

void __start() noexcept {
const bool __already_started
[[maybe_unused]] = __started_.test_and_set(std::memory_order_relaxed);
const bool __already_started [[maybe_unused]]
= __started_.test_and_set(std::memory_order_relaxed);
STDEXEC_ASSERT(!__already_started);
stdexec::start(__child_op_.__get());
}
Expand Down Expand Up @@ -225,7 +225,7 @@ namespace stdexec {
struct __sexpr_impl<exec::repeat_effect_until_t> : __sexpr_defaults {
static constexpr auto get_completion_signatures = //
[]<class _Sender>(_Sender &&) noexcept //
-> exec::__repeat_effect_until::__completions_t<__data_of<_Sender>> {
-> exec::__repeat_effect_until::__completions_t<__data_of<_Sender>> {
return {};
};
};
Expand Down
9 changes: 4 additions & 5 deletions include/exec/repeat_n.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ namespace exec {
stdexec::set_value(static_cast<_Receiver &&>(this->__receiver()));
} else {

const bool __already_started
[[maybe_unused]] = __started_.test_and_set(std::memory_order_relaxed);
const bool __already_started [[maybe_unused]]
= __started_.test_and_set(std::memory_order_relaxed);
STDEXEC_ASSERT(!__already_started);
stdexec::start(__child_op_.__get());
}
Expand Down Expand Up @@ -235,13 +235,12 @@ namespace exec {

namespace stdexec {
template <>
struct __sexpr_impl<exec::__repeat_n::__repeat_n_tag>
: exec::__repeat_n::__repeat_n_impl { };
struct __sexpr_impl<exec::__repeat_n::__repeat_n_tag> : exec::__repeat_n::__repeat_n_impl { };

template <>
struct __sexpr_impl<exec::repeat_n_t> : __sexpr_defaults {
static constexpr auto get_completion_signatures = //
[]<class _Sender>(_Sender&&) noexcept //
[]<class _Sender>(_Sender &&) noexcept //
-> __completion_signatures_of_t< //
transform_sender_result_t<default_domain, _Sender, empty_env>> {
};
Expand Down
2 changes: 1 addition & 1 deletion include/exec/sequence/any_sequence_of.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace exec {

template <class _Rcvr>
requires sequence_receiver_of<_Rcvr, __item_types>
&& (__callable<__query_vfun_fn<_Rcvr>, _Queries> && ...)
&& (__callable<__query_vfun_fn<_Rcvr>, _Queries> && ...)
STDEXEC_MEMFN_DECL(
auto __create_vtable)(this __mtype<__t>, __mtype<_Rcvr>) noexcept -> const __t* {
static const __t __vtable_{
Expand Down
2 changes: 1 addition & 1 deletion include/exec/sequence/ignore_all_values.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ namespace exec {

template <class _Child>
requires receiver_of<_Receiver, __completion_sigs<_Child>>
&& sequence_sender_to<_Child, __receiver_t<_Child>>
&& sequence_sender_to<_Child, __receiver_t<_Child>>
auto operator()(__ignore, __ignore, _Child&& __child) //
noexcept(__nothrow_constructible_from<__operation_t<_Child>, _Child, _Receiver>)
-> __operation_t<_Child> {
Expand Down
Loading

0 comments on commit 519f931

Please sign in to comment.