File tree 2 files changed +55
-0
lines changed
2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -70,3 +70,34 @@ 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 std::set<irep_idt> &start_functions,
77
+ std::size_t &n,
78
+ bool forwards)
79
+ {
80
+ std::vector<std::size_t > start_indices;
81
+ std::set<irep_idt> result;
82
+
83
+ for (const auto &func : start_functions)
84
+ start_indices.push_back (*(graph.get_node_index (func)));
85
+
86
+ for (const auto &index :
87
+ graph.depth_limited_search (start_indices, n, forwards))
88
+ result.insert (graph[index ].function );
89
+
90
+ return result;
91
+ }
92
+
93
+ std::set<irep_idt> get_functions_reachable_within_n_steps (
94
+ const call_grapht::directed_grapht &graph,
95
+ const irep_idt &start_function,
96
+ std::size_t &n,
97
+ bool forwards)
98
+ {
99
+ std::set<irep_idt> start_functions;
100
+ start_functions.insert (start_function);
101
+ return get_functions_reachable_within_n_steps (
102
+ graph, start_functions, n, forwards);
103
+ }
Original file line number Diff line number Diff line change @@ -49,4 +49,28 @@ 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
+ // / Get either callers or callees reachable from a given
53
+ // / list of functions within N steps
54
+ // / \param graph: call graph
55
+ // / \param start_functions: set of start functions
56
+ // / \param forwards: if true, get callees; otherwise get callers
57
+ // / \param n: number of steps to consider
58
+ std::set<irep_idt> get_functions_reachable_within_n_steps (
59
+ const call_grapht::directed_grapht &graph,
60
+ const std::set<irep_idt> &start_functions,
61
+ std::size_t &n,
62
+ bool forwards);
63
+
64
+ // / Get either callers or callees reachable from a given
65
+ // / list of functions within N steps
66
+ // / \param graph: call graph
67
+ // / \param start_function: single start function
68
+ // / \param forwards: if true, get callees; otherwise get callers
69
+ // / \param n: number of steps to consider
70
+ std::set<irep_idt> get_functions_reachable_within_n_steps (
71
+ const call_grapht::directed_grapht &graph,
72
+ const irep_idt &start_function,
73
+ std::size_t &n,
74
+ bool forwards);
75
+
52
76
#endif
You can’t perform that action at this time.
0 commit comments