Skip to content

Commit afe33df

Browse files
committed
Various cleanups and fixes based on clang-tidy reports
Fiddle with the clang-tidy config and add fixes.
1 parent 37b7242 commit afe33df

17 files changed

+54
-34
lines changed

.clang-tidy

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
Checks: '*,-android-cloexec-*,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-cstyle-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-vararg,-fuchsia-*,-google-readability-casting,-google-readability-todo,-hicpp-no-array-decay,-hicpp-vararg,-llvm-include-order,-modernize-make-unique,-readability-implicit-bool-conversion,-readability-named-parameter'
2+
Checks: '*,-android-cloexec-*,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-cstyle-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-vararg,-fuchsia-*,-google-readability-casting,-google-readability-todo,-hicpp-no-array-decay,-hicpp-vararg,-llvm-include-order,-llvm-header-guard,-modernize-make-unique,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-named-parameter,-readability-magic-numbers'
33
#
44
# cppcoreguidelines-pro-type-cstyle-cast
55
# google-build-using-namespace
@@ -11,6 +11,12 @@ Checks: '*,-android-cloexec-*,-cppcoreguidelines-owning-memory,-cppcoreguideline
1111
# android-cloexec-*
1212
# O_CLOEXEC isn't available on Windows
1313
#
14+
# cppcoreguidelines-avoid-magic-numbers
15+
# readability-magic-numbers
16+
# We have a lot of these and should probably at least fix some. But remove
17+
# it for the time being because with it we can't see the forest for the
18+
# trees. (TODO)
19+
#
1420
# cppcoreguidelines-owning-memory
1521
# cppcoreguidelines-pro-bounds-array-to-pointer-decay
1622
# cppcoreguidelines-pro-bounds-pointer-arithmetic
@@ -26,11 +32,18 @@ Checks: '*,-android-cloexec-*,-cppcoreguidelines-owning-memory,-cppcoreguideline
2632
# google-readability-todo
2733
# We are not that organized
2834
#
35+
# llvm-header-guard
36+
# Not our style
37+
#
2938
# modernize-make-unique
3039
# Not available in C++11
3140
#
41+
# modernize-use-trailing-return-type
42+
# We are not that modern...
43+
#
3244
# readability-implicit-bool-conversion
3345
# Readability is a matter of opinion here
3446
#
3547
#WarningsAsErrors: '*'
48+
HeaderFilterRegex: '\/src\/'
3649
...

src/flex-table.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class flex_table_t
3131
permanent
3232
};
3333

34-
flex_table_t(std::string const &name, int srid) : m_name(name), m_srid(srid)
34+
flex_table_t(std::string name, int srid)
35+
: m_name(std::move(name)), m_srid(srid)
3536
{}
3637

3738
std::string const &name() const noexcept { return m_name; }

src/gazetteer-style.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ class db_deleter_place_t
7373
class gazetteer_copy_mgr_t : public db_copy_mgr_t<db_deleter_place_t>
7474
{
7575
public:
76-
gazetteer_copy_mgr_t(std::shared_ptr<db_copy_thread_t> const &processor)
76+
explicit gazetteer_copy_mgr_t(
77+
std::shared_ptr<db_copy_thread_t> const &processor)
7778
: db_copy_mgr_t<db_deleter_place_t>(processor),
7879
m_table(std::make_shared<db_target_descr_t>("place", "place_id"))
7980
{}
@@ -167,7 +168,7 @@ class gazetteer_style_t
167168
/// addresstags to include
168169
std::vector<ptag_t> m_address;
169170
/// value of operator tag
170-
char const *m_operator;
171+
char const *m_operator = nullptr;
171172
/// admin level
172173
int m_admin_level;
173174

src/middle-ram.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ void middle_ram_t::stop(thread_pool_t &)
118118
}
119119

120120
middle_ram_t::middle_ram_t(options_t const *options)
121-
: m_ways(), m_rels(),
122-
m_cache(new node_ram_cache{options->alloc_chunkwise, options->cache}),
121+
: m_cache(new node_ram_cache{options->alloc_chunkwise, options->cache}),
123122
m_extra_attributes(options->extra_attributes)
124123
{}
125124

src/middle-ram.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class elem_cache_t
7575
assert(block < m_blocks.size());
7676

7777
if (!m_blocks[block]) {
78-
return 0;
78+
return nullptr;
7979
}
8080

8181
return m_blocks[block]->get(id2offset(id));
@@ -91,8 +91,8 @@ class elem_cache_t
9191

9292
struct middle_ram_t : public middle_t, public middle_query_t
9393
{
94-
middle_ram_t(options_t const *options);
95-
virtual ~middle_ram_t() noexcept = default;
94+
explicit middle_ram_t(options_t const *options);
95+
~middle_ram_t() noexcept override = default;
9696

9797
void start() override {}
9898
void stop(thread_pool_t &pool) override;

src/middle.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ struct middle_t
8787

8888
virtual void start() = 0;
8989
virtual void stop(thread_pool_t &pool) = 0;
90-
virtual void analyze(void) = 0;
91-
virtual void commit(void) = 0;
90+
virtual void analyze() = 0;
91+
virtual void commit() = 0;
9292

9393
/**
9494
* Add a node to data storage. The node must not already be in the
@@ -135,7 +135,7 @@ inline middle_t::~middle_t() = default;
135135
*/
136136
struct slim_middle_t : public middle_t
137137
{
138-
virtual ~slim_middle_t() = 0;
138+
~slim_middle_t() override = 0;
139139

140140
/**
141141
* Delete a node from data storage. Either because you want it removed

src/options.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,11 @@ options_t::options_t()
297297

298298
static osmium::Box parse_bbox(char const *bbox)
299299
{
300-
double minx, maxx, miny, maxy;
300+
double minx;
301+
double maxx;
302+
double miny;
303+
double maxy;
304+
301305
int const n = sscanf(bbox, "%lf,%lf,%lf,%lf", &minx, &miny, &maxx, &maxy);
302306
if (n != 4) {
303307
throw std::runtime_error{"Bounding box must be specified like: "

src/output-flex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ int output_flex_t::table_add_row()
799799

800800
auto &table_connection =
801801
m_table_connections.at(table_idx_from_param(lua_state()));
802-
auto &table = table_connection.table();
802+
auto const &table = table_connection.table();
803803
luaL_checktype(lua_state(), 2, LUA_TTABLE);
804804
lua_remove(lua_state(), 1);
805805

src/output-flex.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class prepared_lua_function_t
7676
calling_context context() const noexcept { return m_calling_context; }
7777

7878
/// Is this function defined in the users Lua code?
79-
operator bool() const noexcept { return m_index != 0; }
79+
explicit operator bool() const noexcept { return m_index != 0; }
8080

8181
private:
8282
char const *m_name = nullptr;
@@ -107,7 +107,7 @@ class output_flex_t : public output_t
107107
output_flex_t(output_flex_t &&) = delete;
108108
output_flex_t &operator=(output_flex_t &&) = delete;
109109

110-
virtual ~output_flex_t() noexcept = default;
110+
~output_flex_t() noexcept override = default;
111111

112112
std::shared_ptr<output_t>
113113
clone(std::shared_ptr<middle_query_t> const &mid,

src/output-null.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class output_null_t : public output_t
1111
public:
1212
output_null_t(std::shared_ptr<middle_query_t> const &mid,
1313
options_t const &options);
14-
virtual ~output_null_t();
14+
15+
~output_null_t() override;
1516

1617
std::shared_ptr<output_t>
1718
clone(std::shared_ptr<middle_query_t> const &mid,

0 commit comments

Comments
 (0)