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