Get*Union: disallow nulltpr Refs

This commit is contained in:
Greg Sanders 2025-03-31 13:05:20 -04:00
parent 57433502e6
commit a40bd374aa
2 changed files with 4 additions and 2 deletions

View file

@ -1595,6 +1595,7 @@ std::vector<TxGraph::Ref*> TxGraphImpl::GetAncestorsUnion(std::span<const Ref* c
std::vector<std::pair<Cluster*, DepGraphIndex>> matches; std::vector<std::pair<Cluster*, DepGraphIndex>> matches;
matches.reserve(args.size()); matches.reserve(args.size());
for (auto arg : args) { for (auto arg : args) {
Assume(arg);
// Skip empty Refs. // Skip empty Refs.
if (GetRefGraph(*arg) == nullptr) continue; if (GetRefGraph(*arg) == nullptr) continue;
Assume(GetRefGraph(*arg) == this); Assume(GetRefGraph(*arg) == this);
@ -1627,6 +1628,7 @@ std::vector<TxGraph::Ref*> TxGraphImpl::GetDescendantsUnion(std::span<const Ref*
std::vector<std::pair<Cluster*, DepGraphIndex>> matches; std::vector<std::pair<Cluster*, DepGraphIndex>> matches;
matches.reserve(args.size()); matches.reserve(args.size());
for (auto arg : args) { for (auto arg : args) {
Assume(arg);
// Skip empty Refs. // Skip empty Refs.
if (GetRefGraph(*arg) == nullptr) continue; if (GetRefGraph(*arg) == nullptr) continue;
Assume(GetRefGraph(*arg) == this); Assume(GetRefGraph(*arg) == this);

View file

@ -144,11 +144,11 @@ public:
virtual std::vector<Ref*> GetDescendants(const Ref& arg, bool main_only = false) noexcept = 0; virtual std::vector<Ref*> GetDescendants(const Ref& arg, bool main_only = false) noexcept = 0;
/** Like GetAncestors, but return the Refs for all transactions in the union of the provided /** Like GetAncestors, but return the Refs for all transactions in the union of the provided
* arguments' ancestors (each transaction is only reported once). Refs that do not exist in * arguments' ancestors (each transaction is only reported once). Refs that do not exist in
* the queried graph are ignored. */ * the queried graph are ignored. Null refs are not allowed. */
virtual std::vector<Ref*> GetAncestorsUnion(std::span<const Ref* const> args, bool main_only = false) noexcept = 0; virtual std::vector<Ref*> GetAncestorsUnion(std::span<const Ref* const> args, bool main_only = false) noexcept = 0;
/** Like GetDescendants, but return the Refs for all transactions in the union of the provided /** Like GetDescendants, but return the Refs for all transactions in the union of the provided
* arguments' descendants (each transaction is only reported once). Refs that do not exist in * arguments' descendants (each transaction is only reported once). Refs that do not exist in
* the queried graph are ignored. */ * the queried graph are ignored. Null refs are not allowed. */
virtual std::vector<Ref*> GetDescendantsUnion(std::span<const Ref* const> args, bool main_only = false) noexcept = 0; virtual std::vector<Ref*> GetDescendantsUnion(std::span<const Ref* const> args, bool main_only = false) noexcept = 0;
/** Get the total number of transactions in the graph. If main_only is false and a staging /** Get the total number of transactions in the graph. If main_only is false and a staging
* graph exists, it is queried; otherwise the main graph is queried. This is available even * graph exists, it is queried; otherwise the main graph is queried. This is available even