summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/CPack/cmCPackCygwinBinaryGenerator.cxx5
-rw-r--r--Source/CPack/cmCPackPKGGenerator.cxx54
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx5
-rw-r--r--Source/CTest/cmCTestP4.cxx6
-rw-r--r--Source/CursesDialog/cmCursesLongMessageForm.cxx5
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx17
-rw-r--r--Source/QtDialog/FirstConfigure.cxx23
-rw-r--r--Source/QtDialog/QCMake.cxx33
-rw-r--r--Source/cmAddDependenciesCommand.cxx9
-rw-r--r--Source/cmAddSubDirectoryCommand.cxx9
-rw-r--r--Source/cmCPluginAPI.cxx24
-rw-r--r--Source/cmComputeLinkDepends.cxx18
-rw-r--r--Source/cmComputeTargetDepends.cxx6
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx5
-rw-r--r--Source/cmFLTKWrapUICommand.cxx10
-rw-r--r--Source/cmFileCommand.cxx36
-rw-r--r--Source/cmFindBase.cxx9
-rw-r--r--Source/cmFindPackageCommand.cxx8
-rw-r--r--Source/cmForEachCommand.cxx6
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx27
-rw-r--r--Source/cmGeneratorExpressionNode.cxx8
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx37
-rw-r--r--Source/cmGlobalGenerator.cxx12
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx6
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx3
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx9
-rw-r--r--Source/cmInstallCommandArguments.cxx6
-rw-r--r--Source/cmInstallDirectoryGenerator.cxx10
-rw-r--r--Source/cmInstallExportAndroidMKGenerator.cxx14
-rw-r--r--Source/cmInstallFilesCommand.cxx6
-rw-r--r--Source/cmInstallFilesGenerator.cxx12
-rw-r--r--Source/cmInstallGenerator.cxx9
-rw-r--r--Source/cmLocalGenerator.cxx13
-rw-r--r--Source/cmLocalNinjaGenerator.cxx8
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx108
-rw-r--r--Source/cmMakefile.cxx25
-rw-r--r--Source/cmMakefileTargetGenerator.cxx11
-rw-r--r--Source/cmQTWrapCPPCommand.cxx15
-rw-r--r--Source/cmQTWrapUICommand.cxx15
-rw-r--r--Source/cmSetPropertyCommand.cxx35
-rw-r--r--Source/cmStateDirectory.cxx11
-rw-r--r--Source/cmSystemTools.cxx8
-rw-r--r--Source/cmTarget.cxx6
-rw-r--r--Source/cmTestGenerator.cxx17
-rw-r--r--Source/cmTryRunCommand.cxx7
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx7
46 files changed, 317 insertions, 416 deletions
diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx
index 2119f78..49a9f15 100644
--- a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx
+++ b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx
@@ -44,10 +44,9 @@ int cmCPackCygwinBinaryGenerator::PackageFiles()
// to create the file before the super class is called
{
cmGeneratedFileStream ofs(manifestFile.c_str());
- for (std::vector<std::string>::const_iterator i = files.begin();
- i != files.end(); ++i) {
+ for (std::string const& file : files) {
// remove the temp dir and replace with /usr
- ofs << (*i).substr(tempdir.size()) << "\n";
+ ofs << file.substr(tempdir.size()) << "\n";
}
ofs << manifest << "\n";
}
diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx
index ae227aa..d54ab56 100644
--- a/Source/CPack/cmCPackPKGGenerator.cxx
+++ b/Source/CPack/cmCPackPKGGenerator.cxx
@@ -66,21 +66,17 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
xout.StartElement("choices-outline");
// Emit the outline for the groups
- std::map<std::string, cmCPackComponentGroup>::iterator groupIt;
- for (groupIt = this->ComponentGroups.begin();
- groupIt != this->ComponentGroups.end(); ++groupIt) {
- if (groupIt->second.ParentGroup == nullptr) {
- CreateChoiceOutline(groupIt->second, xout);
+ for (auto const& group : this->ComponentGroups) {
+ if (group.second.ParentGroup == nullptr) {
+ CreateChoiceOutline(group.second, xout);
}
}
// Emit the outline for the non-grouped components
- std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
- if (!compIt->second.Group) {
+ for (auto const& comp : this->Components) {
+ if (!comp.second.Group) {
xout.StartElement("line");
- xout.Attribute("choice", compIt->first + "Choice");
+ xout.Attribute("choice", comp.first + "Choice");
xout.Content(""); // Avoid self-closing tag.
xout.EndElement();
}
@@ -94,13 +90,11 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
xout.EndElement(); // choices-outline>
// Create the actual choices
- for (groupIt = this->ComponentGroups.begin();
- groupIt != this->ComponentGroups.end(); ++groupIt) {
- CreateChoice(groupIt->second, xout);
+ for (auto const& group : this->ComponentGroups) {
+ CreateChoice(group.second, xout);
}
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
- CreateChoice(compIt->second, xout);
+ for (auto const& comp : this->Components) {
+ CreateChoice(comp.second, xout);
}
if (!this->PostFlightComponent.Name.empty()) {
@@ -119,17 +113,13 @@ void cmCPackPKGGenerator::CreateChoiceOutline(
{
xout.StartElement("line");
xout.Attribute("choice", group.Name + "Choice");
- std::vector<cmCPackComponentGroup*>::const_iterator groupIt;
- for (groupIt = group.Subgroups.begin(); groupIt != group.Subgroups.end();
- ++groupIt) {
- CreateChoiceOutline(**groupIt, xout);
+ for (cmCPackComponentGroup* subgroup : group.Subgroups) {
+ CreateChoiceOutline(*subgroup, xout);
}
- std::vector<cmCPackComponent*>::const_iterator compIt;
- for (compIt = group.Components.begin(); compIt != group.Components.end();
- ++compIt) {
+ for (cmCPackComponent* comp : group.Components) {
xout.StartElement("line");
- xout.Attribute("choice", (*compIt)->Name + "Choice");
+ xout.Attribute("choice", comp->Name + "Choice");
xout.Content(""); // Avoid self-closing tag.
xout.EndElement();
}
@@ -238,11 +228,9 @@ void cmCPackPKGGenerator::AddDependencyAttributes(
}
visited.insert(&component);
- std::vector<cmCPackComponent*>::const_iterator dependIt;
- for (dependIt = component.Dependencies.begin();
- dependIt != component.Dependencies.end(); ++dependIt) {
- out << " && choices['" << (*dependIt)->Name << "Choice'].selected";
- AddDependencyAttributes(**dependIt, visited, out);
+ for (cmCPackComponent* depend : component.Dependencies) {
+ out << " && choices['" << depend->Name << "Choice'].selected";
+ AddDependencyAttributes(*depend, visited, out);
}
}
@@ -255,11 +243,9 @@ void cmCPackPKGGenerator::AddReverseDependencyAttributes(
}
visited.insert(&component);
- std::vector<cmCPackComponent*>::const_iterator dependIt;
- for (dependIt = component.ReverseDependencies.begin();
- dependIt != component.ReverseDependencies.end(); ++dependIt) {
- out << " || choices['" << (*dependIt)->Name << "Choice'].selected";
- AddReverseDependencyAttributes(**dependIt, visited, out);
+ for (cmCPackComponent* depend : component.ReverseDependencies) {
+ out << " || choices['" << depend->Name << "Choice'].selected";
+ AddReverseDependencyAttributes(*depend, visited, out);
}
}
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 756ac6c..63c2fcc 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -3,6 +3,7 @@
#include "cmCTestMultiProcessHandler.h"
#include "cmAffinity.h"
+#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestRunTest.h"
#include "cmCTestTestHandler.h"
@@ -651,9 +652,7 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
// Reverse iterate over the different dependency levels (deepest first).
// Sort tests within each level by COST and append them to the cost list.
- for (std::list<TestSet>::reverse_iterator i = priorityStack.rbegin();
- i != priorityStack.rend(); ++i) {
- TestSet const& currentSet = *i;
+ for (TestSet const& currentSet : cmReverseRange(priorityStack)) {
TestComparator comp(this);
TestList sortedCopy;
diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx
index 435be97..ac4753c 100644
--- a/Source/CTest/cmCTestP4.cxx
+++ b/Source/CTest/cmCTestP4.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestP4.h"
+#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestVC.h"
#include "cmProcessTools.h"
@@ -425,12 +426,11 @@ bool cmCTestP4::LoadRevisions()
// p4 describe -s ...@1111111,2222222
std::vector<char const*> p4_describe;
- for (std::vector<std::string>::reverse_iterator i = ChangeLists.rbegin();
- i != ChangeLists.rend(); ++i) {
+ for (std::string const& i : cmReverseRange(ChangeLists)) {
SetP4Options(p4_describe);
p4_describe.push_back("describe");
p4_describe.push_back("-s");
- p4_describe.push_back(i->c_str());
+ p4_describe.push_back(i.c_str());
p4_describe.push_back(nullptr);
DescribeParser outDescribe(this, "p4_describe-out> ");
diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx
index a41d051..4e887d6 100644
--- a/Source/CursesDialog/cmCursesLongMessageForm.cxx
+++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx
@@ -19,9 +19,8 @@ cmCursesLongMessageForm::cmCursesLongMessageForm(
std::vector<std::string> const& messages, const char* title)
{
// Append all messages into on big string
- std::vector<std::string>::const_iterator it;
- for (it = messages.begin(); it != messages.end(); it++) {
- this->Messages += (*it);
+ for (std::string const& message : messages) {
+ this->Messages += message;
// Add one blank line after each message
this->Messages += "\n\n";
}
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 8ca7802..b9a7c85 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -107,10 +107,9 @@ void cmCursesMainForm::InitializeUI()
// Count non-internal and non-static entries
int count = 0;
- for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
- it != cacheKeys.end(); ++it) {
+ for (std::string const& key : cacheKeys) {
cmStateEnums::CacheEntryType t =
- this->CMakeInstance->GetState()->GetCacheEntryType(*it);
+ this->CMakeInstance->GetState()->GetCacheEntryType(key);
if (t != cmStateEnums::INTERNAL && t != cmStateEnums::STATIC &&
t != cmStateEnums::UNINITIALIZED) {
++count;
@@ -130,11 +129,9 @@ void cmCursesMainForm::InitializeUI()
// Create the composites.
// First add entries which are new
- for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
- it != cacheKeys.end(); ++it) {
- std::string key = *it;
+ for (std::string const& key : cacheKeys) {
cmStateEnums::CacheEntryType t =
- this->CMakeInstance->GetState()->GetCacheEntryType(*it);
+ this->CMakeInstance->GetState()->GetCacheEntryType(key);
if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC ||
t == cmStateEnums::UNINITIALIZED) {
continue;
@@ -148,11 +145,9 @@ void cmCursesMainForm::InitializeUI()
}
// then add entries which are old
- for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
- it != cacheKeys.end(); ++it) {
- std::string key = *it;
+ for (std::string const& key : cacheKeys) {
cmStateEnums::CacheEntryType t =
- this->CMakeInstance->GetState()->GetCacheEntryType(*it);
+ this->CMakeInstance->GetState()->GetCacheEntryType(key);
if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC ||
t == cmStateEnums::UNINITIALIZED) {
continue;
diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx
index f28e1a8..364a378 100644
--- a/Source/QtDialog/FirstConfigure.cxx
+++ b/Source/QtDialog/FirstConfigure.cxx
@@ -95,33 +95,32 @@ void StartCompilerSetup::setGenerators(
QStringList generator_list;
- std::vector<cmake::GeneratorInfo>::const_iterator it;
- for (it = gens.begin(); it != gens.end(); ++it) {
- generator_list.append(QString::fromLocal8Bit(it->name.c_str()));
+ for (cmake::GeneratorInfo const& gen : gens) {
+ generator_list.append(QString::fromLocal8Bit(gen.name.c_str()));
- if (it->supportsPlatform) {
+ if (gen.supportsPlatform) {
this->GeneratorsSupportingPlatform.append(
- QString::fromLocal8Bit(it->name.c_str()));
+ QString::fromLocal8Bit(gen.name.c_str()));
this
- ->GeneratorDefaultPlatform[QString::fromLocal8Bit(it->name.c_str())] =
- QString::fromLocal8Bit(it->defaultPlatform.c_str());
+ ->GeneratorDefaultPlatform[QString::fromLocal8Bit(gen.name.c_str())] =
+ QString::fromLocal8Bit(gen.defaultPlatform.c_str());
std::vector<std::string>::const_iterator platformIt =
- it->supportedPlatforms.cbegin();
- while (platformIt != it->supportedPlatforms.cend()) {
+ gen.supportedPlatforms.cbegin();
+ while (platformIt != gen.supportedPlatforms.cend()) {
this->GeneratorSupportedPlatforms.insert(
- QString::fromLocal8Bit(it->name.c_str()),
+ QString::fromLocal8Bit(gen.name.c_str()),
QString::fromLocal8Bit((*platformIt).c_str()));
platformIt++;
}
}
- if (it->supportsToolset) {
+ if (gen.supportsToolset) {
this->GeneratorsSupportingToolset.append(
- QString::fromLocal8Bit(it->name.c_str()));
+ QString::fromLocal8Bit(gen.name.c_str()));
}
}
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index a073c30..bf7726e 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -48,9 +48,8 @@ QCMake::QCMake(QObject* p)
this->CMakeInstance->GetRegisteredGenerators(
generators, /*includeNamesWithPlatform=*/false);
- std::vector<cmake::GeneratorInfo>::const_iterator it;
- for (it = generators.begin(); it != generators.end(); ++it) {
- this->AvailableGenerators.push_back(*it);
+ for (cmake::GeneratorInfo const& gen : generators) {
+ this->AvailableGenerators.push_back(gen);
}
}
@@ -234,24 +233,23 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
// set the value of properties
cmState* state = this->CMakeInstance->GetState();
std::vector<std::string> cacheKeys = state->GetCacheEntryKeys();
- for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
- it != cacheKeys.end(); ++it) {
- cmStateEnums::CacheEntryType t = state->GetCacheEntryType(*it);
+ for (std::string const& key : cacheKeys) {
+ cmStateEnums::CacheEntryType t = state->GetCacheEntryType(key);
if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC) {
continue;
}
QCMakeProperty prop;
- prop.Key = QString::fromLocal8Bit(it->c_str());
+ prop.Key = QString::fromLocal8Bit(key.c_str());
int idx = props.indexOf(prop);
if (idx == -1) {
- toremove.append(QString::fromLocal8Bit(it->c_str()));
+ toremove.append(QString::fromLocal8Bit(key.c_str()));
} else {
prop = props[idx];
if (prop.Value.type() == QVariant::Bool) {
- state->SetCacheEntryValue(*it, prop.Value.toBool() ? "ON" : "OFF");
+ state->SetCacheEntryValue(key, prop.Value.toBool() ? "ON" : "OFF");
} else {
- state->SetCacheEntryValue(*it,
+ state->SetCacheEntryValue(key,
prop.Value.toString().toLocal8Bit().data());
}
props.removeAt(idx);
@@ -297,22 +295,21 @@ QCMakePropertyList QCMake::properties() const
cmState* state = this->CMakeInstance->GetState();
std::vector<std::string> cacheKeys = state->GetCacheEntryKeys();
- for (std::vector<std::string>::const_iterator i = cacheKeys.begin();
- i != cacheKeys.end(); ++i) {
- cmStateEnums::CacheEntryType t = state->GetCacheEntryType(*i);
+ for (std::string const& key : cacheKeys) {
+ cmStateEnums::CacheEntryType t = state->GetCacheEntryType(key);
if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC ||
t == cmStateEnums::UNINITIALIZED) {
continue;
}
- const char* cachedValue = state->GetCacheEntryValue(*i);
+ const char* cachedValue = state->GetCacheEntryValue(key);
QCMakeProperty prop;
- prop.Key = QString::fromLocal8Bit(i->c_str());
+ prop.Key = QString::fromLocal8Bit(key.c_str());
prop.Help =
- QString::fromLocal8Bit(state->GetCacheEntryProperty(*i, "HELPSTRING"));
+ QString::fromLocal8Bit(state->GetCacheEntryProperty(key, "HELPSTRING"));
prop.Value = QString::fromLocal8Bit(cachedValue);
- prop.Advanced = state->GetCacheEntryPropertyAsBool(*i, "ADVANCED");
+ prop.Advanced = state->GetCacheEntryPropertyAsBool(key, "ADVANCED");
if (t == cmStateEnums::BOOL) {
prop.Type = QCMakeProperty::BOOL;
prop.Value = cmSystemTools::IsOn(cachedValue);
@@ -323,7 +320,7 @@ QCMakePropertyList QCMake::properties() const
} else if (t == cmStateEnums::STRING) {
prop.Type = QCMakeProperty::STRING;
const char* stringsProperty =
- state->GetCacheEntryProperty(*i, "STRINGS");
+ state->GetCacheEntryProperty(key, "STRINGS");
if (stringsProperty) {
prop.Strings = QString::fromLocal8Bit(stringsProperty).split(";");
}
diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx
index 021bd29..1023808 100644
--- a/Source/cmAddDependenciesCommand.cxx
+++ b/Source/cmAddDependenciesCommand.cxx
@@ -4,6 +4,7 @@
#include <sstream>
+#include "cmAlgorithms.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmTarget.h"
@@ -27,10 +28,10 @@ bool cmAddDependenciesCommand::InitialPass(
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
}
if (cmTarget* target = this->Makefile->FindTargetToUse(target_name)) {
- std::vector<std::string>::const_iterator s = args.begin();
- ++s; // skip over target_name
- for (; s != args.end(); ++s) {
- target->AddUtility(*s, this->Makefile);
+
+ // skip over target_name
+ for (std::string const& arg : cmMakeRange(args).advance(1)) {
+ target->AddUtility(arg, this->Makefile);
}
} else {
std::ostringstream e;
diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx
index 75e5aa4..c47092a 100644
--- a/Source/cmAddSubDirectoryCommand.cxx
+++ b/Source/cmAddSubDirectoryCommand.cxx
@@ -5,6 +5,7 @@
#include <sstream>
#include <string.h>
+#include "cmAlgorithms.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
@@ -26,15 +27,13 @@ bool cmAddSubDirectoryCommand::InitialPass(
bool excludeFromAll = false;
// process the rest of the arguments looking for optional args
- std::vector<std::string>::const_iterator i = args.begin();
- ++i;
- for (; i != args.end(); ++i) {
- if (*i == "EXCLUDE_FROM_ALL") {
+ for (std::string const& arg : cmMakeRange(args).advance(1)) {
+ if (arg == "EXCLUDE_FROM_ALL") {
excludeFromAll = true;
continue;
}
if (binArg.empty()) {
- binArg = *i;
+ binArg = arg;
} else {
this->SetError("called with incorrect number of arguments");
return false;
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index c0088ac..576d2c3 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -683,26 +683,24 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
}
// Next, try the various source extensions
- for (std::vector<std::string>::const_iterator ext = sourceExts.begin();
- ext != sourceExts.end(); ++ext) {
+ for (std::string const& ext : sourceExts) {
hname = pathname;
hname += ".";
- hname += *ext;
+ hname += ext;
if (cmSystemTools::FileExists(hname)) {
- sf->SourceExtension = *ext;
+ sf->SourceExtension = ext;
sf->FullPath = hname;
return;
}
}
// Finally, try the various header extensions
- for (std::vector<std::string>::const_iterator ext = headerExts.begin();
- ext != headerExts.end(); ++ext) {
+ for (std::string const& ext : headerExts) {
hname = pathname;
hname += ".";
- hname += *ext;
+ hname += ext;
if (cmSystemTools::FileExists(hname)) {
- sf->SourceExtension = *ext;
+ sf->SourceExtension = ext;
sf->FullPath = hname;
return;
}
@@ -711,13 +709,11 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
std::ostringstream e;
e << "Cannot find source file \"" << pathname << "\"";
e << "\n\nTried extensions";
- for (std::vector<std::string>::const_iterator ext = sourceExts.begin();
- ext != sourceExts.end(); ++ext) {
- e << " ." << *ext;
+ for (std::string const& ext : sourceExts) {
+ e << " ." << ext;
}
- for (std::vector<std::string>::const_iterator ext = headerExts.begin();
- ext != headerExts.end(); ++ext) {
- e << " ." << *ext;
+ for (std::string const& ext : headerExts) {
+ e << " ." << ext;
}
cmSystemTools::Error(e.str());
}
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 4717cf6..5ed6c29 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -256,11 +256,7 @@ cmComputeLinkDepends::Compute()
// Iterate in reverse order so we can keep only the last occurrence
// of a shared library.
std::set<int> emmitted;
- for (std::vector<int>::const_reverse_iterator
- li = this->FinalLinkOrder.rbegin(),
- le = this->FinalLinkOrder.rend();
- li != le; ++li) {
- int i = *li;
+ for (int i : cmReverseRange(this->FinalLinkOrder)) {
LinkEntry const& e = this->EntryList[i];
cmGeneratorTarget const* t = e.Target;
// Entries that we know the linker will re-use do not need to be repeated.
@@ -586,11 +582,10 @@ void cmComputeLinkDepends::InferDependencies()
}
// Intersect the sets for this item.
- DependSetList::const_iterator i = sets->begin();
- DependSet common = *i;
- for (++i; i != sets->end(); ++i) {
+ DependSet common = sets->front();
+ for (DependSet const& i : cmMakeRange(*sets).advance(1)) {
DependSet intersection;
- std::set_intersection(common.begin(), common.end(), i->begin(), i->end(),
+ std::set_intersection(common.begin(), common.end(), i.begin(), i.end(),
std::inserter(intersection, intersection.begin()));
common = intersection;
}
@@ -708,9 +703,8 @@ void cmComputeLinkDepends::VisitComponent(unsigned int c)
// Run in reverse order so the topological order will preserve the
// original order where there are no constraints.
EdgeList const& nl = this->CCG->GetComponentGraphEdges(c);
- for (EdgeList::const_reverse_iterator ni = nl.rbegin(); ni != nl.rend();
- ++ni) {
- this->VisitComponent(*ni);
+ for (cmGraphEdge const& edge : cmReverseRange(nl)) {
+ this->VisitComponent(edge);
}
// Assign an ordering id to this component.
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index 9b7b02f..70d1675 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmComputeTargetDepends.h"
+#include "cmAlgorithms.h"
#include "cmComputeComponentGraph.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
@@ -549,10 +550,9 @@ bool cmComputeTargetDepends::ComputeFinalDepends(
int head = -1;
std::set<int> emitted;
NodeList const& nl = components[c];
- for (NodeList::const_reverse_iterator ni = nl.rbegin(); ni != nl.rend();
- ++ni) {
+ for (int ni : cmReverseRange(nl)) {
std::set<int> visited;
- if (!this->IntraComponent(cmap, c, *ni, &head, emitted, visited)) {
+ if (!this->IntraComponent(cmap, c, ni, &head, emitted, visited)) {
// Cycle in add_dependencies within component!
this->ComplainAboutBadComponent(ccg, c, true);
return false;
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index e408de3..345ecaa 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -589,10 +589,9 @@ void cmExtraCodeBlocksGenerator::AppendTarget(
std::vector<std::string>::const_iterator end =
cmRemoveDuplicates(allIncludeDirs);
- for (std::vector<std::string>::const_iterator i = allIncludeDirs.begin();
- i != end; ++i) {
+ for (std::string const& str : cmMakeRange(allIncludeDirs.cbegin(), end)) {
xml.StartElement("Add");
- xml.Attribute("directory", *i);
+ xml.Attribute("directory", str);
xml.EndElement();
}
diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx
index 4b14d26..1b509ef 100644
--- a/Source/cmFLTKWrapUICommand.cxx
+++ b/Source/cmFLTKWrapUICommand.cxx
@@ -4,6 +4,7 @@
#include <stddef.h>
+#include "cmAlgorithms.h"
#include "cmCustomCommandLines.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
@@ -40,18 +41,17 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
this->Makefile->AddIncludeDirectories(outputDirectories);
}
- for (std::vector<std::string>::const_iterator i = (args.begin() + 1);
- i != args.end(); i++) {
- cmSourceFile* curr = this->Makefile->GetSource(*i);
+ for (std::string const& arg : cmMakeRange(args).advance(1)) {
+ cmSourceFile* curr = this->Makefile->GetSource(arg);
// if we should use the source GUI
// to generate .cxx and .h files
if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE")) {
std::string outName = outputDirectory;
outName += "/";
- outName += cmSystemTools::GetFilenameWithoutExtension(*i);
+ outName += cmSystemTools::GetFilenameWithoutExtension(arg);
std::string hname = outName;
hname += ".h";
- std::string origname = cdir + "/" + *i;
+ std::string origname = cdir + "/" + arg;
// add starting depends
std::vector<std::string> depends;
depends.push_back(origname);
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 2fe0d63..fb3a1bc 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -947,16 +947,14 @@ bool cmFileCommand::HandleMakeDirectoryCommand(
// File command has at least one argument
assert(args.size() > 1);
- std::vector<std::string>::const_iterator i = args.begin();
-
- i++; // Get rid of subcommand
-
std::string expr;
- for (; i != args.end(); ++i) {
- const std::string* cdir = &(*i);
- if (!cmsys::SystemTools::FileIsFullPath(*i)) {
+ for (std::string const& arg :
+ cmMakeRange(args).advance(1)) // Get rid of subcommand
+ {
+ const std::string* cdir = &arg;
+ if (!cmsys::SystemTools::FileIsFullPath(arg)) {
expr = this->Makefile->GetCurrentSourceDirectory();
- expr += "/" + *i;
+ expr += "/" + arg;
cdir = &expr;
}
if (!this->Makefile->CanIWriteThisFile(*cdir)) {
@@ -981,15 +979,13 @@ bool cmFileCommand::HandleTouchCommand(std::vector<std::string> const& args,
// File command has at least one argument
assert(args.size() > 1);
- std::vector<std::string>::const_iterator i = args.begin();
-
- i++; // Get rid of subcommand
-
- for (; i != args.end(); ++i) {
- std::string tfile = *i;
+ for (std::string const& arg :
+ cmMakeRange(args).advance(1)) // Get rid of subcommand
+ {
+ std::string tfile = arg;
if (!cmsys::SystemTools::FileIsFullPath(tfile)) {
tfile = this->Makefile->GetCurrentSourceDirectory();
- tfile += "/" + *i;
+ tfile += "/" + arg;
}
if (!this->Makefile->CanIWriteThisFile(tfile)) {
std::string e =
@@ -2481,14 +2477,14 @@ bool cmFileCommand::HandleRemove(std::vector<std::string> const& args,
{
std::string message;
- std::vector<std::string>::const_iterator i = args.begin();
- i++; // Get rid of subcommand
- for (; i != args.end(); ++i) {
- std::string fileName = *i;
+ for (std::string const& arg :
+ cmMakeRange(args).advance(1)) // Get rid of subcommand
+ {
+ std::string fileName = arg;
if (!cmsys::SystemTools::FileIsFullPath(fileName)) {
fileName = this->Makefile->GetCurrentSourceDirectory();
- fileName += "/" + *i;
+ fileName += "/" + arg;
}
if (cmSystemTools::FileIsDirectory(fileName) &&
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index 425546a..f92f66e 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -4,7 +4,6 @@
#include <deque>
#include <iostream>
-#include <iterator>
#include <map>
#include <stddef.h>
@@ -205,11 +204,9 @@ void cmFindBase::FillPackageRootPath()
cmSearchPath& paths = this->LabeledPaths[PathLabel::PackageRoot];
// Add the PACKAGE_ROOT_PATH from each enclosing find_package call.
- for (std::deque<std::vector<std::string>>::const_reverse_iterator pkgPaths =
- this->Makefile->FindPackageRootPathStack.rbegin();
- pkgPaths != this->Makefile->FindPackageRootPathStack.rend();
- ++pkgPaths) {
- paths.AddPrefixPaths(*pkgPaths);
+ for (std::vector<std::string> const& pkgPaths :
+ cmReverseRange(this->Makefile->FindPackageRootPathStack)) {
+ paths.AddPrefixPaths(pkgPaths);
}
paths.AddSuffixes(this->SearchPathSuffixes);
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 93c71a1..52ff5ea 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -827,10 +827,10 @@ bool cmFindPackageCommand::HandlePackageMode()
<< " requested version \"" << this->Version << "\".\n"
<< "The following configuration files were considered but not "
"accepted:\n";
- for (std::vector<ConfigFileInfo>::const_iterator i =
- this->ConsideredConfigs.begin();
- i != duplicate_end; ++i) {
- e << " " << i->filename << ", version: " << i->version << "\n";
+
+ for (ConfigFileInfo const& info :
+ cmMakeRange(this->ConsideredConfigs.cbegin(), duplicate_end)) {
+ e << " " << info.filename << ", version: " << info.version << "\n";
}
} else {
std::string requestedVersionString;
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index e359def..39430d0 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -48,12 +48,10 @@ bool cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
if (mf.GetDefinition(this->Args[0])) {
oldDef = mf.GetDefinition(this->Args[0]);
}
- std::vector<std::string>::const_iterator j = this->Args.begin();
- ++j;
- for (; j != this->Args.end(); ++j) {
+ for (std::string const& arg : cmMakeRange(this->Args).advance(1)) {
// set the variable to the loop value
- mf.AddDefinition(this->Args[0], j->c_str());
+ mf.AddDefinition(this->Args[0], arg.c_str());
// Invoke all the functions that were collected in the block.
cmExecutionStatus status;
for (cmListFileFunction const& func : this->Functions) {
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index f9a6d64..268de6f 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -34,20 +34,16 @@ std::string GeneratorExpressionContent::ProcessArbitraryContent(
std::vector<cmGeneratorExpressionEvaluator*>>::const_iterator pend =
this->ParamChildren.end();
for (; pit != pend; ++pit) {
- std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
- pit->begin();
- const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
- pit->end();
- for (; it != end; ++it) {
+ for (cmGeneratorExpressionEvaluator* pExprEval : *pit) {
if (node->RequiresLiteralInput()) {
- if ((*it)->GetType() != cmGeneratorExpressionEvaluator::Text) {
+ if (pExprEval->GetType() != cmGeneratorExpressionEvaluator::Text) {
reportError(context, this->GetOriginalExpression(),
"$<" + identifier +
"> expression requires literal input.");
return std::string();
}
}
- result += (*it)->Evaluate(context, dagChecker);
+ result += pExprEval->Evaluate(context, dagChecker);
if (context->HadError) {
return std::string();
}
@@ -70,12 +66,9 @@ std::string GeneratorExpressionContent::Evaluate(
{
std::string identifier;
{
- std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
- this->IdentifierChildren.begin();
- const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
- this->IdentifierChildren.end();
- for (; it != end; ++it) {
- identifier += (*it)->Evaluate(context, dagChecker);
+ for (cmGeneratorExpressionEvaluator* pExprEval :
+ this->IdentifierChildren) {
+ identifier += pExprEval->Evaluate(context, dagChecker);
if (context->HadError) {
return std::string();
}
@@ -138,12 +131,8 @@ std::string GeneratorExpressionContent::EvaluateParameters(
return std::string();
}
std::string parameter;
- std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
- pit->begin();
- const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
- pit->end();
- for (; it != end; ++it) {
- parameter += (*it)->Evaluate(context, dagChecker);
+ for (cmGeneratorExpressionEvaluator* pExprEval : *pit) {
+ parameter += pExprEval->Evaluate(context, dagChecker);
if (context->HadError) {
return std::string();
}
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index e8cb151..dcec0a4 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -103,13 +103,11 @@ static const struct ZeroNode installInterfaceNode;
const GeneratorExpressionContent* content, \
cmGeneratorExpressionDAGChecker*) const \
{ \
- std::vector<std::string>::const_iterator it = parameters.begin(); \
- const std::vector<std::string>::const_iterator end = parameters.end(); \
- for (; it != end; ++it) { \
- if (*it == #FAILURE_VALUE) { \
+ for (std::string const& param : parameters) { \
+ if (param == #FAILURE_VALUE) { \
return #FAILURE_VALUE; \
} \
- if (*it != #SUCCESS_VALUE) { \
+ if (param != #SUCCESS_VALUE) { \
reportError(context, content->GetOriginalExpression(), \
"Parameters to $<" #OP \
"> must resolve to either '0' or '1'."); \
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index 04a8b3c..3562e7e 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -238,10 +238,8 @@ void cmGhsMultiTargetGenerator::WriteCompilerDefinitions(
std::vector<std::string> compileDefinitions;
this->GeneratorTarget->GetCompileDefinitions(compileDefinitions, config,
language);
- for (std::vector<std::string>::const_iterator cdI =
- compileDefinitions.begin();
- cdI != compileDefinitions.end(); ++cdI) {
- fout << " -D" << (*cdI) << std::endl;
+ for (std::string const& compileDefinition : compileDefinitions) {
+ fout << " -D" << compileDefinition << std::endl;
}
}
@@ -253,9 +251,8 @@ void cmGhsMultiTargetGenerator::WriteIncludes(std::ostream& fout,
this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
language, config);
- for (std::vector<std::string>::const_iterator includes_i = includes.begin();
- includes_i != includes.end(); ++includes_i) {
- fout << " -I\"" << *includes_i << "\"" << std::endl;
+ for (std::string const& include : includes) {
+ fout << " -I\"" << include << "\"" << std::endl;
}
}
@@ -324,12 +321,9 @@ void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper(
std::ostream& fout, std::vector<cmCustomCommand> const& commandsSet,
cmTarget::CustomCommandType const commandType)
{
- for (std::vector<cmCustomCommand>::const_iterator commandsSetI =
- commandsSet.begin();
- commandsSetI != commandsSet.end(); ++commandsSetI) {
- cmCustomCommandLines const& commands = commandsSetI->GetCommandLines();
- for (cmCustomCommandLines::const_iterator commandI = commands.begin();
- commandI != commands.end(); ++commandI) {
+ for (cmCustomCommand const& customCommand : commandsSet) {
+ cmCustomCommandLines const& commandLines = customCommand.GetCommandLines();
+ for (cmCustomCommandLine const& command : commandLines) {
switch (commandType) {
case cmTarget::PRE_BUILD:
fout << " :preexecShellSafe=";
@@ -340,17 +334,16 @@ void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper(
default:
assert("Only pre and post are supported");
}
- cmCustomCommandLine const& command = *commandI;
- for (cmCustomCommandLine::const_iterator commandLineI = command.begin();
- commandLineI != command.end(); ++commandLineI) {
+
+ bool firstIteration = true;
+ for (std::string const& commandLine : command) {
std::string subCommandE =
- this->LocalGenerator->EscapeForShell(*commandLineI, true);
- if (!command.empty()) {
- fout << (command.begin() == commandLineI ? "'" : " ");
- // Need to double escape backslashes
- cmSystemTools::ReplaceString(subCommandE, "\\", "\\\\");
- }
+ this->LocalGenerator->EscapeForShell(commandLine, true);
+ fout << (firstIteration ? "'" : " ");
+ // Need to double escape backslashes
+ cmSystemTools::ReplaceString(subCommandE, "\\", "\\\\");
fout << subCommandE;
+ firstIteration = false;
}
if (!command.empty()) {
fout << "'" << std::endl;
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 386a3f7..e56dc4c 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -314,9 +314,11 @@ bool cmGlobalGenerator::CheckTargetsForMissingSources() const
if (configs.empty()) {
target->GetSourceFiles(srcs, "");
} else {
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end() && srcs.empty(); ++ci) {
- target->GetSourceFiles(srcs, *ci);
+ for (std::string const& config : configs) {
+ target->GetSourceFiles(srcs, config);
+ if (srcs.empty()) {
+ break;
+ }
}
}
if (srcs.empty()) {
@@ -2983,10 +2985,8 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
}
std::vector<cmSourceFile*>::const_iterator sourcesEnd =
cmRemoveDuplicates(sources);
- for (std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sourcesEnd; ++si) {
+ for (cmSourceFile* sf : cmMakeRange(sources.cbegin(), sourcesEnd)) {
Json::Value& lj_source = lj_sources.append(Json::objectValue);
- cmSourceFile* sf = *si;
std::string const& sfp = sf->GetFullPath();
fout << sfp << "\n";
lj_source["file"] = sfp;
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index 45fa052..746ddad 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -420,10 +420,8 @@ void cmGlobalGhsMultiGenerator::WriteMacros(std::ostream& fout)
if (NULL != ghsGpjMacros) {
std::vector<std::string> expandedList;
cmSystemTools::ExpandListArgument(std::string(ghsGpjMacros), expandedList);
- for (std::vector<std::string>::const_iterator expandedListI =
- expandedList.begin();
- expandedListI != expandedList.end(); ++expandedListI) {
- fout << "macro " << *expandedListI << std::endl;
+ for (std::string const& arg : expandedList) {
+ fout << "macro " << arg << std::endl;
}
}
}
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 6498024..ba1ace6 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -1640,8 +1640,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
std::string arg_dep;
std::string arg_obj;
std::string arg_ddi;
- for (std::vector<std::string>::const_iterator a = argBeg; a != argEnd; ++a) {
- std::string const& arg = *a;
+ for (std::string const& arg : cmMakeRange(argBeg, argEnd)) {
if (cmHasLiteralPrefix(arg, "--tdi=")) {
arg_tdi = arg.substr(6);
} else if (cmHasLiteralPrefix(arg, "--pp=")) {
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index d8b2e89..7284f0b 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -913,10 +913,11 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
if (parser.ParseFile(slnFile, slnData,
cmVisualStudioSlnParser::DataGroupProjects)) {
std::vector<cmSlnProjectEntry> slnProjects = slnData.GetProjects();
- for (std::vector<cmSlnProjectEntry>::const_iterator i =
- slnProjects.cbegin();
- !useDevEnv && i != slnProjects.cend(); ++i) {
- std::string proj = i->GetRelativePath();
+ for (cmSlnProjectEntry const& project : slnProjects) {
+ if (useDevEnv) {
+ break;
+ }
+ std::string proj = project.GetRelativePath();
if (proj.size() > 7 && proj.substr(proj.size() - 7) == ".vfproj") {
useDevEnv = true;
}
diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx
index 155f055..647c786 100644
--- a/Source/cmInstallCommandArguments.cxx
+++ b/Source/cmInstallCommandArguments.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallCommandArguments.h"
+#include "cmAlgorithms.h"
#include "cmSystemTools.h"
#include <utility>
@@ -220,10 +221,7 @@ void cmInstallCommandIncludesArgument::Parse(
if (args->empty()) {
return;
}
- std::vector<std::string>::const_iterator it = args->begin();
- ++it;
- for (; it != args->end(); ++it) {
- std::string dir = *it;
+ for (std::string dir : cmMakeRange(*args).advance(1)) {
cmSystemTools::ConvertToUnixSlashes(dir);
this->IncludeDirs.push_back(std::move(dir));
}
diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx
index a88c7af..62ce9f2 100644
--- a/Source/cmInstallDirectoryGenerator.cxx
+++ b/Source/cmInstallDirectoryGenerator.cxx
@@ -31,10 +31,12 @@ cmInstallDirectoryGenerator::cmInstallDirectoryGenerator(
}
// We need per-config actions if any directories have generator expressions.
- for (std::vector<std::string>::const_iterator i = dirs.begin();
- !this->ActionsPerConfig && i != dirs.end(); ++i) {
- if (cmGeneratorExpression::Find(*i) != std::string::npos) {
- this->ActionsPerConfig = true;
+ if (!this->ActionsPerConfig) {
+ for (std::string const& dir : dirs) {
+ if (cmGeneratorExpression::Find(dir) != std::string::npos) {
+ this->ActionsPerConfig = true;
+ break;
+ }
}
}
}
diff --git a/Source/cmInstallExportAndroidMKGenerator.cxx b/Source/cmInstallExportAndroidMKGenerator.cxx
index 85b7021..186b9df 100644
--- a/Source/cmInstallExportAndroidMKGenerator.cxx
+++ b/Source/cmInstallExportAndroidMKGenerator.cxx
@@ -67,10 +67,8 @@ void cmInstallExportAndroidMKGenerator::GenerateScript(std::ostream& os)
this->EFGen->AddConfiguration("");
}
} else {
- for (std::vector<std::string>::const_iterator ci =
- this->ConfigurationTypes->begin();
- ci != this->ConfigurationTypes->end(); ++ci) {
- this->EFGen->AddConfiguration(*ci);
+ for (std::string const& config : this->ConfigurationTypes) {
+ this->EFGen->AddConfiguration(config);
}
}
this->EFGen->GenerateImportFile();
@@ -88,11 +86,9 @@ void cmInstallExportAndroidMKGenerator::GenerateScriptConfigs(
// Now create a configuration-specific install rule for the import
// file of each configuration.
std::vector<std::string> files;
- for (std::map<std::string, std::string>::const_iterator i =
- this->EFGen->GetConfigImportFiles().begin();
- i != this->EFGen->GetConfigImportFiles().end(); ++i) {
- files.push_back(i->second);
- std::string config_test = this->CreateConfigTest(i->first);
+ for (auto const& pair : this->EFGen->GetConfigImportFiles()) {
+ files.push_back(pair.second);
+ std::string config_test = this->CreateConfigTest(pair.first);
os << indent << "if(" << config_test << ")\n";
this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files,
false, this->FilePermissions.c_str(), nullptr,
diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx
index 4dde18f..1b72ce6 100644
--- a/Source/cmInstallFilesCommand.cxx
+++ b/Source/cmInstallFilesCommand.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallFilesCommand.h"
+#include "cmAlgorithms.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmInstallFilesGenerator.h"
@@ -27,10 +28,9 @@ bool cmInstallFilesCommand::InitialPass(std::vector<std::string> const& args,
if ((args.size() > 1) && (args[1] == "FILES")) {
this->IsFilesForm = true;
- for (std::vector<std::string>::const_iterator s = args.begin() + 2;
- s != args.end(); ++s) {
+ for (std::string const& arg : cmMakeRange(args).advance(2)) {
// Find the source location for each file listed.
- this->Files.push_back(this->FindInstallSource(s->c_str()));
+ this->Files.push_back(this->FindInstallSource(arg.c_str()));
}
this->CreateInstallGenerator();
} else {
diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx
index 07094cb..9eb8ad4 100644
--- a/Source/cmInstallFilesGenerator.cxx
+++ b/Source/cmInstallFilesGenerator.cxx
@@ -29,11 +29,13 @@ cmInstallFilesGenerator::cmInstallFilesGenerator(
this->ActionsPerConfig = true;
}
- // We need per-config actions if any files have generator expressions.
- for (std::vector<std::string>::const_iterator i = files.begin();
- !this->ActionsPerConfig && i != files.end(); ++i) {
- if (cmGeneratorExpression::Find(*i) != std::string::npos) {
- this->ActionsPerConfig = true;
+ // We need per-config actions if any directories have generator expressions.
+ if (!this->ActionsPerConfig) {
+ for (std::string const& file : files) {
+ if (cmGeneratorExpression::Find(file) != std::string::npos) {
+ this->ActionsPerConfig = true;
+ break;
+ }
}
}
}
diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx
index d139190..bb4eb3e 100644
--- a/Source/cmInstallGenerator.cxx
+++ b/Source/cmInstallGenerator.cxx
@@ -69,17 +69,18 @@ void cmInstallGenerator::AddInstallRule(
if (cmSystemTools::FileIsFullPath(dest)) {
os << "list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES\n";
os << indent << " \"";
- for (std::vector<std::string>::const_iterator fi = files.begin();
- fi != files.end(); ++fi) {
- if (fi != files.begin()) {
+ bool firstIteration = true;
+ for (std::string const& file : files) {
+ if (!firstIteration) {
os << ";";
}
os << dest << "/";
if (rename && *rename) {
os << rename;
} else {
- os << cmSystemTools::GetFilenameName(*fi);
+ os << cmSystemTools::GetFilenameName(file);
}
+ firstIteration = false;
}
os << "\")\n";
os << indent << "if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)\n";
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 252aa4c..938098d 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2223,11 +2223,8 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
dflag = df;
}
}
-
- std::set<std::string>::const_iterator defineIt = defines.begin();
- const std::set<std::string>::const_iterator defineEnd = defines.end();
const char* itemSeparator = definesString.empty() ? "" : " ";
- for (; defineIt != defineEnd; ++defineIt) {
+ for (std::string const& define : defines) {
// Append the definition with proper escaping.
std::string def = dflag;
if (this->GetState()->UseWatcomWMake()) {
@@ -2241,7 +2238,7 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
// command line without any escapes. However we still have to
// get the '$' and '#' characters through WMake as '$$' and
// '$#'.
- for (const char* c = defineIt->c_str(); *c; ++c) {
+ for (const char* c = define.c_str(); *c; ++c) {
if (*c == '$' || *c == '#') {
def += '$';
}
@@ -2250,11 +2247,11 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
} else {
// Make the definition appear properly on the command line. Use
// -DNAME="value" instead of -D"NAME=value" for historical reasons.
- std::string::size_type eq = defineIt->find("=");
- def += defineIt->substr(0, eq);
+ std::string::size_type eq = define.find('=');
+ def += define.substr(0, eq);
if (eq != std::string::npos) {
def += "=";
- def += this->EscapeForShell(defineIt->c_str() + eq + 1, true);
+ def += this->EscapeForShell(define.c_str() + eq + 1, true);
}
}
definesString += itemSeparator;
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index c0afc25..4dc04d5 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -466,10 +466,12 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
cmNinjaDeps ninjaOutputs(outputs.size() + byproducts.size()), ninjaDeps;
bool symbolic = false;
- for (std::vector<std::string>::const_iterator o = outputs.begin();
- !symbolic && o != outputs.end(); ++o) {
- if (cmSourceFile* sf = this->Makefile->GetSource(*o)) {
+ for (std::string const& output : outputs) {
+ if (cmSourceFile* sf = this->Makefile->GetSource(output)) {
symbolic = sf->GetPropertyAsBool("SYMBOLIC");
+ if (symbolic) {
+ break;
+ }
}
}
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 7019552..7c67192 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -293,9 +293,8 @@ void cmLocalVisualStudio7Generator::WriteConfigurations(
const std::string& libName, cmGeneratorTarget* target)
{
fout << "\t<Configurations>\n";
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
- this->WriteConfiguration(fout, i->c_str(), libName, target);
+ for (std::string const& config : configs) {
+ this->WriteConfiguration(fout, config.c_str(), libName, target);
}
fout << "\t</Configurations>\n";
}
@@ -569,9 +568,8 @@ public:
void Finish() { this->Stream << (this->First ? "" : "\"") << "/>\n"; }
void Write(std::vector<cmCustomCommand> const& ccs)
{
- for (std::vector<cmCustomCommand>::const_iterator ci = ccs.begin();
- ci != ccs.end(); ++ci) {
- this->Write(*ci);
+ for (cmCustomCommand const& command : ccs) {
+ this->Write(command);
}
}
void Write(cmCustomCommand const& cc)
@@ -897,10 +895,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
target->GetManifests(manifest_srcs, configName);
if (!manifest_srcs.empty()) {
fout << "\n\t\t\t\tAdditionalManifestFiles=\"";
- for (std::vector<cmSourceFile const*>::const_iterator mi =
- manifest_srcs.begin();
- mi != manifest_srcs.end(); ++mi) {
- std::string m = (*mi)->GetFullPath();
+ for (cmSourceFile const* manifest : manifest_srcs) {
+ std::string m = manifest->GetFullPath();
fout << this->ConvertToXMLOutputPath(m.c_str()) << ";";
}
fout << "\"";
@@ -1303,14 +1299,14 @@ void cmLocalVisualStudio7GeneratorInternals::OutputLibraries(
{
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
std::string currentBinDir = lg->GetCurrentBinaryDirectory();
- for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) {
- if (l->IsPath) {
+ for (auto const& lib : libs) {
+ if (lib.IsPath) {
std::string rel =
- lg->MaybeConvertToRelativePath(currentBinDir, l->Value.c_str());
+ lg->MaybeConvertToRelativePath(currentBinDir, lib.Value.c_str());
fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " ";
- } else if (!l->Target ||
- l->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
- fout << l->Value << " ";
+ } else if (!lib.Target ||
+ lib.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+ fout << lib.Value << " ";
}
}
}
@@ -1328,10 +1324,9 @@ void cmLocalVisualStudio7GeneratorInternals::OutputObjects(
gt->GetExternalObjects(objs, configName);
const char* sep = isep ? isep : "";
- for (std::vector<cmSourceFile const*>::const_iterator i = objs.begin();
- i != objs.end(); ++i) {
- if (!(*i)->GetObjectLibrary().empty()) {
- std::string const& objFile = (*i)->GetFullPath();
+ for (cmSourceFile const* obj : objs) {
+ if (!obj->GetObjectLibrary().empty()) {
+ std::string const& objFile = obj->GetFullPath();
std::string rel = lg->MaybeConvertToRelativePath(currentBinDir, objFile);
fout << sep << lg->ConvertToXMLOutputPath(rel.c_str());
sep = " ";
@@ -1344,10 +1339,8 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories(
{
const char* comma = "";
std::string currentBinDir = this->GetCurrentBinaryDirectory();
- for (std::vector<std::string>::const_iterator d = dirs.begin();
- d != dirs.end(); ++d) {
+ for (std::string dir : dirs) {
// Remove any trailing slash and skip empty paths.
- std::string dir = *d;
if (dir.back() == '/') {
dir = dir.substr(0, dir.size() - 1);
}
@@ -1483,9 +1476,8 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
// Compute per-source, per-config information.
size_t ci = 0;
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i, ++ci) {
- std::string configUpper = cmSystemTools::UpperCase(*i);
+ for (std::string const& config : configs) {
+ std::string configUpper = cmSystemTools::UpperCase(config);
cmLVS7GFileConfig fc;
std::string lang =
@@ -1498,7 +1490,7 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
lang = sourceLang;
}
- cmGeneratorExpressionInterpreter genexInterpreter(lg, *i, gt, lang);
+ cmGeneratorExpressionInterpreter genexInterpreter(lg, config, gt, lang);
bool needfc = false;
if (!objectName.empty()) {
@@ -1564,7 +1556,7 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
}
}
- const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str());
+ const std::string& linkLanguage = gt->GetLinkerLanguage(config.c_str());
// If HEADER_FILE_ONLY is set, we must suppress this generation in
// the project file
fc.ExcludedFromBuild = sf.GetPropertyAsBool("HEADER_FILE_ONLY") ||
@@ -1589,8 +1581,9 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
}
if (needfc) {
- this->FileConfigMap[*i] = fc;
+ this->FileConfigMap[config] = fc;
}
+ ++ci;
}
}
@@ -1654,16 +1647,14 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
}
// Loop through each source in the source group.
- for (std::vector<const cmSourceFile*>::const_iterator sf =
- sourceFiles.begin();
- sf != sourceFiles.end(); ++sf) {
- std::string source = (*sf)->GetFullPath();
+ for (const cmSourceFile* sf : sourceFiles) {
+ std::string source = sf->GetFullPath();
if (source != libName || target->GetType() == cmStateEnums::UTILITY ||
target->GetType() == cmStateEnums::GLOBAL_TARGET) {
// Look up the source kind and configs.
std::map<cmSourceFile const*, size_t>::const_iterator map_it =
- sources.Index.find(*sf);
+ sources.Index.find(sf);
// The map entry must exist because we populated it earlier.
assert(map_it != sources.Index.end());
cmGeneratorTarget::AllConfigSource const& acs =
@@ -1676,7 +1667,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
// Tell MS-Dev what the source is. If the compiler knows how to
// build it, then it will.
fout << "\t\t\t\tRelativePath=\"" << d << "\">\n";
- if (cmCustomCommand const* command = (*sf)->GetCustomCommand()) {
+ if (cmCustomCommand const* command = sf->GetCustomCommand()) {
this->WriteCustomRule(fout, configs, source.c_str(), *command, fcinfo);
} else if (!fcinfo.FileConfigMap.empty()) {
const char* aCompilerTool = "VCCLCompilerTool";
@@ -1684,8 +1675,8 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
if (this->FortranProject) {
aCompilerTool = "VFFortranCompilerTool";
}
- std::string const& lang = (*sf)->GetLanguage();
- std::string ext = (*sf)->GetExtension();
+ std::string const& lang = sf->GetLanguage();
+ std::string ext = sf->GetExtension();
ext = cmSystemTools::LowerCase(ext);
if (ext == "idl") {
aCompilerTool = "VCMIDLTool";
@@ -1713,12 +1704,10 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
if (acs.Kind == cmGeneratorTarget::SourceKindExternalObject) {
aCompilerTool = "VCCustomBuildTool";
}
- for (std::map<std::string, cmLVS7GFileConfig>::const_iterator fci =
- fcinfo.FileConfigMap.begin();
- fci != fcinfo.FileConfigMap.end(); ++fci) {
- cmLVS7GFileConfig const& fc = fci->second;
+ for (auto const& fci : fcinfo.FileConfigMap) {
+ cmLVS7GFileConfig const& fc = fci.second;
fout << "\t\t\t\t<FileConfiguration\n"
- << "\t\t\t\t\tName=\"" << fci->first << "|"
+ << "\t\t\t\t\tName=\"" << fci.first << "|"
<< gg->GetPlatformName() << "\"";
if (fc.ExcludedFromBuild) {
fout << " ExcludedFromBuild=\"true\"";
@@ -1741,7 +1730,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
fileOptions.AddDefines(fc.CompileDefsConfig);
// validate source level include directories
std::vector<std::string> includes;
- this->AppendIncludeDirectories(includes, fc.IncludeDirs, **sf);
+ this->AppendIncludeDirectories(includes, fc.IncludeDirs, *sf);
fileOptions.AddIncludes(includes);
fileOptions.OutputFlagMap(fout, 5);
fileOptions.OutputAdditionalIncludeDirectories(
@@ -1794,12 +1783,11 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(
if (this->FortranProject) {
customTool = "VFCustomBuildTool";
}
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
- cmCustomCommandGenerator ccg(command, *i, this);
- cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i];
+ for (std::string const& config : configs) {
+ cmCustomCommandGenerator ccg(command, config, this);
+ cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[config];
fout << "\t\t\t\t<FileConfiguration\n";
- fout << "\t\t\t\t\tName=\"" << *i << "|" << gg->GetPlatformName()
+ fout << "\t\t\t\t\tName=\"" << config << "|" << gg->GetPlatformName()
<< "\">\n";
if (!fc.CompileFlags.empty()) {
fout << "\t\t\t\t\t<Tool\n"
@@ -1811,7 +1799,7 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(
std::string comment = this->ConstructComment(ccg);
std::string script = this->ConstructScript(ccg);
if (this->FortranProject) {
- cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str());
+ cmSystemTools::ReplaceString(script, "$(Configuration)", config.c_str());
}
/* clang-format off */
fout << "\t\t\t\t\t<Tool\n"
@@ -1832,12 +1820,10 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(
fout << this->ConvertToXMLOutputPath(source);
} else {
// Write out the dependencies for the rule.
- for (std::vector<std::string>::const_iterator d =
- ccg.GetDepends().begin();
- d != ccg.GetDepends().end(); ++d) {
+ for (std::string const& d : ccg.GetDepends()) {
// Get the real name of the dependency in case it is a CMake target.
std::string dep;
- if (this->GetRealDependency(d->c_str(), i->c_str(), dep)) {
+ if (this->GetRealDependency(d.c_str(), config.c_str(), dep)) {
fout << this->ConvertToXMLOutputPath(dep.c_str()) << ";";
}
}
@@ -1849,10 +1835,8 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(
} else {
// Write a rule for the output generated by this command.
const char* sep = "";
- for (std::vector<std::string>::const_iterator o =
- ccg.GetOutputs().begin();
- o != ccg.GetOutputs().end(); ++o) {
- fout << sep << this->ConvertToXMLOutputPathSingle(o->c_str());
+ for (std::string const& output : ccg.GetOutputs()) {
+ fout << sep << this->ConvertToXMLOutputPathSingle(output.c_str());
sep = ";";
}
}
@@ -2063,16 +2047,14 @@ void cmLocalVisualStudio7Generator::WriteVCProjFooter(
{
fout << "\t<Globals>\n";
- std::vector<std::string> const& props = target->GetPropertyKeys();
- for (std::vector<std::string>::const_iterator i = props.begin();
- i != props.end(); ++i) {
- if (i->find("VS_GLOBAL_") == 0) {
- std::string name = i->substr(10);
+ for (std::string const& key : target->GetPropertyKeys()) {
+ if (key.find("VS_GLOBAL_") == 0) {
+ std::string name = key.substr(10);
if (!name.empty()) {
/* clang-format off */
fout << "\t\t<Global\n"
<< "\t\t\tName=\"" << name << "\"\n"
- << "\t\t\tValue=\"" << target->GetProperty(*i) << "\"\n"
+ << "\t\t\tValue=\"" << target->GetProperty(key) << "\"\n"
<< "\t\t/>\n";
/* clang-format on */
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index cc61318..3d22f57 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -292,13 +292,14 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
std::string const& only_filename = cmSystemTools::GetFilenameName(full_path);
bool trace = trace_only_this_files.empty();
if (!trace) {
- for (std::vector<std::string>::const_iterator i =
- trace_only_this_files.begin();
- !trace && i != trace_only_this_files.end(); ++i) {
- std::string::size_type const pos = full_path.rfind(*i);
+ for (std::string const& file : trace_only_this_files) {
+ std::string::size_type const pos = full_path.rfind(file);
trace = (pos != std::string::npos) &&
- ((pos + i->size()) == full_path.size()) &&
- (only_filename == cmSystemTools::GetFilenameName(*i));
+ ((pos + file.size()) == full_path.size()) &&
+ (only_filename == cmSystemTools::GetFilenameName(file));
+ if (trace) {
+ break;
+ }
}
// Do nothing if current file wasn't requested for trace...
if (!trace) {
@@ -1848,10 +1849,8 @@ void cmMakefile::CheckForUnusedVariables() const
if (!this->WarnUnused) {
return;
}
- const std::vector<std::string>& unused = this->StateSnapshot.UnusedKeys();
- std::vector<std::string>::const_iterator it = unused.begin();
- for (; it != unused.end(); ++it) {
- this->LogUnused("out of scope", *it);
+ for (const std::string& key : this->StateSnapshot.UnusedKeys()) {
+ this->LogUnused("out of scope", key);
}
}
@@ -3055,10 +3054,8 @@ bool cmMakefile::IsFunctionBlocked(const cmListFileFunction& lff,
// loop over all function blockers to see if any block this command
// evaluate in reverse, this is critical for balanced IF statements etc
- std::vector<cmFunctionBlocker*>::reverse_iterator pos;
- for (pos = this->FunctionBlockers.rbegin();
- pos != this->FunctionBlockers.rend(); ++pos) {
- if ((*pos)->IsFunctionBlocked(lff, *this, status)) {
+ for (cmFunctionBlocker* pos : cmReverseRange(this->FunctionBlockers)) {
+ if (pos->IsFunctionBlocked(lff, *this, status)) {
return true;
}
}
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index af34169..9372ed5 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -974,18 +974,17 @@ bool cmMakefileTargetGenerator::WriteMakeRule(
// For multiple outputs, make the extra ones depend on the first one.
std::vector<std::string> const output_depends(1, outputs[0]);
std::string binDir = this->LocalGenerator->GetBinaryDirectory();
- for (std::vector<std::string>::const_iterator o = outputs.begin() + 1;
- o != outputs.end(); ++o) {
+ for (std::string const& output : cmMakeRange(outputs).advance(1)) {
// Touch the extra output so "make" knows that it was updated,
// but only if the output was actually created.
std::string const out = this->LocalGenerator->ConvertToOutputFormat(
- this->LocalGenerator->MaybeConvertToRelativePath(binDir, *o),
+ this->LocalGenerator->MaybeConvertToRelativePath(binDir, output),
cmOutputConverter::SHELL);
std::vector<std::string> output_commands;
bool o_symbolic = false;
if (need_symbolic) {
- if (cmSourceFile* sf = this->Makefile->GetSource(*o)) {
+ if (cmSourceFile* sf = this->Makefile->GetSource(output)) {
o_symbolic = sf->GetPropertyAsBool("SYMBOLIC");
}
}
@@ -994,13 +993,13 @@ bool cmMakefileTargetGenerator::WriteMakeRule(
if (!o_symbolic) {
output_commands.push_back("@$(CMAKE_COMMAND) -E touch_nocreate " + out);
}
- this->LocalGenerator->WriteMakeRule(os, nullptr, *o, output_depends,
+ this->LocalGenerator->WriteMakeRule(os, nullptr, output, output_depends,
output_commands, o_symbolic, in_help);
if (!o_symbolic) {
// At build time, remove the first output if this one does not exist
// so that "make" will rerun the real commands that create this one.
- MultipleOutputPairsType::value_type p(*o, outputs[0]);
+ MultipleOutputPairsType::value_type p(output, outputs[0]);
this->MultipleOutputPairs.insert(p);
}
}
diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx
index 6acc7ef..8b42119 100644
--- a/Source/cmQTWrapCPPCommand.cxx
+++ b/Source/cmQTWrapCPPCommand.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmQTWrapCPPCommand.h"
+#include "cmAlgorithms.h"
#include "cmCustomCommandLines.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
@@ -29,13 +30,13 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args,
std::string sourceListValue = this->Makefile->GetSafeDefinition(sourceList);
// Create a rule for all sources listed.
- for (std::vector<std::string>::const_iterator j = (args.begin() + 2);
- j != args.end(); ++j) {
- cmSourceFile* curr = this->Makefile->GetSource(*j);
+ for (std::string const& arg : cmMakeRange(args).advance(2)) {
+ cmSourceFile* curr = this->Makefile->GetSource(arg);
// if we should wrap the class
if (!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE"))) {
// Compute the name of the file to generate.
- std::string srcName = cmSystemTools::GetFilenameWithoutLastExtension(*j);
+ std::string srcName =
+ cmSystemTools::GetFilenameWithoutLastExtension(arg);
std::string newName = this->Makefile->GetCurrentBinaryDirectory();
newName += "/moc_";
newName += srcName;
@@ -47,8 +48,8 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args,
// Compute the name of the header from which to generate the file.
std::string hname;
- if (cmSystemTools::FileIsFullPath(*j)) {
- hname = *j;
+ if (cmSystemTools::FileIsFullPath(arg)) {
+ hname = arg;
} else {
if (curr && curr->GetIsGenerated()) {
hname = this->Makefile->GetCurrentBinaryDirectory();
@@ -56,7 +57,7 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args,
hname = this->Makefile->GetCurrentSourceDirectory();
}
hname += "/";
- hname += *j;
+ hname += arg;
}
// Append the generated source file to the list.
diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx
index 43b1fb9..6a620c1 100644
--- a/Source/cmQTWrapUICommand.cxx
+++ b/Source/cmQTWrapUICommand.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmQTWrapUICommand.h"
+#include "cmAlgorithms.h"
#include "cmCustomCommandLines.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
@@ -33,13 +34,13 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
std::string sourceListValue = this->Makefile->GetSafeDefinition(sourceList);
// Create rules for all sources listed.
- for (std::vector<std::string>::const_iterator j = (args.begin() + 3);
- j != args.end(); ++j) {
- cmSourceFile* curr = this->Makefile->GetSource(*j);
+ for (std::string const& arg : cmMakeRange(args).advance(3)) {
+ cmSourceFile* curr = this->Makefile->GetSource(arg);
// if we should wrap the class
if (!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE"))) {
// Compute the name of the files to generate.
- std::string srcName = cmSystemTools::GetFilenameWithoutLastExtension(*j);
+ std::string srcName =
+ cmSystemTools::GetFilenameWithoutLastExtension(arg);
std::string hName = this->Makefile->GetCurrentBinaryDirectory();
hName += "/";
hName += srcName;
@@ -55,8 +56,8 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
// Compute the name of the ui file from which to generate others.
std::string uiName;
- if (cmSystemTools::FileIsFullPath(*j)) {
- uiName = *j;
+ if (cmSystemTools::FileIsFullPath(arg)) {
+ uiName = arg;
} else {
if (curr && curr->GetIsGenerated()) {
uiName = this->Makefile->GetCurrentBinaryDirectory();
@@ -64,7 +65,7 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
uiName = this->Makefile->GetCurrentSourceDirectory();
}
uiName += "/";
- uiName += *j;
+ uiName += arg;
}
// create the list of headers
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index 3c4111b..2a0ccb4 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -4,6 +4,7 @@
#include <sstream>
+#include "cmAlgorithms.h"
#include "cmGlobalGenerator.h"
#include "cmInstalledFile.h"
#include "cmMakefile.h"
@@ -33,25 +34,25 @@ bool cmSetPropertyCommand::InitialPass(std::vector<std::string> const& args,
}
// Get the scope on which to set the property.
- std::vector<std::string>::const_iterator arg = args.begin();
+ std::string const& scopeName = args.front();
cmProperty::ScopeType scope;
- if (*arg == "GLOBAL") {
+ if (scopeName == "GLOBAL") {
scope = cmProperty::GLOBAL;
- } else if (*arg == "DIRECTORY") {
+ } else if (scopeName == "DIRECTORY") {
scope = cmProperty::DIRECTORY;
- } else if (*arg == "TARGET") {
+ } else if (scopeName == "TARGET") {
scope = cmProperty::TARGET;
- } else if (*arg == "SOURCE") {
+ } else if (scopeName == "SOURCE") {
scope = cmProperty::SOURCE_FILE;
- } else if (*arg == "TEST") {
+ } else if (scopeName == "TEST") {
scope = cmProperty::TEST;
- } else if (*arg == "CACHE") {
+ } else if (scopeName == "CACHE") {
scope = cmProperty::CACHE;
- } else if (*arg == "INSTALL") {
+ } else if (scopeName == "INSTALL") {
scope = cmProperty::INSTALL;
} else {
std::ostringstream e;
- e << "given invalid scope " << *arg << ". "
+ e << "given invalid scope " << scopeName << ". "
<< "Valid scopes are GLOBAL, DIRECTORY, "
"TARGET, SOURCE, TEST, CACHE, INSTALL.";
this->SetError(e.str());
@@ -68,32 +69,32 @@ bool cmSetPropertyCommand::InitialPass(std::vector<std::string> const& args,
};
Doing doing = DoingNames;
const char* sep = "";
- for (++arg; arg != args.end(); ++arg) {
- if (*arg == "PROPERTY") {
+ for (std::string const& arg : cmMakeRange(args).advance(1)) {
+ if (arg == "PROPERTY") {
doing = DoingProperty;
- } else if (*arg == "APPEND") {
+ } else if (arg == "APPEND") {
doing = DoingNone;
this->AppendMode = true;
this->Remove = false;
this->AppendAsString = false;
- } else if (*arg == "APPEND_STRING") {
+ } else if (arg == "APPEND_STRING") {
doing = DoingNone;
this->AppendMode = true;
this->Remove = false;
this->AppendAsString = true;
} else if (doing == DoingNames) {
- this->Names.insert(*arg);
+ this->Names.insert(arg);
} else if (doing == DoingProperty) {
- this->PropertyName = *arg;
+ this->PropertyName = arg;
doing = DoingValues;
} else if (doing == DoingValues) {
this->PropertyValue += sep;
sep = ";";
- this->PropertyValue += *arg;
+ this->PropertyValue += arg;
this->Remove = false;
} else {
std::ostringstream e;
- e << "given invalid argument \"" << *arg << "\".";
+ e << "given invalid argument \"" << arg << "\".";
this->SetError(e.str());
return false;
}
diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx
index 6752743..15c8a61 100644
--- a/Source/cmStateDirectory.cxx
+++ b/Source/cmStateDirectory.cxx
@@ -8,6 +8,7 @@
#include <iterator>
#include <utility>
+#include "cmAlgorithms.h"
#include "cmProperty.h"
#include "cmPropertyMap.h"
#include "cmState.h"
@@ -40,9 +41,8 @@ void cmStateDirectory::ComputeRelativePathTopSource()
std::string result = snapshots.front().GetDirectory().GetCurrentSource();
- for (std::vector<cmStateSnapshot>::const_iterator it = snapshots.begin() + 1;
- it != snapshots.end(); ++it) {
- std::string currentSource = it->GetDirectory().GetCurrentSource();
+ for (cmStateSnapshot const& snp : cmMakeRange(snapshots).advance(1)) {
+ std::string currentSource = snp.GetDirectory().GetCurrentSource();
if (cmSystemTools::IsSubDirectory(result, currentSource)) {
result = currentSource;
}
@@ -66,9 +66,8 @@ void cmStateDirectory::ComputeRelativePathTopBinary()
std::string result = snapshots.front().GetDirectory().GetCurrentBinary();
- for (std::vector<cmStateSnapshot>::const_iterator it = snapshots.begin() + 1;
- it != snapshots.end(); ++it) {
- std::string currentBinary = it->GetDirectory().GetCurrentBinary();
+ for (cmStateSnapshot const& snp : cmMakeRange(snapshots).advance(1)) {
+ std::string currentBinary = snp.GetDirectory().GetCurrentBinary();
if (cmSystemTools::IsSubDirectory(result, currentBinary)) {
result = currentBinary;
}
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index ba40ce1..aa4e3f9 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -542,8 +542,7 @@ std::vector<std::string> cmSystemTools::HandleResponseFile(
std::vector<std::string>::const_iterator argEnd)
{
std::vector<std::string> arg_full;
- for (std::vector<std::string>::const_iterator a = argBeg; a != argEnd; ++a) {
- std::string const& arg = *a;
+ for (std::string const& arg : cmMakeRange(argBeg, argEnd)) {
if (cmHasLiteralPrefix(arg, "@")) {
cmsys::ifstream responseFile(arg.substr(1).c_str(), std::ios::in);
if (!responseFile) {
@@ -1219,9 +1218,8 @@ void cmSystemTools::GlobDirs(const std::string& path,
void cmSystemTools::ExpandList(std::vector<std::string> const& arguments,
std::vector<std::string>& newargs)
{
- std::vector<std::string>::const_iterator i;
- for (i = arguments.begin(); i != arguments.end(); ++i) {
- cmSystemTools::ExpandListArgument(*i, newargs);
+ for (std::string const& arg : arguments) {
+ cmSystemTools::ExpandListArgument(arg, newargs);
}
}
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 93cdd46..e871634 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -707,10 +707,8 @@ std::string cmTarget::GetDebugGeneratorExpressions(
std::string configString = "$<CONFIG:" + debugConfigs[0] + ">";
if (debugConfigs.size() > 1) {
- for (std::vector<std::string>::const_iterator li =
- debugConfigs.begin() + 1;
- li != debugConfigs.end(); ++li) {
- configString += ",$<CONFIG:" + *li + ">";
+ for (std::string const& conf : cmMakeRange(debugConfigs).advance(1)) {
+ configString += ",$<CONFIG:" + conf + ">";
}
configString = "$<OR:" + configString + ">";
}
diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx
index 5102613..a0e309d 100644
--- a/Source/cmTestGenerator.cxx
+++ b/Source/cmTestGenerator.cxx
@@ -5,6 +5,7 @@
#include <ostream>
#include <utility>
+#include "cmAlgorithms.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmListFileCache.h"
@@ -94,10 +95,8 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
std::string emulatorExe(emulatorWithArgs[0]);
cmSystemTools::ConvertToUnixSlashes(emulatorExe);
os << cmOutputConverter::EscapeForCMake(emulatorExe) << " ";
- for (std::vector<std::string>::const_iterator ei =
- emulatorWithArgs.begin() + 1;
- ei != emulatorWithArgs.end(); ++ei) {
- os << cmOutputConverter::EscapeForCMake(*ei) << " ";
+ for (std::string const& arg : cmMakeRange(emulatorWithArgs).advance(1)) {
+ os << cmOutputConverter::EscapeForCMake(arg) << " ";
}
}
} else {
@@ -108,11 +107,10 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
// Generate the command line with full escapes.
os << cmOutputConverter::EscapeForCMake(exe);
- for (std::vector<std::string>::const_iterator ci = command.begin() + 1;
- ci != command.end(); ++ci) {
+ for (std::string const& arg : cmMakeRange(command).advance(1)) {
os << " "
<< cmOutputConverter::EscapeForCMake(
- ge.Parse(*ci)->Evaluate(this->LG, config));
+ ge.Parse(arg)->Evaluate(this->LG, config));
}
// Finish the test command.
@@ -157,12 +155,11 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout, Indent indent)
fout << "add_test(";
fout << this->Test->GetName() << " \"" << exe << "\"";
- for (std::vector<std::string>::const_iterator argit = command.begin() + 1;
- argit != command.end(); ++argit) {
+ for (std::string const& arg : cmMakeRange(command).advance(1)) {
// Just double-quote all arguments so they are re-parsed
// correctly by the test system.
fout << " \"";
- for (char c : *argit) {
+ for (char c : arg) {
// Escape quotes within arguments. We should escape
// backslashes too but we cannot because it makes the result
// inconsistent with previous behavior of this command.
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index c57aabd..0f7323d 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -5,6 +5,7 @@
#include "cmsys/FStream.hxx"
#include <stdio.h>
+#include "cmAlgorithms.h"
#include "cmDuration.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -174,11 +175,9 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs,
finalCommand +=
cmSystemTools::ConvertToRunCommandPath(emulatorWithArgs[0].c_str());
finalCommand += " ";
- for (std::vector<std::string>::const_iterator ei =
- emulatorWithArgs.begin() + 1;
- ei != emulatorWithArgs.end(); ++ei) {
+ for (std::string const& arg : cmMakeRange(emulatorWithArgs).advance(1)) {
finalCommand += "\"";
- finalCommand += *ei;
+ finalCommand += arg;
finalCommand += "\"";
finalCommand += " ";
}
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 5c3e533..e8b2668 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -438,14 +438,13 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
const char* sep = "";
std::vector<std::string>::const_iterator de =
cmRemoveDuplicates(this->Defines);
- for (std::vector<std::string>::const_iterator di = this->Defines.begin();
- di != de; ++di) {
+ for (std::string const& di : cmMakeRange(this->Defines.cbegin(), de)) {
// Escape the definition for the compiler.
std::string define;
if (this->Version < cmGlobalVisualStudioGenerator::VS10) {
- define = this->LocalGenerator->EscapeForShell(*di, true);
+ define = this->LocalGenerator->EscapeForShell(di, true);
} else {
- define = *di;
+ define = di;
}
// Escape this flag for the MSBuild.
if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {