cmGlobalGenerator: Use auto for long iterator types

This commit is contained in:
Sebastian Holtermann
2019-03-25 11:10:46 +01:00
parent 4bbd315097
commit bf9afa1e15
+30 -44
View File
@@ -272,8 +272,7 @@ void cmGlobalGenerator::AddBuildExportExportSet(
bool cmGlobalGenerator::GenerateImportFile(const std::string& file) bool cmGlobalGenerator::GenerateImportFile(const std::string& file)
{ {
std::map<std::string, cmExportBuildFileGenerator*>::iterator it = auto const it = this->BuildExportSets.find(file);
this->BuildExportSets.find(file);
if (it != this->BuildExportSets.end()) { if (it != this->BuildExportSets.end()) {
bool result = it->second->GenerateImportFile(); bool result = it->second->GenerateImportFile();
@@ -338,8 +337,7 @@ bool cmGlobalGenerator::CheckTargetsForMissingSources() const
bool cmGlobalGenerator::IsExportedTargetsFile( bool cmGlobalGenerator::IsExportedTargetsFile(
const std::string& filename) const const std::string& filename) const
{ {
const std::map<std::string, cmExportBuildFileGenerator*>::const_iterator it = auto const it = this->BuildExportSets.find(filename);
this->BuildExportSets.find(filename);
if (it == this->BuildExportSets.end()) { if (it == this->BuildExportSets.end()) {
return false; return false;
} }
@@ -993,9 +991,7 @@ std::string cmGlobalGenerator::GetLanguageOutputExtension(
{ {
const std::string& lang = source.GetLanguage(); const std::string& lang = source.GetLanguage();
if (!lang.empty()) { if (!lang.empty()) {
std::map<std::string, std::string>::const_iterator it = auto const it = this->LanguageToOutputExtension.find(lang);
this->LanguageToOutputExtension.find(lang);
if (it != this->LanguageToOutputExtension.end()) { if (it != this->LanguageToOutputExtension.end()) {
return it->second; return it->second;
} }
@@ -1020,8 +1016,7 @@ std::string cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const
if (ext && *ext == '.') { if (ext && *ext == '.') {
++ext; ++ext;
} }
std::map<std::string, std::string>::const_iterator it = auto const it = this->ExtensionToLanguage.find(ext);
this->ExtensionToLanguage.find(ext);
if (it != this->ExtensionToLanguage.end()) { if (it != this->ExtensionToLanguage.end()) {
return it->second; return it->second;
} }
@@ -1272,7 +1267,7 @@ void cmGlobalGenerator::CreateImportedGenerationObjects(
std::vector<const cmGeneratorTarget*>& exports) std::vector<const cmGeneratorTarget*>& exports)
{ {
this->CreateGenerationObjects(ImportedOnly); this->CreateGenerationObjects(ImportedOnly);
std::vector<cmMakefile*>::iterator mfit = auto const mfit =
std::find(this->Makefiles.begin(), this->Makefiles.end(), mf); std::find(this->Makefiles.begin(), this->Makefiles.end(), mf);
cmLocalGenerator* lg = cmLocalGenerator* lg =
this->LocalGenerators[std::distance(this->Makefiles.begin(), mfit)]; this->LocalGenerators[std::distance(this->Makefiles.begin(), mfit)];
@@ -1287,8 +1282,7 @@ void cmGlobalGenerator::CreateImportedGenerationObjects(
cmExportBuildFileGenerator* cmGlobalGenerator::GetExportedTargetsFile( cmExportBuildFileGenerator* cmGlobalGenerator::GetExportedTargetsFile(
const std::string& filename) const const std::string& filename) const
{ {
std::map<std::string, cmExportBuildFileGenerator*>::const_iterator it = auto const it = this->BuildExportSets.find(filename);
this->BuildExportSets.find(filename);
return it == this->BuildExportSets.end() ? nullptr : it->second; return it == this->BuildExportSets.end() ? nullptr : it->second;
} }
@@ -1556,12 +1550,12 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
continue; continue;
} }
cmBacktraceRange::const_iterator btIt = {
noconfig_compile_definitions_bts.begin(); auto btIt = noconfig_compile_definitions_bts.begin();
for (cmStringRange::const_iterator it = auto it = noconfig_compile_definitions.begin();
noconfig_compile_definitions.begin(); for (; it != noconfig_compile_definitions.end(); ++it, ++btIt) {
it != noconfig_compile_definitions.end(); ++it, ++btIt) { t->InsertCompileDefinition(*it, *btIt);
t->InsertCompileDefinition(*it, *btIt); }
} }
cmPolicies::PolicyStatus polSt = cmPolicies::PolicyStatus polSt =
@@ -2072,8 +2066,7 @@ void cmGlobalGenerator::GetEnabledLanguages(
int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const
{ {
std::map<std::string, int>::const_iterator it = auto const it = this->LanguageToLinkerPreference.find(lang);
this->LanguageToLinkerPreference.find(lang);
if (it != this->LanguageToLinkerPreference.end()) { if (it != this->LanguageToLinkerPreference.end()) {
return it->second; return it->second;
} }
@@ -2100,9 +2093,9 @@ void cmGlobalGenerator::FillProjectMap()
cmMakefile* cmGlobalGenerator::FindMakefile(const std::string& start_dir) const cmMakefile* cmGlobalGenerator::FindMakefile(const std::string& start_dir) const
{ {
MakefileMap::const_iterator i = this->MakefileSearchIndex.find(start_dir); auto const it = this->MakefileSearchIndex.find(start_dir);
if (i != this->MakefileSearchIndex.end()) { if (it != this->MakefileSearchIndex.end()) {
return i->second; return it->second;
} }
return nullptr; return nullptr;
} }
@@ -2110,10 +2103,9 @@ cmMakefile* cmGlobalGenerator::FindMakefile(const std::string& start_dir) const
cmLocalGenerator* cmGlobalGenerator::FindLocalGenerator( cmLocalGenerator* cmGlobalGenerator::FindLocalGenerator(
cmDirectoryId const& id) const cmDirectoryId const& id) const
{ {
LocalGeneratorMap::const_iterator i = auto const it = this->LocalGeneratorSearchIndex.find(id.String);
this->LocalGeneratorSearchIndex.find(id.String); if (it != this->LocalGeneratorSearchIndex.end()) {
if (i != this->LocalGeneratorSearchIndex.end()) { return it->second;
return i->second;
} }
return nullptr; return nullptr;
} }
@@ -2187,9 +2179,9 @@ void cmGlobalGenerator::IndexLocalGenerator(cmLocalGenerator* lg)
cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const
{ {
TargetMap::const_iterator i = this->TargetSearchIndex.find(name); auto const it = this->TargetSearchIndex.find(name);
if (i != this->TargetSearchIndex.end()) { if (it != this->TargetSearchIndex.end()) {
return i->second; return it->second;
} }
return nullptr; return nullptr;
} }
@@ -2197,10 +2189,9 @@ cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const
cmGeneratorTarget* cmGlobalGenerator::FindGeneratorTargetImpl( cmGeneratorTarget* cmGlobalGenerator::FindGeneratorTargetImpl(
std::string const& name) const std::string const& name) const
{ {
GeneratorTargetMap::const_iterator i = auto const it = this->GeneratorTargetSearchIndex.find(name);
this->GeneratorTargetSearchIndex.find(name); if (it != this->GeneratorTargetSearchIndex.end()) {
if (i != this->GeneratorTargetSearchIndex.end()) { return it->second;
return i->second;
} }
return nullptr; return nullptr;
} }
@@ -2209,8 +2200,7 @@ cmTarget* cmGlobalGenerator::FindTarget(const std::string& name,
bool excludeAliases) const bool excludeAliases) const
{ {
if (!excludeAliases) { if (!excludeAliases) {
std::map<std::string, std::string>::const_iterator ai = auto const ai = this->AliasTargets.find(name);
this->AliasTargets.find(name);
if (ai != this->AliasTargets.end()) { if (ai != this->AliasTargets.end()) {
return this->FindTargetImpl(ai->second); return this->FindTargetImpl(ai->second);
} }
@@ -2221,8 +2211,7 @@ cmTarget* cmGlobalGenerator::FindTarget(const std::string& name,
cmGeneratorTarget* cmGlobalGenerator::FindGeneratorTarget( cmGeneratorTarget* cmGlobalGenerator::FindGeneratorTarget(
const std::string& name) const const std::string& name) const
{ {
std::map<std::string, std::string>::const_iterator ai = auto const ai = this->AliasTargets.find(name);
this->AliasTargets.find(name);
if (ai != this->AliasTargets.end()) { if (ai != this->AliasTargets.end()) {
return this->FindGeneratorTargetImpl(ai->second); return this->FindGeneratorTargetImpl(ai->second);
} }
@@ -2653,8 +2642,7 @@ bool cmGlobalGenerator::ShouldStripResourcePath(cmMakefile* mf) const
std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage( std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage(
std::string const& l) const std::string const& l) const
{ {
std::map<std::string, std::string>::const_iterator it = auto const it = this->LanguageToOriginalSharedLibFlags.find(l);
this->LanguageToOriginalSharedLibFlags.find(l);
if (it != this->LanguageToOriginalSharedLibFlags.end()) { if (it != this->LanguageToOriginalSharedLibFlags.end()) {
return it->second; return it->second;
} }
@@ -2875,8 +2863,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
fname = line.substr(33); fname = line.substr(33);
// Look for a hash for this file's rule. // Look for a hash for this file's rule.
std::map<std::string, RuleHash>::const_iterator rhi = auto const rhi = this->RuleHashes.find(fname);
this->RuleHashes.find(fname);
if (rhi != this->RuleHashes.end()) { if (rhi != this->RuleHashes.end()) {
// Compare the rule hash in the file to that we were given. // Compare the rule hash in the file to that we were given.
if (strncmp(line.c_str(), rhi->second.Data, 32) != 0) { if (strncmp(line.c_str(), rhi->second.Data, 32) != 0) {
@@ -3015,8 +3002,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
for (std::string const& c : configs) { for (std::string const& c : configs) {
target->GetSourceFiles(sources, c); target->GetSourceFiles(sources, c);
} }
std::vector<cmSourceFile*>::const_iterator sourcesEnd = auto const sourcesEnd = cmRemoveDuplicates(sources);
cmRemoveDuplicates(sources);
for (cmSourceFile* sf : cmMakeRange(sources.cbegin(), sourcesEnd)) { for (cmSourceFile* sf : cmMakeRange(sources.cbegin(), sourcesEnd)) {
Json::Value& lj_source = lj_sources.append(Json::objectValue); Json::Value& lj_source = lj_sources.append(Json::objectValue);
std::string const& sfp = sf->GetFullPath(); std::string const& sfp = sf->GetFullPath();