Skip to content

Commit

Permalink
clang-tidy auto-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf W. Grosse-Kunstleve committed Feb 12, 2024
1 parent ca31ae2 commit b5d3bf5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ class cpp_function : public function {
// chain.
chain_start = rec;
rec->next = chain;
auto py_func_rec
auto *py_func_rec
= (detail::function_record_PyObject *) PyCFunction_GET_SELF(m_ptr);
py_func_rec->cpp_func_rec = unique_rec.release();
guarded_strdup.release();
Expand Down Expand Up @@ -1321,34 +1321,38 @@ namespace function_record_PyTypeObject_methods {

inline PyObject *tp_new_impl(PyTypeObject *type, PyObject *args, PyObject *kwds) {
// Create a new instance using the type's tp_alloc slot.
if (type)
if (type) {
pybind11_fail("INTENTIONAL BREAKAGE: tp_new_impl");
}
return PyType_GenericNew(type, args, kwds);
}

inline PyObject *tp_alloc_impl(PyTypeObject *type, Py_ssize_t nitems) {
// Use Python's default memory allocation mechanism to allocate a new instance
// and initialize all its contents to NULL.
if (type)
if (type) {
pybind11_fail("INTENTIONAL BREAKAGE: tp_alloc_impl");
}
return PyType_GenericAlloc(type, nitems);
}

inline int tp_init_impl(PyObject *self, PyObject *, PyObject *) {
if (self)
if (self) {
pybind11_fail("INTENTIONAL BREAKAGE: tp_init_impl");
}
return -1;
}

inline void tp_dealloc_impl(PyObject *self) {
auto py_func_rec = (function_record_PyObject *) self;
auto *py_func_rec = (function_record_PyObject *) self;
cpp_function::destruct(py_func_rec->cpp_func_rec);
py_func_rec->cpp_func_rec = nullptr;
}

inline void tp_free_impl(void *self) {
if (self)
if (self) {
pybind11_fail("INTENTIONAL BREAKAGE: tp_free_impl");
}
}

} // namespace function_record_PyTypeObject_methods
Expand Down
2 changes: 1 addition & 1 deletion tests/pybind11_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class UnusualOpRef {
using NonTrivialType = std::shared_ptr<int>; // Almost any non-trivial type will do.
// Overriding operator& should not break pybind11.
NonTrivialType operator&() { return non_trivial_member; }
const NonTrivialType operator&() const { return non_trivial_member; }
NonTrivialType operator&() const { return non_trivial_member; }

private:
NonTrivialType non_trivial_member;
Expand Down

0 comments on commit b5d3bf5

Please sign in to comment.