From f0323e80b617df22d3ad4556d156133c99f1d9b9 Mon Sep 17 00:00:00 2001 From: Dominik Charousset Date: Sun, 14 Jul 2024 09:56:19 +0200 Subject: [PATCH] Switch to clang-format 18 in CI --- .clang-format | 4 +++- .pre-commit-config.yaml | 3 +-- bindings/python/_broker.cpp | 2 +- bindings/python/set_bind.h | 3 +-- libbroker/broker/alm/multipath.hh | 8 ++++---- libbroker/broker/builder.hh | 9 ++++----- libbroker/broker/data.hh | 9 ++++----- libbroker/broker/detail/type_traits.hh | 10 +++++----- libbroker/broker/expected.hh | 8 ++++---- libbroker/broker/internal/clone_actor.cc | 3 +-- libbroker/broker/internal/master_actor.cc | 3 +-- libbroker/broker/internal_command.cc | 14 +++++++------- libbroker/broker/intrusive_ptr.hh | 8 ++++---- 13 files changed, 40 insertions(+), 44 deletions(-) diff --git a/.clang-format b/.clang-format index c45278f7c..bc22ecbc4 100644 --- a/.clang-format +++ b/.clang-format @@ -37,5 +37,7 @@ SpaceBeforeParens: ControlStatements SpacesBeforeTrailingComments: '1' Standard: Cpp11 UseTab: Never - +--- +Language: Json +DisableFormat: true ... diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e04646fb5..84042b8df 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,6 @@ # repos: - repo: https://github.com/pre-commit/mirrors-clang-format - rev: 'v13.0.0' + rev: 'v18.1.8' hooks: - id: clang-format - exclude: ^tests/benchmark/readerwriterqueue/ diff --git a/bindings/python/_broker.cpp b/bindings/python/_broker.cpp index 9d801f7e6..aa8400e4a 100644 --- a/bindings/python/_broker.cpp +++ b/bindings/python/_broker.cpp @@ -333,7 +333,7 @@ PYBIND11_MODULE(_broker, m) { // the standard class right at that point, one cannot pass an already // created one in, which is unfortunate. struct Configuration { - Configuration(){}; + Configuration() {} Configuration(broker::broker_options opts) : options(std::move(opts)) {} broker::broker_options options = {}; std::string openssl_cafile; diff --git a/bindings/python/set_bind.h b/bindings/python/set_bind.h index 48cbc896a..b44d06ab3 100644 --- a/bindings/python/set_bind.h +++ b/bindings/python/set_bind.h @@ -64,8 +64,7 @@ void set_modifiers( "remove", [](Set& s, const T& x) { s.erase(x); }, arg("x"), "Removes an item from this set."); - cl.def( - "clear", [](Set& s) { s.clear(); }, "Empties this set."); + cl.def("clear", [](Set& s) { s.clear(); }, "Empties this set."); } // To iterate by copying objects, as std::set iterators are const. diff --git a/libbroker/broker/alm/multipath.hh b/libbroker/broker/alm/multipath.hh index c8adf40d1..e528b93ba 100644 --- a/libbroker/broker/alm/multipath.hh +++ b/libbroker/broker/alm/multipath.hh @@ -68,14 +68,14 @@ private: }; template -auto operator==(node_iterator x, node_iterator y) - -> decltype(x.get() == y.get()) { +auto operator==(node_iterator x, + node_iterator y) -> decltype(x.get() == y.get()) { return x.get() == y.get(); } template -auto operator!=(node_iterator x, node_iterator y) - -> decltype(x.get() != y.get()) { +auto operator!=(node_iterator x, + node_iterator y) -> decltype(x.get() != y.get()) { return x.get() != y.get(); } diff --git a/libbroker/broker/builder.hh b/libbroker/broker/builder.hh index c5c0b9bcf..cd4770041 100644 --- a/libbroker/broker/builder.hh +++ b/libbroker/broker/builder.hh @@ -54,8 +54,8 @@ struct builder_access { static Builder& add(Builder& builder, T&& value) { namespace bin_v1 = format::bin::v1; using value_type = std::decay_t; - static_assert(variant_data::is_primitive< - value_type> || detail::has_builder_access, + static_assert(variant_data::is_primitive + || detail::has_builder_access, "T is neither a builder nor a recognized data type"); using value_type = std::decay_t; if constexpr (is_builder) { @@ -65,9 +65,8 @@ struct builder_access { } else { // Omit the tag for `variant` and `data`, because they will write it // themselves. - if constexpr (!std::is_same_v< - value_type, - variant> && !std::is_same_v) { + if constexpr (!std::is_same_v + && !std::is_same_v) { bin_v1::write_unsigned(data_tag_v, builder.adder()); } bin_v1::encode(std::forward(value), builder.adder()); diff --git a/libbroker/broker/data.hh b/libbroker/broker/data.hh index 072abf5f1..94d412fd0 100644 --- a/libbroker/broker/data.hh +++ b/libbroker/broker/data.hh @@ -64,11 +64,10 @@ public: return detail::tag{}; } else if constexpr (std::is_signed_v) { return detail::tag{}; - } else if constexpr ( - std::is_same_v< - T, - std:: - string> || std::is_same_v || std::is_same_v || std::is_same_v) { + } else if constexpr (std::is_same_v + || std::is_same_v + || std::is_same_v + || std::is_same_v) { return detail::tag{}; } else if constexpr (std::is_same_v // || std::is_same_v // diff --git a/libbroker/broker/detail/type_traits.hh b/libbroker/broker/detail/type_traits.hh index 1dd683cf0..0169cd4d9 100644 --- a/libbroker/broker/detail/type_traits.hh +++ b/libbroker/broker/detail/type_traits.hh @@ -115,8 +115,8 @@ inline constexpr bool are_same_v = are_same::value; template struct has_convert { template - static auto test(const T* x) - -> decltype(convert(*x, std::declval()), std::true_type()); + static auto test(const T* x) -> decltype(convert(*x, std::declval()), + std::true_type()); template static auto test(...) -> std::false_type; @@ -240,9 +240,9 @@ inline constexpr bool is_tuple = is_tuple_oracle::value; class has_encode_overload { \ private: \ template \ - static auto sfinae(U& y) \ - -> decltype(::ns_name::encode(y, std::declval()), \ - std::true_type{}); \ + static auto \ + sfinae(U& y) -> decltype(::ns_name::encode(y, std::declval()), \ + std::true_type{}); \ static std::false_type sfinae(...); \ using result_type = decltype(sfinae(std::declval())); \ \ diff --git a/libbroker/broker/expected.hh b/libbroker/broker/expected.hh index b82951478..731f601d8 100644 --- a/libbroker/broker/expected.hh +++ b/libbroker/broker/expected.hh @@ -246,8 +246,8 @@ private: /// @relates expected template -auto operator==(const expected& x, const expected& y) - -> decltype(*x == *y) { +auto operator==(const expected& x, + const expected& y) -> decltype(*x == *y) { return x && y ? *x == *y : (!x && !y ? x.error() == y.error() : false); } @@ -290,8 +290,8 @@ bool operator==(ec x, const expected& y) { /// @relates expected template -auto operator!=(const expected& x, const expected& y) - -> decltype(*x == *y) { +auto operator!=(const expected& x, + const expected& y) -> decltype(*x == *y) { return !(x == y); } diff --git a/libbroker/broker/internal/clone_actor.cc b/libbroker/broker/internal/clone_actor.cc index 8343b5d01..57f490c1b 100644 --- a/libbroker/broker/internal/clone_actor.cc +++ b/libbroker/broker/internal/clone_actor.cc @@ -559,8 +559,7 @@ caf::behavior clone_state::make_behavior() { rp, [this, rp, id]() mutable { auto x = keys(); - BROKER_INFO("KEYS" - << "with id" << id << "->" << x); + BROKER_INFO("KEYS" << "with id" << id << "->" << x); rp.deliver(std::move(x), id); }, id); diff --git a/libbroker/broker/internal/master_actor.cc b/libbroker/broker/internal/master_actor.cc index c92c9fecc..3f232a857 100644 --- a/libbroker/broker/internal/master_actor.cc +++ b/libbroker/broker/internal/master_actor.cc @@ -553,8 +553,7 @@ caf::behavior master_state::make_behavior() { }, [this](atom::get, atom::keys, request_id id) { auto x = backend->keys(); - BROKER_INFO("KEYS" - << "with id:" << id << "->" << x); + BROKER_INFO("KEYS" << "with id:" << id << "->" << x); if (x) return caf::make_message(std::move(*x), id); else diff --git a/libbroker/broker/internal_command.cc b/libbroker/broker/internal_command.cc index 31653afd9..fe60f18b9 100644 --- a/libbroker/broker/internal_command.cc +++ b/libbroker/broker/internal_command.cc @@ -2,17 +2,17 @@ namespace broker { -#define TO_STRING_CASE(name) \ - name: \ - return #name; - std::string to_string(command_tag x) { switch (x) { - TO_STRING_CASE(action) - TO_STRING_CASE(producer_control) - TO_STRING_CASE(consumer_control) + case command_tag::action: + return "action"; + case command_tag::producer_control: + return "producer_control"; + case command_tag::consumer_control: + return "consumer_control"; default: return "???"; } } + } // namespace broker diff --git a/libbroker/broker/intrusive_ptr.hh b/libbroker/broker/intrusive_ptr.hh index f264c33e6..bad08387c 100644 --- a/libbroker/broker/intrusive_ptr.hh +++ b/libbroker/broker/intrusive_ptr.hh @@ -224,15 +224,15 @@ bool operator!=(const T* x, const intrusive_ptr& y) { /// @relates intrusive_ptr template -auto operator==(const intrusive_ptr& x, const intrusive_ptr& y) - -> decltype(x.get() == y.get()) { +auto operator==(const intrusive_ptr& x, + const intrusive_ptr& y) -> decltype(x.get() == y.get()) { return x.get() == y.get(); } /// @relates intrusive_ptr template -auto operator!=(const intrusive_ptr& x, const intrusive_ptr& y) - -> decltype(x.get() != y.get()) { +auto operator!=(const intrusive_ptr& x, + const intrusive_ptr& y) -> decltype(x.get() != y.get()) { return x.get() != y.get(); }