qmake: eradicate Q_FOREACH loops [needing qAsConst()]
... by replacing them with C++11 range-for loops. To avoid detaches of these mutable Qt containers, wrap the container in qAsConst(). Change-Id: If086bea06fe26232a7bb99fad8b09fce4dc74c27 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
This commit is contained in:
parent
8d7e913248
commit
e31541fa6f
@ -474,17 +474,17 @@ ProjectBuilderSources::files(QMakeProject *project) const
|
|||||||
|
|
||||||
static QString xcodeFiletypeForFilename(const QString &filename)
|
static QString xcodeFiletypeForFilename(const QString &filename)
|
||||||
{
|
{
|
||||||
foreach (const QString &ext, Option::cpp_ext) {
|
for (const QString &ext : qAsConst(Option::cpp_ext)) {
|
||||||
if (filename.endsWith(ext))
|
if (filename.endsWith(ext))
|
||||||
return QStringLiteral("sourcecode.cpp.cpp");
|
return QStringLiteral("sourcecode.cpp.cpp");
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const QString &ext, Option::c_ext) {
|
for (const QString &ext : qAsConst(Option::c_ext)) {
|
||||||
if (filename.endsWith(ext))
|
if (filename.endsWith(ext))
|
||||||
return QStringLiteral("sourcecode.c.c");
|
return QStringLiteral("sourcecode.c.c");
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const QString &ext, Option::h_ext) {
|
for (const QString &ext : qAsConst(Option::h_ext)) {
|
||||||
if (filename.endsWith(ext))
|
if (filename.endsWith(ext))
|
||||||
return "sourcecode.c.h";
|
return "sourcecode.c.h";
|
||||||
}
|
}
|
||||||
@ -1129,7 +1129,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
|
|||||||
|
|
||||||
if (copyBundleResources && ((ios && path.isEmpty())
|
if (copyBundleResources && ((ios && path.isEmpty())
|
||||||
|| (!ios && path == QLatin1String("Contents/Resources")))) {
|
|| (!ios && path == QLatin1String("Contents/Resources")))) {
|
||||||
foreach (const ProString &s, bundle_files)
|
for (const ProString &s : qAsConst(bundle_files))
|
||||||
bundle_resources_files << s;
|
bundle_resources_files << s;
|
||||||
} else {
|
} else {
|
||||||
QString phase_key = keyFor("QMAKE_PBX_BUNDLE_COPY." + bundle_data[i]);
|
QString phase_key = keyFor("QMAKE_PBX_BUNDLE_COPY." + bundle_data[i]);
|
||||||
|
@ -1864,7 +1864,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
|||||||
if (raw_clean.isEmpty())
|
if (raw_clean.isEmpty())
|
||||||
raw_clean << tmp_out;
|
raw_clean << tmp_out;
|
||||||
QString tmp_clean;
|
QString tmp_clean;
|
||||||
foreach (const QString &rc, raw_clean)
|
for (const QString &rc : qAsConst(raw_clean))
|
||||||
tmp_clean += ' ' + escapeFilePath(Option::fixPathToTargetOS(rc));
|
tmp_clean += ' ' + escapeFilePath(Option::fixPathToTargetOS(rc));
|
||||||
QString tmp_clean_cmds = project->values(ProKey(*it + ".clean_commands")).join(' ');
|
QString tmp_clean_cmds = project->values(ProKey(*it + ".clean_commands")).join(' ');
|
||||||
if(!tmp_inputs.isEmpty())
|
if(!tmp_inputs.isEmpty())
|
||||||
@ -1889,7 +1889,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
|||||||
for (ProStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) {
|
for (ProStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) {
|
||||||
QString tinp = (*input).toQString();
|
QString tinp = (*input).toQString();
|
||||||
QString out = replaceExtraCompilerVariables(tmp_out, tinp, QString(), NoShell);
|
QString out = replaceExtraCompilerVariables(tmp_out, tinp, QString(), NoShell);
|
||||||
foreach (const QString &rc, raw_clean) {
|
for (const QString &rc : qAsConst(raw_clean)) {
|
||||||
dels << ' ' + escapeFilePath(Option::fixPathToTargetOS(
|
dels << ' ' + escapeFilePath(Option::fixPathToTargetOS(
|
||||||
replaceExtraCompilerVariables(rc, tinp, out, NoShell), false));
|
replaceExtraCompilerVariables(rc, tinp, out, NoShell), false));
|
||||||
}
|
}
|
||||||
@ -1899,7 +1899,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
|||||||
} else {
|
} else {
|
||||||
QString files;
|
QString files;
|
||||||
const int commandlineLimit = 2047; // NT limit, expanded
|
const int commandlineLimit = 2047; // NT limit, expanded
|
||||||
foreach (const QString &file, dels) {
|
for (const QString &file : qAsConst(dels)) {
|
||||||
if(del_statement.length() + files.length() +
|
if(del_statement.length() + files.length() +
|
||||||
qMax(fixEnvVariables(file).length(), file.length()) > commandlineLimit) {
|
qMax(fixEnvVariables(file).length(), file.length()) > commandlineLimit) {
|
||||||
cleans.append(files);
|
cleans.append(files);
|
||||||
@ -2245,7 +2245,7 @@ QString MakefileGenerator::buildArgs()
|
|||||||
{
|
{
|
||||||
QString ret;
|
QString ret;
|
||||||
|
|
||||||
foreach (const QString &arg, Option::globals->qmake_args)
|
for (const QString &arg : qAsConst(Option::globals->qmake_args))
|
||||||
ret += " " + shellQuote(arg);
|
ret += " " + shellQuote(arg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -421,7 +421,7 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
|
|||||||
opt = (*++it).toQString();
|
opt = (*++it).toQString();
|
||||||
else
|
else
|
||||||
opt = opt.mid(10).trimmed();
|
opt = opt.mid(10).trimmed();
|
||||||
foreach (const QMakeLocalFileName &dir, frameworkdirs) {
|
for (const QMakeLocalFileName &dir : qAsConst(frameworkdirs)) {
|
||||||
QString prl = dir.local() + "/" + opt + ".framework/" + opt + Option::prl_ext;
|
QString prl = dir.local() + "/" + opt + ".framework/" + opt + Option::prl_ext;
|
||||||
if (processPrlFile(prl))
|
if (processPrlFile(prl))
|
||||||
break;
|
break;
|
||||||
|
@ -816,7 +816,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
|
|||||||
QString icon = fileFixify(var("ICON"));
|
QString icon = fileFixify(var("ICON"));
|
||||||
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
|
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
|
||||||
<< "@sed ";
|
<< "@sed ";
|
||||||
foreach (const ProString &arg, commonSedArgs)
|
for (const ProString &arg : qAsConst(commonSedArgs))
|
||||||
t << arg;
|
t << arg;
|
||||||
t << "-e \"s,@ICON@," << icon.section(Option::dir_sep, -1) << ",g\" "
|
t << "-e \"s,@ICON@," << icon.section(Option::dir_sep, -1) << ",g\" "
|
||||||
<< "-e \"s,@EXECUTABLE@," << var("QMAKE_ORIG_TARGET") << ",g\" "
|
<< "-e \"s,@EXECUTABLE@," << var("QMAKE_ORIG_TARGET") << ",g\" "
|
||||||
@ -840,7 +840,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
|
|||||||
symlinks[bundle_dir + "Resources"] = "Versions/Current/Resources";
|
symlinks[bundle_dir + "Resources"] = "Versions/Current/Resources";
|
||||||
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
|
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
|
||||||
<< "@sed ";
|
<< "@sed ";
|
||||||
foreach (const ProString &arg, commonSedArgs)
|
for (const ProString &arg : qAsConst(commonSedArgs))
|
||||||
t << arg;
|
t << arg;
|
||||||
t << "-e \"s,@LIBRARY@," << var("QMAKE_ORIG_TARGET") << ",g\" "
|
t << "-e \"s,@LIBRARY@," << var("QMAKE_ORIG_TARGET") << ",g\" "
|
||||||
<< "-e \"s,@TYPEINFO@,"
|
<< "-e \"s,@TYPEINFO@,"
|
||||||
|
@ -856,7 +856,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool)
|
|||||||
<< tag("AppxManifest")
|
<< tag("AppxManifest")
|
||||||
<< attrTag("Include", manifest)
|
<< attrTag("Include", manifest)
|
||||||
<< closetag();
|
<< closetag();
|
||||||
foreach (const QString &icon, icons) {
|
for (const QString &icon : qAsConst(icons)) {
|
||||||
xml << tag("Image")
|
xml << tag("Image")
|
||||||
<< attrTag("Include", icon)
|
<< attrTag("Include", icon)
|
||||||
<< closetag();
|
<< closetag();
|
||||||
|
@ -427,9 +427,9 @@ QStringList NmakeMakefileGenerator::sourceFilesForImplicitRulesFilter()
|
|||||||
{
|
{
|
||||||
QStringList filter;
|
QStringList filter;
|
||||||
const QChar wildcard = QLatin1Char('*');
|
const QChar wildcard = QLatin1Char('*');
|
||||||
foreach (const QString &ext, Option::c_ext)
|
for (const QString &ext : qAsConst(Option::c_ext))
|
||||||
filter << wildcard + ext;
|
filter << wildcard + ext;
|
||||||
foreach (const QString &ext, Option::cpp_ext)
|
for (const QString &ext : qAsConst(Option::cpp_ext))
|
||||||
filter << wildcard + ext;
|
filter << wildcard + ext;
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
@ -477,7 +477,7 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t)
|
|||||||
const QStringList sourceFilesFilter = sourceFilesForImplicitRulesFilter();
|
const QStringList sourceFilesFilter = sourceFilesForImplicitRulesFilter();
|
||||||
QStringList fixifiedSourceDirs = fileFixify(source_directories.toList(), FileFixifyAbsolute);
|
QStringList fixifiedSourceDirs = fileFixify(source_directories.toList(), FileFixifyAbsolute);
|
||||||
fixifiedSourceDirs.removeDuplicates();
|
fixifiedSourceDirs.removeDuplicates();
|
||||||
foreach (const QString &sourceDir, fixifiedSourceDirs) {
|
for (const QString &sourceDir : qAsConst(fixifiedSourceDirs)) {
|
||||||
QDirIterator dit(sourceDir, sourceFilesFilter, QDir::Files | QDir::NoDotAndDotDot);
|
QDirIterator dit(sourceDir, sourceFilesFilter, QDir::Files | QDir::NoDotAndDotDot);
|
||||||
while (dit.hasNext()) {
|
while (dit.hasNext()) {
|
||||||
dit.next();
|
dit.next();
|
||||||
@ -502,7 +502,7 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t)
|
|||||||
project->variables().remove("QMAKE_RUN_CXX");
|
project->variables().remove("QMAKE_RUN_CXX");
|
||||||
project->variables().remove("QMAKE_RUN_CC");
|
project->variables().remove("QMAKE_RUN_CC");
|
||||||
|
|
||||||
foreach (const QString &sourceDir, source_directories) {
|
for (const QString &sourceDir : qAsConst(source_directories)) {
|
||||||
if (sourceDir.isEmpty())
|
if (sourceDir.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
QString objDir = var("OBJECTS_DIR");
|
QString objDir = var("OBJECTS_DIR");
|
||||||
|
@ -2224,7 +2224,7 @@ void VCFilter::modifyPCHstage(QString str)
|
|||||||
lines << "* WARNING: All changes made in this file will be lost.";
|
lines << "* WARNING: All changes made in this file will be lost.";
|
||||||
lines << "--------------------------------------------------------------------*/";
|
lines << "--------------------------------------------------------------------*/";
|
||||||
lines << "#include \"" + Project->precompHFilename + "\"";
|
lines << "#include \"" + Project->precompHFilename + "\"";
|
||||||
foreach(QString line, lines)
|
for (const QString &line : qAsConst(lines))
|
||||||
CustomBuildTool.CommandLine += "echo " + line + ">>" + toFile;
|
CustomBuildTool.CommandLine += "echo " + line + ">>" + toFile;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -2415,9 +2415,8 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
|
|||||||
|
|
||||||
// Ensure that none of the output files are also dependencies. Or else, the custom buildstep
|
// Ensure that none of the output files are also dependencies. Or else, the custom buildstep
|
||||||
// will be rebuild every time, even if nothing has changed.
|
// will be rebuild every time, even if nothing has changed.
|
||||||
foreach(QString output, CustomBuildTool.Outputs) {
|
for (const QString &output : qAsConst(CustomBuildTool.Outputs))
|
||||||
CustomBuildTool.AdditionalDependencies.removeAll(output);
|
CustomBuildTool.AdditionalDependencies.removeAll(output);
|
||||||
}
|
|
||||||
|
|
||||||
useCustomBuildTool = !CustomBuildTool.CommandLine.isEmpty();
|
useCustomBuildTool = !CustomBuildTool.CommandLine.isEmpty();
|
||||||
return useCustomBuildTool;
|
return useCustomBuildTool;
|
||||||
|
@ -437,7 +437,7 @@ void QMakeEvaluator::populateDeps(
|
|||||||
if (depends.isEmpty()) {
|
if (depends.isEmpty()) {
|
||||||
rootSet.insert(first(ProKey(prefix + item + priosfx)).toInt(), item);
|
rootSet.insert(first(ProKey(prefix + item + priosfx)).toInt(), item);
|
||||||
} else {
|
} else {
|
||||||
foreach (const ProString &dep, depends) {
|
for (const ProString &dep : qAsConst(depends)) {
|
||||||
dset.insert(dep.toKey());
|
dset.insert(dep.toKey());
|
||||||
dependees[dep.toKey()] << item;
|
dependees[dep.toKey()] << item;
|
||||||
}
|
}
|
||||||
@ -989,7 +989,7 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
|
|||||||
rootSet.erase(it);
|
rootSet.erase(it);
|
||||||
if ((func_t == E_RESOLVE_DEPENDS) || orgList.contains(item))
|
if ((func_t == E_RESOLVE_DEPENDS) || orgList.contains(item))
|
||||||
ret.prepend(item);
|
ret.prepend(item);
|
||||||
foreach (const ProString &dep, dependees[item.toKey()]) {
|
for (const ProString &dep : qAsConst(dependees[item.toKey()])) {
|
||||||
QSet<ProKey> &dset = dependencies[dep.toKey()];
|
QSet<ProKey> &dset = dependencies[dep.toKey()];
|
||||||
dset.remove(item.toKey());
|
dset.remove(item.toKey());
|
||||||
if (dset.isEmpty())
|
if (dset.isEmpty())
|
||||||
@ -1000,11 +1000,11 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
|
|||||||
break;
|
break;
|
||||||
case E_ENUMERATE_VARS: {
|
case E_ENUMERATE_VARS: {
|
||||||
QSet<ProString> keys;
|
QSet<ProString> keys;
|
||||||
foreach (const ProValueMap &vmap, m_valuemapStack)
|
for (const ProValueMap &vmap : qAsConst(m_valuemapStack))
|
||||||
for (ProValueMap::ConstIterator it = vmap.constBegin(); it != vmap.constEnd(); ++it)
|
for (ProValueMap::ConstIterator it = vmap.constBegin(); it != vmap.constEnd(); ++it)
|
||||||
keys.insert(it.key());
|
keys.insert(it.key());
|
||||||
ret.reserve(keys.size());
|
ret.reserve(keys.size());
|
||||||
foreach (const ProString &key, keys)
|
for (const ProString &key : qAsConst(keys))
|
||||||
ret << key;
|
ret << key;
|
||||||
break; }
|
break; }
|
||||||
case E_SHADOWED:
|
case E_SHADOWED:
|
||||||
|
@ -1218,7 +1218,7 @@ bool QMakeEvaluator::loadSpec()
|
|||||||
qmakespec = m_hostBuild ? QLatin1String("default-host") : QLatin1String("default");
|
qmakespec = m_hostBuild ? QLatin1String("default-host") : QLatin1String("default");
|
||||||
#endif
|
#endif
|
||||||
if (IoUtils::isRelativePath(qmakespec)) {
|
if (IoUtils::isRelativePath(qmakespec)) {
|
||||||
foreach (const QString &root, m_mkspecPaths) {
|
for (const QString &root : qAsConst(m_mkspecPaths)) {
|
||||||
QString mkspec = root + QLatin1Char('/') + qmakespec;
|
QString mkspec = root + QLatin1Char('/') + qmakespec;
|
||||||
if (IoUtils::exists(mkspec)) {
|
if (IoUtils::exists(mkspec)) {
|
||||||
qmakespec = mkspec;
|
qmakespec = mkspec;
|
||||||
@ -1452,7 +1452,7 @@ void QMakeEvaluator::updateMkspecPaths()
|
|||||||
for (const QString &it : paths)
|
for (const QString &it : paths)
|
||||||
ret << it + concat;
|
ret << it + concat;
|
||||||
|
|
||||||
foreach (const QString &it, m_qmakepath)
|
for (const QString &it : qAsConst(m_qmakepath))
|
||||||
ret << it + concat;
|
ret << it + concat;
|
||||||
|
|
||||||
if (!m_buildRoot.isEmpty())
|
if (!m_buildRoot.isEmpty())
|
||||||
@ -1493,7 +1493,7 @@ void QMakeEvaluator::updateFeaturePaths()
|
|||||||
for (const QString &item : items)
|
for (const QString &item : items)
|
||||||
feature_bases << (item + mkspecs_concat);
|
feature_bases << (item + mkspecs_concat);
|
||||||
|
|
||||||
foreach (const QString &item, m_qmakepath)
|
for (const QString &item : qAsConst(m_qmakepath))
|
||||||
feature_bases << (item + mkspecs_concat);
|
feature_bases << (item + mkspecs_concat);
|
||||||
|
|
||||||
if (!m_qmakespec.isEmpty()) {
|
if (!m_qmakespec.isEmpty()) {
|
||||||
@ -1515,7 +1515,7 @@ void QMakeEvaluator::updateFeaturePaths()
|
|||||||
feature_bases << (m_option->propertyValue(ProKey("QT_HOST_DATA/get")) + mkspecs_concat);
|
feature_bases << (m_option->propertyValue(ProKey("QT_HOST_DATA/get")) + mkspecs_concat);
|
||||||
feature_bases << (m_option->propertyValue(ProKey("QT_HOST_DATA/src")) + mkspecs_concat);
|
feature_bases << (m_option->propertyValue(ProKey("QT_HOST_DATA/src")) + mkspecs_concat);
|
||||||
|
|
||||||
foreach (const QString &fb, feature_bases) {
|
for (const QString &fb : qAsConst(feature_bases)) {
|
||||||
const auto sfxs = values(ProKey("QMAKE_PLATFORM"));
|
const auto sfxs = values(ProKey("QMAKE_PLATFORM"));
|
||||||
for (const ProString &sfx : sfxs)
|
for (const ProString &sfx : sfxs)
|
||||||
feature_roots << (fb + features_concat + sfx + QLatin1Char('/'));
|
feature_roots << (fb + features_concat + sfx + QLatin1Char('/'));
|
||||||
@ -1529,7 +1529,7 @@ void QMakeEvaluator::updateFeaturePaths()
|
|||||||
feature_roots.removeDuplicates();
|
feature_roots.removeDuplicates();
|
||||||
|
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
foreach (const QString &root, feature_roots)
|
for (const QString &root : qAsConst(feature_roots))
|
||||||
if (IoUtils::exists(root))
|
if (IoUtils::exists(root))
|
||||||
ret << root;
|
ret << root;
|
||||||
m_featureRoots = new QMakeFeatureRoots(ret);
|
m_featureRoots = new QMakeFeatureRoots(ret);
|
||||||
|
@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
ProFileCache::~ProFileCache()
|
ProFileCache::~ProFileCache()
|
||||||
{
|
{
|
||||||
foreach (const Entry &ent, parsed_files)
|
for (const Entry &ent : qAsConst(parsed_files))
|
||||||
if (ent.pro)
|
if (ent.pro)
|
||||||
ent.pro->deref();
|
ent.pro->deref();
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ static int doSed(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if (inFiles.isEmpty())
|
if (inFiles.isEmpty())
|
||||||
inFiles << "-";
|
inFiles << "-";
|
||||||
foreach (const char *inFile, inFiles) {
|
for (const char *inFile : qAsConst(inFiles)) {
|
||||||
FILE *f;
|
FILE *f;
|
||||||
if (!strcmp(inFile, "-")) {
|
if (!strcmp(inFile, "-")) {
|
||||||
f = stdin;
|
f = stdin;
|
||||||
|
@ -160,7 +160,7 @@ QMakeMetaInfo::readLibtoolFile(const QString &f)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ProStringList &prlLibs = vars["QMAKE_PRL_LIBS"];
|
ProStringList &prlLibs = vars["QMAKE_PRL_LIBS"];
|
||||||
foreach (const ProString &s, lst) {
|
for (const ProString &s : qAsConst(lst)) {
|
||||||
prlLibs.removeAll(s);
|
prlLibs.removeAll(s);
|
||||||
prlLibs.append(s);
|
prlLibs.append(s);
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ void QMakeProject::dump() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
out.sort();
|
out.sort();
|
||||||
foreach (const QString &v, out)
|
for (const QString &v : qAsConst(out))
|
||||||
puts(qPrintable(v));
|
puts(qPrintable(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ QMakeProperty::exec()
|
|||||||
#ifdef QT_VERSION_STR
|
#ifdef QT_VERSION_STR
|
||||||
specialProps.append("QT_VERSION");
|
specialProps.append("QT_VERSION");
|
||||||
#endif
|
#endif
|
||||||
foreach (QString prop, specialProps) {
|
for (const QString &prop : qAsConst(specialProps)) {
|
||||||
ProString val = value(ProKey(prop));
|
ProString val = value(ProKey(prop));
|
||||||
ProString pval = value(ProKey(prop + "/raw"));
|
ProString pval = value(ProKey(prop + "/raw"));
|
||||||
ProString gval = value(ProKey(prop + "/get"));
|
ProString gval = value(ProKey(prop + "/get"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user