Skip to content

Commit cfbdf83

Browse files
authored
Merge pull request #2351 from joto/ct-fixes
Various fixes for stuff found by clang-tidy
2 parents 35c6d73 + b3b1055 commit cfbdf83

File tree

11 files changed

+38
-28
lines changed

11 files changed

+38
-28
lines changed

src/db-copy-mgr.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ class db_copy_mgr_t
9393
* a column delimiter.
9494
*/
9595
template <typename T>
96-
void add_column(T value)
96+
void add_column(T &&value)
9797
{
98-
add_value(value);
98+
add_value(std::forward<T>(value));
9999
m_current.buffer += '\t';
100100
}
101101

src/geom-boost-adaptor.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS(::geom::box_t, ::geom::point_t)
8585
template <>
8686
struct indexed_access<::geom::box_t, min_corner, 0>
8787
{
88-
static inline double get(::geom::box_t const &b) { return b.min_x(); }
89-
static inline void set(::geom::box_t &b, double value)
88+
static double get(::geom::box_t const &b) { return b.min_x(); }
89+
static void set(::geom::box_t &b, double value)
9090
{
9191
b.set_min_x(value);
9292
}
@@ -95,8 +95,8 @@ struct indexed_access<::geom::box_t, min_corner, 0>
9595
template <>
9696
struct indexed_access<::geom::box_t, min_corner, 1>
9797
{
98-
static inline double get(::geom::box_t const &b) { return b.min_y(); }
99-
static inline void set(::geom::box_t &b, double value)
98+
static double get(::geom::box_t const &b) { return b.min_y(); }
99+
static void set(::geom::box_t &b, double value)
100100
{
101101
b.set_min_y(value);
102102
}
@@ -105,8 +105,8 @@ struct indexed_access<::geom::box_t, min_corner, 1>
105105
template <>
106106
struct indexed_access<::geom::box_t, max_corner, 0>
107107
{
108-
static inline double get(::geom::box_t const &b) { return b.max_x(); }
109-
static inline void set(::geom::box_t &b, double value)
108+
static double get(::geom::box_t const &b) { return b.max_x(); }
109+
static void set(::geom::box_t &b, double value)
110110
{
111111
b.set_max_x(value);
112112
}
@@ -115,8 +115,8 @@ struct indexed_access<::geom::box_t, max_corner, 0>
115115
template <>
116116
struct indexed_access<::geom::box_t, max_corner, 1>
117117
{
118-
static inline double get(::geom::box_t const &b) { return b.max_y(); }
119-
static inline void set(::geom::box_t &b, double value)
118+
static double get(::geom::box_t const &b) { return b.max_y(); }
119+
static void set(::geom::box_t &b, double value)
120120
{
121121
b.set_max_y(value);
122122
}

src/geom-functions.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ point_t interpolate(point_t p1, point_t p2, double frac) noexcept;
4343
* \pre \code !list.empty() \endcode
4444
*/
4545
template <typename FUNC>
46-
void for_each_segment(point_list_t const &list, FUNC &&func)
46+
void for_each_segment(point_list_t const &list, FUNC const &func)
4747
{
4848
assert(!list.empty());
4949
auto it = list.cbegin();
5050
auto prev = it;
5151
for (++it; it != list.cend(); ++it) {
52-
std::forward<FUNC>(func)(*prev, *it);
52+
func(*prev, *it);
5353
prev = it;
5454
}
5555
}

src/lua-utils.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ void luaX_add_table_func(lua_State *lua_state, char const *key,
4040

4141
template <typename COLLECTION, typename FUNC>
4242
void luaX_add_table_array(lua_State *lua_state, char const *key,
43-
COLLECTION const &collection, FUNC &&func)
43+
COLLECTION const &collection, FUNC const &func)
4444
{
4545
lua_pushstring(lua_state, key);
4646
lua_createtable(lua_state, (int)collection.size(), 0);
4747
int n = 0;
4848
for (auto const &member : collection) {
4949
lua_pushinteger(lua_state, ++n);
50-
std::forward<FUNC>(func)(member);
50+
func(member);
5151
lua_rawset(lua_state, -3);
5252
}
5353
lua_rawset(lua_state, -3);
@@ -99,15 +99,15 @@ bool luaX_is_array(lua_State *lua_state);
9999
* \post Stack is unchanged.
100100
*/
101101
template <typename FUNC>
102-
void luaX_for_each(lua_State *lua_state, FUNC &&func)
102+
void luaX_for_each(lua_State *lua_state, FUNC const &func)
103103
{
104104
assert(lua_istable(lua_state, -1));
105105
lua_pushnil(lua_state);
106106
while (lua_next(lua_state, -2) != 0) {
107107
#ifndef NDEBUG
108108
int const top = lua_gettop(lua_state);
109109
#endif
110-
std::forward<FUNC>(func)();
110+
func();
111111
assert(top == lua_gettop(lua_state));
112112
lua_pop(lua_state, 1);
113113
}

src/output-pgsql.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@
2323
#include "tagtransform.hpp"
2424

2525
#include <array>
26+
#include <cstdint>
2627
#include <memory>
2728

2829
class output_pgsql_t : public output_t
2930
{
3031
public:
31-
enum table_id
32+
enum table_id : std::uint8_t
3233
{
3334
t_point = 0,
3435
t_line,

src/params.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class params_t
5454
m_map.insert_or_assign(std::forward<K>(key), value);
5555
}
5656

57+
// NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
5758
template <typename K, typename V,
5859
std::enable_if_t<std::is_integral_v<std::remove_reference_t<V>>,
5960
bool> = true>
@@ -71,6 +72,7 @@ class params_t
7172
{
7273
m_map.insert_or_assign(std::forward<K>(key), std::string(value));
7374
}
75+
// NOLINTEND(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
7476

7577
template <typename K>
7678
void remove(K &&key)

src/pgsql.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class pg_conn_t
180180
* status code PGRES_COMMAND_OK or PGRES_TUPLES_OK).
181181
*/
182182
template <typename... TArgs>
183-
pg_result_t exec(fmt::format_string<TArgs...> sql, TArgs... params) const
183+
pg_result_t exec(fmt::format_string<TArgs...> sql, TArgs &&...params) const
184184
{
185185
return exec(fmt::format(sql, std::forward<TArgs>(params)...));
186186
}
@@ -196,7 +196,7 @@ class pg_conn_t
196196
*/
197197
template <typename... TArgs>
198198
void prepare(std::string const &stmt, fmt::format_string<TArgs...> sql,
199-
TArgs... params) const
199+
TArgs &&...params) const
200200
{
201201
std::string const query =
202202
fmt::format(sql, std::forward<TArgs>(params)...);
@@ -213,7 +213,7 @@ class pg_conn_t
213213
* \throws exception if the command failed.
214214
*/
215215
template <typename... TArgs>
216-
pg_result_t exec_prepared(char const *stmt, TArgs... params) const
216+
pg_result_t exec_prepared(char const *stmt, TArgs &&...params) const
217217
{
218218
return exec_prepared_with_result_format(stmt, false,
219219
std::forward<TArgs>(params)...);
@@ -229,7 +229,8 @@ class pg_conn_t
229229
* \throws exception if the command failed.
230230
*/
231231
template <typename... TArgs>
232-
pg_result_t exec_prepared_as_binary(char const *stmt, TArgs... params) const
232+
pg_result_t exec_prepared_as_binary(char const *stmt,
233+
TArgs &&...params) const
233234
{
234235
return exec_prepared_with_result_format(stmt, true,
235236
std::forward<TArgs>(params)...);
@@ -312,7 +313,7 @@ class pg_conn_t
312313
template <typename... TArgs>
313314
pg_result_t exec_prepared_with_result_format(char const *stmt,
314315
bool result_as_binary,
315-
TArgs... params) const
316+
TArgs &&...params) const
316317
{
317318
// We have to convert all non-string parameters into strings and
318319
// store them somewhere. We use the exec_params vector for this.

src/table.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ void table_t::task_wait()
355355
util::human_readable_duration(run_time));
356356
}
357357

358+
// NOLINTBEGIN(google-runtime-int,cert-err34-c)
359+
// This is legacy code which will be removed anyway.
360+
358361
/* Escape data appropriate to the type */
359362
void table_t::escape_type(std::string const &value, ColumnType flags)
360363
{
@@ -423,6 +426,7 @@ void table_t::escape_type(std::string const &value, ColumnType flags)
423426
break;
424427
}
425428
}
429+
// NOLINTEND(google-runtime-int,cert-err34-c)
426430

427431
pg_result_t table_t::get_wkb(osmid_t id)
428432
{

src/taginfo-impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <utility>
2020
#include <vector>
2121

22-
enum column_flags : unsigned int
22+
enum column_flags : unsigned int // NOLINT(performance-enum-size)
2323
{
2424
FLAG_POLYGON = 1, /* For polygon table */
2525
FLAG_LINEAR = 2, /* For lines table */

src/taginfo.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ unsigned get_tag_type(std::string const &tag)
8787

8888
} // anonymous namespace
8989

90+
// NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
91+
// This is legacy code which will be removed anyway.
9092
bool read_style_file(std::string const &filename, export_list *exlist)
9193
{
9294
bool enable_way_area = true;
@@ -195,3 +197,4 @@ bool read_style_file(std::string const &filename, export_list *exlist)
195197

196198
return enable_way_area;
197199
}
200+
// NOLINTEND(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)

0 commit comments

Comments
 (0)