diff --git a/include/pup/graph/dag.hpp b/include/pup/graph/dag.hpp index aeb5bfd..aae5197 100644 --- a/include/pup/graph/dag.hpp +++ b/include/pup/graph/dag.hpp @@ -134,10 +134,6 @@ struct Graph { [[nodiscard]] auto make_graph() -> Graph; -/// Validate that a node ID exists in the graph -[[nodiscard]] -auto validate_node_id(Graph const& graph, NodeId id) -> bool; - /// Add a file node to the graph [[nodiscard]] auto add_file_node(Graph& graph, FileNode node) -> Result; @@ -188,22 +184,6 @@ auto get_condition_node(Graph& graph, NodeId id) -> ConditionNode*; [[nodiscard]] auto get_condition_node(Graph const& graph, NodeId id) -> ConditionNode const*; -/// Add a phi node to the graph -[[nodiscard]] -auto add_phi_node(Graph& graph, PhiNode node) -> Result; - -/// Get a phi node by ID (mutable) - returns nullptr for non-phi IDs -[[nodiscard]] -auto get_phi_node(Graph& graph, NodeId id) -> PhiNode*; - -/// Get a phi node by ID (const) - returns nullptr for non-phi IDs -[[nodiscard]] -auto get_phi_node(Graph const& graph, NodeId id) -> PhiNode const*; - -/// Resolve a phi node to its active output based on current condition values -[[nodiscard]] -auto resolve_phi_node(Graph const& graph, NodeId phi_id) -> NodeId; - /// Check if all guards on a command are satisfied [[nodiscard]] auto is_guard_satisfied(Graph const& graph, CommandNode const& cmd) -> bool; @@ -304,10 +284,6 @@ auto all_nodes(Graph const& graph) -> Vec; [[nodiscard]] auto root_nodes(Graph const& graph) -> Vec; -/// Get leaf nodes (nodes with no outputs) -[[nodiscard]] -auto leaf_nodes(Graph const& graph) -> Vec; - /// Materialize a PathId to its display string. For BuildRoot-grounded paths, /// prepends the build root name (e.g., "build/gcc/foo.o"). [[nodiscard]] diff --git a/src/graph/dag.cpp b/src/graph/dag.cpp index 54e91c3..242c2fc 100644 --- a/src/graph/dag.cpp +++ b/src/graph/dag.cpp @@ -329,12 +329,6 @@ auto add_phi_node(Graph& graph, PhiNode node) -> Result return id; } -auto get_phi_node(Graph& graph, NodeId id) -> PhiNode* -{ - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) - Scott Meyers const_cast pattern - return const_cast(get_phi_node(std::as_const(graph), id)); -} - auto get_phi_node(Graph const& graph, NodeId id) -> PhiNode const* { if (!node_id::is_phi(id)) { @@ -348,6 +342,12 @@ auto get_phi_node(Graph const& graph, NodeId id) -> PhiNode const* return node.id == id ? &node : nullptr; } +auto get_phi_node(Graph& graph, NodeId id) -> PhiNode* +{ + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) - Scott Meyers const_cast pattern + return const_cast(get_phi_node(std::as_const(graph), id)); +} + auto resolve_phi_node(Graph const& graph, NodeId phi_id) -> NodeId { auto const* phi = get_phi_node(graph, phi_id); diff --git a/test/unit/test_graph.cpp b/test/unit/test_graph.cpp index 7ba1904..30916c2 100644 --- a/test/unit/test_graph.cpp +++ b/test/unit/test_graph.cpp @@ -237,11 +237,6 @@ TEST_CASE("BuildGraph basic operations", "[graph]") REQUIRE(roots.size() == 2); // One of the roots should be the file we added REQUIRE(std::ranges::find(roots, *id1) != roots.end()); - - auto leaves = leaf_nodes(g); - // BUILD_ROOT_ID is also a leaf (no outputs unless used) - REQUIRE(leaves.size() == 2); - REQUIRE(std::ranges::find(leaves, *id3) != leaves.end()); } } @@ -585,16 +580,6 @@ TEST_CASE("Unified edge storage for order-only edges", "[graph]") REQUIRE(std::ranges::find(roots, *input_id) != roots.end()); } - SECTION("leaf_nodes excludes nodes with only order-only forward edges") - { - // group1 has only an order-only forward edge to cmd. - // Before unification this was stored separately and leaf_nodes missed it, - // so group1 incorrectly appeared as a leaf. After unification, group1 - // should NOT be a leaf because it has a forward edge (order-only counts). - auto leaves = leaf_nodes(g); - REQUIRE(std::ranges::find(leaves, *group_id) == leaves.end()); - } - SECTION("root_nodes excludes command with only order-only input") { auto bs2 = make_build_graph();