clang-tidy fixes (mostly manual) related to PR #3166

This commit is contained in:
Ralf W. Grosse-Kunstleve 2021-08-14 12:45:50 -07:00
parent e3e1d29fdb
commit e41fb99e7e
4 changed files with 5 additions and 7 deletions

View File

@ -309,7 +309,7 @@ struct smart_holder {
hld.vptr.reset(static_cast<void *>(unq_ptr.get()), std::move(gd)); hld.vptr.reset(static_cast<void *>(unq_ptr.get()), std::move(gd));
else else
hld.vptr.reset(unq_ptr.get(), std::move(gd)); hld.vptr.reset(unq_ptr.get(), std::move(gd));
unq_ptr.release(); (void) unq_ptr.release();
hld.is_populated = true; hld.is_populated = true;
return hld; return hld;
} }

View File

@ -704,13 +704,11 @@ struct smart_holder_type_caster<std::shared_ptr<T>> : smart_holder_type_caster_l
static handle cast(const std::shared_ptr<T> &src, return_value_policy policy, handle parent) { static handle cast(const std::shared_ptr<T> &src, return_value_policy policy, handle parent) {
switch (policy) { switch (policy) {
case return_value_policy::automatic: case return_value_policy::automatic:
break;
case return_value_policy::automatic_reference: case return_value_policy::automatic_reference:
break; break;
case return_value_policy::take_ownership: case return_value_policy::take_ownership:
throw cast_error("Invalid return_value_policy for shared_ptr (take_ownership)."); throw cast_error("Invalid return_value_policy for shared_ptr (take_ownership).");
case return_value_policy::copy: case return_value_policy::copy:
break;
case return_value_policy::move: case return_value_policy::move:
break; break;
case return_value_policy::reference: case return_value_policy::reference:
@ -809,7 +807,7 @@ struct smart_holder_type_caster<std::unique_ptr<T, D>> : smart_holder_type_caste
// Critical transfer-of-ownership section. This must stay together. // Critical transfer-of-ownership section. This must stay together.
self_life_support->deactivate_life_support(); self_life_support->deactivate_life_support();
holder.reclaim_disowned(); holder.reclaim_disowned();
src.release(); (void) src.release();
// Critical section end. // Critical section end.
return existing_inst; return existing_inst;
} }

View File

@ -137,8 +137,8 @@ TEST_CASE("from_raw_ptr_take_ownership+disown+reclaim_disowned", "[S]") {
REQUIRE(*new_owner == 19); REQUIRE(*new_owner == 19);
hld.reclaim_disowned(); // Manually veriified: without this, clang++ -fsanitize=address reports hld.reclaim_disowned(); // Manually veriified: without this, clang++ -fsanitize=address reports
// "detected memory leaks". // "detected memory leaks".
new_owner.release(); // Manually verified: without this, clang++ -fsanitize=address reports (void) new_owner.release(); // Manually verified: without this, clang++ -fsanitize=address
// "attempting double-free". // reports "attempting double-free".
REQUIRE(hld.as_lvalue_ref<int>() == 19); REQUIRE(hld.as_lvalue_ref<int>() == 19);
REQUIRE(new_owner.get() == nullptr); REQUIRE(new_owner.get() == nullptr);
} }

View File

@ -21,7 +21,7 @@ struct Sft : std::enable_shared_from_this<Sft> {
// history in case something goes wrong. // history in case something goes wrong.
// However, compilers other than clang have a variety of issues. It is not // However, compilers other than clang have a variety of issues. It is not
// worth the trouble covering all platforms. // worth the trouble covering all platforms.
Sft(const Sft &other) { history = other.history + "_CpCtor"; } Sft(const Sft &other) : enable_shared_from_this(other) { history = other.history + "_CpCtor"; }
Sft(Sft &&other) noexcept { history = other.history + "_MvCtor"; } Sft(Sft &&other) noexcept { history = other.history + "_MvCtor"; }