mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-20 15:40:45 +00:00
clang-tidy fixes (mostly manual) related to PR #3166
This commit is contained in:
parent
e3e1d29fdb
commit
e41fb99e7e
@ -309,7 +309,7 @@ struct smart_holder {
|
||||
hld.vptr.reset(static_cast<void *>(unq_ptr.get()), std::move(gd));
|
||||
else
|
||||
hld.vptr.reset(unq_ptr.get(), std::move(gd));
|
||||
unq_ptr.release();
|
||||
(void) unq_ptr.release();
|
||||
hld.is_populated = true;
|
||||
return hld;
|
||||
}
|
||||
|
@ -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) {
|
||||
switch (policy) {
|
||||
case return_value_policy::automatic:
|
||||
break;
|
||||
case return_value_policy::automatic_reference:
|
||||
break;
|
||||
case return_value_policy::take_ownership:
|
||||
throw cast_error("Invalid return_value_policy for shared_ptr (take_ownership).");
|
||||
case return_value_policy::copy:
|
||||
break;
|
||||
case return_value_policy::move:
|
||||
break;
|
||||
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.
|
||||
self_life_support->deactivate_life_support();
|
||||
holder.reclaim_disowned();
|
||||
src.release();
|
||||
(void) src.release();
|
||||
// Critical section end.
|
||||
return existing_inst;
|
||||
}
|
||||
|
@ -137,8 +137,8 @@ TEST_CASE("from_raw_ptr_take_ownership+disown+reclaim_disowned", "[S]") {
|
||||
REQUIRE(*new_owner == 19);
|
||||
hld.reclaim_disowned(); // Manually veriified: without this, clang++ -fsanitize=address reports
|
||||
// "detected memory leaks".
|
||||
new_owner.release(); // Manually verified: without this, clang++ -fsanitize=address reports
|
||||
// "attempting double-free".
|
||||
(void) new_owner.release(); // Manually verified: without this, clang++ -fsanitize=address
|
||||
// reports "attempting double-free".
|
||||
REQUIRE(hld.as_lvalue_ref<int>() == 19);
|
||||
REQUIRE(new_owner.get() == nullptr);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ struct Sft : std::enable_shared_from_this<Sft> {
|
||||
// history in case something goes wrong.
|
||||
// However, compilers other than clang have a variety of issues. It is not
|
||||
// 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"; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user