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>
bb10
David Skoland 2020-10-06 18:11:26 +02:00 committed by Volker Hilsheimer
parent b61d67f897
commit 4a7280598b
7 changed files with 16 additions and 16 deletions

View File

@ -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;

View File

@ -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());
}

View File

@ -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;

View File

@ -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());
}
}

View File

@ -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());
}

View File

@ -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);
}

View File

@ -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))