Commit d882ae9c authored by Marc Mutz's avatar Marc Mutz Committed by Oswald Buddenhagen

qmake: eradicate Q_FOREACH loops [already const]

(or trivially marked const) ... by replacing them
with C++11 range-for loops.

Change-Id: I1522e220a57ecb1c5ee0d4281233b3c3931a2ff8
Reviewed-by: default avatarLars Knoll <lars.knoll@theqtcompany.com>
(cherry picked from qtbase/d9229d849f44cf94e4ee19fac390811b474127d2)
Reviewed-by: default avatarMarc Mutz <marc.mutz@kdab.com>
Reviewed-by: Jake Petroules's avatarJake Petroules <jake.petroules@qt.io>
parent 1a4f0f1d
......@@ -388,7 +388,7 @@ void ProStringList::removeAll(const char *str)
void ProStringList::removeEach(const ProStringList &value)
{
foreach (const ProString &str, value)
for (const ProString &str : value)
if (!str.isEmpty())
removeAll(str);
}
......@@ -421,7 +421,7 @@ void ProStringList::removeDuplicates()
void ProStringList::insertUnique(const ProStringList &value)
{
foreach (const ProString &str, value)
for (const ProString &str : value)
if (!str.isEmpty() && !contains(str))
append(str);
}
......@@ -429,7 +429,7 @@ void ProStringList::insertUnique(const ProStringList &value)
ProStringList::ProStringList(const QStringList &list)
{
reserve(list.size());
foreach (const QString &str, list)
for (const QString &str : list)
*this << ProString(str);
}
......@@ -437,8 +437,8 @@ QStringList ProStringList::toQStringList() const
{
QStringList ret;
ret.reserve(size());
for (int i = 0; i < size(); i++) // foreach causes MSVC2010 ICE
ret << at(i).toQString();
for (const auto &e : *this)
ret.append(e.toQString());
return ret;
}
......
......@@ -434,11 +434,11 @@ void QMakeEvaluator::populateDeps(
QHash<ProKey, QSet<ProKey> > &dependencies, ProValueMap &dependees,
QMultiMap<int, ProString> &rootSet) const
{
foreach (const ProString &item, deps)
for (const ProString &item : deps)
if (!dependencies.contains(item.toKey())) {
QSet<ProKey> &dset = dependencies[item.toKey()]; // Always create entry
ProStringList depends;
foreach (const ProString &suffix, suffixes)
for (const ProString &suffix : suffixes)
depends += values(ProKey(prefix + item + suffix));
if (depends.isEmpty()) {
rootSet.insert(first(ProKey(prefix + item + priosfx)).toInt(), item);
......@@ -605,7 +605,7 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
const ProStringList &var = values(map(args.at(0)));
if (!var.isEmpty()) {
const ProFile *src = currentProFile();
foreach (const ProString &v, var)
for (const ProString &v : var)
if (const ProFile *s = v.sourceFile()) {
src = s;
break;
......@@ -756,7 +756,7 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
tmp.sprintf(".QMAKE_INTERNAL_TMP_variableName_%d", m_listCount++);
ret = ProStringList(ProString(tmp));
ProStringList lst;
foreach (const ProString &arg, args)
for (const ProString &arg : args)
lst += split_value_list(arg.toQString(m_tmp1), arg.sourceFile()); // Relies on deep copy
m_valuemapStack.top()[ret.at(0).toKey()] = lst;
break; }
......@@ -876,7 +876,7 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
} else {
const ProStringList &vals = values(args.at(0).toKey());
ret.reserve(vals.size());
foreach (const ProString &str, vals)
for (const ProString &str : vals)
ret += ProString(quoteValue(str));
}
break;
......@@ -1769,7 +1769,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
varstr += QLatin1Char(' ');
varstr += quoteValue(diffval.at(0));
} else if (!diffval.isEmpty()) {
foreach (const ProString &vval, diffval) {
for (const ProString &vval : diffval) {
varstr += QLatin1String(" \\\n ");
varstr += quoteValue(vval);
}
......
......@@ -1794,7 +1794,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditional(
QMakeEvaluator::VisitReturn QMakeEvaluator::checkRequirements(const ProStringList &deps)
{
ProStringList &failed = valuesRef(ProKey("QMAKE_FAILED_REQUIREMENTS"));
foreach (const ProString &dep, deps) {
for (const ProString &dep : deps) {
VisitReturn vr = evaluateConditional(dep.toQString(), m_current.pro->fileName(), m_current.line);
if (vr == ReturnError)
return ReturnError;
......@@ -1918,9 +1918,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFileChecked(
{
if (fileName.isEmpty())
return ReturnFalse;
QMakeEvaluator *ref = this;
const QMakeEvaluator *ref = this;
do {
foreach (const ProFile *pf, ref->m_profileStack)
for (const ProFile *pf : ref->m_profileStack)
if (pf->fileName() == fileName) {
evalError(fL1S("Circular inclusion of %1.").arg(fileName));
return ReturnFalse;
......@@ -2121,7 +2121,7 @@ QString QMakeEvaluator::formatValueList(const ProStringList &vals, bool commas)
{
QString ret;
foreach (const ProString &str, vals) {
for (const ProString &str : vals) {
if (!ret.isEmpty()) {
if (commas)
ret += QLatin1Char(',');
......@@ -2136,7 +2136,7 @@ QString QMakeEvaluator::formatValueListList(const QList<ProStringList> &lists)
{
QString ret;
foreach (const ProStringList &list, lists) {
for (const ProStringList &list : lists) {
if (!ret.isEmpty())
ret += QLatin1String(", ");
ret += formatValueList(list);
......
......@@ -247,9 +247,9 @@ QStringList QMakeGlobals::splitPathList(const QString &val) const
QStringList ret;
if (!val.isEmpty()) {
QDir bdir;
QStringList vals = val.split(dirlist_sep);
const QStringList vals = val.split(dirlist_sep);
ret.reserve(vals.length());
foreach (const QString &it, vals)
for (const QString &it : vals)
ret << QDir::cleanPath(bdir.absoluteFilePath(it));
}
return ret;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment