diff --git a/pytype/typegraph/solver.cc b/pytype/typegraph/solver.cc index 85e1479cf..0cb58b968 100644 --- a/pytype/typegraph/solver.cc +++ b/pytype/typegraph/solver.cc @@ -151,27 +151,6 @@ QueryResult PathCacheTrie::GetResult(const CFGNode* start, return {false, nullptr}; } -bool PathFinder::FindAnyPathToNode( - const CFGNode* start, - const CFGNode* finish, - const CFGNodeSet& blocked) const { - std::vector stack; - stack.push_back(start); - CFGNodeSet seen; - const CFGNode* node; - while (!stack.empty()) { - node = stack.back(); - stack.pop_back(); - if (node == finish) - return true; - if (seen.count(node) || blocked.count(node)) - continue; - seen.insert(node); - stack.insert(stack.end(), node->incoming().begin(), node->incoming().end()); - } - return false; -} - std::deque PathFinder::FindShortestPathToNode( const CFGNode* start, const CFGNode* finish, const CFGNodeSet& blocked) const { diff --git a/pytype/typegraph/solver.h b/pytype/typegraph/solver.h index ae0560eb9..1febaa341 100644 --- a/pytype/typegraph/solver.h +++ b/pytype/typegraph/solver.h @@ -150,10 +150,6 @@ class PathFinder { PathFinder(const PathFinder&) = delete; PathFinder& operator=(const PathFinder&) = delete; - // Determine whether we can reach a node at all. - bool FindAnyPathToNode(const CFGNode* start, const CFGNode* finish, - const CFGNodeSet& blocked) const; - // Find a shortest path from start to finish, going backwards. Returns an // empty path if no path exists. std::deque FindShortestPathToNode( diff --git a/pytype/typegraph/solver_test.cc b/pytype/typegraph/solver_test.cc index 192a28d00..27124282f 100644 --- a/pytype/typegraph/solver_test.cc +++ b/pytype/typegraph/solver_test.cc @@ -350,13 +350,6 @@ TEST(SolverTest, TestPathFinder) { CFGNode* n5 = n4->ConnectNew("n5"); n5->ConnectTo(n5); internal::PathFinder f; - EXPECT_TRUE(f.FindAnyPathToNode(n1, n1, {})); - EXPECT_TRUE(f.FindAnyPathToNode(n1, n1, {n1})); - EXPECT_TRUE(f.FindAnyPathToNode(n4, n1, {n1})); - EXPECT_TRUE(f.FindAnyPathToNode(n4, n1, {n2})); - EXPECT_TRUE(f.FindAnyPathToNode(n4, n1, {n3})); - EXPECT_FALSE(f.FindAnyPathToNode(n4, n1, {n4})); - EXPECT_FALSE(f.FindAnyPathToNode(n4, n1, {n2, n3})); EXPECT_THAT(f.FindShortestPathToNode(n1, n1, {}), ElementsAre(n1)); EXPECT_THAT(f.FindShortestPathToNode(n1, n1, {n1}), ElementsAre(n1)); EXPECT_FALSE(f.FindShortestPathToNode(n4, n1, {n1}).empty());