File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -70,3 +70,21 @@ std::set<irep_idt> get_reaching_functions(
70
70
{
71
71
return get_connected_functions (graph, function, false );
72
72
}
73
+
74
+ std::set<irep_idt> get_functions_reachable_within_n_steps (
75
+ const call_grapht::directed_grapht &graph,
76
+ const irep_idt &start_function,
77
+ std::size_t n)
78
+ {
79
+ std::set<irep_idt> result;
80
+
81
+ if (auto start_idx = graph.get_node_index (start_function))
82
+ {
83
+ for (const auto &index : graph.depth_limited_search (*start_idx, n))
84
+ result.insert (graph[index].function );
85
+ }
86
+ else
87
+ throw " unknown start function" ;
88
+
89
+ return result;
90
+ }
Original file line number Diff line number Diff line change @@ -49,4 +49,18 @@ std::set<irep_idt> get_reachable_functions(
49
49
std::set<irep_idt> get_reaching_functions (
50
50
const call_grapht::directed_grapht &graph, const irep_idt &function);
51
51
52
+
53
+ // / Get either callers or callees reachable from a given
54
+ // / start function within N steps
55
+ // / \param graph: call graph
56
+ // / \param start_function: single start function
57
+ // / \param n: number of steps to consider
58
+ // / \param forwards: if true, get callees; otherwise get callers
59
+ // / \return set of functions that can be reached from the start function
60
+ // / including the start function
61
+ std::set<irep_idt> get_functions_reachable_within_n_steps (
62
+ const call_grapht::directed_grapht &graph,
63
+ const irep_idt &start_function,
64
+ std::size_t n);
65
+
52
66
#endif
You can’t perform that action at this time.
0 commit comments