Skip to content

Commit 52c3f4c

Browse files
authored
This was meant to be PR #3065: pure clang-format changes. NO manual changes. (#3073)
1 parent 05417a4 commit 52c3f4c

15 files changed

+64
-64
lines changed

include/pybind11/detail/init.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void construct(value_and_holder &v_h, std::shared_ptr<Cpp<Class>> &&shd_ptr, boo
217217
if (Class::has_alias && need_alias && !is_alias<Class>(ptr))
218218
throw type_error("pybind11::init(): construction failed: returned std::shared_ptr pointee "
219219
"is not an alias instance");
220-
auto smhldr = type_caster<Cpp<Class>>::template smart_holder_from_shared_ptr(shd_ptr);
220+
auto smhldr = type_caster<Cpp<Class>>::template smart_holder_from_shared_ptr(shd_ptr);
221221
v_h.value_ptr() = ptr;
222222
v_h.type->init_instance(v_h.inst, &smhldr);
223223
}
@@ -230,7 +230,7 @@ void construct(value_and_holder &v_h,
230230
bool /*need_alias*/) {
231231
auto *ptr = shd_ptr.get();
232232
no_nullptr(ptr);
233-
auto smhldr = type_caster<Alias<Class>>::template smart_holder_from_shared_ptr(shd_ptr);
233+
auto smhldr = type_caster<Alias<Class>>::template smart_holder_from_shared_ptr(shd_ptr);
234234
v_h.value_ptr() = ptr;
235235
v_h.type->init_instance(v_h.inst, &smhldr);
236236
}

include/pybind11/detail/smart_holder_poc.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct smart_holder {
124124
bool pointee_depends_on_holder_owner : 1; // SMART_HOLDER_WIP: See PR #2839.
125125

126126
// Design choice: smart_holder is movable but not copyable.
127-
smart_holder(smart_holder &&) = default;
127+
smart_holder(smart_holder &&) = default;
128128
smart_holder(const smart_holder &) = delete;
129129
smart_holder &operator=(smart_holder &&) = delete;
130130
smart_holder &operator=(const smart_holder &) = delete;
@@ -219,7 +219,7 @@ struct smart_holder {
219219
smart_holder hld;
220220
hld.vptr.reset(raw_ptr, [](void *) {});
221221
hld.vptr_is_using_noop_deleter = true;
222-
hld.is_populated = true;
222+
hld.is_populated = true;
223223
return hld;
224224
}
225225

@@ -254,7 +254,7 @@ struct smart_holder {
254254
else
255255
hld.vptr.reset(raw_ptr, std::move(gd));
256256
hld.vptr_is_using_builtin_delete = true;
257-
hld.is_populated = true;
257+
hld.is_populated = true;
258258
return hld;
259259
}
260260

@@ -298,7 +298,7 @@ struct smart_holder {
298298
static smart_holder from_unique_ptr(std::unique_ptr<T, D> &&unq_ptr,
299299
bool void_cast_raw_ptr = false) {
300300
smart_holder hld;
301-
hld.rtti_uqp_del = &typeid(D);
301+
hld.rtti_uqp_del = &typeid(D);
302302
hld.vptr_is_using_builtin_delete = is_std_default_delete<T>(*hld.rtti_uqp_del);
303303
guarded_delete gd{nullptr, false};
304304
if (hld.vptr_is_using_builtin_delete)
@@ -327,9 +327,9 @@ struct smart_holder {
327327
template <typename T>
328328
static smart_holder from_shared_ptr(std::shared_ptr<T> shd_ptr) {
329329
smart_holder hld;
330-
hld.vptr = std::static_pointer_cast<void>(shd_ptr);
330+
hld.vptr = std::static_pointer_cast<void>(shd_ptr);
331331
hld.vptr_is_external_shared_ptr = true;
332-
hld.is_populated = true;
332+
hld.is_populated = true;
333333
return hld;
334334
}
335335

include/pybind11/detail/smart_holder_type_casters.h

+19-19
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ struct smart_holder_type_caster_class_hooks : smart_holder_type_caster_base_tag
308308
v_h.set_instance_registered();
309309
}
310310
auto uninitialized_location = std::addressof(v_h.holder<holder_type>());
311-
auto value_ptr_w_t = v_h.value_ptr<WrappedType>();
311+
auto value_ptr_w_t = v_h.value_ptr<WrappedType>();
312312
bool pointee_depends_on_holder_owner
313313
= dynamic_raw_ptr_cast_if_possible<AliasType>(value_ptr_w_t) != nullptr;
314314
if (holder_void_ptr) {
@@ -627,21 +627,21 @@ struct smart_holder_type_caster : smart_holder_type_caster_load<T>,
627627
if (handle existing_inst = find_registered_python_instance(src, tinfo))
628628
return existing_inst;
629629

630-
auto inst = reinterpret_steal<object>(make_new_instance(tinfo->type));
631-
auto wrapper = reinterpret_cast<instance *>(inst.ptr());
632-
wrapper->owned = false;
630+
auto inst = reinterpret_steal<object>(make_new_instance(tinfo->type));
631+
auto wrapper = reinterpret_cast<instance *>(inst.ptr());
632+
wrapper->owned = false;
633633
void *&valueptr = values_and_holders(wrapper).begin()->value_ptr();
634634

635635
switch (policy) {
636636
case return_value_policy::automatic:
637637
case return_value_policy::take_ownership:
638-
valueptr = src;
638+
valueptr = src;
639639
wrapper->owned = true;
640640
break;
641641

642642
case return_value_policy::automatic_reference:
643643
case return_value_policy::reference:
644-
valueptr = src;
644+
valueptr = src;
645645
wrapper->owned = false;
646646
break;
647647

@@ -683,7 +683,7 @@ struct smart_holder_type_caster : smart_holder_type_caster_load<T>,
683683
break;
684684

685685
case return_value_policy::reference_internal:
686-
valueptr = src;
686+
valueptr = src;
687687
wrapper->owned = false;
688688
keep_alive_impl(inst, parent);
689689
break;
@@ -724,22 +724,22 @@ struct smart_holder_type_caster<std::shared_ptr<T>> : smart_holder_type_caster_l
724724
return none().release();
725725

726726
auto src_raw_ptr = src.get();
727-
auto st = type_caster_base<T>::src_and_type(src_raw_ptr);
727+
auto st = type_caster_base<T>::src_and_type(src_raw_ptr);
728728
if (st.second == nullptr)
729729
return handle(); // no type info: error will be set already
730730

731-
void *src_raw_void_ptr = static_cast<void *>(src_raw_ptr);
731+
void *src_raw_void_ptr = static_cast<void *>(src_raw_ptr);
732732
const detail::type_info *tinfo = st.second;
733733
if (handle existing_inst = find_registered_python_instance(src_raw_void_ptr, tinfo))
734734
// SMART_HOLDER_WIP: MISSING: Enforcement of consistency with existing smart_holder.
735735
// SMART_HOLDER_WIP: MISSING: keep_alive.
736736
return existing_inst;
737737

738-
auto inst = reinterpret_steal<object>(make_new_instance(tinfo->type));
739-
auto *inst_raw_ptr = reinterpret_cast<instance *>(inst.ptr());
738+
auto inst = reinterpret_steal<object>(make_new_instance(tinfo->type));
739+
auto *inst_raw_ptr = reinterpret_cast<instance *>(inst.ptr());
740740
inst_raw_ptr->owned = true;
741-
void *&valueptr = values_and_holders(inst_raw_ptr).begin()->value_ptr();
742-
valueptr = src_raw_void_ptr;
741+
void *&valueptr = values_and_holders(inst_raw_ptr).begin()->value_ptr();
742+
valueptr = src_raw_void_ptr;
743743

744744
auto smhldr = pybindit::memory::smart_holder::from_shared_ptr(src);
745745
tinfo->init_instance(inst_raw_ptr, static_cast<const void *>(&smhldr));
@@ -791,11 +791,11 @@ struct smart_holder_type_caster<std::unique_ptr<T, D>> : smart_holder_type_caste
791791
return none().release();
792792

793793
auto src_raw_ptr = src.get();
794-
auto st = type_caster_base<T>::src_and_type(src_raw_ptr);
794+
auto st = type_caster_base<T>::src_and_type(src_raw_ptr);
795795
if (st.second == nullptr)
796796
return handle(); // no type info: error will be set already
797797

798-
void *src_raw_void_ptr = static_cast<void *>(src_raw_ptr);
798+
void *src_raw_void_ptr = static_cast<void *>(src_raw_ptr);
799799
const detail::type_info *tinfo = st.second;
800800
if (handle existing_inst = find_registered_python_instance(src_raw_void_ptr, tinfo)) {
801801
auto *self_life_support
@@ -819,11 +819,11 @@ struct smart_holder_type_caster<std::unique_ptr<T, D>> : smart_holder_type_caste
819819
throw cast_error("Invalid unique_ptr: another instance owns this pointer already.");
820820
}
821821

822-
auto inst = reinterpret_steal<object>(make_new_instance(tinfo->type));
823-
auto *inst_raw_ptr = reinterpret_cast<instance *>(inst.ptr());
822+
auto inst = reinterpret_steal<object>(make_new_instance(tinfo->type));
823+
auto *inst_raw_ptr = reinterpret_cast<instance *>(inst.ptr());
824824
inst_raw_ptr->owned = true;
825-
void *&valueptr = values_and_holders(inst_raw_ptr).begin()->value_ptr();
826-
valueptr = src_raw_void_ptr;
825+
void *&valueptr = values_and_holders(inst_raw_ptr).begin()->value_ptr();
826+
valueptr = src_raw_void_ptr;
827827

828828
auto smhldr = pybindit::memory::smart_holder::from_unique_ptr(std::move(src),
829829
/*void_cast_raw_ptr*/ false);

include/pybind11/trampoline_self_life_support.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct trampoline_self_life_support {
4141
void *value_void_ptr = v_h.value_ptr();
4242
if (value_void_ptr != nullptr) {
4343
PyGILState_STATE threadstate = PyGILState_Ensure();
44-
v_h.value_ptr() = nullptr;
44+
v_h.value_ptr() = nullptr;
4545
v_h.holder<pybindit::memory::smart_holder>().release_disowned();
4646
detail::deregister_instance(v_h.inst, value_void_ptr, v_h.type);
4747
Py_DECREF((PyObject *) v_h.inst); // Must be after deregister.

tests/pure_cpp/smart_holder_poc_test.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct movable_int {
1111
int valu;
1212
movable_int(int v) : valu{v} {}
1313
movable_int(movable_int &&other) noexcept {
14-
valu = other.valu;
14+
valu = other.valu;
1515
other.valu = 91;
1616
}
1717
};
@@ -36,13 +36,13 @@ struct indestructible_int {
3636

3737
TEST_CASE("from_raw_ptr_unowned+as_raw_ptr_unowned", "[S]") {
3838
static int value = 19;
39-
auto hld = smart_holder::from_raw_ptr_unowned(&value);
39+
auto hld = smart_holder::from_raw_ptr_unowned(&value);
4040
REQUIRE(*hld.as_raw_ptr_unowned<int>() == 19);
4141
}
4242

4343
TEST_CASE("from_raw_ptr_unowned+as_lvalue_ref", "[S]") {
4444
static int value = 19;
45-
auto hld = smart_holder::from_raw_ptr_unowned(&value);
45+
auto hld = smart_holder::from_raw_ptr_unowned(&value);
4646
REQUIRE(hld.as_lvalue_ref<int>() == 19);
4747
}
4848

@@ -58,28 +58,28 @@ TEST_CASE("from_raw_ptr_unowned+as_rvalue_ref", "[S]") {
5858

5959
TEST_CASE("from_raw_ptr_unowned+as_raw_ptr_release_ownership", "[E]") {
6060
static int value = 19;
61-
auto hld = smart_holder::from_raw_ptr_unowned(&value);
61+
auto hld = smart_holder::from_raw_ptr_unowned(&value);
6262
REQUIRE_THROWS_WITH(hld.as_raw_ptr_release_ownership<int>(),
6363
"Cannot disown non-owning holder (as_raw_ptr_release_ownership).");
6464
}
6565

6666
TEST_CASE("from_raw_ptr_unowned+as_unique_ptr", "[E]") {
6767
static int value = 19;
68-
auto hld = smart_holder::from_raw_ptr_unowned(&value);
68+
auto hld = smart_holder::from_raw_ptr_unowned(&value);
6969
REQUIRE_THROWS_WITH(hld.as_unique_ptr<int>(),
7070
"Cannot disown non-owning holder (as_unique_ptr).");
7171
}
7272

7373
TEST_CASE("from_raw_ptr_unowned+as_unique_ptr_with_deleter", "[E]") {
7474
static int value = 19;
75-
auto hld = smart_holder::from_raw_ptr_unowned(&value);
75+
auto hld = smart_holder::from_raw_ptr_unowned(&value);
7676
REQUIRE_THROWS_WITH((hld.as_unique_ptr<int, helpers::functor_builtin_delete<int>>()),
7777
"Missing unique_ptr deleter (as_unique_ptr).");
7878
}
7979

8080
TEST_CASE("from_raw_ptr_unowned+as_shared_ptr", "[S]") {
8181
static int value = 19;
82-
auto hld = smart_holder::from_raw_ptr_unowned(&value);
82+
auto hld = smart_holder::from_raw_ptr_unowned(&value);
8383
REQUIRE(*hld.as_shared_ptr<int>() == 19);
8484
}
8585

@@ -90,28 +90,28 @@ TEST_CASE("from_raw_ptr_take_ownership+as_lvalue_ref", "[S]") {
9090
}
9191

9292
TEST_CASE("from_raw_ptr_take_ownership+as_raw_ptr_release_ownership1", "[S]") {
93-
auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19));
93+
auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19));
9494
auto new_owner = std::unique_ptr<int>(hld.as_raw_ptr_release_ownership<int>());
9595
REQUIRE(!hld.has_pointee());
9696
REQUIRE(*new_owner == 19);
9797
}
9898

9999
TEST_CASE("from_raw_ptr_take_ownership+as_raw_ptr_release_ownership2", "[E]") {
100-
auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19));
100+
auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19));
101101
auto shd_ptr = hld.as_shared_ptr<int>();
102102
REQUIRE_THROWS_WITH(hld.as_raw_ptr_release_ownership<int>(),
103103
"Cannot disown use_count != 1 (as_raw_ptr_release_ownership).");
104104
}
105105

106106
TEST_CASE("from_raw_ptr_take_ownership+as_unique_ptr1", "[S]") {
107-
auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19));
107+
auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19));
108108
std::unique_ptr<int> new_owner = hld.as_unique_ptr<int>();
109109
REQUIRE(!hld.has_pointee());
110110
REQUIRE(*new_owner == 19);
111111
}
112112

113113
TEST_CASE("from_raw_ptr_take_ownership+as_unique_ptr2", "[E]") {
114-
auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19));
114+
auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19));
115115
auto shd_ptr = hld.as_shared_ptr<int>();
116116
REQUIRE_THROWS_WITH(hld.as_unique_ptr<int>(), "Cannot disown use_count != 1 (as_unique_ptr).");
117117
}
@@ -123,7 +123,7 @@ TEST_CASE("from_raw_ptr_take_ownership+as_unique_ptr_with_deleter", "[E]") {
123123
}
124124

125125
TEST_CASE("from_raw_ptr_take_ownership+as_shared_ptr", "[S]") {
126-
auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19));
126+
auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19));
127127
std::shared_ptr<int> new_owner = hld.as_shared_ptr<int>();
128128
REQUIRE(hld.has_pointee());
129129
REQUIRE(*new_owner == 19);
@@ -155,7 +155,7 @@ TEST_CASE("from_raw_ptr_take_ownership+disown+release_disowned", "[S]") {
155155

156156
TEST_CASE("from_raw_ptr_take_ownership+disown+ensure_is_not_disowned", "[E]") {
157157
const char *context = "test_case";
158-
auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19));
158+
auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19));
159159
hld.ensure_is_not_disowned(context); // Does not throw.
160160
std::unique_ptr<int> new_owner(hld.as_raw_ptr_unowned<int>());
161161
hld.disown();
@@ -327,7 +327,7 @@ TEST_CASE("indestructible_int-from_raw_ptr_unowned+as_raw_ptr_unowned", "[S]") {
327327
// Using placement new instead of plain new, to not trigger leak sanitizer errors.
328328
static std::aligned_storage<sizeof(zombie), alignof(zombie)>::type memory_block[1];
329329
auto *value = new (memory_block) zombie(19);
330-
auto hld = smart_holder::from_raw_ptr_unowned(value);
330+
auto hld = smart_holder::from_raw_ptr_unowned(value);
331331
REQUIRE(hld.as_raw_ptr_unowned<zombie>()->valu == 19);
332332
}
333333

@@ -341,7 +341,7 @@ TEST_CASE("from_raw_ptr_take_ownership+as_shared_ptr-outliving_smart_holder", "[
341341
// Exercises guarded_builtin_delete flag_ptr validity past destruction of smart_holder.
342342
std::shared_ptr<int> longer_living;
343343
{
344-
auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19));
344+
auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19));
345345
longer_living = hld.as_shared_ptr<int>();
346346
}
347347
REQUIRE(*longer_living == 19);
@@ -352,7 +352,7 @@ TEST_CASE("from_unique_ptr_with_deleter+as_shared_ptr-outliving_smart_holder", "
352352
std::shared_ptr<int> longer_living;
353353
{
354354
std::unique_ptr<int, helpers::functor_builtin_delete<int>> orig_owner(new int(19));
355-
auto hld = smart_holder::from_unique_ptr(std::move(orig_owner));
355+
auto hld = smart_holder::from_unique_ptr(std::move(orig_owner));
356356
longer_living = hld.as_shared_ptr<int>();
357357
}
358358
REQUIRE(*longer_living == 19);

tests/test_class_sh_disowning_mi.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ namespace class_sh_disowning_mi {
99

1010
// Diamond inheritance (copied from test_multiple_inheritance.cpp).
1111
struct B {
12-
int val_b = 10;
13-
B() = default;
12+
int val_b = 10;
13+
B() = default;
1414
B(const B &) = default;
1515
virtual ~B() = default;
1616
};

tests/test_class_sh_factory_constructors.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ std::unique_ptr<atyp_udcp const, sddc> rtrn_udcp() { return std::unique_ptr<atyp
5757
// Minimalistic approach to achieve full coverage of construct() overloads for constructing
5858
// smart_holder from unique_ptr and shared_ptr returns.
5959
struct with_alias {
60-
int val = 0;
60+
int val = 0;
6161
virtual ~with_alias() = default;
6262
// Some compilers complain about implicitly defined versions of some of the following:
63-
with_alias() = default;
63+
with_alias() = default;
6464
with_alias(const with_alias &) = default;
65-
with_alias(with_alias &&) = default;
65+
with_alias(with_alias &&) = default;
6666
with_alias &operator=(const with_alias &) = default;
6767
with_alias &operator=(with_alias &&) = default;
6868
};

tests/test_class_sh_inheritance.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ 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;
18+
base_template(const base_template &) = default;
1919
base_template(base_template &&) noexcept = default;
2020
base_template &operator=(const base_template &) = default;
2121
base_template &operator=(base_template &&) noexcept = default;

tests/test_class_sh_trampoline_basic.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ namespace class_sh_trampoline_basic {
99

1010
template <int SerNo> // Using int as a trick to easily generate a series of types.
1111
struct Abase {
12-
int val = 0;
12+
int val = 0;
1313
virtual ~Abase() = default;
1414
Abase(int val_) : val{val_} {}
1515
int Get() const { return val * 10 + 3; }
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;
19+
Abase(const Abase &) = default;
2020
Abase(Abase &&) noexcept = default;
2121
Abase &operator=(const Abase &) = default;
2222
Abase &operator=(Abase &&) noexcept = default;

tests/test_class_sh_trampoline_self_life_support.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ TEST_SUBMODULE(class_sh_trampoline_self_life_support, m) {
6868
case 2: { // operator= lvalue
6969
std::unique_ptr<Big5> lv(new Big5Trampoline);
7070
*lv = *obj_trampoline;
71-
o2 = py::cast(std::move(lv));
71+
o2 = py::cast(std::move(lv));
7272
} break;
7373
case 3: { // operator= rvalue
7474
std::unique_ptr<Big5> rv(new Big5Trampoline);
7575
*rv = std::move(*obj_trampoline);
76-
o2 = py::cast(std::move(rv));
76+
o2 = py::cast(std::move(rv));
7777
} break;
7878
default:
7979
break;

tests/test_class_sh_trampoline_shared_ptr_cpp_arg.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ struct SpBase {
2121
return (bool) py::detail::get_object_handle(this, tinfo);
2222
}
2323

24-
SpBase() = default;
24+
SpBase() = default;
2525
SpBase(const SpBase &) = delete;
26-
virtual ~SpBase() = default;
26+
virtual ~SpBase() = default;
2727
};
2828

2929
std::shared_ptr<SpBase> pass_through_shd_ptr(const std::shared_ptr<SpBase> &obj) { return obj; }

0 commit comments

Comments
 (0)