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
e428a7f6
Commit
e428a7f6
authored
Jul 23, 2020
by
Henry Schreiner
Committed by
Henry Schreiner
Jul 26, 2020
Browse files
ci: fix clang warnings
parent
6a80171c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
4 deletions
+37
-4
include/pybind11/pytypes.h
include/pybind11/pytypes.h
+1
-1
tests/test_call_policies.cpp
tests/test_call_policies.cpp
+1
-0
tests/test_class.cpp
tests/test_class.cpp
+9
-1
tests/test_gil_scoped.cpp
tests/test_gil_scoped.cpp
+3
-1
tests/test_methods_and_attributes.cpp
tests/test_methods_and_attributes.cpp
+1
-0
tests/test_smart_ptr.cpp
tests/test_smart_ptr.cpp
+2
-0
tests/test_virtual_functions.cpp
tests/test_virtual_functions.cpp
+20
-1
No files found.
include/pybind11/pytypes.h
View file @
e428a7f6
...
@@ -370,7 +370,7 @@ bool isinstance(handle obj) { return T::check_(obj); }
...
@@ -370,7 +370,7 @@ bool isinstance(handle obj) { return T::check_(obj); }
template
<
typename
T
,
detail
::
enable_if_t
<!
std
::
is_base_of
<
object
,
T
>
::
value
,
int
>
=
0
>
template
<
typename
T
,
detail
::
enable_if_t
<!
std
::
is_base_of
<
object
,
T
>
::
value
,
int
>
=
0
>
bool
isinstance
(
handle
obj
)
{
return
detail
::
isinstance_generic
(
obj
,
typeid
(
T
));
}
bool
isinstance
(
handle
obj
)
{
return
detail
::
isinstance_generic
(
obj
,
typeid
(
T
));
}
template
<
>
inline
bool
isinstance
<
handle
>
(
handle
obj
)
=
delete
;
template
<
>
inline
bool
isinstance
<
handle
>
(
handle
)
=
delete
;
template
<
>
inline
bool
isinstance
<
object
>
(
handle
obj
)
{
return
obj
.
ptr
()
!=
nullptr
;
}
template
<
>
inline
bool
isinstance
<
object
>
(
handle
obj
)
{
return
obj
.
ptr
()
!=
nullptr
;
}
/// \ingroup python_builtins
/// \ingroup python_builtins
...
...
tests/test_call_policies.cpp
View file @
e428a7f6
...
@@ -46,6 +46,7 @@ TEST_SUBMODULE(call_policies, m) {
...
@@ -46,6 +46,7 @@ TEST_SUBMODULE(call_policies, m) {
class
Parent
{
class
Parent
{
public:
public:
Parent
()
{
py
::
print
(
"Allocating parent."
);
}
Parent
()
{
py
::
print
(
"Allocating parent."
);
}
Parent
(
const
Parent
&
parent
)
=
default
;
~
Parent
()
{
py
::
print
(
"Releasing parent."
);
}
~
Parent
()
{
py
::
print
(
"Releasing parent."
);
}
void
addChild
(
Child
*
)
{
}
void
addChild
(
Child
*
)
{
}
Child
*
returnChild
()
{
return
new
Child
();
}
Child
*
returnChild
()
{
return
new
Child
();
}
...
...
tests/test_class.cpp
View file @
e428a7f6
...
@@ -227,6 +227,8 @@ TEST_SUBMODULE(class_, m) {
...
@@ -227,6 +227,8 @@ TEST_SUBMODULE(class_, m) {
static
void
*
operator
new
(
size_t
s
,
void
*
ptr
)
{
py
::
print
(
"C placement-new"
,
s
);
return
ptr
;
}
static
void
*
operator
new
(
size_t
s
,
void
*
ptr
)
{
py
::
print
(
"C placement-new"
,
s
);
return
ptr
;
}
static
void
operator
delete
(
void
*
p
,
size_t
s
)
{
py
::
print
(
"C delete"
,
s
);
return
::
operator
delete
(
p
);
}
static
void
operator
delete
(
void
*
p
,
size_t
s
)
{
py
::
print
(
"C delete"
,
s
);
return
::
operator
delete
(
p
);
}
virtual
~
AliasedHasOpNewDelSize
()
=
default
;
virtual
~
AliasedHasOpNewDelSize
()
=
default
;
AliasedHasOpNewDelSize
()
=
default
;
AliasedHasOpNewDelSize
(
const
AliasedHasOpNewDelSize
&
)
=
delete
;
};
};
struct
PyAliasedHasOpNewDelSize
:
AliasedHasOpNewDelSize
{
struct
PyAliasedHasOpNewDelSize
:
AliasedHasOpNewDelSize
{
PyAliasedHasOpNewDelSize
()
=
default
;
PyAliasedHasOpNewDelSize
()
=
default
;
...
@@ -277,6 +279,8 @@ TEST_SUBMODULE(class_, m) {
...
@@ -277,6 +279,8 @@ TEST_SUBMODULE(class_, m) {
class
ProtectedB
{
class
ProtectedB
{
public:
public:
virtual
~
ProtectedB
()
=
default
;
virtual
~
ProtectedB
()
=
default
;
ProtectedB
()
=
default
;
ProtectedB
(
const
ProtectedB
&
)
=
delete
;
protected:
protected:
virtual
int
foo
()
const
{
return
value
;
}
virtual
int
foo
()
const
{
return
value
;
}
...
@@ -377,7 +381,11 @@ TEST_SUBMODULE(class_, m) {
...
@@ -377,7 +381,11 @@ TEST_SUBMODULE(class_, m) {
py
::
class_
<
IsNonFinalFinal
>
(
m
,
"IsNonFinalFinal"
,
py
::
is_final
());
py
::
class_
<
IsNonFinalFinal
>
(
m
,
"IsNonFinalFinal"
,
py
::
is_final
());
}
}
template
<
int
N
>
class
BreaksBase
{
public
:
virtual
~
BreaksBase
()
=
default
;
};
template
<
int
N
>
class
BreaksBase
{
public
:
virtual
~
BreaksBase
()
=
default
;
BreaksBase
()
=
default
;
BreaksBase
(
const
BreaksBase
&
)
=
delete
;
};
template
<
int
N
>
class
BreaksTramp
:
public
BreaksBase
<
N
>
{};
template
<
int
N
>
class
BreaksTramp
:
public
BreaksBase
<
N
>
{};
// These should all compile just fine:
// These should all compile just fine:
typedef
py
::
class_
<
BreaksBase
<
1
>
,
std
::
unique_ptr
<
BreaksBase
<
1
>>
,
BreaksTramp
<
1
>>
DoesntBreak1
;
typedef
py
::
class_
<
BreaksBase
<
1
>
,
std
::
unique_ptr
<
BreaksBase
<
1
>>
,
BreaksTramp
<
1
>>
DoesntBreak1
;
...
...
tests/test_gil_scoped.cpp
View file @
e428a7f6
...
@@ -13,7 +13,9 @@
...
@@ -13,7 +13,9 @@
class
VirtClass
{
class
VirtClass
{
public:
public:
virtual
~
VirtClass
()
{}
virtual
~
VirtClass
()
=
default
;
VirtClass
()
=
default
;
VirtClass
(
const
VirtClass
&
)
=
delete
;
virtual
void
virtual_func
()
{}
virtual
void
virtual_func
()
{}
virtual
void
pure_virtual_func
()
=
0
;
virtual
void
pure_virtual_func
()
=
0
;
};
};
...
...
tests/test_methods_and_attributes.cpp
View file @
e428a7f6
...
@@ -289,6 +289,7 @@ TEST_SUBMODULE(methods_and_attributes, m) {
...
@@ -289,6 +289,7 @@ TEST_SUBMODULE(methods_and_attributes, m) {
class
DynamicClass
{
class
DynamicClass
{
public:
public:
DynamicClass
()
{
print_default_created
(
this
);
}
DynamicClass
()
{
print_default_created
(
this
);
}
DynamicClass
(
const
DynamicClass
&
)
=
delete
;
~
DynamicClass
()
{
print_destroyed
(
this
);
}
~
DynamicClass
()
{
print_destroyed
(
this
);
}
};
};
py
::
class_
<
DynamicClass
>
(
m
,
"DynamicClass"
,
py
::
dynamic_attr
())
py
::
class_
<
DynamicClass
>
(
m
,
"DynamicClass"
,
py
::
dynamic_attr
())
...
...
tests/test_smart_ptr.cpp
View file @
e428a7f6
...
@@ -339,6 +339,8 @@ TEST_SUBMODULE(smart_ptr, m) {
...
@@ -339,6 +339,8 @@ TEST_SUBMODULE(smart_ptr, m) {
// #187: issue involving std::shared_ptr<> return value policy & garbage collection
// #187: issue involving std::shared_ptr<> return value policy & garbage collection
struct
ElementBase
{
struct
ElementBase
{
virtual
~
ElementBase
()
{
}
/* Force creation of virtual table */
virtual
~
ElementBase
()
{
}
/* Force creation of virtual table */
ElementBase
()
=
default
;
ElementBase
(
const
ElementBase
&
)
=
delete
;
};
};
py
::
class_
<
ElementBase
,
std
::
shared_ptr
<
ElementBase
>>
(
m
,
"ElementBase"
);
py
::
class_
<
ElementBase
,
std
::
shared_ptr
<
ElementBase
>>
(
m
,
"ElementBase"
);
...
...
tests/test_virtual_functions.cpp
View file @
e428a7f6
...
@@ -130,6 +130,8 @@ private:
...
@@ -130,6 +130,8 @@ private:
class
NCVirt
{
class
NCVirt
{
public:
public:
virtual
~
NCVirt
()
{
}
virtual
~
NCVirt
()
{
}
NCVirt
()
=
default
;
NCVirt
(
const
NCVirt
&
)
=
delete
;
virtual
NonCopyable
get_noncopyable
(
int
a
,
int
b
)
{
return
NonCopyable
(
a
,
b
);
}
virtual
NonCopyable
get_noncopyable
(
int
a
,
int
b
)
{
return
NonCopyable
(
a
,
b
);
}
virtual
Movable
get_movable
(
int
a
,
int
b
)
=
0
;
virtual
Movable
get_movable
(
int
a
,
int
b
)
=
0
;
...
@@ -151,6 +153,8 @@ struct Base {
...
@@ -151,6 +153,8 @@ struct Base {
/* for some reason MSVC2015 can't compile this if the function is pure virtual */
/* for some reason MSVC2015 can't compile this if the function is pure virtual */
virtual
std
::
string
dispatch
()
const
{
return
{};
};
virtual
std
::
string
dispatch
()
const
{
return
{};
};
virtual
~
Base
()
=
default
;
virtual
~
Base
()
=
default
;
Base
()
=
default
;
Base
(
const
Base
&
)
=
delete
;
};
};
struct
DispatchIssue
:
Base
{
struct
DispatchIssue
:
Base
{
...
@@ -221,12 +225,15 @@ TEST_SUBMODULE(virtual_functions, m) {
...
@@ -221,12 +225,15 @@ TEST_SUBMODULE(virtual_functions, m) {
// don't invoke Python dispatch classes by default when instantiating C++ classes
// don't invoke Python dispatch classes by default when instantiating C++ classes
// that were not extended on the Python side
// that were not extended on the Python side
struct
A
{
struct
A
{
A
()
=
default
;
A
(
const
A
&
)
=
delete
;
virtual
~
A
()
{}
virtual
~
A
()
{}
virtual
void
f
()
{
py
::
print
(
"A.f()"
);
}
virtual
void
f
()
{
py
::
print
(
"A.f()"
);
}
};
};
struct
PyA
:
A
{
struct
PyA
:
A
{
PyA
()
{
py
::
print
(
"PyA.PyA()"
);
}
PyA
()
{
py
::
print
(
"PyA.PyA()"
);
}
PyA
(
const
PyA
&
)
=
delete
;
~
PyA
()
{
py
::
print
(
"PyA.~PyA()"
);
}
~
PyA
()
{
py
::
print
(
"PyA.~PyA()"
);
}
void
f
()
override
{
void
f
()
override
{
...
@@ -246,12 +253,15 @@ TEST_SUBMODULE(virtual_functions, m) {
...
@@ -246,12 +253,15 @@ TEST_SUBMODULE(virtual_functions, m) {
// test_alias_delay_initialization2
// test_alias_delay_initialization2
// ... unless we explicitly request it, as in this example:
// ... unless we explicitly request it, as in this example:
struct
A2
{
struct
A2
{
A2
()
=
default
;
A2
(
const
A2
&
)
=
delete
;
virtual
~
A2
()
{}
virtual
~
A2
()
{}
virtual
void
f
()
{
py
::
print
(
"A2.f()"
);
}
virtual
void
f
()
{
py
::
print
(
"A2.f()"
);
}
};
};
struct
PyA2
:
A2
{
struct
PyA2
:
A2
{
PyA2
()
{
py
::
print
(
"PyA2.PyA2()"
);
}
PyA2
()
{
py
::
print
(
"PyA2.PyA2()"
);
}
PyA2
(
const
PyA2
&
)
=
delete
;
~
PyA2
()
{
py
::
print
(
"PyA2.~PyA2()"
);
}
~
PyA2
()
{
py
::
print
(
"PyA2.~PyA2()"
);
}
void
f
()
override
{
void
f
()
override
{
py
::
print
(
"PyA2.f()"
);
py
::
print
(
"PyA2.f()"
);
...
@@ -282,6 +292,8 @@ TEST_SUBMODULE(virtual_functions, m) {
...
@@ -282,6 +292,8 @@ TEST_SUBMODULE(virtual_functions, m) {
std
::
string
v
;
std
::
string
v
;
A
a
;
A
a
;
explicit
OverrideTest
(
const
std
::
string
&
v
)
:
v
{
v
}
{}
explicit
OverrideTest
(
const
std
::
string
&
v
)
:
v
{
v
}
{}
OverrideTest
()
=
default
;
OverrideTest
(
const
OverrideTest
&
)
=
delete
;
virtual
std
::
string
str_value
()
{
return
v
;
}
virtual
std
::
string
str_value
()
{
return
v
;
}
virtual
std
::
string
&
str_ref
()
{
return
v
;
}
virtual
std
::
string
&
str_ref
()
{
return
v
;
}
virtual
A
A_value
()
{
return
a
;
}
virtual
A
A_value
()
{
return
a
;
}
...
@@ -339,6 +351,8 @@ public: \
...
@@ -339,6 +351,8 @@ public: \
return say_something(1) + " " + std::to_string(unlucky_number()); \
return say_something(1) + " " + std::to_string(unlucky_number()); \
}
}
A_METHODS
A_METHODS
A_Repeat
()
=
default
;
A_Repeat
(
const
A_Repeat
&
)
=
delete
;
virtual
~
A_Repeat
()
=
default
;
virtual
~
A_Repeat
()
=
default
;
};
};
class
B_Repeat
:
public
A_Repeat
{
class
B_Repeat
:
public
A_Repeat
{
...
@@ -364,7 +378,12 @@ D_METHODS
...
@@ -364,7 +378,12 @@ D_METHODS
};
};
// Base classes for templated inheritance trampolines. Identical to the repeat-everything version:
// Base classes for templated inheritance trampolines. Identical to the repeat-everything version:
class
A_Tpl
{
A_METHODS
;
virtual
~
A_Tpl
()
=
default
;
};
class
A_Tpl
{
A_METHODS
;
A_Tpl
()
=
default
;
A_Tpl
(
const
A_Tpl
&
)
=
delete
;
virtual
~
A_Tpl
()
=
default
;
};
class
B_Tpl
:
public
A_Tpl
{
B_METHODS
};
class
B_Tpl
:
public
A_Tpl
{
B_METHODS
};
class
C_Tpl
:
public
B_Tpl
{
C_METHODS
};
class
C_Tpl
:
public
B_Tpl
{
C_METHODS
};
class
D_Tpl
:
public
C_Tpl
{
D_METHODS
};
class
D_Tpl
:
public
C_Tpl
{
D_METHODS
};
...
...
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