Skip to content

Commit

Permalink
* Removing stray semicolons (discovered by running clang-format v12 f…
Browse files Browse the repository at this point in the history
…ollowed by tools/check-style.sh).

(* Manually moving `// NOLINT` and `// NOLINTNEXTLINE` comments so that clang-format does not move them to the wrong places.)

* Manually reformatting comments related to `static_assert`s so that clang-format does not need two passes.

* Empty lines between #includes, to prevent clang-format from shuffling the order and thereby confusing MSVC 2015.

* git diff -U0 --no-color HEAD^ | python3 $HOME/clone/llvm-project/clang/tools/clang-format/clang-format-diff.py -p1 -style=file -i
  • Loading branch information
Ralf W. Grosse-Kunstleve committed Jul 13, 2021
1 parent 7509064 commit e90a959
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
3 changes: 2 additions & 1 deletion include/pybind11/attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ struct metaclass {
handle value;

PYBIND11_DEPRECATED("py::metaclass() is no longer required. It's turned on by default now.")
metaclass() { } // NOLINT(modernize-use-equals-default): breaks MSVC 2015 when adding an attribute
// NOLINTNEXTLINE(modernize-use-equals-default): breaks MSVC 2015 when adding an attribute
metaclass() {}

/// Override pybind11's default metaclass
explicit metaclass(handle value) : value(value) { }
Expand Down
3 changes: 2 additions & 1 deletion include/pybind11/detail/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,8 @@ struct nodelete { template <typename T> void operator()(T*) { } };
PYBIND11_NAMESPACE_BEGIN(detail)
template <typename... Args>
struct overload_cast_impl {
constexpr overload_cast_impl() {}; // NOLINT(modernize-use-equals-default): MSVC 2015 needs this
// NOLINTNEXTLINE(modernize-use-equals-default): MSVC 2015 needs this
constexpr overload_cast_impl() {}

template <typename Return>
constexpr auto operator()(Return (*pf)(Args...)) const noexcept
Expand Down
7 changes: 6 additions & 1 deletion tests/pybind11_tests.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#pragma once

// This must be kept first for MSVC 2015.
// Do not remove the empty line between the #includes.
#include <pybind11/pybind11.h>

#include <pybind11/eval.h>

#if defined(_MSC_VER) && _MSC_VER < 1910
// We get some really long type names here which causes MSVC 2015 to emit warnings
# pragma warning(disable: 4503) // warning C4503: decorated name length exceeded, name was truncated
# pragma warning( \
disable : 4503) // warning C4503: decorated name length exceeded, name was truncated
#endif

namespace py = pybind11;
Expand Down
2 changes: 1 addition & 1 deletion tests/test_buffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ TEST_SUBMODULE(buffers, m) {
py::format_descriptor<int32_t>::format(), 1);
}

ConstBuffer() : value(new int32_t{0}) { };
ConstBuffer() : value(new int32_t{0}) {}
};
py::class_<ConstBuffer>(m, "ConstBuffer", py::buffer_protocol())
.def(py::init<>())
Expand Down
2 changes: 1 addition & 1 deletion tests/test_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ TEST_SUBMODULE(callbacks, m) {
// [workaround(intel)] = default does not work here
// Defaulting this destructor results in linking errors with the Intel compiler
// (in Debug builds only, tested with icpc (ICC) 2021.1 Beta 20200827)
virtual ~AbstractBase() {}; // NOLINT(modernize-use-equals-default)
virtual ~AbstractBase() {} // NOLINT(modernize-use-equals-default)
virtual unsigned int func() = 0;
};
m.def("func_accepting_func_accepting_base",
Expand Down
12 changes: 6 additions & 6 deletions tests/test_methods_and_attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class NoneCastTester {
public:
int answer = -1;
NoneCastTester() = default;
NoneCastTester(int v) : answer(v) {};
NoneCastTester(int v) : answer(v) {}
};

struct StrIssue {
Expand Down Expand Up @@ -390,14 +390,14 @@ TEST_SUBMODULE(methods_and_attributes, m) {
.def("increase_value", &RegisteredDerived::increase_value)
.def_readwrite("rw_value", &RegisteredDerived::rw_value)
.def_readonly("ro_value", &RegisteredDerived::ro_value)
// These should trigger a static_assert if uncommented
//.def_readwrite("fails", &UserType::value) // should trigger a static_assert if uncommented
//.def_readonly("fails", &UserType::value) // should trigger a static_assert if uncommented
// Uncommenting the next line should trigger a static_assert:
// .def_readwrite("fails", &UserType::value)
// Uncommenting the next line should trigger a static_assert:
// .def_readonly("fails", &UserType::value)
.def_property("rw_value_prop", &RegisteredDerived::get_int, &RegisteredDerived::set_int)
.def_property_readonly("ro_value_prop", &RegisteredDerived::get_double)
// This one is in the registered class:
.def("sum", &RegisteredDerived::sum)
;
.def("sum", &RegisteredDerived::sum);

using Adapted = decltype(py::method_adaptor<RegisteredDerived>(&RegisteredDerived::do_nothing));
static_assert(std::is_same<Adapted, void (RegisteredDerived::*)() const>::value, "");
Expand Down
2 changes: 1 addition & 1 deletion tests/test_smart_ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ template <typename T> class huge_unique_ptr {
std::unique_ptr<T> ptr;
uint64_t padding[10];
public:
huge_unique_ptr(T *p) : ptr(p) {};
huge_unique_ptr(T *p) : ptr(p) {}
T *get() { return ptr.get(); }
};

Expand Down

0 comments on commit e90a959

Please sign in to comment.