summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-09-17 18:05:43 (GMT)
committerBrad King <brad.king@kitware.com>2024-09-20 17:45:45 (GMT)
commitdccdd030cd6b3e57f5f5e1e810c38cc7bc46c4eb (patch)
treea6466863483722cce8ed7af9691ee57ecc91c841 /Source
parent6c9d8dc243be7b55c7bffd1a7a400b3e042ead90 (diff)
downloadCMake-dccdd030cd6b3e57f5f5e1e810c38cc7bc46c4eb.zip
CMake-dccdd030cd6b3e57f5f5e1e810c38cc7bc46c4eb.tar.gz
CMake-dccdd030cd6b3e57f5f5e1e810c38cc7bc46c4eb.tar.bz2
cmComputeLinkDepends: Replace depender index sentinel value with cm::optional
Diffstat (limited to 'Source')
-rw-r--r--Source/cmComputeLinkDepends.cxx40
-rw-r--r--Source/cmComputeLinkDepends.h9
2 files changed, 24 insertions, 25 deletions
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 014d600..8a1e38b 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -941,8 +941,8 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
}
}
-void cmComputeLinkDepends::AddVarLinkEntries(size_t depender_index,
- const char* value)
+void cmComputeLinkDepends::AddVarLinkEntries(
+ cm::optional<size_t> const& depender_index, const char* value)
{
// This is called to add the dependencies named by
// <item>_LIB_DEPENDS. The variable contains a semicolon-separated
@@ -1003,15 +1003,13 @@ void cmComputeLinkDepends::AddDirectLinkEntries()
// Add direct link dependencies in this configuration.
cmLinkImplementation const* impl = this->Target->GetLinkImplementation(
this->Config, cmGeneratorTarget::UseTo::Link);
- this->AddLinkEntries(cmComputeComponentGraph::INVALID_COMPONENT,
- impl->Libraries);
+ this->AddLinkEntries(cm::nullopt, 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(cmComputeComponentGraph::INVALID_COMPONENT,
- runtimeEntries->second);
+ this->AddLinkEntries(cm::nullopt, runtimeEntries->second);
}
}
for (cmLinkItem const& wi : impl->WrongConfigLibraries) {
@@ -1020,8 +1018,8 @@ void cmComputeLinkDepends::AddDirectLinkEntries()
}
template <typename T>
-void cmComputeLinkDepends::AddLinkEntries(size_t depender_index,
- std::vector<T> const& libs)
+void cmComputeLinkDepends::AddLinkEntries(
+ cm::optional<size_t> const& depender_index, std::vector<T> const& libs)
{
// Track inferred dependency sets implied by this list.
std::map<size_t, DependSet> dependSets;
@@ -1040,9 +1038,8 @@ void cmComputeLinkDepends::AddLinkEntries(size_t depender_index,
// emit a warning if an undefined feature is used as part of
// an imported target
- if (item.Feature != LinkEntry::DEFAULT &&
- depender_index != cmComputeComponentGraph::INVALID_COMPONENT) {
- const auto& depender = this->EntryList[depender_index];
+ if (item.Feature != LinkEntry::DEFAULT && depender_index) {
+ const auto& depender = this->EntryList[*depender_index];
if (depender.Target && depender.Target->IsImported() &&
!IsFeatureSupported(this->Makefile, this->LinkLanguage,
item.Feature)) {
@@ -1068,8 +1065,8 @@ void cmComputeLinkDepends::AddLinkEntries(size_t depender_index,
LinkEntry& entry = this->EntryList[group->first];
entry.Feature = ExtractGroupFeature(item.AsStr());
}
- if (depender_index != cmComputeComponentGraph::INVALID_COMPONENT) {
- this->EntryConstraintGraph[depender_index].emplace_back(
+ if (depender_index) {
+ this->EntryConstraintGraph[*depender_index].emplace_back(
group->first, false, false, cmListFileBacktrace());
} else {
// This is a direct dependency of the target being linked.
@@ -1091,9 +1088,8 @@ void cmComputeLinkDepends::AddLinkEntries(size_t depender_index,
continue;
}
- if (depender_index != cmComputeComponentGraph::INVALID_COMPONENT &&
- group) {
- const auto& depender = this->EntryList[depender_index];
+ if (depender_index && group) {
+ const auto& depender = this->EntryList[*depender_index];
const auto& groupFeature = this->EntryList[group->first].Feature;
if (depender.Target && depender.Target->IsImported() &&
!IsGroupFeatureSupported(this->Makefile, this->LinkLanguage,
@@ -1261,8 +1257,8 @@ void cmComputeLinkDepends::AddLinkEntries(size_t depender_index,
for (auto index : indexes) {
// The dependee must come after the depender.
- if (depender_index != cmComputeComponentGraph::INVALID_COMPONENT) {
- this->EntryConstraintGraph[depender_index].emplace_back(
+ if (depender_index) {
+ this->EntryConstraintGraph[*depender_index].emplace_back(
index, false, false, cmListFileBacktrace());
} else {
// This is a direct dependency of the target being linked.
@@ -1305,14 +1301,14 @@ void cmComputeLinkDepends::AddLinkObjects(std::vector<cmLinkItem> const& objs)
}
}
-cmLinkItem cmComputeLinkDepends::ResolveLinkItem(size_t depender_index,
- const std::string& name)
+cmLinkItem cmComputeLinkDepends::ResolveLinkItem(
+ cm::optional<size_t> const& depender_index, const std::string& name)
{
// Look for a target in the scope of the depender.
cmGeneratorTarget const* from = this->Target;
- if (depender_index != cmComputeComponentGraph::INVALID_COMPONENT) {
+ if (depender_index) {
if (cmGeneratorTarget const* depender =
- this->EntryList[depender_index].Target) {
+ this->EntryList[*depender_index].Target) {
from = depender;
}
}
diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h
index e3d179b..de6e6fa 100644
--- a/Source/cmComputeLinkDepends.h
+++ b/Source/cmComputeLinkDepends.h
@@ -103,12 +103,15 @@ private:
std::pair<size_t, bool> AddLinkEntry(cmLinkItem const& item,
cm::optional<size_t> const& groupIndex);
void AddLinkObject(cmLinkItem const& item);
- void AddVarLinkEntries(size_t depender_index, const char* value);
+ void AddVarLinkEntries(cm::optional<size_t> const& depender_index,
+ const char* value);
void AddDirectLinkEntries();
template <typename T>
- void AddLinkEntries(size_t depender_index, std::vector<T> const& libs);
+ void AddLinkEntries(cm::optional<size_t> const& depender_index,
+ std::vector<T> const& libs);
void AddLinkObjects(std::vector<cmLinkItem> const& objs);
- cmLinkItem ResolveLinkItem(size_t depender_index, const std::string& name);
+ cmLinkItem ResolveLinkItem(cm::optional<size_t> const& depender_index,
+ const std::string& name);
// One entry for each unique item.
std::vector<LinkEntry> EntryList;