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>
This commit is contained in:
parent
e31541fa6f
commit
d9229d849f
@ -1646,7 +1646,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
|
||||
if (attributes.isEmpty())
|
||||
continue;
|
||||
t << "\t\t\t\t\t" << target << " = {\n";
|
||||
foreach (const ProString &attribute, attributes)
|
||||
for (const ProString &attribute : attributes)
|
||||
t << "\t\t\t\t\t\t" << writeSettings(attribute.toQString(), project->first(ProKey("QMAKE_PBX_TARGET_ATTRIBUTES_" + target + "_" + attribute))) << ";\n";
|
||||
t << "\t\t\t\t\t};\n";
|
||||
}
|
||||
|
@ -954,7 +954,7 @@ static QString
|
||||
qv(const ProStringList &val)
|
||||
{
|
||||
QString ret;
|
||||
foreach (const ProString &v, val)
|
||||
for (const ProString &v : val)
|
||||
ret += qv(v);
|
||||
return ret;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ QStringList CeSdkHandler::getMsBuildToolPaths() const
|
||||
QStringList CeSdkHandler::filterMsBuildToolPaths(const QStringList &paths) const
|
||||
{
|
||||
QStringList result;
|
||||
foreach (const QString &path, paths) {
|
||||
for (const QString &path : paths) {
|
||||
QDir dirVC110(path);
|
||||
if (path.endsWith(QLatin1String("bin")))
|
||||
dirVC110.cdUp();
|
||||
@ -191,9 +191,9 @@ bool CeSdkHandler::retrieveEnvironment(const QStringList &relativePaths,
|
||||
CeSdkInfo *info)
|
||||
{
|
||||
bool result = false;
|
||||
foreach (const QString &path, toolPaths) {
|
||||
for (const QString &path : toolPaths) {
|
||||
const QDir dir(path);
|
||||
foreach (const QString &filePath, relativePaths) {
|
||||
for (const QString &filePath : relativePaths) {
|
||||
QFile file(dir.absoluteFilePath(filePath));
|
||||
if (file.exists())
|
||||
result = parseMsBuildFile(&file, info) || result;
|
||||
@ -209,7 +209,7 @@ void CeSdkHandler::retrieveWEC2013SDKs()
|
||||
const QStringList filteredToolPaths = filterMsBuildToolPaths(toolPaths);
|
||||
QSettings settings("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows CE Tools\\SDKs", QSettings::NativeFormat);
|
||||
const QStringList keys = settings.allKeys();
|
||||
foreach (const QString &key, keys) {
|
||||
for (const QString &key : keys) {
|
||||
if (key.contains(QLatin1String("SDKInformation")) || key.contains(QLatin1Char('.'))) {
|
||||
QFile sdkPropertyFile(settings.value(key).toString());
|
||||
if (!sdkPropertyFile.exists())
|
||||
|
@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE
|
||||
static QString nmakePathList(const QStringList &list)
|
||||
{
|
||||
QStringList pathList;
|
||||
foreach (const QString &path, list)
|
||||
for (const QString &path : list)
|
||||
pathList.append(QDir::cleanPath(path));
|
||||
|
||||
return QDir::toNativeSeparators(pathList.join(QLatin1Char(';')))
|
||||
@ -79,7 +79,7 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t)
|
||||
+ " (" + variables["CE_ARCH"].join(' ') + ")";
|
||||
const QList<CeSdkInfo> sdkList = sdkhandler.listAll();
|
||||
CeSdkInfo sdk;
|
||||
foreach (const CeSdkInfo &info, sdkList) {
|
||||
for (const CeSdkInfo &info : sdkList) {
|
||||
if (info.name().compare(sdkName, Qt::CaseInsensitive ) == 0) {
|
||||
sdk = info;
|
||||
break;
|
||||
@ -91,7 +91,7 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t)
|
||||
t << "\nPATH = " << sdk.binPath() << "\n";
|
||||
} else {
|
||||
QStringList sdkStringList;
|
||||
foreach (const CeSdkInfo &info, sdkList)
|
||||
for (const CeSdkInfo &info : sdkList)
|
||||
sdkStringList << info.name();
|
||||
|
||||
fprintf(stderr, "Failed to find Windows CE SDK matching %s, found: %s\n"
|
||||
|
@ -124,7 +124,7 @@ DotNET which_dotnet_version(const QByteArray &preferredVersion = QByteArray())
|
||||
// More than one version installed, search directory path
|
||||
QString paths = qgetenv("PATH");
|
||||
const QStringList pathlist = paths.split(QLatin1Char(';'));
|
||||
foreach (const QString &path, pathlist) {
|
||||
for (const QString &path : pathlist) {
|
||||
for (i = 0; dotNetCombo[i].version; ++i) {
|
||||
const QString productPath = installPaths.value(dotNetCombo[i].version);
|
||||
if (productPath.isEmpty())
|
||||
@ -533,13 +533,13 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QSt
|
||||
|
||||
if (tmpList.size()) {
|
||||
const ProStringList depends = tmpList;
|
||||
foreach (const ProString &dep, depends) {
|
||||
for (const ProString &dep : depends) {
|
||||
QString depend = dep.toQString();
|
||||
if (!projGuids[depend].isEmpty()) {
|
||||
newDep->dependencies << projGuids[depend];
|
||||
} else if (subdirProjectLookup[projLookup[depend]].size() > 0) {
|
||||
ProStringList tmpLst = subdirProjectLookup[projLookup[depend]];
|
||||
foreach (const ProString &tDep, tmpLst) {
|
||||
const ProStringList tmpLst = subdirProjectLookup[projLookup[depend]];
|
||||
for (const ProString &tDep : tmpLst) {
|
||||
QString tmpDep = tDep.toQString();
|
||||
newDep->dependencies << projGuids[projLookup[tmpDep]];
|
||||
}
|
||||
@ -1264,7 +1264,7 @@ void VcprojGenerator::initDeploymentTool()
|
||||
if (targetPath.endsWith("/") || targetPath.endsWith("\\"))
|
||||
targetPath.chop(1);
|
||||
}
|
||||
ProStringList dllPaths = project->values("QMAKE_DLL_PATHS");
|
||||
const ProStringList dllPaths = project->values("QMAKE_DLL_PATHS");
|
||||
// Only deploy Qt libs for shared build
|
||||
if (!dllPaths.isEmpty() &&
|
||||
!(conf.WinRT && project->first("MSVC_VER").toQString() == "14.0")) {
|
||||
@ -1282,7 +1282,7 @@ void VcprojGenerator::initDeploymentTool()
|
||||
// Use only the file name and check in Qt's install path and LIBPATHs to check for existence
|
||||
dllName.remove(0, dllName.lastIndexOf(QLatin1Char('/')) + 1);
|
||||
QFileInfo info;
|
||||
foreach (const ProString &dllPath, dllPaths) {
|
||||
for (const ProString &dllPath : dllPaths) {
|
||||
QString absoluteDllFilePath = dllPath.toQString();
|
||||
if (!absoluteDllFilePath.endsWith(QLatin1Char('/')))
|
||||
absoluteDllFilePath += QLatin1Char('/');
|
||||
@ -1664,7 +1664,7 @@ void VcprojGenerator::initExtraCompilerOutputs()
|
||||
// provided that the input file variable is not handled already (those in otherFilters
|
||||
// are handled, so we avoid them).
|
||||
const ProStringList &inputVars = project->values(ProKey(*it + ".input"));
|
||||
foreach (const ProString &inputVar, inputVars) {
|
||||
for (const ProString &inputVar : inputVars) {
|
||||
if (!otherFilters.contains(inputVar)) {
|
||||
const ProStringList &tmp_in = project->values(inputVar.toKey());
|
||||
for (int i = 0; i < tmp_in.count(); ++i) {
|
||||
|
@ -391,7 +391,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);
|
||||
}
|
||||
@ -424,7 +424,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);
|
||||
}
|
||||
@ -432,7 +432,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);
|
||||
}
|
||||
|
||||
@ -440,8 +440,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;
|
||||
}
|
||||
|
||||
|
@ -428,11 +428,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);
|
||||
@ -599,7 +599,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;
|
||||
@ -750,7 +750,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; }
|
||||
@ -870,7 +870,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;
|
||||
@ -1753,7 +1753,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);
|
||||
}
|
||||
|
@ -1774,7 +1774,7 @@ bool QMakeEvaluator::evaluateConditional(const QString &cond, const QString &whe
|
||||
void QMakeEvaluator::checkRequirements(const ProStringList &deps)
|
||||
{
|
||||
ProStringList &failed = valuesRef(ProKey("QMAKE_FAILED_REQUIREMENTS"));
|
||||
foreach (const ProString &dep, deps)
|
||||
for (const ProString &dep : deps)
|
||||
if (!evaluateConditional(dep.toQString(), m_current.pro->fileName(), m_current.line))
|
||||
failed << dep;
|
||||
}
|
||||
@ -1871,9 +1871,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;
|
||||
@ -2074,7 +2074,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(',');
|
||||
@ -2089,7 +2089,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);
|
||||
|
@ -248,9 +248,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;
|
||||
|
@ -153,7 +153,7 @@ struct Option
|
||||
|
||||
inline static bool hasFileExtension(const QString &str, const QStringList &extensions)
|
||||
{
|
||||
foreach (const QString &ext, extensions)
|
||||
for (const QString &ext : extensions)
|
||||
if (str.endsWith(ext))
|
||||
return true;
|
||||
return false;
|
||||
|
@ -73,7 +73,7 @@ static ProStringList prepareBuiltinArgs(const QList<ProStringList> &args)
|
||||
{
|
||||
ProStringList ret;
|
||||
ret.reserve(args.size());
|
||||
foreach (const ProStringList &arg, args)
|
||||
for (const ProStringList &arg : args)
|
||||
ret << arg.join(' ');
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user