diff options
author | David Skoland <david.skoland@qt.io> | 2020-10-06 18:11:26 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-10-17 11:56:30 +0200 |
commit | 4a7280598b99379425043a8773dd274e5bcb24d5 (patch) | |
tree | 58e431ba1a8d2a2c062de98fbfea6faf135387f3 | |
parent | b61d67f897bcf4cb11f08b322ed97bf12988f741 (diff) |
Fix Clang compiler warnings (-Wrange-loop-analysis)
In a macOS environment, Clang throws a number of compiler warnings
about loop variables when building qtbase.
See task for more info about the environment.
This changes a handful of loop variables,
like QJsonValue references into QJsonValueRefs.
Task-number: QTBUG-87216
Pick-to: 5.15
Change-Id: I26006efd7c75c2d56ebc7f7efb4c9bdcabe92e8b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/gui/image/qpnghandler.cpp | 2 | ||||
-rw-r--r-- | src/gui/util/qshadergraphloader.cpp | 8 | ||||
-rw-r--r-- | src/gui/util/qshadernodesloader.cpp | 6 | ||||
-rw-r--r-- | src/tools/androiddeployqt/main.cpp | 2 | ||||
-rw-r--r-- | src/tools/cmake_automoc_parser/main.cpp | 6 | ||||
-rw-r--r-- | src/tools/moc/generator.cpp | 2 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsscene.cpp | 6 |
7 files changed, 16 insertions, 16 deletions
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 897055f7ae..6c05e0a567 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -836,7 +836,7 @@ static void set_text(const QImage &image, png_structp png_ptr, png_infop info_pt #ifdef PNG_iTXt_SUPPORTED bool needsItxt = false; - for (const QChar c : it.value()) { + for (QChar c : it.value()) { uchar ch = c.cell(); if (c.row() || (ch < 0x20 && ch != '\n') || (ch > 0x7e && ch < 0xa0)) { needsItxt = true; diff --git a/src/gui/util/qshadergraphloader.cpp b/src/gui/util/qshadergraphloader.cpp index a938904651..defa88b9d3 100644 --- a/src/gui/util/qshadergraphloader.cpp +++ b/src/gui/util/qshadergraphloader.cpp @@ -145,7 +145,7 @@ void QShaderGraphLoader::load() } const QJsonArray nodes = nodesValue.toArray(); - for (const QJsonValue &nodeValue : nodes) { + for (const QJsonValue nodeValue : nodes) { if (!nodeValue.isObject()) { qWarning() << "Invalid node found"; hasError = true; @@ -171,7 +171,7 @@ void QShaderGraphLoader::load() const QJsonArray layersArray = nodeObject.value(QStringLiteral("layers")).toArray(); auto layers = QStringList(); - for (const QJsonValue &layerValue : layersArray) { + for (const QJsonValue layerValue : layersArray) { layers.append(layerValue.toString()); } @@ -214,7 +214,7 @@ void QShaderGraphLoader::load() } const QJsonArray edges = edgesValue.toArray(); - for (const QJsonValue &edgeValue : edges) { + for (const QJsonValue edgeValue : edges) { if (!edgeValue.isObject()) { qWarning() << "Invalid edge found"; hasError = true; @@ -245,7 +245,7 @@ void QShaderGraphLoader::load() const QJsonArray layersArray = edgeObject.value(QStringLiteral("layers")).toArray(); auto layers = QStringList(); - for (const QJsonValue &layerValue : layersArray) { + for (const QJsonValue layerValue : layersArray) { layers.append(layerValue.toString()); } diff --git a/src/gui/util/qshadernodesloader.cpp b/src/gui/util/qshadernodesloader.cpp index e6dcc8799b..db1755e33a 100644 --- a/src/gui/util/qshadernodesloader.cpp +++ b/src/gui/util/qshadernodesloader.cpp @@ -121,7 +121,7 @@ void QShaderNodesLoader::load(const QJsonObject &prototypesObject) const QJsonValue inputsValue = nodeObject.value(QStringLiteral("inputs")); if (inputsValue.isArray()) { const QJsonArray inputsArray = inputsValue.toArray(); - for (const QJsonValue &inputValue : inputsArray) { + for (const QJsonValue inputValue : inputsArray) { if (!inputValue.isString()) { qWarning() << "Non-string value in inputs"; hasError = true; @@ -138,7 +138,7 @@ void QShaderNodesLoader::load(const QJsonObject &prototypesObject) const QJsonValue outputsValue = nodeObject.value(QStringLiteral("outputs")); if (outputsValue.isArray()) { const QJsonArray outputsArray = outputsValue.toArray(); - for (const QJsonValue &outputValue : outputsArray) { + for (const QJsonValue outputValue : outputsArray) { if (!outputValue.isString()) { qWarning() << "Non-string value in outputs"; hasError = true; @@ -186,7 +186,7 @@ void QShaderNodesLoader::load(const QJsonObject &prototypesObject) const QJsonValue rulesValue = nodeObject.value(QStringLiteral("rules")); if (rulesValue.isArray()) { const QJsonArray rulesArray = rulesValue.toArray(); - for (const QJsonValue &ruleValue : rulesArray) { + for (const QJsonValue ruleValue : rulesArray) { if (!ruleValue.isObject()) { qWarning() << "Rules should be objects"; hasError = true; diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index ea278a37a2..0e04f97a33 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -875,7 +875,7 @@ bool readInputFile(Options *options) { const auto extraPrefixDirs = jsonObject.value(QLatin1String("extraPrefixDirs")).toArray(); options->extraPrefixDirs.reserve(extraPrefixDirs.size()); - for (const auto &prefix : extraPrefixDirs) { + for (const QJsonValue prefix : extraPrefixDirs) { options->extraPrefixDirs.push_back(prefix.toString()); } } diff --git a/src/tools/cmake_automoc_parser/main.cpp b/src/tools/cmake_automoc_parser/main.cpp index 7ef57a1d6c..6d0214638e 100644 --- a/src/tools/cmake_automoc_parser/main.cpp +++ b/src/tools/cmake_automoc_parser/main.cpp @@ -89,7 +89,7 @@ static bool readAutogenInfoJson(AutoGenHeaderMap &headers, AutoGenSourcesList &s QJsonArray sourcesArray = sourcesValue.toArray(); QJsonArray headerExtArray = headerExtValue.toArray(); - for (const auto &value : headersArray) { + for (const QJsonValue value : headersArray) { QJsonArray entry_array = value.toArray(); if (entry_array.size() > 2) { // Array[0] : header path @@ -100,7 +100,7 @@ static bool readAutogenInfoJson(AutoGenHeaderMap &headers, AutoGenSourcesList &s } sources.reserve(sourcesArray.size()); - for (const auto &value : sourcesArray) { + for (const QJsonValue value : sourcesArray) { QJsonArray entry_array = value.toArray(); if (entry_array.size() > 1) { sources.push_back(entry_array[0].toString()); @@ -108,7 +108,7 @@ static bool readAutogenInfoJson(AutoGenHeaderMap &headers, AutoGenSourcesList &s } headerExts.reserve(headerExtArray.size()); - for (const auto &value : headerExtArray) { + for (const QJsonValue value : headerExtArray) { headerExts.push_back(value.toString()); } diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index c562d4acc1..c49419c530 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1527,7 +1527,7 @@ static CborError jsonArrayToCbor(CborEncoder *parent, const QJsonArray &a) { CborEncoder array; cbor_encoder_create_array(parent, &array, a.size()); - for (const QJsonValue &v : a) + for (const QJsonValue v : a) jsonValueToCbor(&array, v); return cbor_encoder_close_container(parent, &array); } diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 53e72ab542..4880e316e2 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -4420,7 +4420,7 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte QRegion pixmapExposed; QRectF exposedRect; if (!itemCache->allExposed) { - for (const auto rect : qAsConst(itemCache->exposed)) { + for (const auto &rect : qAsConst(itemCache->exposed)) { exposedRect |= rect; pixmapExposed += itemToPixmap.mapRect(rect).toAlignedRect(); } @@ -4580,7 +4580,7 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte // Map the item's logical expose to pixmap coordinates. QRegion pixmapExposed = scrollExposure; if (!itemCache->allExposed) { - for (const auto rect : qAsConst(itemCache->exposed)) + for (const auto &rect : qAsConst(itemCache->exposed)) pixmapExposed += itemToPixmap.mapRect(rect).toRect().adjusted(-1, -1, 1, 1); } @@ -4589,7 +4589,7 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte if (itemCache->allExposed) { br = item->boundingRect(); } else { - for (const auto rect : qAsConst(itemCache->exposed)) + for (const auto &rect : qAsConst(itemCache->exposed)) br |= rect; QTransform pixmapToItem = itemToPixmap.inverted(); for (const QRect &r : qAsConst(scrollExposure)) |