aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-09-25 16:15:25 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-09-27 11:13:31 +0200
commitd88eba7e8f8f9951e48709a1503931025a592d6a (patch)
treeb3466d2f03e44b19cc7e1d2748ed1fb791235dfb /sources/shiboken6/tests
parentf6d11df9409da11e084f57633025c2806735e8b7 (diff)
Fix some static analysis warnings in the shiboken tests
- else after return - Do not repeat return types - Use range-based for for std::map - Use constructor member initialization - Initialize variables - Use override instead of repeating virtual - Use noexcept for move special functions - Upper case integer literals - Various other small fixes Pick-to: 6.6 6.5 Change-Id: I06924c60fcd0d8bfcad9cc2cd6e79e72621cb766 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/shiboken6/tests')
-rw-r--r--sources/shiboken6/tests/libminimal/listuser.cpp3
-rw-r--r--sources/shiboken6/tests/libminimal/minbool.h2
-rw-r--r--sources/shiboken6/tests/libother/number.cpp2
-rw-r--r--sources/shiboken6/tests/libother/otherderived.h2
-rw-r--r--sources/shiboken6/tests/libother/smartptrtester.cpp2
-rw-r--r--sources/shiboken6/tests/libsample/blackbox.cpp16
-rw-r--r--sources/shiboken6/tests/libsample/bucket.cpp2
-rw-r--r--sources/shiboken6/tests/libsample/bytearray.cpp2
-rw-r--r--sources/shiboken6/tests/libsample/cvlist.h2
-rw-r--r--sources/shiboken6/tests/libsample/derived.cpp2
-rw-r--r--sources/shiboken6/tests/libsample/expression.cpp14
-rw-r--r--sources/shiboken6/tests/libsample/functions.cpp10
-rw-r--r--sources/shiboken6/tests/libsample/handle.h8
-rw-r--r--sources/shiboken6/tests/libsample/listuser.cpp4
-rw-r--r--sources/shiboken6/tests/libsample/listuser.h4
-rw-r--r--sources/shiboken6/tests/libsample/mapuser.cpp4
-rw-r--r--sources/shiboken6/tests/libsample/modifications.cpp2
-rw-r--r--sources/shiboken6/tests/libsample/modifications.h2
-rw-r--r--sources/shiboken6/tests/libsample/objecttype.cpp11
-rw-r--r--sources/shiboken6/tests/libsample/objecttype.h4
-rw-r--r--sources/shiboken6/tests/libsample/objecttypebyvalue.h2
-rw-r--r--sources/shiboken6/tests/libsample/objecttypeholder.cpp2
-rw-r--r--sources/shiboken6/tests/libsample/objectview.cpp2
-rw-r--r--sources/shiboken6/tests/libsample/pen.cpp4
-rw-r--r--sources/shiboken6/tests/libsample/pen.h4
-rw-r--r--sources/shiboken6/tests/libsample/point.cpp14
-rw-r--r--sources/shiboken6/tests/libsample/pointf.cpp10
-rw-r--r--sources/shiboken6/tests/libsample/polygon.cpp9
-rw-r--r--sources/shiboken6/tests/libsample/rect.h9
-rw-r--r--sources/shiboken6/tests/libsample/samplenamespace.cpp3
-rw-r--r--sources/shiboken6/tests/libsample/size.h20
-rw-r--r--sources/shiboken6/tests/libsample/str.cpp4
-rw-r--r--sources/shiboken6/tests/libsample/str.h2
-rw-r--r--sources/shiboken6/tests/libsample/transform.cpp10
-rw-r--r--sources/shiboken6/tests/libsmart/smart_integer.h5
-rw-r--r--sources/shiboken6/tests/libsmart/smart_obj.h4
-rw-r--r--sources/shiboken6/tests/libsmart/smart_sharedptr.h3
37 files changed, 99 insertions, 106 deletions
diff --git a/sources/shiboken6/tests/libminimal/listuser.cpp b/sources/shiboken6/tests/libminimal/listuser.cpp
index ba8f43902..93c399542 100644
--- a/sources/shiboken6/tests/libminimal/listuser.cpp
+++ b/sources/shiboken6/tests/libminimal/listuser.cpp
@@ -1,11 +1,10 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-#include <numeric>
-#include <cstdlib>
#include "listuser.h"
#include <algorithm>
+#include <cstdlib>
#include <numeric>
std::list<int> ListUser::createIntList(int num)
diff --git a/sources/shiboken6/tests/libminimal/minbool.h b/sources/shiboken6/tests/libminimal/minbool.h
index 4473df975..168ca4863 100644
--- a/sources/shiboken6/tests/libminimal/minbool.h
+++ b/sources/shiboken6/tests/libminimal/minbool.h
@@ -13,7 +13,7 @@ public:
bool value() const { return m_value; }
inline MinBool operator!() const { return MinBool(!m_value); }
inline MinBool& operator|=(const MinBool& other) {
- m_value = m_value | other.m_value;
+ m_value |= other.m_value;
return *this;
}
diff --git a/sources/shiboken6/tests/libother/number.cpp b/sources/shiboken6/tests/libother/number.cpp
index 538cea01e..fbf50dc4a 100644
--- a/sources/shiboken6/tests/libother/number.cpp
+++ b/sources/shiboken6/tests/libother/number.cpp
@@ -14,7 +14,7 @@ Str Number::toStr() const
Point operator*(const Point &p, const Number &n)
{
- return Point(p.x() * n.value(), p.y() * n.value());
+ return {p.x() * n.value(), p.y() * n.value()};
}
Complex Number::toComplex() const
diff --git a/sources/shiboken6/tests/libother/otherderived.h b/sources/shiboken6/tests/libother/otherderived.h
index a233c6e2f..d6bde8808 100644
--- a/sources/shiboken6/tests/libother/otherderived.h
+++ b/sources/shiboken6/tests/libother/otherderived.h
@@ -34,7 +34,7 @@ public:
protected:
inline const char *getClassName() { return className(); }
- virtual const char *className() const override { return "OtherDerived"; }
+ const char *className() const override { return "OtherDerived"; }
private:
void pureVirtualPrivate() override;
diff --git a/sources/shiboken6/tests/libother/smartptrtester.cpp b/sources/shiboken6/tests/libother/smartptrtester.cpp
index 25b6a406e..1c6496b1a 100644
--- a/sources/shiboken6/tests/libother/smartptrtester.cpp
+++ b/sources/shiboken6/tests/libother/smartptrtester.cpp
@@ -5,7 +5,7 @@
SharedPtr<Str> SmartPtrTester::createSharedPtrStr(const char *what)
{
- return SharedPtr<Str>(new Str(what));
+ return {new Str(what)};
}
std::string SmartPtrTester::valueOfSharedPtrStr(const SharedPtr<Str> &str)
diff --git a/sources/shiboken6/tests/libsample/blackbox.cpp b/sources/shiboken6/tests/libsample/blackbox.cpp
index b6fc28fe3..2ac435d3d 100644
--- a/sources/shiboken6/tests/libsample/blackbox.cpp
+++ b/sources/shiboken6/tests/libsample/blackbox.cpp
@@ -6,10 +6,10 @@
BlackBox::~BlackBox()
{
// Free all maps.
- for (auto it = m_objects.begin(), end = m_objects.end(); it != end; ++it)
- delete it->second;
- for (auto it = m_points.begin(), end = m_points.end(); it != end; ++it)
- delete it->second;
+ for (const auto &p :m_objects)
+ delete p.second;
+ for (const auto &p : m_points)
+ delete p.second;
}
int BlackBox::keepObjectType(ObjectType *object)
@@ -64,8 +64,8 @@ std::list<ObjectType*> BlackBox::objects()
{
std::list<ObjectType*> l;
- for (auto it = m_objects.begin(), end = m_objects.end(); it != end; ++it)
- l.push_back((*it).second);
+ for (const auto &p : m_objects)
+ l.push_back(p.second);
return l;
}
@@ -74,8 +74,8 @@ std::list<Point*> BlackBox::points()
{
std::list<Point*> l;
- for (auto it = m_points.begin(), end = m_points.end(); it != end; ++it)
- l.push_back((*it).second);
+ for (const auto &p : m_points)
+ l.push_back(p.second);
return l;
}
diff --git a/sources/shiboken6/tests/libsample/bucket.cpp b/sources/shiboken6/tests/libsample/bucket.cpp
index 277809b15..cafd382a9 100644
--- a/sources/shiboken6/tests/libsample/bucket.cpp
+++ b/sources/shiboken6/tests/libsample/bucket.cpp
@@ -25,7 +25,7 @@ int Bucket::pop(void)
{
int x = 0;
- if (m_data.size() > 0) {
+ if (!m_data.empty()) {
x = m_data.front();
m_data.pop_front();
}
diff --git a/sources/shiboken6/tests/libsample/bytearray.cpp b/sources/shiboken6/tests/libsample/bytearray.cpp
index 1fe4b6fc2..78d5162b0 100644
--- a/sources/shiboken6/tests/libsample/bytearray.cpp
+++ b/sources/shiboken6/tests/libsample/bytearray.cpp
@@ -161,6 +161,6 @@ unsigned int ByteArray::hash(const ByteArray &byteArray)
{
unsigned int result = 0;
for (char c : byteArray.m_data)
- result = 5u * result + unsigned(c);
+ result = 5U * result + unsigned(c);
return result;
}
diff --git a/sources/shiboken6/tests/libsample/cvlist.h b/sources/shiboken6/tests/libsample/cvlist.h
index e0c6dfeb5..e09c7d943 100644
--- a/sources/shiboken6/tests/libsample/cvlist.h
+++ b/sources/shiboken6/tests/libsample/cvlist.h
@@ -21,7 +21,7 @@ using const_ptr_value_list = std::list<const CVValueType*>;
class CVListUser
{
public:
- static const_ptr_value_list produce() { return const_ptr_value_list(); }
+ static const_ptr_value_list produce() { return {}; }
static void consume(const const_ptr_value_list &l) { (void)l; }
};
diff --git a/sources/shiboken6/tests/libsample/derived.cpp b/sources/shiboken6/tests/libsample/derived.cpp
index 310ae5e75..e7a30f311 100644
--- a/sources/shiboken6/tests/libsample/derived.cpp
+++ b/sources/shiboken6/tests/libsample/derived.cpp
@@ -67,7 +67,7 @@ struct SecretClass : public Abstract {
PrintFormat returnAnEnum() override { return Short; }
void hideFunction(HideType*) override {};
private:
- virtual void pureVirtualPrivate() override {}
+ void pureVirtualPrivate() override {}
};
Abstract *Derived::triggerImpossibleTypeDiscovery()
diff --git a/sources/shiboken6/tests/libsample/expression.cpp b/sources/shiboken6/tests/libsample/expression.cpp
index 5a6b4f4bb..6462d509c 100644
--- a/sources/shiboken6/tests/libsample/expression.cpp
+++ b/sources/shiboken6/tests/libsample/expression.cpp
@@ -12,12 +12,12 @@ Expression::Expression(int number) : m_value(number)
{
}
-Expression::Expression(const Expression &other)
+Expression::Expression(const Expression &other) :
+ m_value(other.m_value),
+ m_operation(other.m_operation),
+ m_operand1(other.m_operand1 ? new Expression(*other.m_operand1) : nullptr),
+ m_operand2(other.m_operand2 ? new Expression(*other.m_operand2) : nullptr)
{
- m_operand1 = other.m_operand1 ? new Expression(*other.m_operand1) : nullptr;
- m_operand2 = other.m_operand2 ? new Expression(*other.m_operand2) : nullptr;
- m_value = other.m_value;
- m_operation = other.m_operation;
}
Expression &Expression::operator=(const Expression &other)
@@ -86,7 +86,7 @@ std::string Expression::toString() const
std::string result;
result += '(';
result += m_operand1->toString();
- char op;
+ char op = '?';
switch (m_operation) {
case Add:
op = '+';
@@ -100,9 +100,7 @@ std::string Expression::toString() const
case GreaterThan:
op = '<';
break;
- case None: // just to avoid the compiler warning
default:
- op = '?';
break;
}
result += op;
diff --git a/sources/shiboken6/tests/libsample/functions.cpp b/sources/shiboken6/tests/libsample/functions.cpp
index 6141af8df..ad2f4dd5a 100644
--- a/sources/shiboken6/tests/libsample/functions.cpp
+++ b/sources/shiboken6/tests/libsample/functions.cpp
@@ -49,14 +49,12 @@ double multiplyPair(std::pair<double, double> pair)
int countCharacters(const char *text)
{
- if (!text)
- return -1;
- return std::strlen(text);
+ return text != nullptr ? int(std::strlen(text)) : -1;
}
char *makeCString()
{
- char *string = new char[strlen(__FUNCTION__) + 1];
+ char *string = new char[std::strlen(__FUNCTION__) + 1];
std::strcpy(string, __FUNCTION__);
return string;
}
@@ -181,9 +179,7 @@ double sumDoubleMatrix(double m[2][3])
return result;
}
-ArrayModifyTest::ArrayModifyTest()
-{
-}
+ArrayModifyTest::ArrayModifyTest() = default;
int ArrayModifyTest::sumIntArray(int n, int *array)
{
diff --git a/sources/shiboken6/tests/libsample/handle.h b/sources/shiboken6/tests/libsample/handle.h
index 7af0b3107..07fc89d15 100644
--- a/sources/shiboken6/tests/libsample/handle.h
+++ b/sources/shiboken6/tests/libsample/handle.h
@@ -25,16 +25,16 @@ public:
void set(SAMPLE_HANDLE ptr);
inline void set(const Foo::SAMPLE_HANDLE &val) { m_handle2 = val; }
- inline SAMPLE_HANDLE handle() { return m_handle; }
- inline Foo::SAMPLE_HANDLE handle2() { return m_handle2; }
+ inline SAMPLE_HANDLE handle() const { return m_handle; }
+ inline Foo::SAMPLE_HANDLE handle2() const { return m_handle2; }
static SAMPLE_HANDLE createHandle();
bool compare(HandleHolder *other);
bool compare2(HandleHolder *other);
private:
- SAMPLE_HANDLE m_handle;
- Foo::SAMPLE_HANDLE m_handle2;
+ SAMPLE_HANDLE m_handle = nullptr;
+ Foo::SAMPLE_HANDLE m_handle2 = 0;
};
inline void HandleHolder::set(SAMPLE_HANDLE)
diff --git a/sources/shiboken6/tests/libsample/listuser.cpp b/sources/shiboken6/tests/libsample/listuser.cpp
index fd393b881..9bb7f7798 100644
--- a/sources/shiboken6/tests/libsample/listuser.cpp
+++ b/sources/shiboken6/tests/libsample/listuser.cpp
@@ -13,9 +13,9 @@ std::list<int> ListUser::callCreateList()
ListUser::ListUser() = default;
ListUser::ListUser(const ListUser &other) = default;
-ListUser::ListUser(ListUser &&other) = default;
+ListUser::ListUser(ListUser &&other) noexcept = default;
ListUser &ListUser::operator=(const ListUser &other) = default;
-ListUser &ListUser::operator=(ListUser &&other) = default;
+ListUser &ListUser::operator=(ListUser &&other) noexcept = default;
ListUser::~ListUser() = default;
std::list<int> ListUser::createList()
diff --git a/sources/shiboken6/tests/libsample/listuser.h b/sources/shiboken6/tests/libsample/listuser.h
index 280cfbabd..96781ed16 100644
--- a/sources/shiboken6/tests/libsample/listuser.h
+++ b/sources/shiboken6/tests/libsample/listuser.h
@@ -24,9 +24,9 @@ public:
ListUser();
ListUser(const ListUser &other);
- ListUser(ListUser &&other);
+ ListUser(ListUser &&other) noexcept;
ListUser &operator=(const ListUser &other);
- ListUser &operator=(ListUser &&other);
+ ListUser &operator=(ListUser &&other) noexcept;
virtual ~ListUser();
virtual std::list<int> createList();
diff --git a/sources/shiboken6/tests/libsample/mapuser.cpp b/sources/shiboken6/tests/libsample/mapuser.cpp
index c793235df..40059bbcd 100644
--- a/sources/shiboken6/tests/libsample/mapuser.cpp
+++ b/sources/shiboken6/tests/libsample/mapuser.cpp
@@ -29,8 +29,8 @@ std::map<std::string, std::pair<Complex, int> > MapUser::createMap()
void MapUser::showMap(std::map<std::string, int> mapping)
{
std::cout << __FUNCTION__ << std::endl;
- for (auto it = mapping.begin(), end = mapping.end(); it != end; ++it)
- std::cout << (*it).first << " => " << (*it).second << std::endl;
+ for (const auto &p : mapping)
+ std::cout << p.first << " => " << p.second << std::endl;
}
void MapUser::pointerToMap(std::map<std::string, std::string> *)
diff --git a/sources/shiboken6/tests/libsample/modifications.cpp b/sources/shiboken6/tests/libsample/modifications.cpp
index 2e413946e..6d627c4c1 100644
--- a/sources/shiboken6/tests/libsample/modifications.cpp
+++ b/sources/shiboken6/tests/libsample/modifications.cpp
@@ -7,8 +7,8 @@
#include <iostream>
Modifications::Modifications()
+ : m_object(new ObjectType())
{
- m_object = new ObjectType();
m_object->setObjectName("MyObject");
}
diff --git a/sources/shiboken6/tests/libsample/modifications.h b/sources/shiboken6/tests/libsample/modifications.h
index 0dea163b6..4ade7c444 100644
--- a/sources/shiboken6/tests/libsample/modifications.h
+++ b/sources/shiboken6/tests/libsample/modifications.h
@@ -130,7 +130,7 @@ class LIBSAMPLE_API AbstractModifications : public Modifications
{
public:
AbstractModifications() {}
- virtual ~AbstractModifications() {}
+ ~AbstractModifications() override {}
inline bool invert(bool value) { return !value; }
diff --git a/sources/shiboken6/tests/libsample/objecttype.cpp b/sources/shiboken6/tests/libsample/objecttype.cpp
index a52d2a52a..7df7b46f2 100644
--- a/sources/shiboken6/tests/libsample/objecttype.cpp
+++ b/sources/shiboken6/tests/libsample/objecttype.cpp
@@ -14,8 +14,8 @@ ObjectType::ObjectType(ObjectType *parent)
setParent(parent);
}
-ObjectType::ObjectType(ObjectType &&) = default;
-ObjectType &ObjectType::operator=(ObjectType &&) = default;
+ObjectType::ObjectType(ObjectType &&) noexcept = default;
+ObjectType &ObjectType::operator=(ObjectType &&) noexcept = default;
ObjectType::~ObjectType()
{
@@ -170,10 +170,9 @@ void ObjectType::setLayout(ObjectTypeLayout *l)
<< "' on ObjectType '" << objectName().cstring()
<< "', when the ObjectTypeLayout already has a parent layout.\n";
return;
- } else {
- // Steal the layout from an ObjectType parent.
- oldParent->takeLayout();
}
+ // Steal the layout from an ObjectType parent.
+ oldParent->takeLayout();
}
m_layout = l;
@@ -243,7 +242,7 @@ int ObjectType::callId() const
void ObjectType::callVirtualCreateChild()
{
- ObjectType *fake_parent = new ObjectType();
+ auto *fake_parent = new ObjectType();
ObjectType *fake_child = createChild(fake_parent);
assert(fake_child->isPython());
(void)fake_child;
diff --git a/sources/shiboken6/tests/libsample/objecttype.h b/sources/shiboken6/tests/libsample/objecttype.h
index d7f606012..08128be49 100644
--- a/sources/shiboken6/tests/libsample/objecttype.h
+++ b/sources/shiboken6/tests/libsample/objecttype.h
@@ -50,8 +50,8 @@ public:
virtual ~ObjectType();
ObjectType(const ObjectType &) = delete;
ObjectType &operator=(const ObjectType &) = delete;
- ObjectType(ObjectType &&);
- ObjectType &operator=(ObjectType &&);
+ ObjectType(ObjectType &&) noexcept;
+ ObjectType &operator=(ObjectType &&) noexcept;
// factory method
inline static ObjectType *create() { return new ObjectType(); }
diff --git a/sources/shiboken6/tests/libsample/objecttypebyvalue.h b/sources/shiboken6/tests/libsample/objecttypebyvalue.h
index c6d9aef87..7b12ff945 100644
--- a/sources/shiboken6/tests/libsample/objecttypebyvalue.h
+++ b/sources/shiboken6/tests/libsample/objecttypebyvalue.h
@@ -11,7 +11,7 @@
class ObjectTypeByValue
{
public:
- ObjectTypeByValue returnSomeKindOfMe() { return ObjectTypeByValue(); }
+ ObjectTypeByValue returnSomeKindOfMe() { return {}; }
void acceptKindOfMeAsValue(ObjectTypeByValue kindOfMe);
void acceptListOfObjectTypeByValue(std::list<ObjectTypeByValue> listOfMe);
diff --git a/sources/shiboken6/tests/libsample/objecttypeholder.cpp b/sources/shiboken6/tests/libsample/objecttypeholder.cpp
index dfd7c4020..344f54dbd 100644
--- a/sources/shiboken6/tests/libsample/objecttypeholder.cpp
+++ b/sources/shiboken6/tests/libsample/objecttypeholder.cpp
@@ -5,7 +5,7 @@
ObjectTypeHolder::ObjectTypeHolder(const char *objectName)
{
- auto object = new ObjectType();
+ auto *object = new ObjectType();
object->setObjectName(objectName);
m_objectType = object;
}
diff --git a/sources/shiboken6/tests/libsample/objectview.cpp b/sources/shiboken6/tests/libsample/objectview.cpp
index d12464142..1b727f88c 100644
--- a/sources/shiboken6/tests/libsample/objectview.cpp
+++ b/sources/shiboken6/tests/libsample/objectview.cpp
@@ -8,7 +8,7 @@
Str ObjectView::displayModelData()
{
if (!m_model)
- return Str("(NULL)");
+ return {"(NULL)"};
return Str("Name: %VAR").arg(m_model->objectName());
}
diff --git a/sources/shiboken6/tests/libsample/pen.cpp b/sources/shiboken6/tests/libsample/pen.cpp
index 2d58fa54c..76473a264 100644
--- a/sources/shiboken6/tests/libsample/pen.cpp
+++ b/sources/shiboken6/tests/libsample/pen.cpp
@@ -59,9 +59,9 @@ Pen::Pen(const Pen &) : m_ctor(CopyCtor)
{
}
-Pen::Pen(Pen &&) = default;
+Pen::Pen(Pen &&) noexcept = default;
Pen &Pen::operator=(const Pen &pen) = default;
-Pen &Pen::operator=(Pen &&) = default;
+Pen &Pen::operator=(Pen &&) noexcept = default;
int Pen::ctorType()
{
diff --git a/sources/shiboken6/tests/libsample/pen.h b/sources/shiboken6/tests/libsample/pen.h
index c99dd8add..90a8aa584 100644
--- a/sources/shiboken6/tests/libsample/pen.h
+++ b/sources/shiboken6/tests/libsample/pen.h
@@ -51,9 +51,9 @@ public:
Pen(SampleNamespace::Option option);
Pen(const Color &color);
Pen(const Pen &pen);
- Pen(Pen &&);
+ Pen(Pen &&) noexcept;
Pen &operator=(const Pen &pen);
- Pen &operator=(Pen &&);
+ Pen &operator=(Pen &&) noexcept;
// PYSIDE-1325, default initializer
void drawLine(int x1, int y1, int x2, int y2, RenderHints renderHints = {});
diff --git a/sources/shiboken6/tests/libsample/point.cpp b/sources/shiboken6/tests/libsample/point.cpp
index f85e4650c..d0fa83295 100644
--- a/sources/shiboken6/tests/libsample/point.cpp
+++ b/sources/shiboken6/tests/libsample/point.cpp
@@ -41,12 +41,12 @@ bool Point::operator==(const Point &other)
Point Point::operator+(const Point &other)
{
- return Point(m_x + other.m_x, m_y + other.m_y);
+ return {m_x + other.m_x, m_y + other.m_y};
}
Point Point::operator-(const Point &other)
{
- return Point(m_x - other.m_x, m_y - other.m_y);
+ return {m_x - other.m_x, m_y - other.m_y};
}
Point &Point::operator+=(Point &other)
@@ -70,22 +70,22 @@ Point operator*(const Point &pt, double mult)
Point operator*(const Point &pt, int mult)
{
- return Point(int(pt.m_x) * mult, int(pt.m_y) * mult);
+ return {int(pt.m_x) * mult, int(pt.m_y) * mult};
}
Point operator*(double mult, const Point &pt)
{
- return Point(pt.m_x * mult, pt.m_y * mult);
+ return {pt.m_x * mult, pt.m_y * mult};
}
Point operator*(int mult, const Point &pt)
{
- return Point(int(pt.m_x) * mult, int(pt.m_y) * mult);
+ return {int(pt.m_x) * mult, int(pt.m_y) * mult};
}
Point operator-(const Point &pt)
{
- return Point(-pt.m_x, -pt.m_y);
+ return {-pt.m_x, -pt.m_y};
}
bool operator!(const Point &pt)
@@ -95,7 +95,7 @@ bool operator!(const Point &pt)
Point Point::operator/(int operand)
{
- return Point(m_x/operand, m_y/operand);
+ return {m_x/operand, m_y/operand};
}
Complex transmutePointIntoComplex(const Point &point)
diff --git a/sources/shiboken6/tests/libsample/pointf.cpp b/sources/shiboken6/tests/libsample/pointf.cpp
index e51173c6d..244a10736 100644
--- a/sources/shiboken6/tests/libsample/pointf.cpp
+++ b/sources/shiboken6/tests/libsample/pointf.cpp
@@ -33,12 +33,12 @@ bool PointF::operator==(const PointF &other)
PointF PointF::operator+(const PointF &other)
{
- return PointF(m_x + other.m_x, m_y + other.m_y);
+ return {m_x + other.m_x, m_y + other.m_y};
}
PointF PointF::operator-(const PointF &other)
{
- return PointF(m_x - other.m_x, m_y - other.m_y);
+ return {m_x - other.m_x, m_y - other.m_y};
}
PointF &PointF::operator+=(PointF &other)
@@ -57,7 +57,7 @@ PointF &PointF::operator-=(PointF &other)
PointF operator*(const PointF &pt, double mult)
{
- return PointF(pt.m_x * mult, pt.m_y * mult);
+ return {pt.m_x * mult, pt.m_y * mult};
}
PointF operator*(const PointF &pt, int mult)
@@ -67,7 +67,7 @@ PointF operator*(const PointF &pt, int mult)
PointF operator*(double mult, const PointF &pt)
{
- return PointF(pt.m_x * mult, pt.m_y * mult);
+ return {pt.m_x * mult, pt.m_y * mult};
}
PointF operator*(int mult, const PointF &pt)
@@ -77,7 +77,7 @@ PointF operator*(int mult, const PointF &pt)
PointF operator-(const PointF &pt)
{
- return PointF(-pt.m_x, -pt.m_y);
+ return {-pt.m_x, -pt.m_y};
}
bool operator!(const PointF &pt)
diff --git a/sources/shiboken6/tests/libsample/polygon.cpp b/sources/shiboken6/tests/libsample/polygon.cpp
index 789b94ac1..6af597192 100644
--- a/sources/shiboken6/tests/libsample/polygon.cpp
+++ b/sources/shiboken6/tests/libsample/polygon.cpp
@@ -3,19 +3,16 @@
#include "polygon.h"
-Polygon::Polygon(double x, double y)
+Polygon::Polygon(double x, double y) : m_points({Point(x, y)})
{
- m_points.push_back(Point(x, y));
}
-Polygon::Polygon(Point point)
+Polygon::Polygon(Point point) : m_points({point})
{
- m_points.push_back(point);
}
-Polygon::Polygon(PointList points)
+Polygon::Polygon(PointList points) : m_points(points)
{
- m_points = points;
}
void Polygon::addPoint(Point point)
diff --git a/sources/shiboken6/tests/libsample/rect.h b/sources/shiboken6/tests/libsample/rect.h
index 3218b78a2..4fd40c1bb 100644
--- a/sources/shiboken6/tests/libsample/rect.h
+++ b/sources/shiboken6/tests/libsample/rect.h
@@ -31,13 +31,8 @@ public:
RectF() = default;
explicit RectF(int left, int top, int right, int bottom)
: m_left(left), m_top(top), m_right(right), m_bottom(bottom) { }
- RectF(const Rect &other)
- {
- m_left = other.left();
- m_top = other.top();
- m_right = other.right();
- m_bottom = other.bottom();
- }
+ RectF(const Rect &other) : m_left(other.left()), m_top(other.top()),
+ m_right(other.right()), m_bottom(other.bottom()) {}
~RectF() = default;
inline double left() const { return m_left; }
diff --git a/sources/shiboken6/tests/libsample/samplenamespace.cpp b/sources/shiboken6/tests/libsample/samplenamespace.cpp
index 6a0805c7e..eae5af2d2 100644
--- a/sources/shiboken6/tests/libsample/samplenamespace.cpp
+++ b/sources/shiboken6/tests/libsample/samplenamespace.cpp
@@ -19,7 +19,7 @@ SomeClass::PublicScopedEnum SomeClass::protectedMethodReturningPublicScopedEnum(
OutValue enumInEnumOut(InValue in)
{
- OutValue retval;
+ auto retval = OutValue(-1);
switch(in) {
case ZeroIn:
retval = ZeroOut;
@@ -31,7 +31,6 @@ OutValue enumInEnumOut(InValue in)
retval = TwoOut;
break;
default:
- retval = OutValue(-1);
break;
}
return retval;
diff --git a/sources/shiboken6/tests/libsample/size.h b/sources/shiboken6/tests/libsample/size.h
index 011999d72..163e22927 100644
--- a/sources/shiboken6/tests/libsample/size.h
+++ b/sources/shiboken6/tests/libsample/size.h
@@ -90,11 +90,11 @@ public:
// External operators
friend inline bool operator==(const Size&, const Size&);
friend inline bool operator!=(const Size&, const Size&);
- friend inline const Size operator+(const Size&, const Size&);
- friend inline const Size operator-(const Size&, const Size&);
- friend inline const Size operator*(const Size&, double);
- friend inline const Size operator*(double, const Size&);
- friend inline const Size operator/(const Size&, double);
+ friend inline Size operator+(const Size&, const Size&);
+ friend inline Size operator-(const Size&, const Size&);
+ friend inline Size operator*(const Size&, double);
+ friend inline Size operator*(double, const Size&);
+ friend inline Size operator/(const Size&, double);
friend inline bool operator<(double, const Size&);
friend inline bool operator>(double, const Size&);
@@ -140,27 +140,27 @@ inline bool operator>=(double area, const Size &s)
}
// Arithmetic Operators
-inline const Size operator+(const Size &s1, const Size &s2)
+inline Size operator+(const Size &s1, const Size &s2)
{
return Size(s1.m_width + s2.m_width, s1.m_height + s2.m_height);
}
-inline const Size operator-(const Size &s1, const Size &s2)
+inline Size operator-(const Size &s1, const Size &s2)
{
return Size(s1.m_width - s2.m_width, s1.m_height - s2.m_height);
}
-inline const Size operator*(const Size &s, double mult)
+inline Size operator*(const Size &s, double mult)
{
return Size(s.m_width * mult, s.m_height * mult);
}
-inline const Size operator*(double mult, const Size &s)
+inline Size operator*(double mult, const Size &s)
{
return Size(s.m_width * mult, s.m_height * mult);
}
-inline const Size operator/(const Size &s, double div)
+inline Size operator/(const Size &s, double div)
{
return Size(s.m_width / div, s.m_height / div);
}
diff --git a/sources/shiboken6/tests/libsample/str.cpp b/sources/shiboken6/tests/libsample/str.cpp
index 96fbba74a..742c0bb01 100644
--- a/sources/shiboken6/tests/libsample/str.cpp
+++ b/sources/shiboken6/tests/libsample/str.cpp
@@ -68,7 +68,7 @@ int Str::toInt(bool *ok, int base) const
conv >> std::hex >> result;
break;
}
- const bool my_ok = std::istringstream::eofbit &conv.rdstate();
+ const bool my_ok = std::istringstream::eofbit & conv.rdstate();
if (!my_ok)
result = 0;
if (ok)
@@ -120,7 +120,7 @@ unsigned int strHash(const Str &str)
{
unsigned int result = 0;
for (char c : str.m_str)
- result = 5u * result + unsigned(c);
+ result = 5U * result + unsigned(c);
return result;
}
diff --git a/sources/shiboken6/tests/libsample/str.h b/sources/shiboken6/tests/libsample/str.h
index e75e33085..6b3386cef 100644
--- a/sources/shiboken6/tests/libsample/str.h
+++ b/sources/shiboken6/tests/libsample/str.h
@@ -27,7 +27,7 @@ public:
void show() const;
- inline int size() const { return m_str.size(); }
+ inline int size() const { return int(m_str.size()); }
// nonsense operator just to test reverse operators
Str operator+(int number) const;
diff --git a/sources/shiboken6/tests/libsample/transform.cpp b/sources/shiboken6/tests/libsample/transform.cpp
index ebcab630a..5ccf5d1ed 100644
--- a/sources/shiboken6/tests/libsample/transform.cpp
+++ b/sources/shiboken6/tests/libsample/transform.cpp
@@ -19,10 +19,10 @@ Point applyHomogeneousTransform(const Point &in,
if (std::isfinite(w) && fabs(w) > 1e-10) {
if (okay)
*okay = true;
- return Point(x / w, y / w);
- } else {
- if (okay)
- *okay = false;
- return Point();
+ return {x / w, y / w};
}
+
+ if (okay)
+ *okay = false;
+ return {};
}
diff --git a/sources/shiboken6/tests/libsmart/smart_integer.h b/sources/shiboken6/tests/libsmart/smart_integer.h
index f2381cabb..42a441a00 100644
--- a/sources/shiboken6/tests/libsmart/smart_integer.h
+++ b/sources/shiboken6/tests/libsmart/smart_integer.h
@@ -11,6 +11,8 @@ public:
Integer();
Integer(const Integer &other);
Integer &operator=(const Integer &other);
+ Integer(Integer &&other) noexcept = default;
+ Integer &operator=(Integer &&other) noexcept = default;
~Integer();
void printInteger() const;
@@ -58,6 +60,9 @@ public:
Integer2();
Integer2(const Integer2 &);
Integer2 &operator=(const Integer2 &);
+ Integer2(Integer2 &&other) = delete;
+ Integer2 &operator=(Integer2 &&other) = delete;
+ ~Integer2() = default;
};
} // namespace Smart
diff --git a/sources/shiboken6/tests/libsmart/smart_obj.h b/sources/shiboken6/tests/libsmart/smart_obj.h
index 901d69696..9f4f8425d 100644
--- a/sources/shiboken6/tests/libsmart/smart_obj.h
+++ b/sources/shiboken6/tests/libsmart/smart_obj.h
@@ -17,6 +17,10 @@ namespace Smart { class Integer2; }
class LIB_SMART_API Obj {
public:
Obj();
+ Obj(const Obj &other) = delete;
+ Obj &operator=(const Obj &other) = delete;
+ Obj(Obj &&other) = delete;
+ Obj &operator=(Obj &&other) = delete;
virtual ~Obj();
void printObj();
diff --git a/sources/shiboken6/tests/libsmart/smart_sharedptr.h b/sources/shiboken6/tests/libsmart/smart_sharedptr.h
index 279e199dc..bc2b071c1 100644
--- a/sources/shiboken6/tests/libsmart/smart_sharedptr.h
+++ b/sources/shiboken6/tests/libsmart/smart_sharedptr.h
@@ -40,7 +40,8 @@ public:
SharedPtr &operator=(const SharedPtr &other)
{
- mPtr = other.mPtr;
+ if (this != &other)
+ mPtr = other.mPtr;
return *this;
}