From c61ece5c40a30e99e0f3a45c76dd802a14e4db96 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 22 Nov 2022 13:56:03 -0500 Subject: clang-tidy: fix `modernize-use-auto` lints --- Source/cmGlobalVisualStudio10Generator.cxx | 2 +- Source/cmGlobalVisualStudio71Generator.cxx | 5 ++--- Source/cmGlobalVisualStudio8Generator.cxx | 6 ++---- Source/cmGlobalVisualStudioVersionedGenerator.cxx | 2 +- Source/cmIDEOptions.cxx | 3 +-- Source/cmLocalVisualStudio7Generator.cxx | 12 ++++-------- Source/cmVisualStudioGeneratorOptions.cxx | 15 ++++++--------- Source/cmVisualStudioSlnData.cxx | 9 ++++----- Source/cmVisualStudioWCEPlatformParser.cxx | 3 +-- 9 files changed, 22 insertions(+), 35 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 8687a59..969b801 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -302,7 +302,7 @@ bool cmGlobalVisualStudio10Generator::ParseGeneratorToolset( std::string const& ts, cmMakefile* mf) { std::vector const fields = cmTokenize(ts, ","); - std::vector::const_iterator fi = fields.begin(); + auto fi = fields.begin(); if (fi == fields.end()) { return true; } diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 86d4785..3e84765 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -125,7 +125,7 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, fout << "EndProject\n"; - UtilityDependsMap::iterator ui = this->UtilityDepends.find(t); + auto ui = this->UtilityDepends.find(t); if (ui != this->UtilityDepends.end()) { const char* uname = ui->second.c_str(); /* clang-format off */ @@ -218,8 +218,7 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations( } fout << "\t\t{" << guid << "}." << i << ".ActiveCfg = " << dstConfig << "|" << platformName << std::endl; - std::set::const_iterator ci = - configsPartOfDefaultBuild.find(i); + auto ci = configsPartOfDefaultBuild.find(i); if (!(ci == configsPartOfDefaultBuild.end())) { fout << "\t\t{" << guid << "}." << i << ".Build.0 = " << dstConfig << "|" << platformName << std::endl; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 9585372..1e810b4 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -238,8 +238,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // Sort the list of input files and remove duplicates. std::sort(listFiles.begin(), listFiles.end(), std::less()); - std::vector::iterator new_end = - std::unique(listFiles.begin(), listFiles.end()); + auto new_end = std::unique(listFiles.begin(), listFiles.end()); listFiles.erase(new_end, listFiles.end()); // Create a rule to re-run CMake. @@ -325,8 +324,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations( << (!platformMapping.empty() ? platformMapping : this->GetPlatformName()) << "\n"; - std::set::const_iterator ci = - configsPartOfDefaultBuild.find(i); + auto ci = configsPartOfDefaultBuild.find(i); if (!(ci == configsPartOfDefaultBuild.end())) { fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName() << ".Build.0 = " << dstConfig << "|" diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 6fd4dd6..273bb8b 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -606,7 +606,7 @@ bool cmGlobalVisualStudioVersionedGenerator::ParseGeneratorInstance( this->GeneratorInstanceVersion.clear(); std::vector const fields = cmTokenize(is, ","); - std::vector::const_iterator fi = fields.begin(); + auto fi = fields.begin(); if (fi == fields.end()) { return true; } diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index bb36db3..5a22697 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -246,8 +246,7 @@ bool cmIDEOptions::HasFlag(std::string const& flag) const const char* cmIDEOptions::GetFlag(std::string const& flag) const { // This method works only for single-valued flags! - std::map::const_iterator i = - this->FlagMap.find(flag); + auto i = this->FlagMap.find(flag); if (i != this->FlagMap.cend() && i->second.size() == 1) { return i->second[0].c_str(); } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 3d36b51..c3b5dfc 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -179,8 +179,7 @@ void cmLocalVisualStudio7Generator::WriteStampFiles() // Sort the list of input files and remove duplicates. std::sort(listFiles.begin(), listFiles.end(), std::less()); - std::vector::iterator new_end = - std::unique(listFiles.begin(), listFiles.end()); + auto new_end = std::unique(listFiles.begin(), listFiles.end()); listFiles.erase(new_end, listFiles.end()); for (const std::string& lf : listFiles) { @@ -253,8 +252,7 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() // Sort the list of input files and remove duplicates. std::sort(listFiles.begin(), listFiles.end(), std::less()); - std::vector::iterator new_end = - std::unique(listFiles.begin(), listFiles.end()); + auto new_end = std::unique(listFiles.begin(), listFiles.end()); listFiles.erase(new_end, listFiles.end()); std::string argS = cmStrCat("-S", this->GetSourceDirectory()); @@ -1633,8 +1631,7 @@ std::string cmLocalVisualStudio7Generator::ComputeLongestObjectDirectory( // Compute the maximum length configuration name. std::string config_max; - for (std::vector::iterator i = configs.begin(); - i != configs.end(); ++i) { + for (auto i = configs.begin(); i != configs.end(); ++i) { if (i->size() > config_max.size()) { config_max = *i; } @@ -1690,8 +1687,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup( target->GetType() == cmStateEnums::GLOBAL_TARGET || target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { // Look up the source kind and configs. - std::map::const_iterator map_it = - sources.Index.find(sf); + auto map_it = sources.Index.find(sf); // The map entry must exist because we populated it earlier. assert(map_it != sources.Index.end()); cmGeneratorTarget::AllConfigSource const& acs = diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index e6f5ece..af614af 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -115,8 +115,7 @@ bool cmVisualStudioGeneratorOptions::IsDebug() const if (this->CurrentTool != CSharpCompiler) { return this->FlagMap.find("DebugInformationFormat") != this->FlagMap.end(); } - std::map::const_iterator i = - this->FlagMap.find("DebugType"); + auto i = this->FlagMap.find("DebugType"); if (i != this->FlagMap.end()) { if (i->second.size() == 1) { return i->second[0] != "none"; @@ -267,8 +266,7 @@ void cmVisualStudioGeneratorOptions::ParseFinish() } if (this->CurrentTool == CudaCompiler) { - std::map::iterator i = - this->FlagMap.find("CudaRuntime"); + auto i = this->FlagMap.find("CudaRuntime"); if (i != this->FlagMap.end() && i->second.size() == 1) { std::string& cudaRuntime = i->second[0]; if (cudaRuntime == "static") { @@ -285,7 +283,7 @@ void cmVisualStudioGeneratorOptions::ParseFinish() void cmVisualStudioGeneratorOptions::PrependInheritedString( std::string const& key) { - std::map::iterator i = this->FlagMap.find(key); + auto i = this->FlagMap.find(key); if (i == this->FlagMap.end() || i->second.size() != 1) { return; } @@ -295,7 +293,7 @@ void cmVisualStudioGeneratorOptions::PrependInheritedString( void cmVisualStudioGeneratorOptions::Reparse(std::string const& key) { - std::map::iterator i = this->FlagMap.find(key); + auto i = this->FlagMap.find(key); if (i == this->FlagMap.end() || i->second.size() != 1) { return; } @@ -339,7 +337,7 @@ cmIDEOptions::FlagValue cmVisualStudioGeneratorOptions::TakeFlag( std::string const& key) { FlagValue value; - std::map::iterator i = this->FlagMap.find(key); + auto i = this->FlagMap.find(key); if (i != this->FlagMap.end()) { value = i->second; this->FlagMap.erase(i); @@ -373,8 +371,7 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions( if (this->Version != cmGlobalVisualStudioGenerator::VSVersion::VS9) { oss << "%(" << tag << ")"; } - std::vector::const_iterator de = - cmRemoveDuplicates(this->Defines); + auto de = cmRemoveDuplicates(this->Defines); for (std::string const& di : cmMakeRange(this->Defines.cbegin(), de)) { // Escape the definition for the compiler. std::string define; diff --git a/Source/cmVisualStudioSlnData.cxx b/Source/cmVisualStudioSlnData.cxx index 739183f..da5a56c 100644 --- a/Source/cmVisualStudioSlnData.cxx +++ b/Source/cmVisualStudioSlnData.cxx @@ -23,7 +23,7 @@ std::string cmSlnProjectEntry::GetProjectConfiguration( const cm::optional cmSlnData::GetProjectByGUID( const std::string& projectGUID) const { - ProjectStorage::const_iterator it(ProjectsByGUID.find(projectGUID)); + auto it(ProjectsByGUID.find(projectGUID)); if (it != ProjectsByGUID.end()) return it->second; else @@ -33,7 +33,7 @@ const cm::optional cmSlnData::GetProjectByGUID( const cm::optional cmSlnData::GetProjectByName( const std::string& projectName) const { - ProjectStringIndex::const_iterator it(ProjectNameIndex.find(projectName)); + auto it(ProjectNameIndex.find(projectName)); if (it != ProjectNameIndex.end()) return it->second->second; else @@ -42,8 +42,7 @@ const cm::optional cmSlnData::GetProjectByName( std::vector cmSlnData::GetProjects() const { - ProjectStringIndex::const_iterator it(this->ProjectNameIndex.begin()), - itEnd(this->ProjectNameIndex.end()); + auto it(this->ProjectNameIndex.begin()), itEnd(this->ProjectNameIndex.end()); std::vector result; for (; it != itEnd; ++it) result.push_back(it->second->second); @@ -54,7 +53,7 @@ cmSlnProjectEntry* cmSlnData::AddProject( const std::string& projectGUID, const std::string& projectName, const std::string& projectRelativePath) { - ProjectStorage::iterator it(ProjectsByGUID.find(projectGUID)); + auto it(ProjectsByGUID.find(projectGUID)); if (it != ProjectsByGUID.end()) return nullptr; it = ProjectsByGUID diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx index 175bd4e..7be1f45 100644 --- a/Source/cmVisualStudioWCEPlatformParser.cxx +++ b/Source/cmVisualStudioWCEPlatformParser.cxx @@ -44,8 +44,7 @@ std::string cmVisualStudioWCEPlatformParser::GetOSVersion() const const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const { - std::map::const_iterator it = - this->Macros.find("ARCHFAM"); + auto it = this->Macros.find("ARCHFAM"); if (it != this->Macros.end()) { return it->second.c_str(); } -- cgit v0.12