Skip to content

Commit e41fb99

Browse files
committed
clang-tidy fixes (mostly manual) related to PR pybind#3166
1 parent e3e1d29 commit e41fb99

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

include/pybind11/detail/smart_holder_poc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ struct smart_holder {
309309
hld.vptr.reset(static_cast<void *>(unq_ptr.get()), std::move(gd));
310310
else
311311
hld.vptr.reset(unq_ptr.get(), std::move(gd));
312-
unq_ptr.release();
312+
(void) unq_ptr.release();
313313
hld.is_populated = true;
314314
return hld;
315315
}

include/pybind11/detail/smart_holder_type_casters.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,13 +704,11 @@ struct smart_holder_type_caster<std::shared_ptr<T>> : smart_holder_type_caster_l
704704
static handle cast(const std::shared_ptr<T> &src, return_value_policy policy, handle parent) {
705705
switch (policy) {
706706
case return_value_policy::automatic:
707-
break;
708707
case return_value_policy::automatic_reference:
709708
break;
710709
case return_value_policy::take_ownership:
711710
throw cast_error("Invalid return_value_policy for shared_ptr (take_ownership).");
712711
case return_value_policy::copy:
713-
break;
714712
case return_value_policy::move:
715713
break;
716714
case return_value_policy::reference:
@@ -809,7 +807,7 @@ struct smart_holder_type_caster<std::unique_ptr<T, D>> : smart_holder_type_caste
809807
// Critical transfer-of-ownership section. This must stay together.
810808
self_life_support->deactivate_life_support();
811809
holder.reclaim_disowned();
812-
src.release();
810+
(void) src.release();
813811
// Critical section end.
814812
return existing_inst;
815813
}

tests/pure_cpp/smart_holder_poc_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ TEST_CASE("from_raw_ptr_take_ownership+disown+reclaim_disowned", "[S]") {
137137
REQUIRE(*new_owner == 19);
138138
hld.reclaim_disowned(); // Manually veriified: without this, clang++ -fsanitize=address reports
139139
// "detected memory leaks".
140-
new_owner.release(); // Manually verified: without this, clang++ -fsanitize=address reports
141-
// "attempting double-free".
140+
(void) new_owner.release(); // Manually verified: without this, clang++ -fsanitize=address
141+
// reports "attempting double-free".
142142
REQUIRE(hld.as_lvalue_ref<int>() == 19);
143143
REQUIRE(new_owner.get() == nullptr);
144144
}

tests/test_class_sh_trampoline_shared_from_this.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct Sft : std::enable_shared_from_this<Sft> {
2121
// history in case something goes wrong.
2222
// However, compilers other than clang have a variety of issues. It is not
2323
// worth the trouble covering all platforms.
24-
Sft(const Sft &other) { history = other.history + "_CpCtor"; }
24+
Sft(const Sft &other) : enable_shared_from_this(other) { history = other.history + "_CpCtor"; }
2525

2626
Sft(Sft &&other) noexcept { history = other.history + "_MvCtor"; }
2727

0 commit comments

Comments
 (0)