Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
5dfbe6f9
Commit
5dfbe6f9
authored
Sep 10, 2020
by
Henry Schreiner
Committed by
Henry Schreiner
Sep 15, 2020
Browse files
style: clang-tidy: modernize-use-override
parent
8dc31c7b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
20 deletions
+20
-20
.clang-tidy
.clang-tidy
+1
-0
include/pybind11/iostream.h
include/pybind11/iostream.h
+3
-3
include/pybind11/pytypes.h
include/pybind11/pytypes.h
+1
-1
tests/test_exceptions.cpp
tests/test_exceptions.cpp
+3
-3
tests/test_factory_constructors.cpp
tests/test_factory_constructors.cpp
+5
-6
tests/test_smart_ptr.cpp
tests/test_smart_ptr.cpp
+3
-3
tests/test_virtual_functions.cpp
tests/test_virtual_functions.cpp
+4
-4
No files found.
.clang-tidy
View file @
5dfbe6f9
...
...
@@ -3,6 +3,7 @@ FormatStyle: file
Checks: '
-*,
llvm-namespace-comment,
modernize-use-override,
'
HeaderFilterRegex: 'pybind11/.*h'
include/pybind11/iostream.h
View file @
5dfbe6f9
...
...
@@ -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
();
}
};
...
...
include/pybind11/pytypes.h
View file @
5dfbe6f9
...
...
@@ -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
...
...
tests/test_exceptions.cpp
View file @
5dfbe6f9
...
...
@@ -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
=
""
;
};
...
...
tests/test_factory_constructors.cpp
View file @
5dfbe6f9
...
...
@@ -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_OVER
RIDE
(
int
,
TestFactory6
,
get
,
/*no args*/
);
}
~
PyTF6
()
override
{
print_destroyed
(
this
);
}
int
get
()
override
{
PYBIND11_OVER
LOAD
(
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
);
}
};
...
...
tests/test_smart_ptr.cpp
View file @
5dfbe6f9
...
...
@@ -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
>
());
...
...
tests/test_virtual_functions.cpp
View file @
5dfbe6f9
...
...
@@ -158,8 +158,8 @@ struct Base {
};
struct
DispatchIssue
:
Base
{
virtual
std
::
string
dispatch
()
const
{
PYBIND11_OVER
RIDE
_PURE
(
std
::
string
,
Base
,
dispatch
,
/* no arguments */
);
std
::
string
dispatch
()
const
override
{
PYBIND11_OVER
LOAD
_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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment