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/cmOrderDirectories.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/cmOrderDirectories.cxx')
-rw-r--r-- | Source/cmOrderDirectories.cxx | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 333e313..1ee0578 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -75,9 +75,8 @@ public: void FindImplicitConflicts(std::ostringstream& w) { bool first = true; - for (unsigned int i = 0; i < this->OD->OriginalDirectories.size(); ++i) { + for (std::string const& dir : this->OD->OriginalDirectories) { // Check if this directory conflicts with the entry. - std::string const& dir = this->OD->OriginalDirectories[i]; if (dir != this->Directory && cmSystemTools::GetRealPath(dir) != cmSystemTools::GetRealPath(this->Directory) && @@ -226,12 +225,10 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) this->OD->RemoveLibraryExtension.find(this->FileName)) { std::string lib = this->OD->RemoveLibraryExtension.match(1); std::string ext = this->OD->RemoveLibraryExtension.match(2); - for (std::vector<std::string>::iterator i = - this->OD->LinkExtensions.begin(); - i != this->OD->LinkExtensions.end(); ++i) { - if (*i != ext) { + for (std::string const& LinkExtension : this->OD->LinkExtensions) { + if (LinkExtension != ext) { std::string fname = lib; - fname += *i; + fname += LinkExtension; if (this->FileMayConflict(dir, fname)) { return true; } @@ -346,9 +343,8 @@ void cmOrderDirectories::SetImplicitDirectories( std::set<std::string> const& implicitDirs) { this->ImplicitDirectories.clear(); - for (std::set<std::string>::const_iterator i = implicitDirs.begin(); - i != implicitDirs.end(); ++i) { - this->ImplicitDirectories.insert(this->GetRealPath(*i)); + for (std::string const& implicitDir : implicitDirs) { + this->ImplicitDirectories.insert(this->GetRealPath(implicitDir)); } } @@ -375,8 +371,8 @@ void cmOrderDirectories::CollectOriginalDirectories() this->AddOriginalDirectories(this->UserDirectories); // Add directories containing constraints. - for (unsigned int i = 0; i < this->ConstraintEntries.size(); ++i) { - this->ConstraintEntries[i]->AddDirectory(); + for (cmOrderDirectoriesConstraint* entry : this->ConstraintEntries) { + entry->AddDirectory(); } // Add language runtime directories last. @@ -400,20 +396,19 @@ int cmOrderDirectories::AddOriginalDirectory(std::string const& dir) void cmOrderDirectories::AddOriginalDirectories( std::vector<std::string> const& dirs) { - for (std::vector<std::string>::const_iterator di = dirs.begin(); - di != dirs.end(); ++di) { + for (std::string const& dir : dirs) { // We never explicitly specify implicit link directories. - if (this->IsImplicitDirectory(*di)) { + if (this->IsImplicitDirectory(dir)) { continue; } // Skip the empty string. - if (di->empty()) { + if (dir.empty()) { continue; } // Add this directory. - this->AddOriginalDirectory(*di); + this->AddOriginalDirectory(dir); } } @@ -442,16 +437,15 @@ void cmOrderDirectories::FindConflicts() } // Clean up the conflict graph representation. - for (std::vector<ConflictList>::iterator i = this->ConflictGraph.begin(); - i != this->ConflictGraph.end(); ++i) { + for (ConflictList& cl : this->ConflictGraph) { // Sort the outgoing edges for each graph node so that the // original order will be preserved as much as possible. - std::sort(i->begin(), i->end()); + std::sort(cl.begin(), cl.end()); // Make the edge list unique so cycle detection will be reliable. ConflictList::iterator last = - std::unique(i->begin(), i->end(), cmOrderDirectoriesCompare()); - i->erase(last, i->end()); + std::unique(cl.begin(), cl.end(), cmOrderDirectoriesCompare()); + cl.erase(last, cl.end()); } // Check items in implicit link directories. @@ -463,12 +457,12 @@ void cmOrderDirectories::FindImplicitConflicts() // Check for items in implicit link directories that have conflicts // in the explicit directories. std::ostringstream conflicts; - for (unsigned int i = 0; i < this->ImplicitDirEntries.size(); ++i) { - this->ImplicitDirEntries[i]->FindImplicitConflicts(conflicts); + for (cmOrderDirectoriesConstraint* entry : this->ImplicitDirEntries) { + entry->FindImplicitConflicts(conflicts); } // Skip warning if there were no conflicts. - std::string text = conflicts.str(); + std::string const text = conflicts.str(); if (text.empty()) { return; } @@ -515,8 +509,8 @@ void cmOrderDirectories::VisitDirectory(unsigned int i) // Visit the neighbors of the node first. ConflictList const& clist = this->ConflictGraph[i]; - for (ConflictList::const_iterator j = clist.begin(); j != clist.end(); ++j) { - this->VisitDirectory(j->first); + for (ConflictPair const& j : clist) { + this->VisitDirectory(j.first); } // Now that all directories required to come before this one have @@ -542,10 +536,9 @@ void cmOrderDirectories::DiagnoseCycle() for (unsigned int i = 0; i < this->ConflictGraph.size(); ++i) { ConflictList const& clist = this->ConflictGraph[i]; e << " dir " << i << " is [" << this->OriginalDirectories[i] << "]\n"; - for (ConflictList::const_iterator j = clist.begin(); j != clist.end(); - ++j) { - e << " dir " << j->first << " must precede it due to "; - this->ConstraintEntries[j->second]->Report(e); + for (ConflictPair const& j : clist) { + e << " dir " << j.first << " must precede it due to "; + this->ConstraintEntries[j.second]->Report(e); e << "\n"; } } |