diff options
author | Pavel Solodovnikov <hellyeahdominate@gmail.com> | 2017-09-11 10:40:26 (GMT) |
---|---|---|
committer | Pavel Solodovnikov <hellyeahdominate@gmail.com> | 2017-09-12 13:22:47 (GMT) |
commit | 7d5095796ab616cf9b709036387bb95ab9984141 (patch) | |
tree | c010e922adad95ef86ab4a3ac2a3abd63e9f33ef /Source/cmNinjaNormalTargetGenerator.cxx | |
parent | 00975e926199eea21763470e2ab876246e36669a (diff) | |
download | CMake-7d5095796ab616cf9b709036387bb95ab9984141.zip CMake-7d5095796ab616cf9b709036387bb95ab9984141.tar.gz CMake-7d5095796ab616cf9b709036387bb95ab9984141.tar.bz2 |
Meta: modernize old-fashioned loops to range-based `for`.
Changes done via `clang-tidy` with some manual fine-tuning
for the variable naming and `auto` type deduction
where appropriate.
Diffstat (limited to 'Source/cmNinjaNormalTargetGenerator.cxx')
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 60 |
1 files changed, 24 insertions, 36 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index ddac20e..32377f8 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -10,7 +10,6 @@ #include <sstream> #include "cmAlgorithms.h" -#include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" @@ -33,6 +32,8 @@ #include "cm_auto_ptr.hxx" #include "cmake.h" +class cmCustomCommand; + cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator( cmGeneratorTarget* target) : cmNinjaTargetGenerator(target) @@ -112,17 +113,14 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules() std::vector<cmSourceFile const*> sourceFiles; this->GetGeneratorTarget()->GetObjectSources( sourceFiles, this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); - for (std::vector<cmSourceFile const*>::const_iterator i = - sourceFiles.begin(); - i != sourceFiles.end(); ++i) { - const std::string& lang = (*i)->GetLanguage(); + for (cmSourceFile const* sf : sourceFiles) { + std::string const lang = sf->GetLanguage(); if (!lang.empty()) { languages.insert(lang); } } - for (std::set<std::string>::const_iterator l = languages.begin(); - l != languages.end(); ++l) { - this->WriteLanguageRules(*l); + for (std::string const& language : languages) { + this->WriteLanguageRules(language); } } @@ -248,11 +246,10 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile) // Rule for linking library/executable. std::vector<std::string> linkCmds = this->ComputeDeviceLinkCmd(); - for (std::vector<std::string>::iterator i = linkCmds.begin(); - i != linkCmds.end(); ++i) { - *i = launcher + *i; + for (std::string& linkCmd : linkCmds) { + linkCmd = launcher + linkCmd; rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), - *i, vars); + linkCmd, vars); } // If there is no ranlib the command will be ":". Skip it. @@ -373,11 +370,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) // Rule for linking library/executable. std::vector<std::string> linkCmds = this->ComputeLinkCmd(); - for (std::vector<std::string>::iterator i = linkCmds.begin(); - i != linkCmds.end(); ++i) { - *i = launcher + *i; + for (std::string& linkCmd : linkCmds) { + linkCmd = launcher + linkCmd; rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), - *i, vars); + linkCmd, vars); } // If there is no ranlib the command will be ":". Skip it. @@ -731,10 +727,8 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() &postBuildCmdLines }; for (unsigned i = 0; i != 3; ++i) { - for (std::vector<cmCustomCommand>::const_iterator ci = - cmdLists[i]->begin(); - ci != cmdLists[i]->end(); ++ci) { - cmCustomCommandGenerator ccg(*ci, cfgName, this->GetLocalGenerator()); + for (cmCustomCommand const& cc : *cmdLists[i]) { + cmCustomCommandGenerator ccg(cc, cfgName, this->GetLocalGenerator()); localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]); std::vector<std::string> const& ccByproducts = ccg.GetByproducts(); std::transform(ccByproducts.begin(), ccByproducts.end(), @@ -960,10 +954,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() &postBuildCmdLines }; for (unsigned i = 0; i != 3; ++i) { - for (std::vector<cmCustomCommand>::const_iterator ci = - cmdLists[i]->begin(); - ci != cmdLists[i]->end(); ++ci) { - cmCustomCommandGenerator ccg(*ci, cfgName, this->GetLocalGenerator()); + for (cmCustomCommand const& cc : *cmdLists[i]) { + cmCustomCommandGenerator ccg(cc, cfgName, this->GetLocalGenerator()); localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]); std::vector<std::string> const& ccByproducts = ccg.GetByproducts(); std::transform(ccByproducts.begin(), ccByproducts.end(), @@ -993,17 +985,15 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() if (mdi->WindowsExportAllSymbols) { cmNinjaDeps objs = this->GetObjects(); - for (cmNinjaDeps::iterator i = objs.begin(); i != objs.end(); ++i) { - if (cmHasLiteralSuffix(*i, ".obj")) { - fout << *i << "\n"; + for (std::string const& obj : objs) { + if (cmHasLiteralSuffix(obj, ".obj")) { + fout << obj << "\n"; } } } - for (std::vector<cmSourceFile const*>::const_iterator i = - mdi->Sources.begin(); - i != mdi->Sources.end(); ++i) { - fout << (*i)->GetFullPath() << "\n"; + for (cmSourceFile const* src : mdi->Sources) { + fout << src->GetFullPath() << "\n"; } } // If we have any PRE_LINK commands, we need to go back to CMAKE_BINARY_DIR @@ -1050,11 +1040,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // Ninja should restat after linking if and only if there are byproducts. vars["RESTAT"] = byproducts.empty() ? "" : "1"; - for (cmNinjaDeps::const_iterator oi = byproducts.begin(), - oe = byproducts.end(); - oi != oe; ++oi) { - this->GetGlobalGenerator()->SeenCustomCommandOutput(*oi); - outputs.push_back(*oi); + for (std::string const& o : byproducts) { + this->GetGlobalGenerator()->SeenCustomCommandOutput(o); + outputs.push_back(o); } // Write the build statement for this target. |