Skip to content

Commit 2eeac0c

Browse files
committed
Applying clang-tidy fixes needed after merging PR #3051 (mostly automatically).
1 parent 898d5b3 commit 2eeac0c

5 files changed

+24
-23
lines changed

tests/test_class_sh_basic.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct atyp { // Short for "any type".
1414
atyp() : mtxt("DefaultConstructor") {}
1515
atyp(const std::string &mtxt_) : mtxt(mtxt_) {}
1616
atyp(const atyp &other) { mtxt = other.mtxt + "_CpCtor"; }
17-
atyp(atyp &&other) { mtxt = other.mtxt + "_MvCtor"; }
17+
atyp(atyp &&other) noexcept { mtxt = other.mtxt + "_MvCtor"; }
1818
};
1919

2020
struct uconsumer { // unique_ptr consumer
@@ -37,7 +37,7 @@ atyp& rtrn_mref() { static atyp obj; obj.mtxt = "rtrn_mref"; return obj; }
3737
atyp const* rtrn_cptr() { return new atyp{"rtrn_cptr"}; }
3838
atyp* rtrn_mptr() { return new atyp{"rtrn_mptr"}; }
3939

40-
std::string pass_valu(atyp obj) { return "pass_valu:" + obj.mtxt; }
40+
std::string pass_valu(atyp obj) { return "pass_valu:" + obj.mtxt; } // NOLINT
4141
std::string pass_cref(atyp const& obj) { return "pass_cref:" + obj.mtxt; }
4242
std::string pass_mref(atyp& obj) { return "pass_mref:" + obj.mtxt; }
4343
std::string pass_cptr(atyp const* obj) { return "pass_cptr:" + obj->mtxt; }
@@ -46,8 +46,8 @@ std::string pass_mptr(atyp* obj) { return "pass_mptr:" + obj->mtxt; }
4646
std::shared_ptr<atyp> rtrn_shmp() { return std::shared_ptr<atyp >(new atyp{"rtrn_shmp"}); }
4747
std::shared_ptr<atyp const> rtrn_shcp() { return std::shared_ptr<atyp const>(new atyp{"rtrn_shcp"}); }
4848

49-
std::string pass_shmp(std::shared_ptr<atyp> obj) { return "pass_shmp:" + obj->mtxt; }
50-
std::string pass_shcp(std::shared_ptr<atyp const> obj) { return "pass_shcp:" + obj->mtxt; }
49+
std::string pass_shmp(std::shared_ptr<atyp> obj) { return "pass_shmp:" + obj->mtxt; } // NOLINT
50+
std::string pass_shcp(std::shared_ptr<atyp const> obj) { return "pass_shcp:" + obj->mtxt; } // NOLINT
5151

5252
std::unique_ptr<atyp> rtrn_uqmp() { return std::unique_ptr<atyp >(new atyp{"rtrn_uqmp"}); }
5353
std::unique_ptr<atyp const> rtrn_uqcp() { return std::unique_ptr<atyp const>(new atyp{"rtrn_uqcp"}); }
@@ -77,7 +77,7 @@ const std::unique_ptr<atyp> &unique_ptr_cref_roundtrip(const std::unique_ptr<aty
7777

7878
struct SharedPtrStash {
7979
std::vector<std::shared_ptr<const atyp>> stash;
80-
void Add(std::shared_ptr<const atyp> obj) { stash.push_back(obj); }
80+
void Add(const std::shared_ptr<const atyp> &obj) { stash.push_back(obj); }
8181
};
8282

8383
} // namespace class_sh_basic

tests/test_class_sh_inheritance.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ struct base_template {
1515
int base_id;
1616

1717
// Some compilers complain about implicitly defined versions of some of the following:
18-
base_template(const base_template &) = default;
19-
base_template(base_template &&) = default;
18+
base_template(const base_template &) = default;
19+
base_template(base_template &&) noexcept = default;
2020
base_template &operator=(const base_template &) = default;
21-
base_template &operator=(base_template &&) = default;
21+
base_template &operator=(base_template &&) noexcept = default;
2222
};
2323

2424
using base = base_template<100>;
@@ -37,8 +37,8 @@ inline int pass_cptr_drvd(drvd const *d) { return d->id() + 12; }
3737
inline std::shared_ptr<drvd> rtrn_shmp_drvd() { return std::shared_ptr<drvd>(new drvd); }
3838
inline std::shared_ptr<base> rtrn_shmp_drvd_up_cast() { return std::shared_ptr<drvd>(new drvd); }
3939

40-
inline int pass_shcp_base(std::shared_ptr<base const> b) { return b->id() + 21; }
41-
inline int pass_shcp_drvd(std::shared_ptr<drvd const> d) { return d->id() + 22; }
40+
inline int pass_shcp_base(const std::shared_ptr<base const>& b) { return b->id() + 21; }
41+
inline int pass_shcp_drvd(const std::shared_ptr<drvd const>& d) { return d->id() + 22; }
4242
// clang-format on
4343

4444
using base1 = base_template<110>;

tests/test_class_sh_trampoline_basic.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ struct Abase {
1616
virtual int Add(int other_val) const = 0;
1717

1818
// Some compilers complain about implicitly defined versions of some of the following:
19-
Abase(const Abase &) = default;
20-
Abase(Abase &&) = default;
19+
Abase(const Abase &) = default;
20+
Abase(Abase &&) noexcept = default;
2121
Abase &operator=(const Abase &) = default;
22-
Abase &operator=(Abase &&) = default;
22+
Abase &operator=(Abase &&) noexcept = default;
2323
};
2424

2525
template <int SerNo>

tests/test_class_sh_trampoline_self_life_support.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,25 @@
88

99
#include <memory>
1010
#include <string>
11+
#include <utility>
1112

1213
namespace {
1314

1415
struct Big5 { // Also known as "rule of five".
1516
std::string history;
1617

17-
explicit Big5(std::string history_start) : history{history_start} {}
18+
explicit Big5(std::string history_start) : history{std::move(history_start)} {}
1819

1920
Big5(const Big5 &other) { history = other.history + "_CpCtor"; }
2021

21-
Big5(Big5 &&other) { history = other.history + "_MvCtor"; }
22+
Big5(Big5 &&other) noexcept { history = other.history + "_MvCtor"; }
2223

2324
Big5 &operator=(const Big5 &other) {
2425
history = other.history + "_OpEqLv";
2526
return *this;
2627
}
2728

28-
Big5 &operator=(Big5 &&other) {
29+
Big5 &operator=(Big5 &&other) noexcept {
2930
history = other.history + "_OpEqRv";
3031
return *this;
3132
}

tests/test_class_sh_trampoline_shared_ptr_cpp_arg.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
#include "pybind11_tests.h"
5+
#include <utility>
6+
67
#include "pybind11/smart_holder.h"
8+
#include "pybind11_tests.h"
79

810
namespace {
911

@@ -16,7 +18,7 @@ struct SpBase {
1618
// returns true if there's an associated python instance
1719
bool has_python_instance() {
1820
auto tinfo = py::detail::get_type_info(typeid(SpBase));
19-
return (bool)py::detail::get_object_handle(this, tinfo);
21+
return (bool) py::detail::get_object_handle(this, tinfo);
2022
}
2123

2224
SpBase() = default;
@@ -30,13 +32,11 @@ struct PySpBase : SpBase {
3032

3133
struct SpBaseTester {
3234
std::shared_ptr<SpBase> get_object() const { return m_obj; }
33-
void set_object(std::shared_ptr<SpBase> obj) { m_obj = obj; }
35+
void set_object(std::shared_ptr<SpBase> obj) { m_obj = std::move(obj); }
3436
bool is_base_used() { return m_obj->is_base_used(); }
35-
bool has_instance() { return (bool)m_obj; }
37+
bool has_instance() { return (bool) m_obj; }
3638
bool has_python_instance() { return m_obj && m_obj->has_python_instance(); }
37-
void set_nonpython_instance() {
38-
m_obj = std::make_shared<SpBase>();
39-
}
39+
void set_nonpython_instance() { m_obj = std::make_shared<SpBase>(); }
4040
std::shared_ptr<SpBase> m_obj;
4141
};
4242

0 commit comments

Comments
 (0)