From 50abdaab936e6b1a7e40d17affae03f89ac00da6 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 27 Jan 2023 11:03:32 -0500 Subject: IWYU: exclude `__decay_and_strip` as well --- Utilities/IWYU/mapping.imp | 1 + 1 file changed, 1 insertion(+) diff --git a/Utilities/IWYU/mapping.imp b/Utilities/IWYU/mapping.imp index b0ed911..d1a585a 100644 --- a/Utilities/IWYU/mapping.imp +++ b/Utilities/IWYU/mapping.imp @@ -79,6 +79,7 @@ # Use '-Xiwyu -v7' to see the fully qualified names that need this. # TODO: Can this be simplified with an @-expression? #{ symbol: [ "@std::__decay_and_strip<.*>::__type", private, "\"cmConfigure.h\"", public ] }, + { symbol: [ "std::__decay_and_strip::__type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__decay_and_strip::__type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__decay_and_strip::__type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__decay_and_strip::__type", private, "\"cmConfigure.h\"", public ] }, -- cgit v0.12 From 65c0a64dc5bc7cb0e13721500bdd754b6630e8ea Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 26 Jan 2023 13:23:42 -0500 Subject: cmComputeComponentGraph: use a name for "invalid component" This is to prepare for making the graph use `size_t`. --- Source/cmComputeComponentGraph.cxx | 8 +++++--- Source/cmComputeComponentGraph.h | 2 ++ Source/cmComputeLinkDepends.cxx | 27 +++++++++++++++++---------- Source/cmComputeLinkDepends.h | 5 +++-- Source/cmComputeTargetDepends.cxx | 4 ++-- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/Source/cmComputeComponentGraph.cxx b/Source/cmComputeComponentGraph.cxx index 6591fb1..6826f23 100644 --- a/Source/cmComputeComponentGraph.cxx +++ b/Source/cmComputeComponentGraph.cxx @@ -5,6 +5,8 @@ #include #include +const int cmComputeComponentGraph::INVALID_COMPONENT = -1; + cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input) : InputGraph(input) { @@ -30,7 +32,7 @@ void cmComputeComponentGraph::Tarjan() this->TarjanEntries.resize(0); this->TarjanEntries.resize(n, entry); this->TarjanComponents.resize(0); - this->TarjanComponents.resize(n, -1); + this->TarjanComponents.resize(n, INVALID_COMPONENT); this->TarjanWalkId = 0; this->TarjanVisited.resize(0); this->TarjanVisited.resize(n, 0); @@ -52,7 +54,7 @@ void cmComputeComponentGraph::TarjanVisit(int i) // Initialize the entry. this->TarjanEntries[i].Root = i; - this->TarjanComponents[i] = -1; + this->TarjanComponents[i] = INVALID_COMPONENT; this->TarjanEntries[i].VisitIndex = ++this->TarjanIndex; this->TarjanStack.push(i); @@ -77,7 +79,7 @@ void cmComputeComponentGraph::TarjanVisit(int i) // If the destination has not yet been assigned to a component, // check if it has a better root for the current object. - if (this->TarjanComponents[j] < 0) { + if (this->TarjanComponents[j] == INVALID_COMPONENT) { if (this->TarjanEntries[this->TarjanEntries[j].Root].VisitIndex < this->TarjanEntries[this->TarjanEntries[i].Root].VisitIndex) { this->TarjanEntries[i].Root = this->TarjanEntries[j].Root; diff --git a/Source/cmComputeComponentGraph.h b/Source/cmComputeComponentGraph.h index 1d1d134..76879c7 100644 --- a/Source/cmComputeComponentGraph.h +++ b/Source/cmComputeComponentGraph.h @@ -53,6 +53,8 @@ public: return this->TarjanComponents; } + static const int INVALID_COMPONENT; + private: void TransferEdges(); diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 8e05fac..d72a1fe 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -518,7 +518,10 @@ void cmComputeLinkDepends::AddLinkObject(cmLinkItem const& item) void cmComputeLinkDepends::FollowLinkEntry(BFSEntry qe) { // Get this entry representation. - int depender_index = qe.GroupIndex == -1 ? qe.Index : qe.GroupIndex; + int depender_index = + qe.GroupIndex == cmComputeComponentGraph::INVALID_COMPONENT + ? qe.Index + : qe.GroupIndex; LinkEntry const& entry = this->EntryList[qe.Index]; // Follow the item's dependencies. @@ -679,13 +682,15 @@ void cmComputeLinkDepends::AddDirectLinkEntries() // Add direct link dependencies in this configuration. cmLinkImplementation const* impl = this->Target->GetLinkImplementation( this->Config, cmGeneratorTarget::LinkInterfaceFor::Link); - this->AddLinkEntries(-1, impl->Libraries); + this->AddLinkEntries(cmComputeComponentGraph::INVALID_COMPONENT, + impl->Libraries); this->AddLinkObjects(impl->Objects); for (auto const& language : impl->Languages) { auto runtimeEntries = impl->LanguageRuntimeLibraries.find(language); if (runtimeEntries != impl->LanguageRuntimeLibraries.end()) { - this->AddLinkEntries(-1, runtimeEntries->second); + this->AddLinkEntries(cmComputeComponentGraph::INVALID_COMPONENT, + runtimeEntries->second); } } for (cmLinkItem const& wi : impl->WrongConfigLibraries) { @@ -702,7 +707,8 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index, std::string feature = LinkEntry::DEFAULT; bool inGroup = false; - std::pair groupIndex{ -1, false }; + std::pair groupIndex{ cmComputeComponentGraph::INVALID_COMPONENT, + false }; std::vector groupItems; // Loop over the libraries linked directly by the depender. @@ -719,7 +725,7 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index, feature = ExtractFeature(item.AsStr()); // emit a warning if an undefined feature is used as part of // an imported target - if (depender_index >= 0) { + if (depender_index != cmComputeComponentGraph::INVALID_COMPONENT) { const auto& depender = this->EntryList[depender_index]; if (depender.Target != nullptr && depender.Target->IsImported() && !IsFeatureSupported(this->Makefile, this->LinkLanguage, feature)) { @@ -752,7 +758,7 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index, entry.Feature = ExtractGroupFeature(item.AsStr()); } inGroup = true; - if (depender_index >= 0) { + if (depender_index != cmComputeComponentGraph::INVALID_COMPONENT) { this->EntryConstraintGraph[depender_index].emplace_back( groupIndex.first, false, false, cmListFileBacktrace()); } else { @@ -775,7 +781,8 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index, continue; } - if (depender_index >= 0 && inGroup) { + if (depender_index != cmComputeComponentGraph::INVALID_COMPONENT && + inGroup) { const auto& depender = this->EntryList[depender_index]; const auto& groupFeature = this->EntryList[groupIndex.first].Feature; if (depender.Target != nullptr && depender.Target->IsImported() && @@ -913,7 +920,7 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index, for (auto index : indexes) { // The dependee must come after the depender. - if (depender_index >= 0) { + if (depender_index != cmComputeComponentGraph::INVALID_COMPONENT) { this->EntryConstraintGraph[depender_index].emplace_back( index, false, false, cmListFileBacktrace()); } else { @@ -962,7 +969,7 @@ cmLinkItem cmComputeLinkDepends::ResolveLinkItem(int depender_index, { // Look for a target in the scope of the depender. cmGeneratorTarget const* from = this->Target; - if (depender_index >= 0) { + if (depender_index != cmComputeComponentGraph::INVALID_COMPONENT) { if (cmGeneratorTarget const* depender = this->EntryList[depender_index].Target) { from = depender; @@ -1140,7 +1147,7 @@ void cmComputeLinkDepends::OrderLinkEntries() this->ComponentOrderId = n; // Run in reverse order so the topological order will preserve the // original order where there are no constraints. - for (int c = n - 1; c >= 0; --c) { + for (int c = n - 1; c != cmComputeComponentGraph::INVALID_COMPONENT; --c) { this->VisitComponent(c); } diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 8cc916a..1bf0ff1 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -93,8 +93,9 @@ private: std::pair::iterator, bool> AllocateLinkEntry( cmLinkItem const& item); - std::pair AddLinkEntry(cmLinkItem const& item, - int groupIndex = -1); + std::pair AddLinkEntry( + cmLinkItem const& item, + int groupIndex = cmComputeComponentGraph::INVALID_COMPONENT); void AddLinkObject(cmLinkItem const& item); void AddVarLinkEntries(int depender_index, const char* value); void AddDirectLinkEntries(); diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 3ff16a4..337bafb 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -693,7 +693,7 @@ bool cmComputeTargetDepends::IntraComponent(std::vector const& cmap, } // Prepend to a linear linked-list of intra-component edges. - if (*head >= 0) { + if (*head != cmComputeComponentGraph::INVALID_COMPONENT) { this->FinalGraph[i].emplace_back(*head, false, false, cmListFileBacktrace()); } else { @@ -721,7 +721,7 @@ bool cmComputeTargetDepends::ComputeFinalDepends( this->ComponentTail.resize(components.size()); int nc = static_cast(components.size()); for (int c = 0; c < nc; ++c) { - int head = -1; + int head = cmComputeComponentGraph::INVALID_COMPONENT; std::set emitted; NodeList const& nl = components[c]; for (int ni : cmReverseRange(nl)) { -- cgit v0.12 From 91a26ce04136ccafbe37a17afc2efb01abf0992e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 26 Jan 2023 13:25:37 -0500 Subject: cmComputeComponentGraph: use `size_t` for component indices This avoids using casts everywhere when dealing with the sizes. --- Source/cmComputeComponentGraph.cxx | 27 +++++---- Source/cmComputeComponentGraph.h | 25 ++++---- Source/cmComputeLinkDepends.cxx | 103 +++++++++++++++++---------------- Source/cmComputeLinkDepends.h | 59 +++++++++---------- Source/cmComputeTargetDepends.cxx | 113 +++++++++++++++++++------------------ Source/cmComputeTargetDepends.h | 31 +++++----- Source/cmGraphAdjacencyList.h | 9 +-- 7 files changed, 191 insertions(+), 176 deletions(-) diff --git a/Source/cmComputeComponentGraph.cxx b/Source/cmComputeComponentGraph.cxx index 6826f23..16540c3 100644 --- a/Source/cmComputeComponentGraph.cxx +++ b/Source/cmComputeComponentGraph.cxx @@ -4,8 +4,11 @@ #include #include +#include +#include -const int cmComputeComponentGraph::INVALID_COMPONENT = -1; +const size_t cmComputeComponentGraph::INVALID_COMPONENT = + std::numeric_limits::max(); cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input) : InputGraph(input) @@ -27,7 +30,7 @@ void cmComputeComponentGraph::Compute() void cmComputeComponentGraph::Tarjan() { - int n = static_cast(this->InputGraph.size()); + size_t n = this->InputGraph.size(); TarjanEntry entry = { 0, 0 }; this->TarjanEntries.resize(0); this->TarjanEntries.resize(n, entry); @@ -36,7 +39,7 @@ void cmComputeComponentGraph::Tarjan() this->TarjanWalkId = 0; this->TarjanVisited.resize(0); this->TarjanVisited.resize(n, 0); - for (int i = 0; i < n; ++i) { + for (size_t i = 0; i < n; ++i) { // Start a new DFS from this node if it has never been visited. if (!this->TarjanVisited[i]) { assert(this->TarjanStack.empty()); @@ -47,7 +50,7 @@ void cmComputeComponentGraph::Tarjan() } } -void cmComputeComponentGraph::TarjanVisit(int i) +void cmComputeComponentGraph::TarjanVisit(size_t i) { // We are now visiting this node. this->TarjanVisited[i] = this->TarjanWalkId; @@ -61,7 +64,7 @@ void cmComputeComponentGraph::TarjanVisit(int i) // Follow outgoing edges. EdgeList const& nl = this->InputGraph[i]; for (cmGraphEdge const& ni : nl) { - int j = ni; + size_t j = ni; // Ignore edges to nodes that have been reached by a previous DFS // walk. Since we did not reach the current node from that walk @@ -90,12 +93,12 @@ void cmComputeComponentGraph::TarjanVisit(int i) // Check if we have found a component. if (this->TarjanEntries[i].Root == i) { // Yes. Create it. - int c = static_cast(this->Components.size()); + size_t c = this->Components.size(); this->Components.emplace_back(); NodeList& component = this->Components[c]; // Populate the component list. - int j; + size_t j; do { // Get the next member of the component. j = this->TarjanStack.top(); @@ -118,13 +121,13 @@ void cmComputeComponentGraph::TransferEdges() { // Map inter-component edges in the original graph to edges in the // component graph. - int n = static_cast(this->InputGraph.size()); - for (int i = 0; i < n; ++i) { - int i_component = this->TarjanComponents[i]; + size_t n = this->InputGraph.size(); + for (size_t i = 0; i < n; ++i) { + size_t i_component = this->TarjanComponents[i]; EdgeList const& nl = this->InputGraph[i]; for (cmGraphEdge const& ni : nl) { - int j = ni; - int j_component = this->TarjanComponents[j]; + size_t j = ni; + size_t j_component = this->TarjanComponents[j]; if (i_component != j_component) { // We do not attempt to combine duplicate edges, but instead // store the inter-component edges with suitable multiplicity. diff --git a/Source/cmComputeComponentGraph.h b/Source/cmComputeComponentGraph.h index 76879c7..878e36d 100644 --- a/Source/cmComputeComponentGraph.h +++ b/Source/cmComputeComponentGraph.h @@ -4,6 +4,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include #include @@ -35,7 +36,7 @@ public: /** Get the adjacency list of the component graph. */ Graph const& GetComponentGraph() const { return this->ComponentGraph; } - EdgeList const& GetComponentGraphEdges(int c) const + EdgeList const& GetComponentGraphEdges(size_t c) const { return this->ComponentGraph[c]; } @@ -45,15 +46,15 @@ public: { return this->Components; } - NodeList const& GetComponent(int c) const { return this->Components[c]; } + NodeList const& GetComponent(size_t c) const { return this->Components[c]; } /** Get map from original node index to component index. */ - std::vector const& GetComponentMap() const + std::vector const& GetComponentMap() const { return this->TarjanComponents; } - static const int INVALID_COMPONENT; + static const size_t INVALID_COMPONENT; private: void TransferEdges(); @@ -64,18 +65,18 @@ private: // Tarjan's algorithm. struct TarjanEntry { - int Root; - int VisitIndex; + size_t Root; + size_t VisitIndex; }; - std::vector TarjanVisited; - std::vector TarjanComponents; + std::vector TarjanVisited; + std::vector TarjanComponents; std::vector TarjanEntries; std::vector Components; - std::stack TarjanStack; - int TarjanWalkId; - int TarjanIndex; + std::stack TarjanStack; + size_t TarjanWalkId; + size_t TarjanIndex; void Tarjan(); - void TarjanVisit(int i); + void TarjanVisit(size_t i); // Connected components. }; diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index d72a1fe..5f408d0 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -375,8 +376,8 @@ cmComputeLinkDepends::Compute() // Compute the final set of link entries. // Iterate in reverse order so we can keep only the last occurrence // of a shared library. - std::set emitted; - for (int i : cmReverseRange(this->FinalLinkOrder)) { + std::set emitted; + for (size_t i : cmReverseRange(this->FinalLinkOrder)) { LinkEntry const& e = this->EntryList[i]; cmGeneratorTarget const* t = e.Target; // Entries that we know the linker will re-use do not need to be repeated. @@ -388,7 +389,7 @@ cmComputeLinkDepends::Compute() // Place explicitly linked object files in the front. The linker will // always use them anyway, and they may depend on symbols from libraries. // Append in reverse order since we reverse the final order below. - for (int i : cmReverseRange(this->ObjectEntries)) { + for (size_t i : cmReverseRange(this->ObjectEntries)) { this->FinalLinkEntries.emplace_back(this->EntryList[i]); } // Reverse the resulting order since we iterated in reverse. @@ -432,11 +433,11 @@ std::string const& cmComputeLinkDepends::GetCurrentFeature( return it == this->LinkLibraryOverride.end() ? defaultFeature : it->second; } -std::pair::iterator, bool> +std::pair::iterator, bool> cmComputeLinkDepends::AllocateLinkEntry(cmLinkItem const& item) { - std::map::value_type index_entry( - item, static_cast(this->EntryList.size())); + std::map::value_type index_entry( + item, static_cast(this->EntryList.size())); auto lei = this->LinkEntryIndex.insert(index_entry); if (lei.second) { this->EntryList.emplace_back(); @@ -446,8 +447,8 @@ cmComputeLinkDepends::AllocateLinkEntry(cmLinkItem const& item) return lei; } -std::pair cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item, - int groupIndex) +std::pair cmComputeLinkDepends::AddLinkEntry( + cmLinkItem const& item, size_t groupIndex) { // Allocate a spot for the item entry. auto lei = this->AllocateLinkEntry(item); @@ -459,7 +460,7 @@ std::pair cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item, } // Initialize the item entry. - int index = lei.first->second; + size_t index = lei.first->second; LinkEntry& entry = this->EntryList[index]; entry.Item = BT(item.AsStr(), item.Backtrace); entry.Target = item.Target; @@ -506,7 +507,7 @@ void cmComputeLinkDepends::AddLinkObject(cmLinkItem const& item) } // Initialize the item entry. - int index = lei.first->second; + size_t index = lei.first->second; LinkEntry& entry = this->EntryList[index]; entry.Item = BT(item.AsStr(), item.Backtrace); entry.Kind = LinkEntry::Object; @@ -518,7 +519,7 @@ void cmComputeLinkDepends::AddLinkObject(cmLinkItem const& item) void cmComputeLinkDepends::FollowLinkEntry(BFSEntry qe) { // Get this entry representation. - int depender_index = + size_t depender_index = qe.GroupIndex == cmComputeComponentGraph::INVALID_COMPONENT ? qe.Index : qe.GroupIndex; @@ -559,7 +560,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry qe) } } -void cmComputeLinkDepends::FollowSharedDeps(int depender_index, +void cmComputeLinkDepends::FollowSharedDeps(size_t depender_index, cmLinkInterface const* iface, bool follow_interface) { @@ -573,7 +574,7 @@ void cmComputeLinkDepends::FollowSharedDeps(int depender_index, } void cmComputeLinkDepends::QueueSharedDependencies( - int depender_index, std::vector const& deps) + size_t depender_index, std::vector const& deps) { for (cmLinkItem const& li : deps) { SharedDepEntry qe; @@ -587,7 +588,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) { // Allocate a spot for the item entry. auto lei = this->AllocateLinkEntry(dep.Item); - int index = lei.first->second; + size_t index = lei.first->second; // Check if the target does not already has an entry. if (lei.second) { @@ -620,7 +621,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) } } -void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, +void cmComputeLinkDepends::AddVarLinkEntries(size_t depender_index, const char* value) { // This is called to add the dependencies named by @@ -699,17 +700,18 @@ void cmComputeLinkDepends::AddDirectLinkEntries() } template -void cmComputeLinkDepends::AddLinkEntries(int depender_index, +void cmComputeLinkDepends::AddLinkEntries(size_t depender_index, std::vector const& libs) { // Track inferred dependency sets implied by this list. - std::map dependSets; + std::map dependSets; std::string feature = LinkEntry::DEFAULT; bool inGroup = false; - std::pair groupIndex{ cmComputeComponentGraph::INVALID_COMPONENT, - false }; - std::vector groupItems; + std::pair groupIndex{ + cmComputeComponentGraph::INVALID_COMPONENT, false + }; + std::vector groupItems; // Loop over the libraries linked directly by the depender. for (T const& l : libs) { @@ -768,7 +770,7 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index, continue; } - int dependee_index; + size_t dependee_index; if (cmHasPrefix(item.AsStr(), LG_END) && cmHasSuffix(item.AsStr(), '>')) { dependee_index = groupIndex.first; @@ -902,7 +904,7 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index, // store item index for dependencies handling groupItems.push_back(dependee_index); } else { - std::vector indexes; + std::vector indexes; bool entryHandled = false; // search any occurrence of the library in already defined groups for (const auto& group : this->GroupItems) { @@ -964,7 +966,7 @@ void cmComputeLinkDepends::AddLinkObjects(std::vector const& objs) } } -cmLinkItem cmComputeLinkDepends::ResolveLinkItem(int depender_index, +cmLinkItem cmComputeLinkDepends::ResolveLinkItem(size_t depender_index, const std::string& name) { // Look for a target in the scope of the depender. @@ -983,7 +985,7 @@ void cmComputeLinkDepends::InferDependencies() // The inferred dependency sets for each item list the possible // dependencies. The intersection of the sets for one item form its // inferred dependencies. - for (unsigned int depender_index = 0; + for (size_t depender_index = 0; 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. @@ -1020,7 +1022,7 @@ void cmComputeLinkDepends::UpdateGroupDependencies() // over raw items by the group it belongs to, if any. for (auto& edgeList : this->EntryConstraintGraph) { for (auto& edge : edgeList) { - int index = edge; + size_t index = edge; if (this->EntryList[index].Kind == LinkEntry::Group || this->EntryList[index].Kind == LinkEntry::Flag || this->EntryList[index].Kind == LinkEntry::Object) { @@ -1056,8 +1058,8 @@ void cmComputeLinkDepends::CleanConstraintGraph() bool cmComputeLinkDepends::CheckCircularDependencies() const { std::vector const& components = this->CCG->GetComponents(); - int nc = static_cast(components.size()); - for (int c = 0; c < nc; ++c) { + size_t nc = components.size(); + for (size_t c = 0; c < nc; ++c) { // Get the current component. NodeList const& nl = components[c]; @@ -1068,7 +1070,7 @@ bool cmComputeLinkDepends::CheckCircularDependencies() const // no group must be evolved bool cycleDetected = false; - for (int ni : nl) { + for (size_t ni : nl) { if (this->EntryList[ni].Kind == LinkEntry::Group) { cycleDetected = true; break; @@ -1096,8 +1098,8 @@ bool cmComputeLinkDepends::CheckCircularDependencies() const << this->Target->GetName() << "\", contains the following strongly connected component " "(cycle):\n"; - std::vector const& cmap = this->CCG->GetComponentMap(); - for (int i : nl) { + std::vector const& cmap = this->CCG->GetComponentMap(); + for (size_t i : nl) { // Get the depender. LinkEntry const& depender = this->EntryList[i]; @@ -1107,7 +1109,7 @@ bool cmComputeLinkDepends::CheckCircularDependencies() const // List its dependencies that are inside the component. EdgeList const& el = this->EntryConstraintGraph[i]; for (cmGraphEdge const& ni : el) { - int j = ni; + size_t j = ni; if (cmap[j] == c) { LinkEntry const& dependee = this->EntryList[j]; e << " depends on " << formatItem(dependee) << "\n"; @@ -1127,7 +1129,7 @@ void cmComputeLinkDepends::DisplayConstraintGraph() { // Display the graph nodes and their edges. std::ostringstream e; - for (unsigned int i = 0; i < this->EntryConstraintGraph.size(); ++i) { + for (size_t i = 0; i < this->EntryConstraintGraph.size(); ++i) { EdgeList const& nl = this->EntryConstraintGraph[i]; e << "item " << i << " is [" << this->EntryList[i].Item << "]\n"; e << cmWrap(" item ", nl, " must follow it", "\n") << "\n"; @@ -1141,13 +1143,14 @@ void cmComputeLinkDepends::OrderLinkEntries() // from every entry to compute a topological order for the // components. Graph const& cgraph = this->CCG->GetComponentGraph(); - int n = static_cast(cgraph.size()); + size_t n = cgraph.size(); this->ComponentVisited.resize(cgraph.size(), 0); this->ComponentOrder.resize(cgraph.size(), n); this->ComponentOrderId = n; // Run in reverse order so the topological order will preserve the // original order where there are no constraints. - for (int c = n - 1; c != cmComputeComponentGraph::INVALID_COMPONENT; --c) { + for (size_t c = n - 1; c != cmComputeComponentGraph::INVALID_COMPONENT; + --c) { this->VisitComponent(c); } @@ -1157,7 +1160,7 @@ void cmComputeLinkDepends::OrderLinkEntries() } // Start with the original link line. - for (int originalEntry : this->OriginalEntries) { + for (size_t originalEntry : this->OriginalEntries) { this->VisitEntry(originalEntry); } @@ -1168,7 +1171,7 @@ void cmComputeLinkDepends::OrderLinkEntries() // logic will update the pending components accordingly. Since // the pending components are kept in topological order this will // not repeat one. - int e = *this->PendingComponents.begin()->second.Entries.begin(); + size_t e = *this->PendingComponents.begin()->second.Entries.begin(); this->VisitEntry(e); } } @@ -1177,24 +1180,24 @@ void cmComputeLinkDepends::DisplayComponents() { fprintf(stderr, "The strongly connected components are:\n"); std::vector const& components = this->CCG->GetComponents(); - for (unsigned int c = 0; c < components.size(); ++c) { - fprintf(stderr, "Component (%u):\n", c); + for (size_t c = 0; c < components.size(); ++c) { + fprintf(stderr, "Component (%zu):\n", c); NodeList const& nl = components[c]; - for (int i : nl) { - fprintf(stderr, " item %d [%s]\n", i, + for (size_t i : nl) { + fprintf(stderr, " item %zu [%s]\n", i, this->EntryList[i].Item.Value.c_str()); } EdgeList const& ol = this->CCG->GetComponentGraphEdges(c); for (cmGraphEdge const& oi : ol) { - int i = oi; - fprintf(stderr, " followed by Component (%d)\n", i); + size_t i = oi; + fprintf(stderr, " followed by Component (%zu)\n", i); } - fprintf(stderr, " topo order index %d\n", this->ComponentOrder[c]); + fprintf(stderr, " topo order index %zu\n", this->ComponentOrder[c]); } fprintf(stderr, "\n"); } -void cmComputeLinkDepends::VisitComponent(unsigned int c) +void cmComputeLinkDepends::VisitComponent(size_t c) { // Check if the node has already been visited. if (this->ComponentVisited[c]) { @@ -1216,14 +1219,14 @@ void cmComputeLinkDepends::VisitComponent(unsigned int c) this->ComponentOrder[c] = --this->ComponentOrderId; } -void cmComputeLinkDepends::VisitEntry(int index) +void cmComputeLinkDepends::VisitEntry(size_t index) { // Include this entry on the link line. this->FinalLinkOrder.push_back(index); // This entry has now been seen. Update its component. bool completed = false; - int component = this->CCG->GetComponentMap()[index]; + size_t component = this->CCG->GetComponentMap()[index]; auto mi = this->PendingComponents.find(this->ComponentOrder[component]); if (mi != this->PendingComponents.end()) { // The entry is in an already pending component. @@ -1274,7 +1277,7 @@ void cmComputeLinkDepends::VisitEntry(int index) } cmComputeLinkDepends::PendingComponent& -cmComputeLinkDepends::MakePendingComponent(unsigned int component) +cmComputeLinkDepends::MakePendingComponent(size_t component) { // Create an entry (in topological order) for the component. PendingComponent& pc = @@ -1307,10 +1310,10 @@ cmComputeLinkDepends::MakePendingComponent(unsigned int component) return pc; } -int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) +size_t cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) { - unsigned int count = 2; - for (int ni : nl) { + size_t count = 2; + for (size_t ni : nl) { if (cmGeneratorTarget const* target = this->EntryList[ni].Target) { if (cmLinkInterface const* iface = target->GetLinkInterface(this->Config, this->Target)) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 1bf0ff1..22c4e2a 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -4,6 +4,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include #include #include @@ -12,12 +13,12 @@ #include #include +#include "cmComputeComponentGraph.h" #include "cmGraphAdjacencyList.h" #include "cmLinkItem.h" #include "cmListFileCache.h" #include "cmTargetLinkLibraryType.h" -class cmComputeComponentGraph; class cmGeneratorTarget; class cmGlobalGenerator; class cmMakefile; @@ -91,31 +92,31 @@ private: std::string const& GetCurrentFeature( std::string const& item, std::string const& defaultFeature) const; - std::pair::iterator, bool> AllocateLinkEntry( + std::pair::iterator, bool> AllocateLinkEntry( cmLinkItem const& item); - std::pair AddLinkEntry( + std::pair AddLinkEntry( cmLinkItem const& item, - int groupIndex = cmComputeComponentGraph::INVALID_COMPONENT); + size_t groupIndex = cmComputeComponentGraph::INVALID_COMPONENT); void AddLinkObject(cmLinkItem const& item); - void AddVarLinkEntries(int depender_index, const char* value); + void AddVarLinkEntries(size_t depender_index, const char* value); void AddDirectLinkEntries(); template - void AddLinkEntries(int depender_index, std::vector const& libs); + void AddLinkEntries(size_t depender_index, std::vector const& libs); void AddLinkObjects(std::vector const& objs); - cmLinkItem ResolveLinkItem(int depender_index, const std::string& name); + cmLinkItem ResolveLinkItem(size_t depender_index, const std::string& name); // One entry for each unique item. std::vector EntryList; - std::map LinkEntryIndex; + std::map LinkEntryIndex; // map storing, for each group, the list of items - std::map> GroupItems; + std::map> GroupItems; // BFS of initial dependencies. struct BFSEntry { - int Index; - int GroupIndex; + size_t Index; + size_t GroupIndex; const char* LibDepends; }; std::queue BFSQueue; @@ -127,18 +128,18 @@ private: struct SharedDepEntry { cmLinkItem Item; - int DependerIndex; + size_t DependerIndex; }; std::queue SharedDepQueue; - std::set SharedDepFollowed; - void FollowSharedDeps(int depender_index, cmLinkInterface const* iface, + std::set SharedDepFollowed; + void FollowSharedDeps(size_t depender_index, cmLinkInterface const* iface, bool follow_interface = false); - void QueueSharedDependencies(int depender_index, + void QueueSharedDependencies(size_t depender_index, std::vector const& deps); void HandleSharedDependency(SharedDepEntry const& dep); // Dependency inferral for each link item. - struct DependSet : public std::set + struct DependSet : public std::set { }; struct DependSetList : public std::vector @@ -163,41 +164,41 @@ private: // Ordering algorithm. void OrderLinkEntries(); std::vector ComponentVisited; - std::vector ComponentOrder; + std::vector ComponentOrder; struct PendingComponent { // The real component id. Needed because the map is indexed by // component topological index. - int Id; + size_t Id; // The number of times the component needs to be seen. This is // always 1 for trivial components and is initially 2 for // non-trivial components. - int Count; + size_t Count; // The entries yet to be seen to complete the component. - std::set Entries; + std::set Entries; }; - std::map PendingComponents; + std::map PendingComponents; std::unique_ptr CCG; - std::vector FinalLinkOrder; + std::vector FinalLinkOrder; void DisplayComponents(); - void VisitComponent(unsigned int c); - void VisitEntry(int index); - PendingComponent& MakePendingComponent(unsigned int component); - int ComputeComponentCount(NodeList const& nl); + void VisitComponent(size_t c); + void VisitEntry(size_t index); + PendingComponent& MakePendingComponent(size_t component); + size_t ComputeComponentCount(NodeList const& nl); void DisplayFinalEntries(); // Record of the original link line. - std::vector OriginalEntries; + std::vector OriginalEntries; std::set OldWrongConfigItems; void CheckWrongConfigItem(cmLinkItem const& item); // Record of explicitly linked object files. - std::vector ObjectEntries; + std::vector ObjectEntries; - int ComponentOrderId; + size_t ComponentOrderId; cmTargetLinkLibraryType LinkType; bool HasConfig; bool DebugMode; diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 337bafb..6763225 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -3,6 +3,7 @@ #include "cmComputeTargetDepends.h" #include +#include #include #include #include @@ -159,7 +160,7 @@ void cmComputeTargetDepends::GetTargetDirectDepends(cmGeneratorTarget const* t, // this point. auto tii = this->TargetIndex.find(t); assert(tii != this->TargetIndex.end()); - int i = tii->second; + size_t i = tii->second; // Get its final dependencies. EdgeList const& nl = this->FinalGraph[i]; @@ -178,7 +179,7 @@ void cmComputeTargetDepends::CollectTargets() auto const& lgens = this->GlobalGenerator->GetLocalGenerators(); for (const auto& lgen : lgens) { for (const auto& ti : lgen->GetGeneratorTargets()) { - int index = static_cast(this->Targets.size()); + size_t index = this->Targets.size(); this->TargetIndex[ti.get()] = index; this->Targets.push_back(ti.get()); } @@ -191,12 +192,12 @@ void cmComputeTargetDepends::CollectDepends() this->InitialGraph.resize(this->Targets.size()); // Compute each dependency list. - for (unsigned int i = 0; i < this->Targets.size(); ++i) { + for (size_t i = 0; i < this->Targets.size(); ++i) { this->CollectTargetDepends(i); } } -void cmComputeTargetDepends::CollectTargetDepends(int depender_index) +void cmComputeTargetDepends::CollectTargetDepends(size_t depender_index) { // Get the depender. cmGeneratorTarget const* depender = this->Targets[depender_index]; @@ -261,7 +262,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) } void cmComputeTargetDepends::AddInterfaceDepends( - int depender_index, const cmGeneratorTarget* dependee, + size_t depender_index, const cmGeneratorTarget* dependee, cmListFileBacktrace const& dependee_backtrace, const std::string& config, std::set& emitted) { @@ -290,7 +291,7 @@ void cmComputeTargetDepends::AddInterfaceDepends( } void cmComputeTargetDepends::AddInterfaceDepends( - int depender_index, cmLinkItem const& dependee_name, + size_t depender_index, cmLinkItem const& dependee_name, const std::string& config, std::set& emitted) { cmGeneratorTarget const* depender = this->Targets[depender_index]; @@ -312,7 +313,7 @@ void cmComputeTargetDepends::AddInterfaceDepends( } } -void cmComputeTargetDepends::AddObjectDepends(int depender_index, +void cmComputeTargetDepends::AddObjectDepends(size_t depender_index, cmSourceFile const* o, std::set& emitted) { @@ -340,7 +341,7 @@ void cmComputeTargetDepends::AddObjectDepends(int depender_index, } } -void cmComputeTargetDepends::AddTargetDepend(int depender_index, +void cmComputeTargetDepends::AddTargetDepend(size_t depender_index, cmLinkItem const& dependee_name, bool linking, bool cross) { @@ -394,7 +395,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, } void cmComputeTargetDepends::AddTargetDepend( - int depender_index, cmGeneratorTarget const* dependee, + size_t depender_index, cmGeneratorTarget const* dependee, cmListFileBacktrace const& dependee_backtrace, bool linking, bool cross) { if (!dependee->IsInBuildSystem()) { @@ -412,7 +413,7 @@ void cmComputeTargetDepends::AddTargetDepend( // this point. auto tii = this->TargetIndex.find(dependee); assert(tii != this->TargetIndex.end()); - int dependee_index = tii->second; + size_t dependee_index = tii->second; // Add this entry to the dependency graph. this->InitialGraph[depender_index].emplace_back(dependee_index, !linking, @@ -425,15 +426,15 @@ void cmComputeTargetDepends::CollectSideEffects() this->SideEffects.resize(0); this->SideEffects.resize(this->InitialGraph.size()); - int n = static_cast(this->InitialGraph.size()); - std::set visited; - for (int i = 0; i < n; ++i) { + size_t n = this->InitialGraph.size(); + std::set visited; + for (size_t i = 0; i < n; ++i) { this->CollectSideEffectsForTarget(visited, i); } } void cmComputeTargetDepends::CollectSideEffectsForTarget( - std::set& visited, int depender_index) + std::set& visited, size_t depender_index) { if (!visited.count(depender_index)) { auto& se = this->SideEffects[depender_index]; @@ -461,8 +462,8 @@ void cmComputeTargetDepends::ComputeIntermediateGraph() this->IntermediateGraph.resize(0); this->IntermediateGraph.resize(this->InitialGraph.size()); - int n = static_cast(this->InitialGraph.size()); - for (int i = 0; i < n; ++i) { + size_t n = this->InitialGraph.size(); + for (size_t i = 0; i < n; ++i) { auto const& initialEdges = this->InitialGraph[i]; auto& intermediateEdges = this->IntermediateGraph[i]; cmGeneratorTarget const* gt = this->Targets[i]; @@ -488,7 +489,7 @@ void cmComputeTargetDepends::OptimizeLinkDependencies( cmGeneratorTarget const* gt, cmGraphEdgeList& outputEdges, cmGraphEdgeList const& inputEdges) { - std::set emitted; + std::set emitted; for (auto const& edge : inputEdges) { if (edge.IsStrong()) { // Preserve strong edges @@ -529,16 +530,16 @@ void cmComputeTargetDepends::DisplayGraph(Graph const& graph, const std::string& name) { fprintf(stderr, "The %s target dependency graph is:\n", name.c_str()); - int n = static_cast(graph.size()); - for (int depender_index = 0; depender_index < n; ++depender_index) { + size_t n = graph.size(); + for (size_t depender_index = 0; depender_index < n; ++depender_index) { EdgeList const& nl = graph[depender_index]; cmGeneratorTarget const* depender = this->Targets[depender_index]; - fprintf(stderr, "target %d is [%s]\n", depender_index, + fprintf(stderr, "target %zu is [%s]\n", depender_index, depender->GetName().c_str()); for (cmGraphEdge const& ni : nl) { - int dependee_index = ni; + size_t dependee_index = ni; cmGeneratorTarget const* dependee = this->Targets[dependee_index]; - fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index, + fprintf(stderr, " depends on target %zu [%s] (%s)\n", dependee_index, dependee->GetName().c_str(), ni.IsStrong() ? "strong" : "weak"); } } @@ -548,16 +549,16 @@ void cmComputeTargetDepends::DisplayGraph(Graph const& graph, void cmComputeTargetDepends::DisplaySideEffects() { fprintf(stderr, "The side effects are:\n"); - int n = static_cast(this->SideEffects.size()); - for (int depender_index = 0; depender_index < n; ++depender_index) { + size_t n = this->SideEffects.size(); + for (size_t depender_index = 0; depender_index < n; ++depender_index) { cmGeneratorTarget const* depender = this->Targets[depender_index]; - fprintf(stderr, "target %d is [%s]\n", depender_index, + fprintf(stderr, "target %zu is [%s]\n", depender_index, depender->GetName().c_str()); if (!this->SideEffects[depender_index].CustomCommandSideEffects.empty()) { fprintf(stderr, " custom commands\n"); for (auto const* gt : this->SideEffects[depender_index].CustomCommandSideEffects) { - fprintf(stderr, " from target %d [%s]\n", this->TargetIndex[gt], + fprintf(stderr, " from target %zu [%s]\n", this->TargetIndex[gt], gt->GetName().c_str()); } } @@ -565,7 +566,7 @@ void cmComputeTargetDepends::DisplaySideEffects() this->SideEffects[depender_index].LanguageSideEffects) { fprintf(stderr, " language %s\n", it.first.c_str()); for (auto const* gt : it.second) { - fprintf(stderr, " from target %d [%s]\n", this->TargetIndex[gt], + fprintf(stderr, " from target %zu [%s]\n", this->TargetIndex[gt], gt->GetName().c_str()); } } @@ -579,12 +580,12 @@ void cmComputeTargetDepends::DisplayComponents( fprintf(stderr, "The strongly connected components for the %s graph are:\n", name.c_str()); std::vector const& components = ccg.GetComponents(); - int n = static_cast(components.size()); - for (int c = 0; c < n; ++c) { + size_t n = components.size(); + for (size_t c = 0; c < n; ++c) { NodeList const& nl = components[c]; - fprintf(stderr, "Component (%d):\n", c); - for (int i : nl) { - fprintf(stderr, " contains target %d [%s]\n", i, + fprintf(stderr, "Component (%zu):\n", c); + for (size_t i : nl) { + fprintf(stderr, " contains target %zu [%s]\n", i, this->Targets[i]->GetName().c_str()); } } @@ -597,8 +598,8 @@ bool cmComputeTargetDepends::CheckComponents( // All non-trivial components should consist only of static // libraries. std::vector const& components = ccg.GetComponents(); - int nc = static_cast(components.size()); - for (int c = 0; c < nc; ++c) { + size_t nc = components.size(); + for (size_t c = 0; c < nc; ++c) { // Get the current component. NodeList const& nl = components[c]; @@ -614,7 +615,7 @@ bool cmComputeTargetDepends::CheckComponents( } // Make sure the component is all STATIC_LIBRARY targets. - for (int ni : nl) { + for (size_t ni : nl) { if (this->Targets[ni]->GetType() != cmStateEnums::STATIC_LIBRARY) { this->ComplainAboutBadComponent(ccg, c); return false; @@ -625,16 +626,16 @@ bool cmComputeTargetDepends::CheckComponents( } void cmComputeTargetDepends::ComplainAboutBadComponent( - cmComputeComponentGraph const& ccg, int c, bool strong) + cmComputeComponentGraph const& ccg, size_t c, bool strong) { // Construct the error message. std::ostringstream e; e << "The inter-target dependency graph contains the following " << "strongly connected component (cycle):\n"; std::vector const& components = ccg.GetComponents(); - std::vector const& cmap = ccg.GetComponentMap(); + std::vector const& cmap = ccg.GetComponentMap(); NodeList const& cl = components[c]; - for (int i : cl) { + for (size_t i : cl) { // Get the depender. cmGeneratorTarget const* depender = this->Targets[i]; @@ -645,7 +646,7 @@ void cmComputeTargetDepends::ComplainAboutBadComponent( // List its dependencies that are inside the component. EdgeList const& nl = this->InitialGraph[i]; for (cmGraphEdge const& ni : nl) { - int j = ni; + size_t j = ni; if (cmap[j] == c) { cmGeneratorTarget const* dependee = this->Targets[j]; e << " depends on \"" << dependee->GetName() << "\"" @@ -669,10 +670,10 @@ void cmComputeTargetDepends::ComplainAboutBadComponent( cmSystemTools::Error(e.str()); } -bool cmComputeTargetDepends::IntraComponent(std::vector const& cmap, - int c, int i, int* head, - std::set& emitted, - std::set& visited) +bool cmComputeTargetDepends::IntraComponent(std::vector const& cmap, + size_t c, size_t i, size_t* head, + std::set& emitted, + std::set& visited) { if (!visited.insert(i).second) { // Cycle in utility depends! @@ -682,7 +683,7 @@ bool cmComputeTargetDepends::IntraComponent(std::vector const& cmap, // Honor strong intra-component edges in the final order. EdgeList const& el = this->InitialGraph[i]; for (cmGraphEdge const& edge : el) { - int j = edge; + size_t j = edge; if (cmap[j] == c && edge.IsStrong()) { this->FinalGraph[i].emplace_back(j, true, edge.IsCross(), edge.GetBacktrace()); @@ -716,16 +717,16 @@ bool cmComputeTargetDepends::ComputeFinalDepends( this->FinalGraph.resize(this->InitialGraph.size()); // Choose intra-component edges to linearize dependencies. - std::vector const& cmap = ccg.GetComponentMap(); + std::vector const& cmap = ccg.GetComponentMap(); this->ComponentHead.resize(components.size()); this->ComponentTail.resize(components.size()); - int nc = static_cast(components.size()); - for (int c = 0; c < nc; ++c) { - int head = cmComputeComponentGraph::INVALID_COMPONENT; - std::set emitted; + size_t nc = components.size(); + for (size_t c = 0; c < nc; ++c) { + size_t head = cmComputeComponentGraph::INVALID_COMPONENT; + std::set emitted; NodeList const& nl = components[c]; - for (int ni : cmReverseRange(nl)) { - std::set visited; + for (size_t ni : cmReverseRange(nl)) { + std::set visited; if (!this->IntraComponent(cmap, c, ni, &head, emitted, visited)) { // Cycle in add_dependencies within component! this->ComplainAboutBadComponent(ccg, c, true); @@ -736,14 +737,14 @@ bool cmComputeTargetDepends::ComputeFinalDepends( } // Convert inter-component edges to connect component tails to heads. - int n = static_cast(cgraph.size()); - for (int depender_component = 0; depender_component < n; + size_t n = cgraph.size(); + for (size_t depender_component = 0; depender_component < n; ++depender_component) { - int depender_component_tail = this->ComponentTail[depender_component]; + size_t depender_component_tail = this->ComponentTail[depender_component]; EdgeList const& nl = cgraph[depender_component]; for (cmGraphEdge const& ni : nl) { - int dependee_component = ni; - int dependee_component_head = this->ComponentHead[dependee_component]; + size_t dependee_component = ni; + size_t dependee_component_head = this->ComponentHead[dependee_component]; this->FinalGraph[depender_component_tail].emplace_back( dependee_component_head, ni.IsStrong(), ni.IsCross(), ni.GetBacktrace()); diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index cdb66f8..3ed041b 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -4,6 +4,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include #include #include @@ -51,28 +52,31 @@ private: void CollectTargets(); void CollectDepends(); - void CollectTargetDepends(int depender_index); - void AddTargetDepend(int depender_index, cmLinkItem const& dependee_name, + void CollectTargetDepends(size_t depender_index); + void AddTargetDepend(size_t depender_index, cmLinkItem const& dependee_name, bool linking, bool cross); - void AddTargetDepend(int depender_index, cmGeneratorTarget const* dependee, + void AddTargetDepend(size_t depender_index, + cmGeneratorTarget const* dependee, cmListFileBacktrace const& dependee_backtrace, bool linking, bool cross); void CollectSideEffects(); - void CollectSideEffectsForTarget(std::set& visited, int depender_index); + void CollectSideEffectsForTarget(std::set& visited, + size_t depender_index); void ComputeIntermediateGraph(); void OptimizeLinkDependencies(cmGeneratorTarget const* gt, cmGraphEdgeList& outputEdges, cmGraphEdgeList const& inputEdges); bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); - void AddInterfaceDepends(int depender_index, cmLinkItem const& dependee_name, + void AddInterfaceDepends(size_t depender_index, + cmLinkItem const& dependee_name, const std::string& config, std::set& emitted); - void AddInterfaceDepends(int depender_index, + void AddInterfaceDepends(size_t depender_index, cmGeneratorTarget const* dependee, cmListFileBacktrace const& dependee_backtrace, const std::string& config, std::set& emitted); - void AddObjectDepends(int depender_index, cmSourceFile const* o, + void AddObjectDepends(size_t depender_index, cmSourceFile const* o, std::set& emitted); cmGlobalGenerator* GlobalGenerator; bool DebugMode; @@ -80,7 +84,7 @@ private: // Collect all targets. std::vector Targets; - std::map TargetIndex; + std::map TargetIndex; // Represent the target dependency graph. The entry at each // top-level index corresponds to a depender whose dependencies are @@ -99,11 +103,12 @@ private: void DisplayComponents(cmComputeComponentGraph const& ccg, const std::string& name); bool CheckComponents(cmComputeComponentGraph const& ccg); - void ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, int c, + void ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, size_t c, bool strong = false); - std::vector ComponentHead; - std::vector ComponentTail; - bool IntraComponent(std::vector const& cmap, int c, int i, int* head, - std::set& emitted, std::set& visited); + std::vector ComponentHead; + std::vector ComponentTail; + bool IntraComponent(std::vector const& cmap, size_t c, size_t i, + size_t* head, std::set& emitted, + std::set& visited); }; diff --git a/Source/cmGraphAdjacencyList.h b/Source/cmGraphAdjacencyList.h index fe9fbe2..01fc5f9 100644 --- a/Source/cmGraphAdjacencyList.h +++ b/Source/cmGraphAdjacencyList.h @@ -4,6 +4,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include #include @@ -17,14 +18,14 @@ class cmGraphEdge { public: - cmGraphEdge(int n, bool s, bool c, cmListFileBacktrace bt) + cmGraphEdge(size_t n, bool s, bool c, cmListFileBacktrace bt) : Dest(n) , Strong(s) , Cross(c) , Backtrace(std::move(bt)) { } - operator int() const { return this->Dest; } + operator size_t() const { return this->Dest; } bool IsStrong() const { return this->Strong; } @@ -33,7 +34,7 @@ public: cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; } private: - int Dest; + size_t Dest; bool Strong; bool Cross; cmListFileBacktrace Backtrace; @@ -41,7 +42,7 @@ private: struct cmGraphEdgeList : public std::vector { }; -struct cmGraphNodeList : public std::vector +struct cmGraphNodeList : public std::vector { }; struct cmGraphAdjacencyList : public std::vector -- cgit v0.12