diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-01-17 08:59:33 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-01-17 10:07:57 +0000 |
commit | 108a64dd89132c10cb1fd06b6ac43677f5528783 (patch) | |
tree | 3b6be8a1a61dbf3eeb16c9703bbd7a7580d0349e /sources/shiboken2/generator/shiboken2/shibokengenerator.cpp | |
parent | 181fa70b7ba06c92c3c0fdc4c70081b14e4b1bdf (diff) |
shiboken: replace first()/last() by constFirst/constLast()
Fix clazy warnings about possibly detaching containers.
Change-Id: I3c3a229de5e0c71f17c1f26273e1b0be3b0d7e81
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/generator/shiboken2/shibokengenerator.cpp')
-rw-r--r-- | sources/shiboken2/generator/shiboken2/shibokengenerator.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index 5a6d5fc17..82f21f6d0 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -495,7 +495,7 @@ QString ShibokenGenerator::guessScopeForDefaultValue(const AbstractMetaFunction* if (prefix.isEmpty() && match.hasMatch()) { QString flagName = match.captured(1); QStringList enumItems = match.captured(2).split(QLatin1Char('|')); - QString scope = searchForEnumScope(func->implementingClass(), enumItems.first()); + QString scope = searchForEnumScope(func->implementingClass(), enumItems.constFirst()); if (!scope.isEmpty()) scope.append(QLatin1String("::")); @@ -1019,7 +1019,7 @@ bool ShibokenGenerator::isValueTypeWithCopyConstructorOnly(const AbstractMetaCla AbstractMetaFunctionList ctors = metaClass->queryFunctions(AbstractMetaClass::Constructors); if (ctors.count() != 1) return false; - return ctors.first()->functionType() == AbstractMetaFunction::CopyConstructorFunction; + return ctors.constFirst()->functionType() == AbstractMetaFunction::CopyConstructorFunction; } bool ShibokenGenerator::isValueTypeWithCopyConstructorOnly(const TypeEntry* type) const @@ -1123,7 +1123,7 @@ QString ShibokenGenerator::cpythonCheckFunction(const AbstractMetaType* metaType || type == ContainerTypeEntry::StackContainer || type == ContainerTypeEntry::SetContainer || type == ContainerTypeEntry::QueueContainer) { - const AbstractMetaType* type = metaType->instantiations().first(); + const AbstractMetaType* type = metaType->instantiations().constFirst(); if (isPointerToWrapperType(type)) { typeCheck += QString::fromLatin1("checkSequenceTypes(%1, ").arg(cpythonTypeNameExt(type)); } else if (isWrapperType(type)) { @@ -1139,8 +1139,8 @@ QString ShibokenGenerator::cpythonCheckFunction(const AbstractMetaType* metaType || type == ContainerTypeEntry::MultiHashContainer || type == ContainerTypeEntry::PairContainer) { QString pyType = (type == ContainerTypeEntry::PairContainer) ? QLatin1String("Pair") : QLatin1String("Dict"); - const AbstractMetaType* firstType = metaType->instantiations().first(); - const AbstractMetaType* secondType = metaType->instantiations().last(); + const AbstractMetaType* firstType = metaType->instantiations().constFirst(); + const AbstractMetaType* secondType = metaType->instantiations().constLast(); if (isPointerToWrapperType(firstType) && isPointerToWrapperType(secondType)) { typeCheck += QString::fromLatin1("check%1Types(%2, %3, ").arg(pyType) .arg(cpythonTypeNameExt(firstType), cpythonTypeNameExt(secondType)); @@ -1966,8 +1966,8 @@ void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVa while (rit.hasNext()) { const QRegularExpressionMatch match = rit.next(); const QStringList list = match.capturedTexts(); - QString conversionString = list.first(); - QString conversionTypeName = list.last(); + QString conversionString = list.constFirst(); + QString conversionTypeName = list.constLast(); const AbstractMetaType* conversionType = buildAbstractMetaTypeFromString(conversionTypeName); if (!conversionType) { qFatal(qPrintable(QString::fromLatin1("Could not find type '%1' for use in '%2' conversion. " @@ -1986,7 +1986,7 @@ void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVa while (code.at(start).isSpace()) ++start; QString varType = code.mid(start, end - start); - conversionString = varType + list.first(); + conversionString = varType + list.constFirst(); varType = miniNormalizer(varType); QString varName = list.at(1).trimmed(); if (!varType.isEmpty()) { @@ -2193,7 +2193,7 @@ AbstractMetaFunctionList ShibokenGenerator::getMethodsWithBothStaticAndNonStatic if (overloads.isEmpty()) continue; if (OverloadData::hasStaticAndInstanceFunctions(overloads)) - methods.append(overloads.first()); + methods.append(overloads.constFirst()); } } return methods; |