qmake: eradicate Q_FOREACH loops [const-& returns]
... by replacing them with C++11 range-for loops. The functions QMakeProject::values(), QMakeMetaInfo::values() and QHashIterator::value() all return by const-reference, so they can be passed to range-for without further changes. Change-Id: Ic3b39ed8ff8cd7a6f287f1aa9d61a1acd67d7aaa Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
This commit is contained in:
parent
c9cb20c01a
commit
3f3140d38a
@ -1641,7 +1641,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
|
|||||||
<< "\t\t\t" << writeSettings("targets", project->values("QMAKE_PBX_TARGETS"), SettingsAsList, 4) << ";\n"
|
<< "\t\t\t" << writeSettings("targets", project->values("QMAKE_PBX_TARGETS"), SettingsAsList, 4) << ";\n"
|
||||||
<< "\t\t\t" << "attributes = {\n"
|
<< "\t\t\t" << "attributes = {\n"
|
||||||
<< "\t\t\t\tTargetAttributes = {\n";
|
<< "\t\t\t\tTargetAttributes = {\n";
|
||||||
foreach (const ProString &target, project->values("QMAKE_PBX_TARGETS")) {
|
for (const ProString &target : project->values("QMAKE_PBX_TARGETS")) {
|
||||||
const ProStringList &attributes = project->values(ProKey("QMAKE_PBX_TARGET_ATTRIBUTES_" + target));
|
const ProStringList &attributes = project->values(ProKey("QMAKE_PBX_TARGET_ATTRIBUTES_" + target));
|
||||||
if (attributes.isEmpty())
|
if (attributes.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
@ -904,7 +904,7 @@ MakefileGenerator::processPrlFile(QString &file)
|
|||||||
project->values("QMAKE_CURRENT_PRL_LIBS") = libinfo.values("QMAKE_PRL_LIBS");
|
project->values("QMAKE_CURRENT_PRL_LIBS") = libinfo.values("QMAKE_PRL_LIBS");
|
||||||
ProStringList &defs = project->values("DEFINES");
|
ProStringList &defs = project->values("DEFINES");
|
||||||
const ProStringList &prl_defs = project->values("PRL_EXPORT_DEFINES");
|
const ProStringList &prl_defs = project->values("PRL_EXPORT_DEFINES");
|
||||||
foreach (const ProString &def, libinfo.values("QMAKE_PRL_DEFINES"))
|
for (const ProString &def : libinfo.values("QMAKE_PRL_DEFINES"))
|
||||||
if (!defs.contains(def) && prl_defs.contains(def))
|
if (!defs.contains(def) && prl_defs.contains(def))
|
||||||
defs.append(def);
|
defs.append(def);
|
||||||
if (try_replace_file) {
|
if (try_replace_file) {
|
||||||
@ -1141,7 +1141,7 @@ MakefileGenerator::writeObj(QTextStream &t, const char *src)
|
|||||||
<< " " << escapeDependencyPaths(findDependencies(srcf)).join(" \\\n\t\t");
|
<< " " << escapeDependencyPaths(findDependencies(srcf)).join(" \\\n\t\t");
|
||||||
|
|
||||||
ProKey comp;
|
ProKey comp;
|
||||||
foreach (const ProString &compiler, project->values("QMAKE_BUILTIN_COMPILERS")) {
|
for (const ProString &compiler : project->values("QMAKE_BUILTIN_COMPILERS")) {
|
||||||
// Unfortunately we were not consistent about the C++ naming
|
// Unfortunately we were not consistent about the C++ naming
|
||||||
ProString extensionSuffix = compiler;
|
ProString extensionSuffix = compiler;
|
||||||
if (extensionSuffix == "CXX")
|
if (extensionSuffix == "CXX")
|
||||||
@ -1152,7 +1152,7 @@ MakefileGenerator::writeObj(QTextStream &t, const char *src)
|
|||||||
if (compilerSuffix == "C")
|
if (compilerSuffix == "C")
|
||||||
compilerSuffix = ProString("CC");
|
compilerSuffix = ProString("CC");
|
||||||
|
|
||||||
foreach (const ProString &extension, project->values(ProKey("QMAKE_EXT_" + extensionSuffix))) {
|
for (const ProString &extension : project->values(ProKey("QMAKE_EXT_" + extensionSuffix))) {
|
||||||
if ((*sit).endsWith(extension)) {
|
if ((*sit).endsWith(extension)) {
|
||||||
comp = ProKey("QMAKE_RUN_" + compilerSuffix);
|
comp = ProKey("QMAKE_RUN_" + compilerSuffix);
|
||||||
break;
|
break;
|
||||||
@ -1450,7 +1450,7 @@ QString
|
|||||||
MakefileGenerator::fixFileVarGlue(const ProKey &var, const QString &before, const QString &glue, const QString &after) const
|
MakefileGenerator::fixFileVarGlue(const ProKey &var, const QString &before, const QString &glue, const QString &after) const
|
||||||
{
|
{
|
||||||
ProStringList varList;
|
ProStringList varList;
|
||||||
foreach (const ProString &val, project->values(var))
|
for (const ProString &val : project->values(var))
|
||||||
varList << escapeFilePath(Option::fixPathToTargetOS(val.toQString()));
|
varList << escapeFilePath(Option::fixPathToTargetOS(val.toQString()));
|
||||||
return valGlue(varList, before, glue, after);
|
return valGlue(varList, before, glue, after);
|
||||||
}
|
}
|
||||||
@ -2769,11 +2769,11 @@ MakefileGenerator::parseLibFlag(const ProString &flag, ProString *arg)
|
|||||||
ProStringList
|
ProStringList
|
||||||
MakefileGenerator::fixLibFlags(const ProKey &var)
|
MakefileGenerator::fixLibFlags(const ProKey &var)
|
||||||
{
|
{
|
||||||
ProStringList in = project->values(var);
|
const ProStringList &in = project->values(var);
|
||||||
ProStringList ret;
|
ProStringList ret;
|
||||||
|
|
||||||
ret.reserve(in.length());
|
ret.reserve(in.length());
|
||||||
foreach (const ProString &v, in)
|
for (const ProString &v : in)
|
||||||
ret << fixLibFlag(v);
|
ret << fixLibFlag(v);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ UnixMakefileGenerator::init()
|
|||||||
project->values("VER_PAT").append(l[2]);
|
project->values("VER_PAT").append(l[2]);
|
||||||
|
|
||||||
QString sroot = project->sourceRoot();
|
QString sroot = project->sourceRoot();
|
||||||
foreach (const ProString &iif, project->values("QMAKE_INTERNAL_INCLUDED_FILES")) {
|
for (const ProString &iif : project->values("QMAKE_INTERNAL_INCLUDED_FILES")) {
|
||||||
if (iif == project->cacheFile())
|
if (iif == project->cacheFile())
|
||||||
continue;
|
continue;
|
||||||
if (iif.startsWith(sroot) && iif.at(sroot.length()) == QLatin1Char('/'))
|
if (iif.startsWith(sroot) && iif.at(sroot.length()) == QLatin1Char('/'))
|
||||||
@ -156,7 +156,7 @@ UnixMakefileGenerator::init()
|
|||||||
if (project->isActiveConfig("objective_c"))
|
if (project->isActiveConfig("objective_c"))
|
||||||
project->values("QMAKE_BUILTIN_COMPILERS") << "OBJC" << "OBJCXX";
|
project->values("QMAKE_BUILTIN_COMPILERS") << "OBJC" << "OBJCXX";
|
||||||
|
|
||||||
foreach (const ProString &compiler, project->values("QMAKE_BUILTIN_COMPILERS")) {
|
for (const ProString &compiler : project->values("QMAKE_BUILTIN_COMPILERS")) {
|
||||||
QString compile_flag = var("QMAKE_COMPILE_FLAG");
|
QString compile_flag = var("QMAKE_COMPILE_FLAG");
|
||||||
if(compile_flag.isEmpty())
|
if(compile_flag.isEmpty())
|
||||||
compile_flag = "-c";
|
compile_flag = "-c";
|
||||||
@ -334,7 +334,7 @@ QStringList
|
|||||||
? project->first("QMAKE_PCH_OUTPUT_EXT").toQString() : "";
|
? project->first("QMAKE_PCH_OUTPUT_EXT").toQString() : "";
|
||||||
header_prefix += Option::dir_sep + project->first("QMAKE_PRECOMP_PREFIX");
|
header_prefix += Option::dir_sep + project->first("QMAKE_PRECOMP_PREFIX");
|
||||||
|
|
||||||
foreach (const ProString &compiler, project->values("QMAKE_BUILTIN_COMPILERS")) {
|
for (const ProString &compiler : project->values("QMAKE_BUILTIN_COMPILERS")) {
|
||||||
if (project->isEmpty(ProKey("QMAKE_" + compiler + "FLAGS_PRECOMPILE")))
|
if (project->isEmpty(ProKey("QMAKE_" + compiler + "FLAGS_PRECOMPILE")))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -347,7 +347,7 @@ QStringList
|
|||||||
if (extensionSuffix == "CXX")
|
if (extensionSuffix == "CXX")
|
||||||
extensionSuffix = ProString("CPP");
|
extensionSuffix = ProString("CPP");
|
||||||
|
|
||||||
foreach (const ProString &extension, project->values(ProKey("QMAKE_EXT_" + extensionSuffix))) {
|
for (const ProString &extension : project->values(ProKey("QMAKE_EXT_" + extensionSuffix))) {
|
||||||
if (!file.endsWith(extension.toQString()))
|
if (!file.endsWith(extension.toQString()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -376,7 +376,7 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
|
|||||||
{
|
{
|
||||||
QList<QMakeLocalFileName> libdirs, frameworkdirs;
|
QList<QMakeLocalFileName> libdirs, frameworkdirs;
|
||||||
int libidx = 0, fwidx = 0;
|
int libidx = 0, fwidx = 0;
|
||||||
foreach (const ProString &dlib, project->values("QMAKE_DEFAULT_LIBDIRS"))
|
for (const ProString &dlib : project->values("QMAKE_DEFAULT_LIBDIRS"))
|
||||||
libdirs.append(QMakeLocalFileName(dlib.toQString()));
|
libdirs.append(QMakeLocalFileName(dlib.toQString()));
|
||||||
frameworkdirs.append(QMakeLocalFileName("/System/Library/Frameworks"));
|
frameworkdirs.append(QMakeLocalFileName("/System/Library/Frameworks"));
|
||||||
frameworkdirs.append(QMakeLocalFileName("/Library/Frameworks"));
|
frameworkdirs.append(QMakeLocalFileName("/Library/Frameworks"));
|
||||||
@ -648,7 +648,7 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
|
|||||||
uninst.append("-$(DEL_FILE) " + dst_targ);
|
uninst.append("-$(DEL_FILE) " + dst_targ);
|
||||||
if (bundle == SlicedBundle) {
|
if (bundle == SlicedBundle) {
|
||||||
int dstlen = project->first("DESTDIR").length();
|
int dstlen = project->first("DESTDIR").length();
|
||||||
foreach (const ProString &src, project->values("QMAKE_BUNDLED_FILES")) {
|
for (const ProString &src : project->values("QMAKE_BUNDLED_FILES")) {
|
||||||
ProString file = src.mid(dstlen);
|
ProString file = src.mid(dstlen);
|
||||||
QString dst = escapeFilePath(
|
QString dst = escapeFilePath(
|
||||||
filePrefixRoot(root, fileFixify(targetdir + file, FileFixifyAbsolute)));
|
filePrefixRoot(root, fileFixify(targetdir + file, FileFixifyAbsolute)));
|
||||||
|
@ -988,7 +988,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
|
|||||||
ProString header_suffix = project->isActiveConfig("clang_pch_style")
|
ProString header_suffix = project->isActiveConfig("clang_pch_style")
|
||||||
? project->first("QMAKE_PCH_OUTPUT_EXT") : "";
|
? project->first("QMAKE_PCH_OUTPUT_EXT") : "";
|
||||||
|
|
||||||
foreach (const ProString &compiler, project->values("QMAKE_BUILTIN_COMPILERS")) {
|
for (const ProString &compiler : project->values("QMAKE_BUILTIN_COMPILERS")) {
|
||||||
if (project->isEmpty(ProKey("QMAKE_" + compiler + "FLAGS_PRECOMPILE")))
|
if (project->isEmpty(ProKey("QMAKE_" + compiler + "FLAGS_PRECOMPILE")))
|
||||||
continue;
|
continue;
|
||||||
ProString language = project->first(ProKey("QMAKE_LANGUAGE_" + compiler));
|
ProString language = project->first(ProKey("QMAKE_LANGUAGE_" + compiler));
|
||||||
@ -1050,7 +1050,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
|
|||||||
if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) {
|
if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) {
|
||||||
QString pchInput = project->first("PRECOMPILED_HEADER").toQString();
|
QString pchInput = project->first("PRECOMPILED_HEADER").toQString();
|
||||||
t << "###### Precompiled headers\n";
|
t << "###### Precompiled headers\n";
|
||||||
foreach (const ProString &compiler, project->values("QMAKE_BUILTIN_COMPILERS")) {
|
for (const ProString &compiler : project->values("QMAKE_BUILTIN_COMPILERS")) {
|
||||||
QString pchFlags = var(ProKey("QMAKE_" + compiler + "FLAGS_PRECOMPILE"));
|
QString pchFlags = var(ProKey("QMAKE_" + compiler + "FLAGS_PRECOMPILE"));
|
||||||
if(pchFlags.isEmpty())
|
if(pchFlags.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
@ -409,7 +409,7 @@ bool VcprojGenerator::isStandardSuffix(const QString &suffix) const
|
|||||||
|
|
||||||
ProString VcprojGenerator::firstInputFileName(const ProString &extraCompilerName) const
|
ProString VcprojGenerator::firstInputFileName(const ProString &extraCompilerName) const
|
||||||
{
|
{
|
||||||
foreach (const ProString &var, project->values(ProKey(extraCompilerName + ".input"))) {
|
for (const ProString &var : project->values(ProKey(extraCompilerName + ".input"))) {
|
||||||
const ProStringList &files = project->values(var.toKey());
|
const ProStringList &files = project->values(var.toKey());
|
||||||
if (!files.isEmpty())
|
if (!files.isEmpty())
|
||||||
return files.first();
|
return files.first();
|
||||||
@ -688,7 +688,7 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
|
|||||||
QHashIterator<VcsolutionDepend *, QStringList> extraIt(extraSubdirs);
|
QHashIterator<VcsolutionDepend *, QStringList> extraIt(extraSubdirs);
|
||||||
while (extraIt.hasNext()) {
|
while (extraIt.hasNext()) {
|
||||||
extraIt.next();
|
extraIt.next();
|
||||||
foreach (const QString &depend, extraIt.value()) {
|
for (const QString &depend : extraIt.value()) {
|
||||||
if (!projGuids[depend].isEmpty()) {
|
if (!projGuids[depend].isEmpty()) {
|
||||||
extraIt.key()->dependencies << projGuids[depend];
|
extraIt.key()->dependencies << projGuids[depend];
|
||||||
} else if (!profileLookup[depend].isEmpty()) {
|
} else if (!profileLookup[depend].isEmpty()) {
|
||||||
@ -867,7 +867,7 @@ void VcprojGenerator::init()
|
|||||||
|
|
||||||
// Add all input files for a custom compiler into a map for uniqueness,
|
// Add all input files for a custom compiler into a map for uniqueness,
|
||||||
// unless the compiler is configure as a combined stage, then use the first one
|
// unless the compiler is configure as a combined stage, then use the first one
|
||||||
foreach (const ProString &quc, project->values("QMAKE_EXTRA_COMPILERS")) {
|
for (const ProString &quc : project->values("QMAKE_EXTRA_COMPILERS")) {
|
||||||
const ProStringList &invar = project->values(ProKey(quc + ".input"));
|
const ProStringList &invar = project->values(ProKey(quc + ".input"));
|
||||||
const QString compiler_out = project->first(ProKey(quc + ".output")).toQString();
|
const QString compiler_out = project->first(ProKey(quc + ".output")).toQString();
|
||||||
for (ProStringList::ConstIterator iit = invar.constBegin(); iit != invar.constEnd(); ++iit) {
|
for (ProStringList::ConstIterator iit = invar.constBegin(); iit != invar.constEnd(); ++iit) {
|
||||||
@ -1189,7 +1189,7 @@ void VcprojGenerator::initResourceTool()
|
|||||||
else
|
else
|
||||||
conf.resource.PreprocessorDefinitions = conf.compiler.PreprocessorDefinitions;
|
conf.resource.PreprocessorDefinitions = conf.compiler.PreprocessorDefinitions;
|
||||||
|
|
||||||
foreach (const ProString &path, project->values("RC_INCLUDEPATH")) {
|
for (const ProString &path : project->values("RC_INCLUDEPATH")) {
|
||||||
QString fixedPath = fileFixify(path.toQString());
|
QString fixedPath = fileFixify(path.toQString());
|
||||||
if (fileInfo(fixedPath).isRelative()) {
|
if (fileInfo(fixedPath).isRelative()) {
|
||||||
if (fixedPath == QLatin1String("."))
|
if (fixedPath == QLatin1String("."))
|
||||||
@ -1344,7 +1344,7 @@ void VcprojGenerator::initDeploymentTool()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const ProString &item, project->values("INSTALLS")) {
|
for (const ProString &item : project->values("INSTALLS")) {
|
||||||
// get item.path
|
// get item.path
|
||||||
QString devicePath = project->first(ProKey(item + ".path")).toQString();
|
QString devicePath = project->first(ProKey(item + ".path")).toQString();
|
||||||
if (!conf.WinRT) {
|
if (!conf.WinRT) {
|
||||||
@ -1359,7 +1359,7 @@ void VcprojGenerator::initDeploymentTool()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// foreach d in item.files
|
// foreach d in item.files
|
||||||
foreach (const ProString &src, project->values(ProKey(item + ".files"))) {
|
for (const ProString &src : project->values(ProKey(item + ".files"))) {
|
||||||
QString itemDevicePath = devicePath;
|
QString itemDevicePath = devicePath;
|
||||||
QString source = Option::normalizePath(src.toQString());
|
QString source = Option::normalizePath(src.toQString());
|
||||||
QString nameFilter;
|
QString nameFilter;
|
||||||
|
@ -263,7 +263,7 @@ void Win32MakefileGenerator::processRcFileVar()
|
|||||||
QString versionString = vers.join('.');
|
QString versionString = vers.join('.');
|
||||||
|
|
||||||
QStringList rcIcons;
|
QStringList rcIcons;
|
||||||
foreach (const ProString &icon, project->values("RC_ICONS"))
|
for (const ProString &icon : project->values("RC_ICONS"))
|
||||||
rcIcons.append(fileFixify(icon.toQString(), FileFixifyAbsolute));
|
rcIcons.append(fileFixify(icon.toQString(), FileFixifyAbsolute));
|
||||||
|
|
||||||
QString companyName;
|
QString companyName;
|
||||||
|
@ -146,7 +146,7 @@ void QMakeProject::dump() const
|
|||||||
it != m_valuemapStack.first().end(); ++it) {
|
it != m_valuemapStack.first().end(); ++it) {
|
||||||
if (!it.key().startsWith('.')) {
|
if (!it.key().startsWith('.')) {
|
||||||
QString str = it.key() + " =";
|
QString str = it.key() + " =";
|
||||||
foreach (const ProString &v, it.value())
|
for (const ProString &v : it.value())
|
||||||
str += ' ' + formatValue(v);
|
str += ' ' + formatValue(v);
|
||||||
out << str;
|
out << str;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user