summaryrefslogtreecommitdiff
path: root/Source/cmComputeLinkDepends.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmComputeLinkDepends.cxx')
-rw-r--r--Source/cmComputeLinkDepends.cxx66
1 files changed, 29 insertions, 37 deletions
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 186deb60c..7a9e2b7f6 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -2,7 +2,16 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmComputeLinkDepends.h"
-#include "cmAlgorithms.h"
+#include <algorithm>
+#include <cassert>
+#include <cstdio>
+#include <cstring>
+#include <iterator>
+#include <sstream>
+#include <utility>
+
+#include <cm/memory>
+
#include "cmComputeComponentGraph.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
@@ -11,18 +20,10 @@
#include "cmMakefile.h"
#include "cmRange.h"
#include "cmStateTypes.h"
-#include "cmSystemTools.h"
+#include "cmStringAlgorithms.h"
#include "cmTarget.h"
#include "cmake.h"
-#include <algorithm>
-#include <assert.h>
-#include <iterator>
-#include <sstream>
-#include <stdio.h>
-#include <string.h>
-#include <utility>
-
/*
This file computes an ordered list of link items to use when linking a
@@ -199,11 +200,7 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target,
this->CCG = nullptr;
}
-cmComputeLinkDepends::~cmComputeLinkDepends()
-{
- cmDeleteAll(this->InferredDependSets);
- delete this->CCG;
-}
+cmComputeLinkDepends::~cmComputeLinkDepends() = default;
void cmComputeLinkDepends::SetOldLinkDirMode(bool b)
{
@@ -282,10 +279,9 @@ std::map<cmLinkItem, int>::iterator cmComputeLinkDepends::AllocateLinkEntry(
{
std::map<cmLinkItem, int>::value_type index_entry(
item, static_cast<int>(this->EntryList.size()));
- std::map<cmLinkItem, int>::iterator lei =
- this->LinkEntryIndex.insert(index_entry).first;
+ auto lei = this->LinkEntryIndex.insert(index_entry).first;
this->EntryList.emplace_back();
- this->InferredDependSets.push_back(nullptr);
+ this->InferredDependSets.emplace_back();
this->EntryConstraintGraph.emplace_back();
return lei;
}
@@ -293,7 +289,7 @@ std::map<cmLinkItem, int>::iterator cmComputeLinkDepends::AllocateLinkEntry(
int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item)
{
// Check if the item entry has already been added.
- std::map<cmLinkItem, int>::iterator lei = this->LinkEntryIndex.find(item);
+ auto lei = this->LinkEntryIndex.find(item);
if (lei != this->LinkEntryIndex.end()) {
// Yes. We do not need to follow the item's dependencies again.
return lei->second;
@@ -318,15 +314,14 @@ int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item)
this->BFSQueue.push(qe);
} else {
// Look for an old-style <item>_LIB_DEPENDS variable.
- std::string var = entry.Item;
- var += "_LIB_DEPENDS";
+ std::string var = cmStrCat(entry.Item, "_LIB_DEPENDS");
if (const char* val = this->Makefile->GetDefinition(var)) {
// The item dependencies are known. Follow them.
BFSEntry qe = { index, val };
this->BFSQueue.push(qe);
} else if (!entry.IsFlag) {
// The item dependencies are not known. We need to infer them.
- this->InferredDependSets[index] = new DependSetList;
+ this->InferredDependSets[index].Initialized = true;
}
}
@@ -394,8 +389,7 @@ void cmComputeLinkDepends::QueueSharedDependencies(
void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
{
// Check if the target already has an entry.
- std::map<cmLinkItem, int>::iterator lei =
- this->LinkEntryIndex.find(dep.Item);
+ auto lei = this->LinkEntryIndex.find(dep.Item);
if (lei == this->LinkEntryIndex.end()) {
// Allocate a spot for the item entry.
lei = this->AllocateLinkEntry(dep.Item);
@@ -436,8 +430,7 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
// This is called to add the dependencies named by
// <item>_LIB_DEPENDS. The variable contains a semicolon-separated
// list. The list contains link-type;item pairs and just items.
- std::vector<std::string> deplist;
- cmSystemTools::ExpandListArgument(value, deplist);
+ std::vector<std::string> deplist = cmExpandedList(value);
// Look for entries meant for this configuration.
std::vector<cmLinkItem> actual_libs;
@@ -460,8 +453,7 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
// the export_library_dependencies command from CMake 2.4 and
// lower.
if (!haveLLT) {
- std::string var = d;
- var += "_LINK_TYPE";
+ std::string var = cmStrCat(d, "_LINK_TYPE");
if (const char* val = this->Makefile->GetDefinition(var)) {
if (strcmp(val, "debug") == 0) {
llt = DEBUG_LibraryType;
@@ -542,7 +534,7 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index,
}
// If this item needs to have dependencies inferred, do so.
- if (this->InferredDependSets[dependee_index]) {
+ if (this->InferredDependSets[dependee_index].Initialized) {
// Make sure an entry exists to hold the set for the item.
dependSets[dependee_index];
}
@@ -550,7 +542,7 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index,
// Store the inferred dependency sets discovered for this list.
for (auto const& dependSet : dependSets) {
- this->InferredDependSets[dependSet.first]->push_back(dependSet.second);
+ this->InferredDependSets[dependSet.first].push_back(dependSet.second);
}
}
@@ -577,14 +569,14 @@ void cmComputeLinkDepends::InferDependencies()
depender_index < this->InferredDependSets.size(); ++depender_index) {
// Skip items for which dependencies do not need to be inferred or
// for which the inferred dependency sets are empty.
- DependSetList* sets = this->InferredDependSets[depender_index];
- if (!sets || sets->empty()) {
+ DependSetList& sets = this->InferredDependSets[depender_index];
+ if (!sets.Initialized || sets.empty()) {
continue;
}
// Intersect the sets for this item.
- DependSet common = sets->front();
- for (DependSet const& i : cmMakeRange(*sets).advance(1)) {
+ DependSet common = sets.front();
+ for (DependSet const& i : cmMakeRange(sets).advance(1)) {
DependSet intersection;
std::set_intersection(common.begin(), common.end(), i.begin(), i.end(),
std::inserter(intersection, intersection.begin()));
@@ -632,7 +624,8 @@ void cmComputeLinkDepends::OrderLinkEntires()
// the same order in which the items were originally discovered in
// the BFS. This should preserve the original order when no
// constraints disallow it.
- this->CCG = new cmComputeComponentGraph(this->EntryConstraintGraph);
+ this->CCG =
+ cm::make_unique<cmComputeComponentGraph>(this->EntryConstraintGraph);
// The component graph is guaranteed to be acyclic. Start a DFS
// from every entry to compute a topological order for the
@@ -720,8 +713,7 @@ void cmComputeLinkDepends::VisitEntry(int index)
// This entry has now been seen. Update its component.
bool completed = false;
int component = this->CCG->GetComponentMap()[index];
- std::map<int, PendingComponent>::iterator mi =
- this->PendingComponents.find(this->ComponentOrder[component]);
+ auto mi = this->PendingComponents.find(this->ComponentOrder[component]);
if (mi != this->PendingComponents.end()) {
// The entry is in an already pending component.
PendingComponent& pc = mi->second;