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)
|
||||
{
|
||||
foreach (const QString &ext, Option::cpp_ext) {
|
||||
for (const QString &ext : qAsConst(Option::cpp_ext)) {
|
||||
if (filename.endsWith(ext))
|
||||
return QStringLiteral("sourcecode.cpp.cpp");
|
||||
}
|
||||
|
||||
foreach (const QString &ext, Option::c_ext) {
|
||||
for (const QString &ext : qAsConst(Option::c_ext)) {
|
||||
if (filename.endsWith(ext))
|
||||
return QStringLiteral("sourcecode.c.c");
|
||||
}
|
||||
|
||||
foreach (const QString &ext, Option::h_ext) {
|
||||
for (const QString &ext : qAsConst(Option::h_ext)) {
|
||||
if (filename.endsWith(ext))
|
||||
return "sourcecode.c.h";
|
||||
}
|
||||
@ -1129,7 +1129,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
|
||||
|
||||
if (copyBundleResources && ((ios && path.isEmpty())
|
||||
|| (!ios && path == QLatin1String("Contents/Resources")))) {
|
||||
foreach (const ProString &s, bundle_files)
|
||||
for (const ProString &s : qAsConst(bundle_files))
|
||||
bundle_resources_files << s;
|
||||
} else {
|
||||
QString phase_key = keyFor("QMAKE_PBX_BUNDLE_COPY." + bundle_data[i]);
|
||||
|
@ -1864,7 +1864,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
||||
if (raw_clean.isEmpty())
|
||||
raw_clean << tmp_out;
|
||||
QString tmp_clean;
|
||||
foreach (const QString &rc, raw_clean)
|
||||
for (const QString &rc : qAsConst(raw_clean))
|
||||
tmp_clean += ' ' + escapeFilePath(Option::fixPathToTargetOS(rc));
|
||||
QString tmp_clean_cmds = project->values(ProKey(*it + ".clean_commands")).join(' ');
|
||||
if(!tmp_inputs.isEmpty())
|
||||
@ -1889,7 +1889,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
||||
for (ProStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) {
|
||||
QString tinp = (*input).toQString();
|
||||
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(
|
||||
replaceExtraCompilerVariables(rc, tinp, out, NoShell), false));
|
||||
}
|
||||
@ -1899,7 +1899,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
||||
} else {
|
||||
QString files;
|
||||
const int commandlineLimit = 2047; // NT limit, expanded
|
||||
foreach (const QString &file, dels) {
|
||||
for (const QString &file : qAsConst(dels)) {
|
||||
if(del_statement.length() + files.length() +
|
||||
qMax(fixEnvVariables(file).length(), file.length()) > commandlineLimit) {
|
||||
cleans.append(files);
|
||||
@ -2245,7 +2245,7 @@ QString MakefileGenerator::buildArgs()
|
||||
{
|
||||
QString ret;
|
||||
|
||||
foreach (const QString &arg, Option::globals->qmake_args)
|
||||
for (const QString &arg : qAsConst(Option::globals->qmake_args))
|
||||
ret += " " + shellQuote(arg);
|
||||
return ret;
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
|
||||
opt = (*++it).toQString();
|
||||
else
|
||||
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;
|
||||
if (processPrlFile(prl))
|
||||
break;
|
||||
|
@ -816,7 +816,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
|
||||
QString icon = fileFixify(var("ICON"));
|
||||
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
|
||||
<< "@sed ";
|
||||
foreach (const ProString &arg, commonSedArgs)
|
||||
for (const ProString &arg : qAsConst(commonSedArgs))
|
||||
t << arg;
|
||||
t << "-e \"s,@ICON@," << icon.section(Option::dir_sep, -1) << ",g\" "
|
||||
<< "-e \"s,@EXECUTABLE@," << var("QMAKE_ORIG_TARGET") << ",g\" "
|
||||
@ -840,7 +840,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
|
||||
symlinks[bundle_dir + "Resources"] = "Versions/Current/Resources";
|
||||
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
|
||||
<< "@sed ";
|
||||
foreach (const ProString &arg, commonSedArgs)
|
||||
for (const ProString &arg : qAsConst(commonSedArgs))
|
||||
t << arg;
|
||||
t << "-e \"s,@LIBRARY@," << var("QMAKE_ORIG_TARGET") << ",g\" "
|
||||
<< "-e \"s,@TYPEINFO@,"
|
||||
|
@ -856,7 +856,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool)
|
||||
<< tag("AppxManifest")
|
||||
<< attrTag("Include", manifest)
|
||||
<< closetag();
|
||||
foreach (const QString &icon, icons) {
|
||||
for (const QString &icon : qAsConst(icons)) {
|
||||
xml << tag("Image")
|
||||
<< attrTag("Include", icon)
|
||||
<< closetag();
|
||||
|
@ -427,9 +427,9 @@ QStringList NmakeMakefileGenerator::sourceFilesForImplicitRulesFilter()
|
||||
{
|
||||
QStringList filter;
|
||||
const QChar wildcard = QLatin1Char('*');
|
||||
foreach (const QString &ext, Option::c_ext)
|
||||
for (const QString &ext : qAsConst(Option::c_ext))
|
||||
filter << wildcard + ext;
|
||||
foreach (const QString &ext, Option::cpp_ext)
|
||||
for (const QString &ext : qAsConst(Option::cpp_ext))
|
||||
filter << wildcard + ext;
|
||||
return filter;
|
||||
}
|
||||
@ -477,7 +477,7 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t)
|
||||
const QStringList sourceFilesFilter = sourceFilesForImplicitRulesFilter();
|
||||
QStringList fixifiedSourceDirs = fileFixify(source_directories.toList(), FileFixifyAbsolute);
|
||||
fixifiedSourceDirs.removeDuplicates();
|
||||
foreach (const QString &sourceDir, fixifiedSourceDirs) {
|
||||
for (const QString &sourceDir : qAsConst(fixifiedSourceDirs)) {
|
||||
QDirIterator dit(sourceDir, sourceFilesFilter, QDir::Files | QDir::NoDotAndDotDot);
|
||||
while (dit.hasNext()) {
|
||||
dit.next();
|
||||
@ -502,7 +502,7 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t)
|
||||
project->variables().remove("QMAKE_RUN_CXX");
|
||||
project->variables().remove("QMAKE_RUN_CC");
|
||||
|
||||
foreach (const QString &sourceDir, source_directories) {
|
||||
for (const QString &sourceDir : qAsConst(source_directories)) {
|
||||
if (sourceDir.isEmpty())
|
||||
continue;
|
||||
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 << "--------------------------------------------------------------------*/";
|
||||
lines << "#include \"" + Project->precompHFilename + "\"";
|
||||
foreach(QString line, lines)
|
||||
for (const QString &line : qAsConst(lines))
|
||||
CustomBuildTool.CommandLine += "echo " + line + ">>" + toFile;
|
||||
}
|
||||
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
|
||||
// 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);
|
||||
}
|
||||
|
||||
useCustomBuildTool = !CustomBuildTool.CommandLine.isEmpty();
|
||||
return useCustomBuildTool;
|
||||
|
@ -437,7 +437,7 @@ void QMakeEvaluator::populateDeps(
|
||||
if (depends.isEmpty()) {
|
||||
rootSet.insert(first(ProKey(prefix + item + priosfx)).toInt(), item);
|
||||
} else {
|
||||
foreach (const ProString &dep, depends) {
|
||||
for (const ProString &dep : qAsConst(depends)) {
|
||||
dset.insert(dep.toKey());
|
||||
dependees[dep.toKey()] << item;
|
||||
}
|
||||
@ -989,7 +989,7 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
|
||||
rootSet.erase(it);
|
||||
if ((func_t == E_RESOLVE_DEPENDS) || orgList.contains(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()];
|
||||
dset.remove(item.toKey());
|
||||
if (dset.isEmpty())
|
||||
@ -1000,11 +1000,11 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
|
||||
break;
|
||||
case E_ENUMERATE_VARS: {
|
||||
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)
|
||||
keys.insert(it.key());
|
||||
ret.reserve(keys.size());
|
||||
foreach (const ProString &key, keys)
|
||||
for (const ProString &key : qAsConst(keys))
|
||||
ret << key;
|
||||
break; }
|
||||
case E_SHADOWED:
|
||||
|
@ -1218,7 +1218,7 @@ bool QMakeEvaluator::loadSpec()
|
||||
qmakespec = m_hostBuild ? QLatin1String("default-host") : QLatin1String("default");
|
||||
#endif
|
||||
if (IoUtils::isRelativePath(qmakespec)) {
|
||||
foreach (const QString &root, m_mkspecPaths) {
|
||||
for (const QString &root : qAsConst(m_mkspecPaths)) {
|
||||
QString mkspec = root + QLatin1Char('/') + qmakespec;
|
||||
if (IoUtils::exists(mkspec)) {
|
||||
qmakespec = mkspec;
|
||||
@ -1452,7 +1452,7 @@ void QMakeEvaluator::updateMkspecPaths()
|
||||
for (const QString &it : paths)
|
||||
ret << it + concat;
|
||||
|
||||
foreach (const QString &it, m_qmakepath)
|
||||
for (const QString &it : qAsConst(m_qmakepath))
|
||||
ret << it + concat;
|
||||
|
||||
if (!m_buildRoot.isEmpty())
|
||||
@ -1493,7 +1493,7 @@ void QMakeEvaluator::updateFeaturePaths()
|
||||
for (const QString &item : items)
|
||||
feature_bases << (item + mkspecs_concat);
|
||||
|
||||
foreach (const QString &item, m_qmakepath)
|
||||
for (const QString &item : qAsConst(m_qmakepath))
|
||||
feature_bases << (item + mkspecs_concat);
|
||||
|
||||
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/src")) + mkspecs_concat);
|
||||
|
||||
foreach (const QString &fb, feature_bases) {
|
||||
for (const QString &fb : qAsConst(feature_bases)) {
|
||||
const auto sfxs = values(ProKey("QMAKE_PLATFORM"));
|
||||
for (const ProString &sfx : sfxs)
|
||||
feature_roots << (fb + features_concat + sfx + QLatin1Char('/'));
|
||||
@ -1529,7 +1529,7 @@ void QMakeEvaluator::updateFeaturePaths()
|
||||
feature_roots.removeDuplicates();
|
||||
|
||||
QStringList ret;
|
||||
foreach (const QString &root, feature_roots)
|
||||
for (const QString &root : qAsConst(feature_roots))
|
||||
if (IoUtils::exists(root))
|
||||
ret << root;
|
||||
m_featureRoots = new QMakeFeatureRoots(ret);
|
||||
|
@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
ProFileCache::~ProFileCache()
|
||||
{
|
||||
foreach (const Entry &ent, parsed_files)
|
||||
for (const Entry &ent : qAsConst(parsed_files))
|
||||
if (ent.pro)
|
||||
ent.pro->deref();
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ static int doSed(int argc, char **argv)
|
||||
}
|
||||
if (inFiles.isEmpty())
|
||||
inFiles << "-";
|
||||
foreach (const char *inFile, inFiles) {
|
||||
for (const char *inFile : qAsConst(inFiles)) {
|
||||
FILE *f;
|
||||
if (!strcmp(inFile, "-")) {
|
||||
f = stdin;
|
||||
|
@ -160,7 +160,7 @@ QMakeMetaInfo::readLibtoolFile(const QString &f)
|
||||
}
|
||||
}
|
||||
ProStringList &prlLibs = vars["QMAKE_PRL_LIBS"];
|
||||
foreach (const ProString &s, lst) {
|
||||
for (const ProString &s : qAsConst(lst)) {
|
||||
prlLibs.removeAll(s);
|
||||
prlLibs.append(s);
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ void QMakeProject::dump() const
|
||||
}
|
||||
}
|
||||
out.sort();
|
||||
foreach (const QString &v, out)
|
||||
for (const QString &v : qAsConst(out))
|
||||
puts(qPrintable(v));
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ QMakeProperty::exec()
|
||||
#ifdef QT_VERSION_STR
|
||||
specialProps.append("QT_VERSION");
|
||||
#endif
|
||||
foreach (QString prop, specialProps) {
|
||||
for (const QString &prop : qAsConst(specialProps)) {
|
||||
ProString val = value(ProKey(prop));
|
||||
ProString pval = value(ProKey(prop + "/raw"));
|
||||
ProString gval = value(ProKey(prop + "/get"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user