diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-01-21 15:41:58 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-01-21 18:04:29 +0100 |
commit | 948bb445b09870f2100ab61d912e3a2f1769c06e (patch) | |
tree | 260ae9bc5cbd2c476b298447673ab2c54d6bec59 | |
parent | 123e27090e0ec4f8d32f301700c9ff9d1b49ba2a (diff) |
Clean up some warnings produced by Qt Creator's clang/clazy code checkers
- Remove unused variables
- Remove assignments that do not have any effect
- Fix mixing const/non-const iterators
- Fix for loops, use const ref and/or qAsConst()
Change-Id: I4b52f11030493c440026b194f18ec0151a3ea710
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
12 files changed, 16 insertions, 32 deletions
diff --git a/sources/pyside6/libpyside/feature_select.cpp b/sources/pyside6/libpyside/feature_select.cpp index b87751271..060c0d2ec 100644 --- a/sources/pyside6/libpyside/feature_select.cpp +++ b/sources/pyside6/libpyside/feature_select.cpp @@ -584,9 +584,8 @@ static PyObject *modifyStaticToClassMethod(PyTypeObject *type, PyObject *sm) new_func->ml_meth = func->m_ml->ml_meth; new_func->ml_flags = (func->m_ml->ml_flags & ~METH_STATIC) | METH_CLASS; new_func->ml_doc = func->m_ml->ml_doc; - auto cfunc = PyCFunction_NewEx(new_func, nullptr, nullptr); - cfunc = PyDescr_NewClassMethod(type, new_func); - return cfunc; + PyCFunction_NewEx(new_func, nullptr, nullptr); + return PyDescr_NewClassMethod(type, new_func); } static PyObject *createProperty(PyTypeObject *type, PyObject *getter, PyObject *setter) diff --git a/sources/pyside6/libpyside/pysideproperty.cpp b/sources/pyside6/libpyside/pysideproperty.cpp index 857041ea0..c00d90c2d 100644 --- a/sources/pyside6/libpyside/pysideproperty.cpp +++ b/sources/pyside6/libpyside/pysideproperty.cpp @@ -128,8 +128,6 @@ static void qpropertyMetaCall(PySideProperty *pp, PyObject *self, QMetaObject::C Shiboken::Conversions::SpecificConverter converter(pp->d->typeName); Q_ASSERT(converter); - QByteArray type(pp->d->typeName); - switch(call) { case QMetaObject::ReadProperty: { diff --git a/sources/pyside6/libpyside/pysidesignal.cpp b/sources/pyside6/libpyside/pysidesignal.cpp index 8533c2a48..63d5b0228 100644 --- a/sources/pyside6/libpyside/pysidesignal.cpp +++ b/sources/pyside6/libpyside/pysidesignal.cpp @@ -352,7 +352,6 @@ static PyObject *signalInstanceConnect(PyObject *self, PyObject *args, PyObject bool isFunction = PyFunction_Check(slot); bool matchedSlot = false; - QByteArray functionName; PySideSignalInstance *it = source; if (isMethod || isFunction) { @@ -896,9 +895,8 @@ void registerSignals(SbkObjectType *pyObj, const QMetaObject *metaObject) // Empty signatures comes first! So they will be the default signal signature std::stable_sort(it.value().begin(), it.value().end(), &compareSignals); - SignalSigMap::mapped_type::const_iterator j = it.value().begin(); - SignalSigMap::mapped_type::const_iterator endJ = it.value().end(); - for (; j != endJ; ++j) { + const auto endJ = it.value().cend(); + for (auto j = it.value().cbegin(); j != endJ; ++j) { const SignalSignature &sig = *j; appendSignature(self, sig); } diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp index caa9e40e2..3a196e487 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp @@ -541,7 +541,6 @@ void AbstractMetaBuilderPrivate::traverseDom(const FileModelItem &dom) } } else if (entry->isEnum() && entry->generateCode()) { auto enumEntry = static_cast<const EnumTypeEntry *>(entry); - const QString name = enumEntry->targetLangQualifier(); AbstractMetaClass *cls = AbstractMetaClass::findClass(m_metaClasses, enumEntry->parent()); diff --git a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp index 1875bf862..d398d9311 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp @@ -948,7 +948,6 @@ AbstractMetaFunctionCList AbstractMetaClass::queryFunctionList(const AbstractMet AbstractMetaFunctionCPtr AbstractMetaClass::queryFirstFunction(const AbstractMetaFunctionCList &list, FunctionQueryOptions query) { - AbstractMetaFunctionCList result; for (const auto &f : list) { if (queryFunction(f.data(), query)) return f; @@ -1116,7 +1115,7 @@ void AbstractMetaClass::fixFunctions() AbstractMetaFunctionCList funcs = functions(); AbstractMetaFunctionCList nonRemovedFuncs; nonRemovedFuncs.reserve(funcs.size()); - for (auto f : qAsConst(funcs)) { + for (const auto &f : qAsConst(funcs)) { // Fishy: Setting up of implementing/declaring/base classes changes // the applicable modifications; clear cached ones. qSharedPointerConstCast<AbstractMetaFunction>(f)->clearModificationsCache(); @@ -1459,7 +1458,7 @@ bool AbstractMetaClass::isValueTypeWithCopyConstructorOnly() const return false; const auto ctors = queryFunctions(FunctionQueryOption::Constructors); bool copyConstructorFound = false; - for (auto ctor : ctors) { + for (const auto &ctor : ctors) { switch (ctor->functionType()) { case AbstractMetaFunction::ConstructorFunction: return false; diff --git a/sources/shiboken6/ApiExtractor/typedatabase.cpp b/sources/shiboken6/ApiExtractor/typedatabase.cpp index eb213f2d1..0613da82a 100644 --- a/sources/shiboken6/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken6/ApiExtractor/typedatabase.cpp @@ -155,11 +155,11 @@ void TypeDatabase::addSystemInclude(const QString &name) void TypeDatabase::addInlineNamespaceLookups(const NamespaceTypeEntry *n) { TypeEntryList additionalEntries; // Store before modifying the hash - for (TypeEntry *entry : m_entries) { + for (TypeEntry *entry : qAsConst(m_entries)) { if (entry->isChildOf(n)) additionalEntries.append(entry); } - for (const auto &ae : additionalEntries) + for (const auto &ae : qAsConst(additionalEntries)) m_entries.insert(ae->shortName(), ae); } diff --git a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp index 2e8ae5e04..931d6cf35 100644 --- a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp +++ b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp @@ -826,7 +826,6 @@ static void writeFancyToc(TextStream& s, const QStringList& items, int cols = 2) QtXmlToSphinx::TableCell cell(currentColData); row << cell; currentColData.clear(); - i = 0; } table.appendRow(row); table.normalize(); diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index 6a2b38f1c..179bfa2d5 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -682,8 +682,6 @@ void CppGenerator::generateClass(TextStream &s, const GeneratorContext &classCon } } - const QString signaturesString = signatureStream.toString(); - if (supportsSequenceProtocol(metaClass)) { writeSequenceMethods(s, metaClass, classContext); } @@ -1053,7 +1051,6 @@ void CppGenerator::writeVirtualMethodNative(TextStream &s, if (func->argumentRemoved(arg.argumentIndex() + 1)) continue; - QString argConv; const auto &argType = arg.type(); auto argTypeEntry = static_cast<const PrimitiveTypeEntry *>(argType.typeEntry()); bool convert = argTypeEntry->isObject() @@ -2277,8 +2274,6 @@ void CppGenerator::writeErrorSection(TextStream &s, OverloadData &overloadData) const auto rfunc = overloadData.referenceFunction(); s << '\n' << cpythonFunctionName(rfunc) << "_TypeError:\n"; Indentation indentation(s); - QString funcName = fullPythonFunctionName(rfunc, true); - QString argsVar = pythonFunctionWrapperUsesListOfArguments(overloadData) ? QLatin1String("args") : QLatin1String(PYTHON_ARG); s << "Shiboken::setErrorAboutWrongArguments(" << argsVar @@ -3354,7 +3349,7 @@ QString CppGenerator::argumentNameFromIndex(const ApiExtractorResult &api, *errorMessage = msgClassNotFound(argType.typeEntry()); if (argIndex == 1 && !func->isConstructor() - && OverloadData::isSingleArgument(getFunctionGroups(func->implementingClass())[func->name()])) + && OverloadData::isSingleArgument(getFunctionGroups(func->implementingClass()).value(func->name()))) pyArgName = QLatin1String(PYTHON_ARG); else pyArgName = pythonArgsAt(argIndex - 1); @@ -4192,12 +4187,8 @@ void CppGenerator::writeClassDefinition(TextStream &s, QLatin1String("Sbk_object_dealloc /* PYSIDE-832: Prevent replacement of \"0\" with subtype_dealloc. */"); tp_init.clear(); } else { - QString deallocClassName = classContext.useWrapper() - ? classContext.wrapperName() : cppClassName; - if (isQApp) - tp_dealloc = QLatin1String("&SbkDeallocQAppWrapper"); - else - tp_dealloc = QLatin1String("&SbkDeallocWrapper"); + tp_dealloc = isQApp + ? QLatin1String("&SbkDeallocQAppWrapper") : QLatin1String("&SbkDeallocWrapper"); if (!onlyPrivCtor && !ctors.isEmpty()) tp_init = cpythonFunctionName(ctors.constFirst()); } @@ -6397,7 +6388,6 @@ void CppGenerator::writeDefaultSequenceMethods(TextStream &s, writeCppSelfDefinition(s, context); writeIndexError(s, QLatin1String("index out of bounds")); - QString value; s << metaClass->qualifiedCppName() << "::const_iterator _item = " << CPP_SELF_VAR << "->begin();\n" << "std::advance(_item, _i);\n"; diff --git a/sources/shiboken6/generator/shiboken/overloaddata.cpp b/sources/shiboken6/generator/shiboken/overloaddata.cpp index 1456ff668..d30335a4a 100644 --- a/sources/shiboken6/generator/shiboken/overloaddata.cpp +++ b/sources/shiboken6/generator/shiboken/overloaddata.cpp @@ -129,7 +129,7 @@ static QString msgCyclicDependency(const QString &funcName, const QString &graph str << "Cyclic dependency found on overloaddata for \"" << funcName << "\" method! The graph boy saved the graph at \"" << QDir::toNativeSeparators(graphName) << "\". Cyclic functions:"; - for (auto c : cyclic) + for (const auto &c : cyclic) str << ' ' << c->signature(); if (const int count = involvedConversions.size()) { str << " Implicit conversions (" << count << "): "; diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp index 9c9f34d31..0ac94beac 100644 --- a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp +++ b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp @@ -1397,7 +1397,7 @@ void ShibokenGenerator::writeArgumentNames(TextStream &s, { const AbstractMetaArgumentList arguments = func->arguments(); int argCount = 0; - for (auto argument : arguments) { + for (const auto &argument : arguments) { const int index = argument.argumentIndex() + 1; if ((options & Generator::SkipRemovedArguments) && (func->argumentRemoved(index))) continue; diff --git a/sources/shiboken6/tests/dumpcodemodel/main.cpp b/sources/shiboken6/tests/dumpcodemodel/main.cpp index a8b2ed2e5..f6db86f71 100644 --- a/sources/shiboken6/tests/dumpcodemodel/main.cpp +++ b/sources/shiboken6/tests/dumpcodemodel/main.cpp @@ -169,7 +169,7 @@ static void formatXmlNamespaceMembers(QXmlStreamWriter &writer, const NamespaceM writer.writeEndElement(); } - for (auto func : nsp->functions()) { + for (const auto &func : nsp->functions()) { const QString signature = func->typeSystemSignature(); if (!signature.contains(QLatin1String("operator"))) { // Skip free operators writer.writeStartElement(QStringLiteral("function")); diff --git a/sources/shiboken6/tests/libsample/expression.cpp b/sources/shiboken6/tests/libsample/expression.cpp index 0c255a659..0b0bcdefe 100644 --- a/sources/shiboken6/tests/libsample/expression.cpp +++ b/sources/shiboken6/tests/libsample/expression.cpp @@ -48,6 +48,8 @@ Expression::Expression(const Expression& other) Expression& Expression::operator=(const Expression& other) { + if (&other == this) + return *this; delete m_operand1; delete m_operand2; m_operand1 = other.m_operand1 ? new Expression(*other.m_operand1) : nullptr; |