From 92c7b5260795153f4152e8562a7abac3d6d77d8a Mon Sep 17 00:00:00 2001 From: Vitaly Stakhovsky Date: Thu, 21 Dec 2017 11:51:28 -0500 Subject: VS: Use range-based 'for' loops in generator code Use `auto` for complex types. --- Source/cmGlobalVisualStudio10Generator.cxx | 12 ++-- Source/cmGlobalVisualStudio11Generator.cxx | 14 ++-- Source/cmGlobalVisualStudio14Generator.cxx | 17 ++--- Source/cmGlobalVisualStudio71Generator.cxx | 35 ++++----- Source/cmGlobalVisualStudio7Generator.cxx | 111 ++++++++++++----------------- Source/cmGlobalVisualStudio8Generator.cxx | 59 +++++++-------- Source/cmGlobalVisualStudio9Generator.cxx | 6 +- Source/cmGlobalVisualStudioGenerator.cxx | 105 ++++++++++----------------- Source/cmLocalVisualStudio10Generator.cxx | 14 ++-- Source/cmLocalVisualStudio7Generator.cxx | 27 ++++--- Source/cmLocalVisualStudioGenerator.cxx | 14 ++-- 11 files changed, 167 insertions(+), 247 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 4c4c62c..73a5dae 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -478,12 +478,11 @@ void cmGlobalVisualStudio10Generator::Generate() void cmGlobalVisualStudio10Generator::EnableLanguage( std::vector const& lang, cmMakefile* mf, bool optional) { - for (std::vector::const_iterator it = lang.begin(); - it != lang.end(); ++it) { - if (*it == "ASM_NASM") { + for (std::string const& it : lang) { + if (it == "ASM_NASM") { this->NasmEnabled = true; } - if (*it == "CUDA") { + if (it == "CUDA") { this->CudaEnabled = true; } } @@ -829,8 +828,9 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( if (parser.ParseFile(slnFile, slnData, cmVisualStudioSlnParser::DataGroupProjects)) { std::vector slnProjects = slnData.GetProjects(); - for (std::vector::iterator i = slnProjects.begin(); - !useDevEnv && i != slnProjects.end(); ++i) { + for (std::vector::const_iterator i = + slnProjects.cbegin(); + !useDevEnv && i != slnProjects.cend(); ++i) { std::string proj = i->GetRelativePath(); if (proj.size() > 7 && proj.substr(proj.size() - 7) == ".vfproj") { useDevEnv = true; diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index cb3b047..f1d5a8c 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -83,9 +83,8 @@ public: std::set installedSDKs = cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs(); - for (std::set::const_iterator i = installedSDKs.begin(); - i != installedSDKs.end(); ++i) { - names.push_back(std::string(vs11generatorName) + " " + *i); + for (std::string const& i : installedSDKs) { + names.push_back(std::string(vs11generatorName) + " " + i); } } @@ -224,18 +223,17 @@ cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs() cmSystemTools::KeyWOW64_32); std::set ret; - for (std::vector::const_iterator i = subkeys.begin(); - i != subkeys.end(); ++i) { + for (std::string const& i : subkeys) { std::string key = sdksKey; key += '\\'; - key += *i; + key += i; key += ';'; std::string path; - if (cmSystemTools::ReadRegistryValue(key.c_str(), path, + if (cmSystemTools::ReadRegistryValue(key, path, cmSystemTools::KeyWOW64_32) && !path.empty()) { - ret.insert(*i); + ret.insert(i); } } diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 97d5313..c440e0d 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -257,9 +257,8 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion() std::vector sdks; // Grab the paths of the different SDKs that are installed - for (std::vector::iterator i = win10Roots.begin(); - i != win10Roots.end(); ++i) { - std::string path = *i + "/Include/*"; + for (std::string const& i : win10Roots) { + std::string path = i + "/Include/*"; cmSystemTools::GlobDirs(path, sdks); } @@ -269,19 +268,17 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion() if (!sdks.empty()) { // Only use the filename, which will be the SDK version. - for (std::vector::iterator i = sdks.begin(); i != sdks.end(); - ++i) { - *i = cmSystemTools::GetFilenameName(*i); + for (std::string& i : sdks) { + i = cmSystemTools::GetFilenameName(i); } // Sort the results to make sure we select the most recent one. std::sort(sdks.begin(), sdks.end(), cmSystemTools::VersionCompareGreater); // Look for a SDK exactly matching the requested target version. - for (std::vector::iterator i = sdks.begin(); i != sdks.end(); - ++i) { - if (cmSystemTools::VersionCompareEqual(*i, this->SystemVersion)) { - return *i; + for (std::string const& i : sdks) { + if (cmSystemTools::VersionCompareEqual(i, this->SystemVersion)) { + return i; } } diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 8a9a3fb..45cc583 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -76,9 +76,8 @@ void cmGlobalVisualStudio71Generator::WriteSolutionConfigurations( std::ostream& fout, std::vector const& configs) { fout << "\tGlobalSection(SolutionConfiguration) = preSolution\n"; - for (std::vector::const_iterator i = configs.begin(); - i != configs.end(); ++i) { - fout << "\t\t" << *i << " = " << *i << "\n"; + for (std::string const& i : configs) { + fout << "\t\t" << i << " = " << i << "\n"; } fout << "\tEndGlobalSection\n"; } @@ -143,9 +142,7 @@ void cmGlobalVisualStudio71Generator::WriteProjectDepends( cmGeneratorTarget const* target) { VSDependSet const& depends = this->VSTargetDepends[target]; - for (VSDependSet::const_iterator di = depends.begin(); di != depends.end(); - ++di) { - const char* name = di->c_str(); + for (std::string const& name : depends) { std::string guid = this->GetGUID(name); if (guid.empty()) { std::string m = "Target: "; @@ -174,11 +171,10 @@ void cmGlobalVisualStudio71Generator::WriteExternalProject( // project instead of in the global section if (!depends.empty()) { fout << "\tProjectSection(ProjectDependencies) = postProject\n"; - std::set::const_iterator it; - for (it = depends.begin(); it != depends.end(); ++it) { - if (!it->empty()) { - fout << "\t\t{" << this->GetGUID(it->c_str()) << "} = {" - << this->GetGUID(it->c_str()) << "}\n"; + for (std::string const& it : depends) { + if (!it.empty()) { + fout << "\t\t{" << this->GetGUID(it) << "} = {" << this->GetGUID(it) + << "}\n"; } } fout << "\tEndProjectSection\n"; @@ -198,26 +194,25 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations( const std::string& platformName = !platformMapping.empty() ? platformMapping : this->GetPlatformName(); std::string guid = this->GetGUID(name); - for (std::vector::const_iterator i = configs.begin(); - i != configs.end(); ++i) { + for (std::string const& i : configs) { std::vector mapConfig; - const char* dstConfig = i->c_str(); + const char* dstConfig = i.c_str(); if (target.GetProperty("EXTERNAL_MSPROJECT")) { if (const char* m = target.GetProperty("MAP_IMPORTED_CONFIG_" + - cmSystemTools::UpperCase(*i))) { + cmSystemTools::UpperCase(i))) { cmSystemTools::ExpandListArgument(m, mapConfig); if (!mapConfig.empty()) { dstConfig = mapConfig[0].c_str(); } } } - fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << dstConfig - << "|" << platformName << std::endl; + fout << "\t\t{" << guid << "}." << i << ".ActiveCfg = " << dstConfig << "|" + << platformName << std::endl; std::set::const_iterator ci = - configsPartOfDefaultBuild.find(*i); + configsPartOfDefaultBuild.find(i); if (!(ci == configsPartOfDefaultBuild.end())) { - fout << "\t\t{" << guid << "}." << *i << ".Build.0 = " << dstConfig - << "|" << platformName << std::endl; + fout << "\t\t{" << guid << "}." << i << ".Build.0 = " << dstConfig << "|" + << platformName << std::endl; } } } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index a14b5f7..c915dc5 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -334,9 +334,8 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile( // output the SLN file void cmGlobalVisualStudio7Generator::OutputSLNFile() { - std::map>::iterator it; - for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) { - this->OutputSLNFile(it->second[0], it->second); + for (auto& it : this->ProjectMap) { + this->OutputSLNFile(it.second[0], it.second); } } @@ -346,9 +345,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( { // loop over again and write out configurations for each target // in the solution - for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); - tt != projectTargets.end(); ++tt) { - cmGeneratorTarget const* target = *tt; + for (cmGeneratorTarget const* target : projectTargets) { if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } @@ -378,9 +375,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( VisualStudioFolders.clear(); std::string rootBinaryDir = root->GetCurrentBinaryDirectory(); - for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); - tt != projectTargets.end(); ++tt) { - cmGeneratorTarget const* target = *tt; + for (cmGeneratorTarget const* target : projectTargets) { if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } @@ -420,19 +415,18 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( std::string cumulativePath; - for (std::vector::iterator iter = tokens.begin(); - iter != tokens.end(); ++iter) { - if (!iter->size()) { + for (cmsys::String const& iter : tokens) { + if (!iter.size()) { continue; } if (cumulativePath.empty()) { - cumulativePath = "CMAKE_FOLDER_GUID_" + *iter; + cumulativePath = "CMAKE_FOLDER_GUID_" + iter; } else { VisualStudioFolders[cumulativePath].insert(cumulativePath + "/" + - *iter); + iter); - cumulativePath = cumulativePath + "/" + *iter; + cumulativePath = cumulativePath + "/" + iter; } } @@ -447,9 +441,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( void cmGlobalVisualStudio7Generator::WriteTargetDepends( std::ostream& fout, OrderedTargetDependSet const& projectTargets) { - for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); - tt != projectTargets.end(); ++tt) { - cmGeneratorTarget const* target = *tt; + for (cmGeneratorTarget const* target : projectTargets) { if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } @@ -467,11 +459,9 @@ void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout) const char* prefix = "CMAKE_FOLDER_GUID_"; const std::string::size_type skip_prefix = strlen(prefix); std::string guidProjectTypeFolder = "2150E333-8FDC-42A3-9474-1A3956D46DE8"; - for (std::map>::iterator iter = - VisualStudioFolders.begin(); - iter != VisualStudioFolders.end(); ++iter) { - std::string fullName = iter->first; - std::string guid = this->GetGUID(fullName.c_str()); + for (auto const& iter : VisualStudioFolders) { + std::string fullName = iter.first; + std::string guid = this->GetGUID(fullName); std::replace(fullName.begin(), fullName.end(), '/', '\\'); if (cmSystemTools::StringStartsWith(fullName.c_str(), prefix)) { @@ -487,16 +477,13 @@ void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout) void cmGlobalVisualStudio7Generator::WriteFoldersContent(std::ostream& fout) { - for (std::map>::iterator iter = - VisualStudioFolders.begin(); - iter != VisualStudioFolders.end(); ++iter) { - std::string key(iter->first); - std::string guidParent(this->GetGUID(key.c_str())); + for (auto const& iter : VisualStudioFolders) { + std::string key(iter.first); + std::string guidParent(this->GetGUID(key)); - for (std::set::iterator it = iter->second.begin(); - it != iter->second.end(); ++it) { - std::string value(*it); - std::string guid(this->GetGUID(value.c_str())); + for (std::string const& it : iter.second) { + std::string value(it); + std::string guid(this->GetGUID(value)); fout << "\t\t{" << guid << "} = {" << guidParent << "}\n"; } @@ -525,11 +512,10 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections( bool extensibilityAddInsOverridden = false; const std::vector propKeys = root->GetMakefile()->GetPropertyKeys(); - for (std::vector::const_iterator it = propKeys.begin(); - it != propKeys.end(); ++it) { - if (it->find("VS_GLOBAL_SECTION_") == 0) { + for (std::string const& it : propKeys) { + if (it.find("VS_GLOBAL_SECTION_") == 0) { std::string sectionType; - std::string name = it->substr(18); + std::string name = it.substr(18); if (name.find("PRE_") == 0) { name = name.substr(4); sectionType = "preSolution"; @@ -549,17 +535,15 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections( } fout << "\tGlobalSection(" << name << ") = " << sectionType << "\n"; std::vector keyValuePairs; - cmSystemTools::ExpandListArgument( - root->GetMakefile()->GetProperty(it->c_str()), keyValuePairs); - for (std::vector::const_iterator itPair = - keyValuePairs.begin(); - itPair != keyValuePairs.end(); ++itPair) { - const std::string::size_type posEqual = itPair->find('='); + cmSystemTools::ExpandListArgument(root->GetMakefile()->GetProperty(it), + keyValuePairs); + for (std::string const& itPair : keyValuePairs) { + const std::string::size_type posEqual = itPair.find('='); if (posEqual != std::string::npos) { const std::string key = - cmSystemTools::TrimWhitespace(itPair->substr(0, posEqual)); + cmSystemTools::TrimWhitespace(itPair.substr(0, posEqual)); const std::string value = - cmSystemTools::TrimWhitespace(itPair->substr(posEqual + 1)); + cmSystemTools::TrimWhitespace(itPair.substr(posEqual + 1)); fout << "\t\t" << key << " = " << value << "\n"; if (key == "SolutionGuid") { addGuid = false; @@ -618,14 +602,13 @@ std::string cmGlobalVisualStudio7Generator::WriteUtilityDepend( "\t\n" ; /* clang-format on */ - for (std::vector::iterator i = configs.begin(); - i != configs.end(); ++i) { + for (std::string const& i : configs) { /* clang-format off */ fout << "\t\t cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( std::vector targetNames; targetNames.push_back("INSTALL"); targetNames.push_back("PACKAGE"); - for (std::vector::const_iterator t = targetNames.begin(); - t != targetNames.end(); ++t) { - // check if target <*t> is part of default build - if (target->GetName() == *t) { + for (std::string const& t : targetNames) { + // check if target is part of default build + if (target->GetName() == t) { const std::string propertyName = - "CMAKE_VS_INCLUDE_" + *t + "_TO_DEFAULT_BUILD"; - // inspect CMAKE_VS_INCLUDE_<*t>_TO_DEFAULT_BUILD properties - for (std::vector::const_iterator i = configs.begin(); - i != configs.end(); ++i) { + "CMAKE_VS_INCLUDE_" + t + "_TO_DEFAULT_BUILD"; + // inspect CMAKE_VS_INCLUDE__TO_DEFAULT_BUILD properties + for (std::string const& i : configs) { const char* propertyValue = target->Target->GetMakefile()->GetDefinition(propertyName); cmGeneratorExpression ge; std::unique_ptr cge = ge.Parse(propertyValue); if (cmSystemTools::IsOn( - cge->Evaluate(target->GetLocalGenerator(), *i))) { - activeConfigs.insert(*i); + cge->Evaluate(target->GetLocalGenerator(), i))) { + activeConfigs.insert(i); } } } @@ -724,12 +705,11 @@ std::set cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( return activeConfigs; } // inspect EXCLUDE_FROM_DEFAULT_BUILD[_] properties - for (std::vector::const_iterator i = configs.begin(); - i != configs.end(); ++i) { + for (std::string const& i : configs) { const char* propertyValue = - target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str()); + target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i); if (cmSystemTools::IsOff(propertyValue)) { - activeConfigs.insert(*i); + activeConfigs.insert(i); } } return activeConfigs; @@ -738,9 +718,8 @@ std::set cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( bool cmGlobalVisualStudio7Generator::IsDependedOn( OrderedTargetDependSet const& projectTargets, cmGeneratorTarget const* gtIn) { - for (OrderedTargetDependSet::const_iterator l = projectTargets.begin(); - l != projectTargets.end(); ++l) { - TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(*l); + for (cmTargetDepend const& l : projectTargets) { + TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(l); if (tgtdeps.count(gtIn)) { return true; } diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 1743b18..ab8ad70 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -66,10 +66,8 @@ public: parser.ParseVersion("8.0"); const std::vector& availablePlatforms = parser.GetAvailablePlatforms(); - for (std::vector::const_iterator i = - availablePlatforms.begin(); - i != availablePlatforms.end(); ++i) { - names.push_back("Visual Studio 8 2005 " + *i); + for (std::string const& i : availablePlatforms) { + names.push_back("Visual Studio 8 2005 " + i); } } @@ -117,9 +115,8 @@ std::string cmGlobalVisualStudio8Generator::FindDevEnvCommand() void cmGlobalVisualStudio8Generator::EnableLanguage( std::vector const& lang, cmMakefile* mf, bool optional) { - for (std::vector::const_iterator it = lang.begin(); - it != lang.end(); ++it) { - if (*it == "ASM_MASM") { + for (std::string const& it : lang) { + if (it == "ASM_MASM") { this->MasmEnabled = true; } } @@ -249,10 +246,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() stampListFile += stampList; std::string stampFile; cmGeneratedFileStream fout(stampListFile.c_str()); - for (std::vector::const_iterator gi = - generators.begin(); - gi != generators.end(); ++gi) { - stampFile = (*gi)->GetMakefile()->GetCurrentBinaryDirectory(); + for (cmLocalGenerator const* gi : generators) { + stampFile = gi->GetMakefile()->GetCurrentBinaryDirectory(); stampFile += "/"; stampFile += cmake::GetCMakeFilesDirectoryPostSlash(); stampFile += "generate.stamp"; @@ -323,10 +318,9 @@ void cmGlobalVisualStudio8Generator::AddExtraIDETargets() const std::vector& tgts = this->LocalGenerators[i]->GetGeneratorTargets(); // All targets depend on the build-system check target. - for (std::vector::const_iterator ti = tgts.begin(); - ti != tgts.end(); ++ti) { - if ((*ti)->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) { - (*ti)->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET); + for (cmGeneratorTarget const* ti : tgts) { + if (ti->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) { + ti->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET); } } } @@ -337,10 +331,9 @@ void cmGlobalVisualStudio8Generator::WriteSolutionConfigurations( std::ostream& fout, std::vector const& configs) { fout << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n"; - for (std::vector::const_iterator i = configs.begin(); - i != configs.end(); ++i) { - fout << "\t\t" << *i << "|" << this->GetPlatformName() << " = " << *i - << "|" << this->GetPlatformName() << "\n"; + for (std::string const& i : configs) { + fout << "\t\t" << i << "|" << this->GetPlatformName() << " = " << i << "|" + << this->GetPlatformName() << "\n"; } fout << "\tEndGlobalSection\n"; } @@ -352,35 +345,34 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations( std::string const& platformMapping) { std::string guid = this->GetGUID(name); - for (std::vector::const_iterator i = configs.begin(); - i != configs.end(); ++i) { + for (std::string const& i : configs) { std::vector mapConfig; - const char* dstConfig = i->c_str(); + const char* dstConfig = i.c_str(); if (target.GetProperty("EXTERNAL_MSPROJECT")) { if (const char* m = target.GetProperty("MAP_IMPORTED_CONFIG_" + - cmSystemTools::UpperCase(*i))) { + cmSystemTools::UpperCase(i))) { cmSystemTools::ExpandListArgument(m, mapConfig); if (!mapConfig.empty()) { dstConfig = mapConfig[0].c_str(); } } } - fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() + fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName() << ".ActiveCfg = " << dstConfig << "|" << (!platformMapping.empty() ? platformMapping : this->GetPlatformName()) << "\n"; std::set::const_iterator ci = - configsPartOfDefaultBuild.find(*i); + configsPartOfDefaultBuild.find(i); if (!(ci == configsPartOfDefaultBuild.end())) { - fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() + fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName() << ".Build.0 = " << dstConfig << "|" << (!platformMapping.empty() ? platformMapping : this->GetPlatformName()) << "\n"; } if (this->NeedsDeploy(target.GetType())) { - fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() + fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName() << ".Deploy.0 = " << dstConfig << "|" << (!platformMapping.empty() ? platformMapping : this->GetPlatformName()) @@ -410,12 +402,11 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends( { TargetDependSet const& unordered = this->GetTargetDirectDepends(gt); OrderedTargetDependSet depends(unordered, std::string()); - for (OrderedTargetDependSet::const_iterator i = depends.begin(); - i != depends.end(); ++i) { - if ((*i)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + for (cmTargetDepend const& i : depends) { + if (i->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } - std::string guid = this->GetGUID((*i)->GetName().c_str()); + std::string guid = this->GetGUID(i->GetName()); fout << "\t\t{" << guid << "} = {" << guid << "}\n"; } } @@ -424,11 +415,9 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies( cmGeneratorTarget* target) { // Look for utility dependencies that magically link. - for (std::set::const_iterator ui = - target->GetUtilities().begin(); - ui != target->GetUtilities().end(); ++ui) { + for (std::string const& ui : target->GetUtilities()) { if (cmGeneratorTarget* depTarget = - target->GetLocalGenerator()->FindGeneratorTargetToUse(ui->c_str())) { + target->GetLocalGenerator()->FindGeneratorTargetToUse(ui)) { if (depTarget->GetType() != cmStateEnums::INTERFACE_LIBRARY && depTarget->GetProperty("EXTERNAL_MSPROJECT")) { // This utility dependency names an external .vcproj target. diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 0abb348..7ac3a6f 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -68,10 +68,8 @@ public: parser.ParseVersion("9.0"); const std::vector& availablePlatforms = parser.GetAvailablePlatforms(); - for (std::vector::const_iterator i = - availablePlatforms.begin(); - i != availablePlatforms.end(); ++i) { - names.push_back("Visual Studio 9 2008 " + *i); + for (std::string const& i : availablePlatforms) { + names.push_back("Visual Studio 9 2008 " + i); } } diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index c89c2c4..d7ebcac 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -61,9 +61,8 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() const char* no_working_dir = 0; std::vector no_depends; cmCustomCommandLines no_commands; - std::map>::iterator it; - for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) { - std::vector& gen = it->second; + for (auto const& it : this->ProjectMap) { + std::vector const& gen = it.second; // add the ALL_BUILD to the first local generator of each project if (!gen.empty()) { // Use no actual command lines so that the target itself is not @@ -83,14 +82,10 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() } // Now make all targets depend on the ALL_BUILD target - for (std::vector::iterator i = gen.begin(); - i != gen.end(); ++i) { - const std::vector& targets = - (*i)->GetGeneratorTargets(); - for (std::vector::const_iterator t = - targets.begin(); - t != targets.end(); ++t) { - cmGeneratorTarget* tgt = *t; + for (cmLocalGenerator const* i : gen) { + std::vector const& targets = + i->GetGeneratorTargets(); + for (cmGeneratorTarget* tgt : targets) { if (tgt->GetType() == cmStateEnums::GLOBAL_TARGET || tgt->IsImported()) { continue; @@ -243,10 +238,9 @@ void cmGlobalVisualStudioGenerator::FillLinkClosure( { if (linked.insert(target).second) { TargetDependSet const& depends = this->GetTargetDirectDepends(target); - for (TargetDependSet::const_iterator di = depends.begin(); - di != depends.end(); ++di) { - if (di->IsLink()) { - this->FillLinkClosure(*di, linked); + for (cmTargetDepend const& di : depends) { + if (di.IsLink()) { + this->FillLinkClosure(di, linked); } } } @@ -275,10 +269,9 @@ void cmGlobalVisualStudioGenerator::FollowLinkDepends( // Static library targets do not list their link dependencies so // we must follow them transitively now. TargetDependSet const& depends = this->GetTargetDirectDepends(target); - for (TargetDependSet::const_iterator di = depends.begin(); - di != depends.end(); ++di) { - if (di->IsLink()) { - this->FollowLinkDepends(*di, linked); + for (cmTargetDepend const& di : depends) { + if (di.IsLink()) { + this->FollowLinkDepends(di, linked); } } } @@ -289,17 +282,13 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends() if (!this->cmGlobalGenerator::ComputeTargetDepends()) { return false; } - std::map>::iterator it; - for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) { - std::vector& gen = it->second; - for (std::vector::iterator i = gen.begin(); - i != gen.end(); ++i) { - const std::vector& targets = - (*i)->GetGeneratorTargets(); - for (std::vector::const_iterator ti = - targets.begin(); - ti != targets.end(); ++ti) { - this->ComputeVSTargetDepends(*ti); + for (auto const& it : this->ProjectMap) { + std::vector const& gen = it.second; + for (const cmLocalGenerator* i : gen) { + std::vector const& targets = + i->GetGeneratorTargets(); + for (cmGeneratorTarget* ti : targets) { + this->ComputeVSTargetDepends(ti); } } } @@ -349,22 +338,20 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends( // due to behavior (2), but they do not really need to. std::set linkDepends; if (target->GetType() != cmStateEnums::STATIC_LIBRARY) { - for (TargetDependSet::const_iterator di = depends.begin(); - di != depends.end(); ++di) { - cmTargetDepend dep = *di; + for (cmTargetDepend const& di : depends) { + cmTargetDepend dep = di; if (dep.IsLink()) { - this->FollowLinkDepends(*di, linkDepends); + this->FollowLinkDepends(di, linkDepends); } } } // Collect explicit util dependencies (add_dependencies). std::set utilDepends; - for (TargetDependSet::const_iterator di = depends.begin(); - di != depends.end(); ++di) { - cmTargetDepend dep = *di; + for (cmTargetDepend const& di : depends) { + cmTargetDepend dep = di; if (dep.IsUtil()) { - this->FollowLinkDepends(*di, utilDepends); + this->FollowLinkDepends(di, utilDepends); } } @@ -376,16 +363,12 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends( } // Emit link dependencies. - for (std::set::iterator di = linkDepends.begin(); - di != linkDepends.end(); ++di) { - cmGeneratorTarget const* dep = *di; + for (cmGeneratorTarget const* dep : linkDepends) { vsTargetDepend.insert(dep->GetName()); } // Emit util dependencies. Possibly use intermediate targets. - for (std::set::iterator di = utilDepends.begin(); - di != utilDepends.end(); ++di) { - cmGeneratorTarget const* dgt = *di; + for (cmGeneratorTarget const* dgt : utilDepends) { if (allowLinkable || !VSLinkable(dgt) || linked.count(dgt)) { // Direct dependency allowed. vsTargetDepend.insert(dgt->GetName()); @@ -815,9 +798,8 @@ cmGlobalVisualStudioGenerator::OrderedTargetDependSet::OrderedTargetDependSet( TargetSet const& targets, std::string const& first) : derived(TargetCompare(first)) { - for (TargetSet::const_iterator it = targets.begin(); it != targets.end(); - ++it) { - this->insert(*it); + for (cmGeneratorTarget const* it : targets) { + this->insert(it); } } @@ -851,10 +833,8 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand( std::vector objectSources; gt->GetObjectSources(objectSources, configName); std::map mapping; - for (std::vector::const_iterator it = - objectSources.begin(); - it != objectSources.end(); ++it) { - mapping[*it]; + for (cmSourceFile const* it : objectSources) { + mapping[it]; } gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); std::string obj_dir = gt->ObjectDirectory; @@ -879,12 +859,10 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand( if (mdi->WindowsExportAllSymbols) { std::vector objs; - for (std::vector::const_iterator it = - objectSources.begin(); - it != objectSources.end(); ++it) { + for (cmSourceFile const* it : objectSources) { // Find the object file name corresponding to this source file. std::map::const_iterator map_it = - mapping.find(*it); + mapping.find(it); // It must exist because we populated the mapping just above. assert(!map_it->second.empty()); std::string objFile = obj_dir + map_it->second; @@ -892,15 +870,12 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand( } std::vector externalObjectSources; gt->GetExternalObjects(externalObjectSources, configName); - for (std::vector::const_iterator it = - externalObjectSources.begin(); - it != externalObjectSources.end(); ++it) { - objs.push_back((*it)->GetFullPath()); + for (cmSourceFile const* it : externalObjectSources) { + objs.push_back(it->GetFullPath()); } - for (std::vector::iterator it = objs.begin(); - it != objs.end(); ++it) { - std::string objFile = *it; + for (std::string const& it : objs) { + std::string objFile = it; // replace $(ConfigurationName) in the object names cmSystemTools::ReplaceString(objFile, this->GetCMakeCFGIntDir(), configName.c_str()); @@ -910,10 +885,8 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand( } } - for (std::vector::const_iterator i = - mdi->Sources.begin(); - i != mdi->Sources.end(); ++i) { - fout << (*i)->GetFullPath() << "\n"; + for (cmSourceFile const* i : mdi->Sources) { + fout << i->GetFullPath() << "\n"; } cmCustomCommandLines commandLines; diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 5e81514..2803d4a 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -64,20 +64,18 @@ cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator() void cmLocalVisualStudio10Generator::Generate() { - const std::vector& tgts = this->GetGeneratorTargets(); - for (std::vector::const_iterator l = tgts.begin(); - l != tgts.end(); ++l) { - if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + for (cmGeneratorTarget* l : tgts) { + if (l->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } if (static_cast(this->GlobalGenerator) - ->TargetIsFortranOnly(*l)) { - this->CreateSingleVCProj((*l)->GetName().c_str(), *l); + ->TargetIsFortranOnly(l)) { + this->CreateSingleVCProj(l->GetName(), l); } else { cmVisualStudio10TargetGenerator tg( - *l, static_cast( - this->GetGlobalGenerator())); + l, static_cast( + this->GetGlobalGenerator())); tg.Generate(); } } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 1b96ef4..eccd4d0 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -70,14 +70,13 @@ void cmLocalVisualStudio7Generator::AddHelperCommands() { // Now create GUIDs for targets const std::vector& tgts = this->GetGeneratorTargets(); - for (std::vector::const_iterator l = tgts.begin(); - l != tgts.end(); ++l) { - if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + for (cmGeneratorTarget const* l : tgts) { + if (l->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } - const char* path = (*l)->GetProperty("EXTERNAL_MSPROJECT"); + const char* path = l->GetProperty("EXTERNAL_MSPROJECT"); if (path) { - this->ReadAndStoreExternalGUID((*l)->GetName().c_str(), path); + this->ReadAndStoreExternalGUID(l->GetName(), path); } } @@ -96,9 +95,8 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() // commands for targets in which no sources are built. Add dummy // rules to force these targets to build. const std::vector& tgts = this->GetGeneratorTargets(); - for (std::vector::const_iterator l = tgts.begin(); - l != tgts.end(); l++) { - if ((*l)->GetType() == cmStateEnums::GLOBAL_TARGET) { + for (cmGeneratorTarget* l : tgts) { + if (l->GetType() == cmStateEnums::GLOBAL_TARGET) { std::vector no_depends; cmCustomCommandLine force_command; force_command.push_back("cd"); @@ -109,12 +107,12 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() std::string force = this->GetCurrentBinaryDirectory(); force += cmake::GetCMakeFilesDirectory(); force += "/"; - force += (*l)->GetName(); + force += l->GetName(); force += "_force"; if (cmSourceFile* file = this->Makefile->AddCustomCommandToOutput( force.c_str(), no_depends, no_main_dependency, force_commands, " ", 0, true)) { - (*l)->AddSource(file->GetFullPath()); + l->AddSource(file->GetFullPath()); } } } @@ -138,15 +136,14 @@ void cmLocalVisualStudio7Generator::WriteProjectFiles() const std::vector& tgts = this->GetGeneratorTargets(); // Create the project file for each target. - for (std::vector::const_iterator l = tgts.begin(); - l != tgts.end(); l++) { - if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + for (cmGeneratorTarget* l : tgts) { + if (l->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace // so don't build a projectfile for it - if (!(*l)->GetProperty("EXTERNAL_MSPROJECT")) { - this->CreateSingleVCProj((*l)->GetName().c_str(), *l); + if (!l->GetProperty("EXTERNAL_MSPROJECT")) { + this->CreateSingleVCProj(l->GetName(), l); } } } diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index bbb91e0..2237da7 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -39,10 +39,8 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames( // windows file names are not case sensitive. std::map counts; - for (std::map::iterator si = - mapping.begin(); - si != mapping.end(); ++si) { - cmSourceFile const* sf = si->first; + for (auto const& si : mapping) { + cmSourceFile const* sf = si.first; std::string objectNameLower = cmSystemTools::LowerCase( cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())); if (custom_ext) { @@ -57,10 +55,8 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames( // For all source files producing duplicate names we need unique // object name computation. - for (std::map::iterator si = - mapping.begin(); - si != mapping.end(); ++si) { - cmSourceFile const* sf = si->first; + for (auto& si : mapping) { + cmSourceFile const* sf = si.first; std::string objectName = cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); if (custom_ext) { @@ -74,7 +70,7 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames( objectName = this->GetObjectFileNameWithoutTarget( *sf, dir_max, &keptSourceExtension, custom_ext); } - si->second = objectName; + si.second = objectName; } } -- cgit v0.12