diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-18 14:59:09 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-23 10:19:39 +0000 |
commit | ff0be5aba1c12be49b305e596a7610d197ca8427 (patch) | |
tree | e68205afbbb7e687223bf0c3fafa4fbcbf037970 /sources/shiboken2/generator/generator.cpp | |
parent | 61edf76aab3cdd0bfcf57b16f6a1c37271e675a5 (diff) |
Fix some clang-tidy warnings in shiboken
- 'else if' after return/break/continue
- Use const ref for complex arguments passed by value where possible
- Fix 'if (foo) delete foo' to 'delete foo'
- Use container.isEmpty() instead of container.size() in checks
- Use ' = default' for trivial constructors/destructors
- Use range based for where possible
- Complete constructor initializer lists
- Fix invocations of static methods
- Replace some reinterpret_cast by static_cast
- Remove unused variables/fields
- Use initializer lists for return types
Change-Id: Id5b44a2f9d429f66ef069d532a1cd31df796d38e
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/generator/generator.cpp')
-rw-r--r-- | sources/shiboken2/generator/generator.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp index 97c314275..63700f2c5 100644 --- a/sources/shiboken2/generator/generator.cpp +++ b/sources/shiboken2/generator/generator.cpp @@ -40,8 +40,9 @@ #include <QDebug> #include <typedatabase.h> -struct Generator::GeneratorPrivate { - const ApiExtractor* apiextractor; +struct Generator::GeneratorPrivate +{ + const ApiExtractor* apiextractor = nullptr; QString outDir; // License comment QString licenseComment; @@ -468,7 +469,7 @@ AbstractMetaFunctionList Generator::implicitConversions(const AbstractMetaType* bool Generator::isObjectType(const TypeEntry* type) { if (type->isComplex()) - return Generator::isObjectType((const ComplexTypeEntry*)type); + return Generator::isObjectType(static_cast<const ComplexTypeEntry *>(type)); return type->isObject(); } bool Generator::isObjectType(const ComplexTypeEntry* type) @@ -586,7 +587,7 @@ QString Generator::minimalConstructor(const AbstractMetaType* type) const return QLatin1String("static_cast< ::") + type->typeEntry()->qualifiedCppName() + QLatin1String(" *>(0)"); if (type->typeEntry()->isComplex()) { - const ComplexTypeEntry* cType = reinterpret_cast<const ComplexTypeEntry*>(type->typeEntry()); + const ComplexTypeEntry* cType = static_cast<const ComplexTypeEntry*>(type->typeEntry()); QString ctor = cType->defaultConstructor(); if (!ctor.isEmpty()) return ctor; @@ -617,7 +618,7 @@ QString Generator::minimalConstructor(const TypeEntry* type) const return type->qualifiedCppName() + QLatin1String("(0)"); if (type->isPrimitive()) { - QString ctor = reinterpret_cast<const PrimitiveTypeEntry*>(type)->defaultConstructor(); + QString ctor = static_cast<const PrimitiveTypeEntry*>(type)->defaultConstructor(); // If a non-C++ (i.e. defined by the user) primitive type does not have // a default constructor defined by the user, the empty constructor is // heuristically returned. If this is wrong the build of the generated @@ -638,7 +639,7 @@ QString Generator::minimalConstructor(const AbstractMetaClass* metaClass) const if (!metaClass) return QString(); - const ComplexTypeEntry* cType = reinterpret_cast<const ComplexTypeEntry*>(metaClass->typeEntry()); + const ComplexTypeEntry* cType = static_cast<const ComplexTypeEntry*>(metaClass->typeEntry()); if (cType->hasDefaultConstructor()) return cType->defaultConstructor(); |