diff options
author | Pavel Solodovnikov <hellyeahdominate@gmail.com> | 2017-09-11 13:40:26 +0300 |
---|---|---|
committer | Pavel Solodovnikov <hellyeahdominate@gmail.com> | 2017-09-12 16:22:47 +0300 |
commit | 7d5095796ab616cf9b709036387bb95ab9984141 (patch) | |
tree | c010e922adad95ef86ab4a3ac2a3abd63e9f33ef /Source/cmOutputRequiredFilesCommand.cxx | |
parent | 00975e926199eea21763470e2ab876246e36669a (diff) | |
download | cmake-7d5095796ab616cf9b709036387bb95ab9984141.tar.gz |
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/cmOutputRequiredFilesCommand.cxx')
-rw-r--r-- | Source/cmOutputRequiredFilesCommand.cxx | 64 |
1 files changed, 19 insertions, 45 deletions
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 2fd266a50e..26816cb7fd 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -5,7 +5,6 @@ #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" #include <map> -#include <unordered_map> #include <utility> #include "cmAlgorithms.h" @@ -114,8 +113,9 @@ public: std::set<std::string> uniqueIncludes; std::vector<std::string> orderedAndUniqueIncludes; cmTargets& targets = this->Makefile->GetTargets(); - for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l) { - const char* incDirProp = l->second.GetProperty("INCLUDE_DIRECTORIES"); + for (auto const& target : targets) { + const char* incDirProp = + target.second.GetProperty("INCLUDE_DIRECTORIES"); if (!incDirProp) { continue; } @@ -126,9 +126,7 @@ public: std::vector<std::string> includes; cmSystemTools::ExpandListArgument(incDirs, includes); - for (std::vector<std::string>::const_iterator j = includes.begin(); - j != includes.end(); ++j) { - std::string path = *j; + for (std::string& path : includes) { this->Makefile->ExpandVariablesInString(path); if (uniqueIncludes.insert(path).second) { orderedAndUniqueIncludes.push_back(path); @@ -136,10 +134,8 @@ public: } } - for (std::vector<std::string>::const_iterator it = - orderedAndUniqueIncludes.begin(); - it != orderedAndUniqueIncludes.end(); ++it) { - this->AddSearchPath(*it); + for (std::string const& inc : orderedAndUniqueIncludes) { + this->AddSearchPath(inc); } } @@ -220,10 +216,7 @@ protected: if (cmSystemTools::FileExists(cxxFile.c_str())) { found = true; } - for (std::vector<std::string>::iterator i = - this->IncludeDirectories.begin(); - i != this->IncludeDirectories.end(); ++i) { - std::string path = *i; + for (std::string path : this->IncludeDirectories) { path = path + "/"; path = path + cxxFile; if (cmSystemTools::FileExists(path.c_str())) { @@ -235,10 +228,7 @@ protected: if (cmSystemTools::FileExists(cxxFile.c_str())) { found = true; } - for (std::vector<std::string>::iterator i = - this->IncludeDirectories.begin(); - i != this->IncludeDirectories.end(); ++i) { - std::string path = *i; + for (std::string path : this->IncludeDirectories) { path = path + "/"; path = path + cxxFile; if (cmSystemTools::FileExists(path.c_str())) { @@ -251,10 +241,7 @@ protected: if (cmSystemTools::FileExists(cxxFile.c_str())) { found = true; } - for (std::vector<std::string>::iterator i = - this->IncludeDirectories.begin(); - i != this->IncludeDirectories.end(); ++i) { - std::string path = *i; + for (std::string path : this->IncludeDirectories) { path = path + "/"; path = path + cxxFile; if (cmSystemTools::FileExists(path.c_str())) { @@ -267,10 +254,7 @@ protected: if (cmSystemTools::FileExists(cxxFile.c_str())) { found = true; } - for (std::vector<std::string>::iterator i = - this->IncludeDirectories.begin(); - i != this->IncludeDirectories.end(); ++i) { - std::string path = *i; + for (std::string path : this->IncludeDirectories) { path = path + "/"; path = path + cxxFile; if (cmSystemTools::FileExists(path.c_str())) { @@ -337,10 +321,8 @@ protected: if (!cFile.GetDepends().empty()) { // Dependency hints have been given. Use them to begin the // recursion. - for (std::vector<std::string>::const_iterator file = - cFile.GetDepends().begin(); - file != cFile.GetDepends().end(); ++file) { - this->AddDependency(info, file->c_str()); + for (std::string const& file : cFile.GetDepends()) { + this->AddDependency(info, file.c_str()); } // Found dependency information. We are done. @@ -357,10 +339,7 @@ protected: found = true; } else { // try to guess which include path to use - for (std::vector<std::string>::iterator t = - this->IncludeDirectories.begin(); - t != this->IncludeDirectories.end(); ++t) { - std::string incpath = *t; + for (std::string incpath : this->IncludeDirectories) { if (!incpath.empty() && incpath[incpath.size() - 1] != '/') { incpath = incpath + "/"; } @@ -442,10 +421,7 @@ protected: return fp; } - for (std::vector<std::string>::iterator i = - this->IncludeDirectories.begin(); - i != this->IncludeDirectories.end(); ++i) { - std::string path = *i; + for (std::string path : this->IncludeDirectories) { if (!path.empty() && path[path.size() - 1] != '/') { path = path + "/"; } @@ -532,19 +508,17 @@ void cmOutputRequiredFilesCommand::ListDependencies( // add info to the visited set visited->insert(info); // now recurse with info's dependencies - for (cmDependInformation::DependencySetType::const_iterator d = - info->DependencySet.begin(); - d != info->DependencySet.end(); ++d) { - if (visited->find(*d) == visited->end()) { + for (cmDependInformation* d : info->DependencySet) { + if (visited->find(d) == visited->end()) { if (info->FullPath != "") { - std::string tmp = (*d)->FullPath; + std::string tmp = d->FullPath; std::string::size_type pos = tmp.rfind('.'); if (pos != std::string::npos && (tmp.substr(pos) != ".h")) { tmp = tmp.substr(0, pos); - fprintf(fout, "%s\n", (*d)->FullPath.c_str()); + fprintf(fout, "%s\n", d->FullPath.c_str()); } } - this->ListDependencies(*d, fout, visited); + this->ListDependencies(d, fout, visited); } } } |