Skip to content

Commit c98c6b1

Browse files
committed
clang-tidy fixes
1 parent cf68e3a commit c98c6b1

File tree

98 files changed

+806
-530
lines changed

Some content is hidden

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

98 files changed

+806
-530
lines changed

phlex/app/load_module.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
#include "boost/dll/import.hpp"
99
#include "boost/json.hpp"
1010

11+
#include <cstdlib>
12+
#include <filesystem>
1113
#include <functional>
14+
#include <stdexcept>
1215
#include <string>
1316

1417
using namespace std::string_literals;
@@ -21,12 +24,13 @@ namespace phlex::experimental {
2124
std::vector<std::function<detail::module_creator_t>> create_module;
2225
std::function<detail::source_creator_t> create_source;
2326

24-
template <typename creator_t>
25-
std::function<creator_t> plugin_loader(std::string const& spec, std::string const& symbol_name)
27+
template <typename CreatorT>
28+
std::function<CreatorT> plugin_loader(std::string const& spec, std::string const& symbol_name)
2629
{
2730
char const* plugin_path_ptr = std::getenv("PHLEX_PLUGIN_PATH");
28-
if (!plugin_path_ptr)
31+
if (!plugin_path_ptr) {
2932
throw std::runtime_error("PHLEX_PLUGIN_PATH has not been set.");
33+
}
3034

3135
using namespace boost;
3236
std::vector<std::string> subdirs;
@@ -37,7 +41,7 @@ namespace phlex::experimental {
3741
std::filesystem::path shared_library_path{subdir};
3842
shared_library_path /= "lib" + spec + ".so";
3943
if (exists(shared_library_path)) {
40-
return dll::import_alias<creator_t>(shared_library_path, symbol_name);
44+
return dll::import_alias<CreatorT>(shared_library_path, symbol_name);
4145
}
4246
}
4347
throw std::runtime_error("Could not locate library with specification '"s + spec +

phlex/configuration.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
#include "boost/json.hpp"
55

66
#include <optional>
7+
#include <utility>
78

89
namespace phlex::experimental {
910
class configuration {
1011
public:
1112
configuration() = default;
12-
explicit configuration(boost::json::object const& config) : config_{config} {}
13+
explicit configuration(boost::json::object config) : config_{std::move(config)} {}
1314

1415
template <typename T>
1516
std::optional<T> get_if_present(std::string const& key) const
1617
{
17-
if (auto pkey = config_.if_contains(key)) {
18+
if (auto const* pkey = config_.if_contains(key)) {
1819
return value_to<T>(*pkey);
1920
}
2021
return std::nullopt;

phlex/core/consumer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#include "phlex/core/consumer.hpp"
2+
#include "phlex/model/algorithm_name.hpp"
3+
4+
#include <string>
5+
#include <utility>
6+
#include <vector>
27

38
namespace phlex::experimental {
49
consumer::consumer(algorithm_name name, std::vector<std::string> predicates) :

phlex/core/declared_fold.hpp

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace phlex::experimental {
3838
declared_fold(algorithm_name name,
3939
std::vector<std::string> predicates,
4040
specified_labels input_products);
41-
virtual ~declared_fold();
41+
~declared_fold() override;
4242

4343
virtual tbb::flow::sender<message>& sender() = 0;
4444
virtual tbb::flow::sender<message>& to_output() = 0;
@@ -55,10 +55,10 @@ namespace phlex::experimental {
5555
class fold_node : public declared_fold, private count_stores {
5656
using all_parameter_types = typename AlgorithmBits::input_parameter_types;
5757
using input_parameter_types = skip_first_type<all_parameter_types>; // Skip fold object
58-
static constexpr auto N = std::tuple_size_v<input_parameter_types>;
59-
using R = std::decay_t<std::tuple_element_t<0, all_parameter_types>>;
58+
static constexpr auto number_inputs = std::tuple_size_v<input_parameter_types>;
59+
using result_type = std::decay_t<std::tuple_element_t<0, all_parameter_types>>;
6060

61-
static constexpr std::size_t M = 1; // hard-coded for now
61+
static constexpr std::size_t number_output_products = 1; // hard-coded for now
6262
using function_t = typename AlgorithmBits::bound_type;
6363

6464
public:
@@ -75,10 +75,11 @@ namespace phlex::experimental {
7575
initializer_{std::move(initializer)},
7676
output_{to_qualified_names(full_name(), std::move(output))},
7777
partition_{std::move(partition)},
78-
join_{make_join_or_none(g, std::make_index_sequence<N>{})},
78+
join_{make_join_or_none(g, std::make_index_sequence<number_inputs>{})},
7979
fold_{g,
8080
concurrency,
81-
[this, ft = alg.release_algorithm()](messages_t<N> const& messages, auto& outputs) {
81+
[this, ft = alg.release_algorithm()](messages_t<number_inputs> const& messages,
82+
auto& outputs) {
8283
// N.B. The assumption is that a fold will *never* need to cache
8384
// the product store it creates. Any flush messages *do not* need
8485
// to be propagated to downstream nodes.
@@ -104,13 +105,13 @@ namespace phlex::experimental {
104105
if (store->is_flush()) {
105106
counter_for(id_hash_for_counter).set_flush_value(store, original_message_id);
106107
} else {
107-
call(ft, messages, std::make_index_sequence<N>{});
108+
call(ft, messages, std::make_index_sequence<number_inputs>{});
108109
counter_for(id_hash_for_counter).increment(store->id()->level_hash());
109110
}
110111

111112
if (auto counter = done_with(id_hash_for_counter)) {
112113
auto parent = fold_store->make_continuation(this->full_name());
113-
commit_(*parent);
114+
commit(*parent);
114115
++product_count_;
115116
// FIXME: This msg.eom value may be wrong!
116117
get<0>(outputs).try_put({parent, msg.eom, counter->original_message_id()});
@@ -123,17 +124,22 @@ namespace phlex::experimental {
123124
private:
124125
tbb::flow::receiver<message>& port_for(specified_label const& product_label) override
125126
{
126-
return receiver_for<N>(join_, input(), product_label);
127+
return receiver_for<number_inputs>(join_, input(), product_label);
127128
}
128129

129-
std::vector<tbb::flow::receiver<message>*> ports() override { return input_ports<N>(join_); }
130+
std::vector<tbb::flow::receiver<message>*> ports() override
131+
{
132+
return input_ports<number_inputs>(join_);
133+
}
130134

131135
tbb::flow::sender<message>& sender() override { return output_port<0ull>(fold_); }
132136
tbb::flow::sender<message>& to_output() override { return sender(); }
133137
qualified_names const& output() const override { return output_; }
134138

135139
template <std::size_t... Is>
136-
void call(function_t const& ft, messages_t<N> const& messages, std::index_sequence<Is...>)
140+
void call(function_t const& ft,
141+
messages_t<number_inputs> const& messages,
142+
std::index_sequence<Is...>)
137143
{
138144
auto const& parent_id = *most_derived(messages).store->id()->parent(partition_);
139145
// FIXME: Not the safest approach!
@@ -142,8 +148,7 @@ namespace phlex::experimental {
142148
it =
143149
results_
144150
.insert({parent_id,
145-
initialized_object(std::move(initializer_),
146-
std::make_index_sequence<std::tuple_size_v<InitTuple>>{})})
151+
initialized_object(std::make_index_sequence<std::tuple_size_v<InitTuple>>{})})
147152
.first;
148153
}
149154
++calls_;
@@ -154,13 +159,12 @@ namespace phlex::experimental {
154159
std::size_t product_count() const final { return product_count_.load(); }
155160

156161
template <size_t... Is>
157-
auto initialized_object(InitTuple&& tuple, std::index_sequence<Is...>) const
162+
auto initialized_object(std::index_sequence<Is...>) const
158163
{
159-
return std::unique_ptr<R>{
160-
new R{std::forward<std::tuple_element_t<Is, InitTuple>>(std::get<Is>(tuple))...}};
164+
return std::unique_ptr<result_type>{new result_type{std::get<Is>(initializer_)...}};
161165
}
162166

163-
void commit_(product_store& store)
167+
void commit(product_store& store)
164168
{
165169
auto& result = results_.at(*store.id());
166170
if constexpr (requires { send(*result); }) {
@@ -177,9 +181,9 @@ namespace phlex::experimental {
177181
input_retriever_types<input_parameter_types> input_{input_arguments<input_parameter_types>()};
178182
qualified_names output_;
179183
std::string partition_;
180-
join_or_none_t<N> join_;
181-
tbb::flow::multifunction_node<messages_t<N>, messages_t<1>> fold_;
182-
tbb::concurrent_unordered_map<level_id, std::unique_ptr<R>> results_;
184+
join_or_none_t<number_inputs> join_;
185+
tbb::flow::multifunction_node<messages_t<number_inputs>, messages_t<1>> fold_;
186+
tbb::concurrent_unordered_map<level_id, std::unique_ptr<result_type>> results_;
183187
std::atomic<std::size_t> calls_;
184188
std::atomic<std::size_t> product_count_;
185189
};

phlex/core/declared_observer.hpp

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace phlex::experimental {
3535
declared_observer(algorithm_name name,
3636
std::vector<std::string> predicates,
3737
specified_labels input_products);
38-
virtual ~declared_observer();
38+
~declared_observer() override;
3939

4040
protected:
4141
using hashes_t = tbb::concurrent_hash_map<level_id::hash_type, bool>;
@@ -51,9 +51,9 @@ namespace phlex::experimental {
5151

5252
template <typename AlgorithmBits>
5353
class observer_node : public declared_observer, private detect_flush_flag {
54-
using InputArgs = typename AlgorithmBits::input_parameter_types;
54+
using input_args = typename AlgorithmBits::input_parameter_types;
5555
using function_t = typename AlgorithmBits::bound_type;
56-
static constexpr auto N = AlgorithmBits::number_inputs;
56+
static constexpr auto number_inputs = AlgorithmBits::number_inputs;
5757

5858
public:
5959
static constexpr auto number_output_products = 0;
@@ -66,17 +66,17 @@ namespace phlex::experimental {
6666
AlgorithmBits alg,
6767
specified_labels input_products) :
6868
declared_observer{std::move(name), std::move(predicates), std::move(input_products)},
69-
join_{make_join_or_none(g, std::make_index_sequence<N>{})},
69+
join_{make_join_or_none(g, std::make_index_sequence<number_inputs>{})},
7070
observer_{g,
7171
concurrency,
7272
[this, ft = alg.release_algorithm()](
73-
messages_t<N> const& messages) -> oneapi::tbb::flow::continue_msg {
73+
messages_t<number_inputs> const& messages) -> oneapi::tbb::flow::continue_msg {
7474
auto const& msg = most_derived(messages);
7575
auto const& [store, message_id] = std::tie(msg.store, msg.id);
7676
if (store->is_flush()) {
7777
flag_for(store->id()->hash()).flush_received(message_id);
7878
} else if (accessor a; needs_new(store, a)) {
79-
call(ft, messages, std::make_index_sequence<N>{});
79+
call(ft, messages, std::make_index_sequence<number_inputs>{});
8080
a->second = true;
8181
flag_for(store->id()->hash()).mark_as_processed();
8282
}
@@ -90,15 +90,26 @@ namespace phlex::experimental {
9090
make_edge(join_, observer_);
9191
}
9292

93-
~observer_node() { report_cached_hashes(cached_hashes_); }
93+
~observer_node() override { report_cached_hashes(cached_hashes_); }
94+
95+
observer_node(observer_node const&) = default;
96+
observer_node& operator=(observer_node const&) = default;
97+
98+
// NOLINTBEGIN(cppcoreguidelines-noexcept-move-operations,performance-noexcept-move-constructor)
99+
observer_node(observer_node&&) = default;
100+
observer_node& operator=(observer_node&&) = default;
101+
// NOLINTEND(cppcoreguidelines-noexcept-move-operations,performance-noexcept-move-constructor)
94102

95103
private:
96104
tbb::flow::receiver<message>& port_for(specified_label const& product_label) override
97105
{
98-
return receiver_for<N>(join_, input(), product_label);
106+
return receiver_for<number_inputs>(join_, input(), product_label);
99107
}
100108

101-
std::vector<tbb::flow::receiver<message>*> ports() override { return input_ports<N>(join_); }
109+
std::vector<tbb::flow::receiver<message>*> ports() override
110+
{
111+
return input_ports<number_inputs>(join_);
112+
}
102113

103114
bool needs_new(product_store_const_ptr const& store, accessor& a)
104115
{
@@ -109,17 +120,19 @@ namespace phlex::experimental {
109120
}
110121

111122
template <std::size_t... Is>
112-
void call(function_t const& ft, messages_t<N> const& messages, std::index_sequence<Is...>)
123+
void call(function_t const& ft,
124+
messages_t<number_inputs> const& messages,
125+
std::index_sequence<Is...>)
113126
{
114127
++calls_;
115128
return std::invoke(ft, std::get<Is>(input_).retrieve(messages)...);
116129
}
117130

118131
std::size_t num_calls() const final { return calls_.load(); }
119132

120-
input_retriever_types<InputArgs> input_{input_arguments<InputArgs>()};
121-
join_or_none_t<N> join_;
122-
tbb::flow::function_node<messages_t<N>> observer_;
133+
input_retriever_types<input_args> input_{input_arguments<input_args>()};
134+
join_or_none_t<number_inputs> join_;
135+
tbb::flow::function_node<messages_t<number_inputs>> observer_;
123136
hashes_t cached_hashes_;
124137
std::atomic<std::size_t> calls_;
125138
};

0 commit comments

Comments
 (0)