Modernize: Use ranged for-loops when possible

Replaced most manual `const_iterator`-based loops and some
reverse-iterator loops with range loops.

Fixes: #18858
This commit is contained in:
Artur Ryt
2019-02-07 22:39:05 +01:00
parent 15bdbec017
commit 01b2d6ab74
46 changed files with 317 additions and 416 deletions
@@ -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";
}
+20 -34
View File
@@ -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);
}
}
+2 -3
View File
@@ -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;
+3 -3
View File
@@ -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> ");
@@ -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";
}
+6 -11
View File
@@ -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;
+11 -12
View File
@@ -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()));
}
}
+15 -18
View File
@@ -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(";");
}
+5 -4
View File
@@ -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;
+4 -5
View File
@@ -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;
+10 -14
View File
@@ -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());
}
+6 -12
View File
@@ -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.
+3 -3
View File
@@ -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;
+2 -3
View File
@@ -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();
}
+5 -5
View File
@@ -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);
+16 -20
View File
@@ -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) &&
+3 -6
View File
@@ -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);
+4 -4
View File
@@ -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;
+2 -4
View File
@@ -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) {
+8 -19
View File
@@ -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();
}
+3 -5
View File
@@ -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'."); \
+15 -22
View File
@@ -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;
+6 -6
View File
@@ -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;
+2 -4
View File
@@ -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;
}
}
}
+1 -2
View File
@@ -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=")) {
+5 -4
View File
@@ -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;
}
+2 -4
View File
@@ -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));
}
+6 -4
View File
@@ -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;
}
}
}
}
+5 -9
View File
@@ -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,
+3 -3
View File
@@ -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 {
+7 -5
View File
@@ -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;
}
}
}
}
+5 -4
View File
@@ -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";
+5 -8
View File
@@ -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;
+5 -3
View File
@@ -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;
}
}
}
+45 -63
View File
@@ -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 */
}
+11 -14
View File
@@ -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;
}
}
+5 -6
View File
@@ -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);
}
}
+8 -7
View File
@@ -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.
+8 -7
View File
@@ -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
+18 -17
View File
@@ -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;
}
+5 -6
View File
@@ -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;
}
+3 -5
View File
@@ -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);
}
}
+2 -4
View File
@@ -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 + ">";
}
+7 -10
View File
@@ -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.
+3 -4
View File
@@ -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 += " ";
}
+3 -4
View File
@@ -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) {