style: clang-tidy: modernize-use-override

This commit is contained in:
Henry Schreiner 2020-09-10 22:43:53 -04:00 committed by Henry Schreiner
parent 8dc31c7b29
commit 5dfbe6f903
7 changed files with 20 additions and 20 deletions

View File

@ -3,6 +3,7 @@ FormatStyle: file
Checks: '
-*,
llvm-namespace-comment,
modernize-use-override,
'
HeaderFilterRegex: 'pybind11/.*h'

View File

@ -30,7 +30,7 @@ private:
object pywrite;
object pyflush;
int overflow(int c) {
int overflow(int c) override {
if (!traits_type::eq_int_type(c, traits_type::eof())) {
*pptr() = traits_type::to_char_type(c);
pbump(1);
@ -38,7 +38,7 @@ private:
return sync() == 0 ? traits_type::not_eof(c) : traits_type::eof();
}
int sync() {
int sync() override {
if (pbase() != pptr()) {
// This subtraction cannot be negative, so dropping the sign
str line(pbase(), static_cast<size_t>(pptr() - pbase()));
@ -67,7 +67,7 @@ public:
pythonbuf(pythonbuf&&) = default;
/// Sync before destroy
~pythonbuf() {
~pythonbuf() override {
sync();
}
};

View File

@ -331,7 +331,7 @@ public:
error_already_set(const error_already_set &) = default;
error_already_set(error_already_set &&) = default;
inline ~error_already_set();
inline ~error_already_set() override;
/// Give the currently-held error back to Python, if any. If there is currently a Python error
/// already set it is cleared first. After this call, the current object no longer stores the

View File

@ -13,7 +13,7 @@
class MyException : public std::exception {
public:
explicit MyException(const char * m) : message{m} {}
virtual const char * what() const noexcept override {return message.c_str();}
const char * what() const noexcept override {return message.c_str();}
private:
std::string message = "";
};
@ -22,7 +22,7 @@ private:
class MyException2 : public std::exception {
public:
explicit MyException2(const char * m) : message{m} {}
virtual const char * what() const noexcept override {return message.c_str();}
const char * what() const noexcept override {return message.c_str();}
private:
std::string message = "";
};
@ -41,7 +41,7 @@ private:
class MyException4 : public std::exception {
public:
explicit MyException4(const char * m) : message{m} {}
virtual const char * what() const noexcept override {return message.c_str();}
const char * what() const noexcept override {return message.c_str();}
private:
std::string message = "";
};

View File

@ -58,13 +58,13 @@ class TestFactory4 : public TestFactory3 {
public:
TestFactory4() : TestFactory3() { print_default_created(this); }
TestFactory4(int v) : TestFactory3(v) { print_created(this, v); }
virtual ~TestFactory4() { print_destroyed(this); }
~TestFactory4() override { print_destroyed(this); }
};
// Another class for an invalid downcast test
class TestFactory5 : public TestFactory3 {
public:
TestFactory5(int i) : TestFactory3(i) { print_created(this, i); }
virtual ~TestFactory5() { print_destroyed(this); }
~TestFactory5() override { print_destroyed(this); }
};
class TestFactory6 {
@ -88,8 +88,8 @@ public:
PyTF6(PyTF6 &&f) : TestFactory6(std::move(f)) { print_move_created(this); }
PyTF6(const PyTF6 &f) : TestFactory6(f) { print_copy_created(this); }
PyTF6(std::string s) : TestFactory6((int) s.size()) { alias = true; print_created(this, s); }
virtual ~PyTF6() { print_destroyed(this); }
int get() override { PYBIND11_OVERRIDE(int, TestFactory6, get, /*no args*/); }
~PyTF6() override { print_destroyed(this); }
int get() override { PYBIND11_OVERLOAD(int, TestFactory6, get, /*no args*/); }
};
class TestFactory7 {
@ -109,8 +109,7 @@ public:
PyTF7(int i) : TestFactory7(i) { alias = true; print_created(this, i); }
PyTF7(PyTF7 &&f) : TestFactory7(std::move(f)) { print_move_created(this); }
PyTF7(const PyTF7 &f) : TestFactory7(f) { print_copy_created(this); }
virtual ~PyTF7() { print_destroyed(this); }
int get() override { PYBIND11_OVERRIDE(int, TestFactory7, get, /*no args*/); }
~PyTF7() override { print_destroyed(this); }
};

View File

@ -98,9 +98,9 @@ TEST_SUBMODULE(smart_ptr, m) {
class MyObject1 : public Object {
public:
MyObject1(int value) : value(value) { print_created(this, toString()); }
std::string toString() const { return "MyObject1[" + std::to_string(value) + "]"; }
std::string toString() const override { return "MyObject1[" + std::to_string(value) + "]"; }
protected:
virtual ~MyObject1() { print_destroyed(this); }
~MyObject1() override { print_destroyed(this); }
private:
int value;
};
@ -208,7 +208,7 @@ TEST_SUBMODULE(smart_ptr, m) {
class MyObject4b : public MyObject4a {
public:
MyObject4b(int i) : MyObject4a(i) { print_created(this); }
~MyObject4b() { print_destroyed(this); }
~MyObject4b() override { print_destroyed(this); }
};
py::class_<MyObject4b, MyObject4a>(m, "MyObject4b")
.def(py::init<int>());

View File

@ -158,8 +158,8 @@ struct Base {
};
struct DispatchIssue : Base {
virtual std::string dispatch() const {
PYBIND11_OVERRIDE_PURE(std::string, Base, dispatch, /* no arguments */);
std::string dispatch() const override {
PYBIND11_OVERLOAD_PURE(std::string, Base, dispatch, /* no arguments */);
}
};
@ -234,7 +234,7 @@ TEST_SUBMODULE(virtual_functions, m) {
struct PyA : A {
PyA() { py::print("PyA.PyA()"); }
PyA(const PyA&) = delete;
~PyA() { py::print("PyA.~PyA()"); }
~PyA() override { py::print("PyA.~PyA()"); }
void f() override {
py::print("PyA.f()");
@ -262,7 +262,7 @@ TEST_SUBMODULE(virtual_functions, m) {
struct PyA2 : A2 {
PyA2() { py::print("PyA2.PyA2()"); }
PyA2(const PyA2&) = delete;
~PyA2() { py::print("PyA2.~PyA2()"); }
~PyA2() override { py::print("PyA2.~PyA2()"); }
void f() override {
py::print("PyA2.f()");
PYBIND11_OVERRIDE(void, A2, f);