From d8e42fbde07db9980e182e80a7b42c20d1485f8d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 25 Jun 2019 09:39:12 +0200 Subject: shiboken: Introduce member initialization Use member initialization, use default bodies for constructors. Initialize missing members as reported by clang. Change-Id: Ibc51e46a37b310912ec8f274543092dfdda78e1b Reviewed-by: Christian Tismer --- sources/shiboken2/ApiExtractor/typedatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sources/shiboken2/ApiExtractor/typedatabase.cpp') diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp index 930f85d30..6a5e8d8ba 100644 --- a/sources/shiboken2/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp @@ -56,7 +56,7 @@ typedef QVector ApiVersions; Q_GLOBAL_STATIC(ApiVersions, apiVersions) -TypeDatabase::TypeDatabase() : m_suppressWarnings(true) +TypeDatabase::TypeDatabase() { addType(new VoidTypeEntry()); addType(new VarargsTypeEntry()); -- cgit v1.2.3 From ddfbbd346b522703a5b6f8d274a7f79983e5f319 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 25 Jun 2019 09:33:27 +0200 Subject: shiboken: Introduce nullptr Apply Fixits by Qt Creator with some amendments. Change-Id: Ie8300ddb834adb8b649324562f2c912a4e8cf4ce Reviewed-by: Christian Tismer --- sources/shiboken2/ApiExtractor/typedatabase.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sources/shiboken2/ApiExtractor/typedatabase.cpp') diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp index 6a5e8d8ba..279be9dc0 100644 --- a/sources/shiboken2/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp @@ -68,7 +68,7 @@ TypeDatabase::~TypeDatabase() TypeDatabase* TypeDatabase::instance(bool newInstance) { - static TypeDatabase* db = 0; + static TypeDatabase *db = nullptr; if (!db || newInstance) { if (db) delete db; @@ -163,7 +163,7 @@ ContainerTypeEntry* TypeDatabase::findContainerType(const QString &name) const TypeEntry* type_entry = findType(template_name); if (type_entry && type_entry->isContainer()) return static_cast(type_entry); - return 0; + return nullptr; } static bool inline useType(const TypeEntry *t) @@ -179,7 +179,7 @@ FunctionTypeEntry* TypeDatabase::findFunctionType(const QString& name) const if (entry->type() == TypeEntry::FunctionType && useType(entry)) return static_cast(entry); } - return 0; + return nullptr; } void TypeDatabase::addTypeSystemType(const TypeSystemTypeEntry *e) @@ -598,7 +598,7 @@ PrimitiveTypeEntry *TypeDatabase::findPrimitiveType(const QString& name) const } } - return 0; + return nullptr; } ComplexTypeEntry* TypeDatabase::findComplexType(const QString& name) const @@ -608,7 +608,7 @@ ComplexTypeEntry* TypeDatabase::findComplexType(const QString& name) const if (entry->isComplex() && useType(entry)) return static_cast(entry); } - return 0; + return nullptr; } ObjectTypeEntry* TypeDatabase::findObjectType(const QString& name) const @@ -618,7 +618,7 @@ ObjectTypeEntry* TypeDatabase::findObjectType(const QString& name) const if (entry && entry->isObject() && useType(entry)) return static_cast(entry); } - return 0; + return nullptr; } NamespaceTypeEntryList TypeDatabase::findNamespaceTypes(const QString& name) const -- cgit v1.2.3 From e5595a4b3010b1bb4b6f80a0339271a7b26934de Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 25 Jun 2019 09:51:39 +0200 Subject: shiboken: Introduce auto Apply Fixits by Qt Creator with some amendments. Change-Id: Ib2be1012ef7e8a2ad0e6cd130371bf1e941c4264 Reviewed-by: Christian Tismer --- sources/shiboken2/ApiExtractor/typedatabase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sources/shiboken2/ApiExtractor/typedatabase.cpp') diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp index 279be9dc0..06667caaf 100644 --- a/sources/shiboken2/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp @@ -351,7 +351,7 @@ TypeEntry *TypeDatabase::resolveTypeDefEntry(TypedefEntry *typedefEntry, return nullptr; } - ComplexTypeEntry *result = static_cast(source->clone()); + auto *result = static_cast(source->clone()); result->useAsTypedef(typedefEntry); typedefEntry->setSource(source); typedefEntry->setTarget(result); @@ -592,7 +592,7 @@ PrimitiveTypeEntry *TypeDatabase::findPrimitiveType(const QString& name) const const auto entries = findTypes(name); for (TypeEntry *entry : entries) { if (entry->isPrimitive()) { - PrimitiveTypeEntry *pe = static_cast(entry); + auto *pe = static_cast(entry); if (pe->preferredTargetLangType()) return pe; } -- cgit v1.2.3 From 7be4e64b4bac6e6b5a90eec74b9f2b661c60db3a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 29 May 2019 10:45:37 +0200 Subject: shiboken: Replace 'typedef' by 'using' Apply Fixits by Qt Creator with some amendments. Remove iterator types by using auto instead. Change-Id: I8a75323da6ae5cdcc6b67af8be9376408953986b Reviewed-by: Christian Tismer --- sources/shiboken2/ApiExtractor/typedatabase.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sources/shiboken2/ApiExtractor/typedatabase.cpp') diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp index 06667caaf..256262f99 100644 --- a/sources/shiboken2/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp @@ -51,8 +51,8 @@ static QString wildcardToRegExp(QString w) return w; } -typedef QPair ApiVersion; -typedef QVector ApiVersions; +using ApiVersion =QPair; +using ApiVersions = QVector; Q_GLOBAL_STATIC(ApiVersions, apiVersions) @@ -85,7 +85,7 @@ struct IntTypeNormalizationEntry QString replacement; }; -typedef QVector IntTypeNormalizationEntries; +using IntTypeNormalizationEntries = QVector; static const IntTypeNormalizationEntries &intTypeNormalizationEntries() { -- cgit v1.2.3 From 4ccfd8de6462ce2ed938587eb0518038640c310f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 29 May 2019 14:59:09 +0200 Subject: shiboken: Fix various clang warnings - Avoid copying complex types by using const ref - Use isEmpty() to check for container emptyness - Use range-based for - Use Q_DISABLE_COPY in 'public:' area - Fix spelling error - Use '= default' for trivial constructors/destructors - Remove non-null checks before deletion - Fix misleading indentation - Fix else after return - Simplify boolean expressions - Fix unused parameters, streamline code Change-Id: I8c6cadd8653e220ba8e5bdb4dd55524d13a81768 Reviewed-by: Christian Tismer --- sources/shiboken2/ApiExtractor/typedatabase.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'sources/shiboken2/ApiExtractor/typedatabase.cpp') diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp index 256262f99..144795c6a 100644 --- a/sources/shiboken2/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp @@ -62,16 +62,13 @@ TypeDatabase::TypeDatabase() addType(new VarargsTypeEntry()); } -TypeDatabase::~TypeDatabase() -{ -} +TypeDatabase::~TypeDatabase() = default; TypeDatabase* TypeDatabase::instance(bool newInstance) { static TypeDatabase *db = nullptr; if (!db || newInstance) { - if (db) - delete db; + delete db; db = new TypeDatabase; } return db; @@ -93,10 +90,8 @@ static const IntTypeNormalizationEntries &intTypeNormalizationEntries() static bool firstTime = true; if (firstTime) { firstTime = false; - static const char *intTypes[] = {"char", "short", "int", "long"}; - const size_t size = sizeof(intTypes) / sizeof(intTypes[0]); - for (size_t i = 0; i < size; ++i) { - const QString intType = QLatin1String(intTypes[i]); + for (auto t : {"char", "short", "int", "long"}) { + const QString intType = QLatin1String(t); if (!TypeDatabase::instance()->findType(QLatin1Char('u') + intType)) { IntTypeNormalizationEntry entry; entry.replacement = QStringLiteral("unsigned ") + intType; @@ -115,8 +110,8 @@ QString TypeDatabase::normalizedSignature(const QString &signature) if (instance() && signature.contains(QLatin1String("unsigned"))) { const IntTypeNormalizationEntries &entries = intTypeNormalizationEntries(); - for (int i = 0, size = entries.size(); i < size; ++i) - normalized.replace(entries.at(i).regex, entries.at(i).replacement); + for (const auto &entry : entries) + normalized.replace(entry.regex, entry.replacement); } return normalized; @@ -146,10 +141,7 @@ void TypeDatabase::addTypesystemPath(const QString& typesystem_paths) IncludeList TypeDatabase::extraIncludes(const QString& className) const { ComplexTypeEntry* typeEntry = findComplexType(className); - if (typeEntry) - return typeEntry->extraIncludes(); - else - return IncludeList(); + return typeEntry ? typeEntry->extraIncludes() : IncludeList(); } ContainerTypeEntry* TypeDatabase::findContainerType(const QString &name) const -- cgit v1.2.3