File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,26 @@ call_grapht call_grapht::get_inverted() const
107
107
return result;
108
108
}
109
109
110
+ std::list<irep_idt>call_grapht::shortest_function_path
111
+ (irep_idt src, irep_idt dest)
112
+ {
113
+ std::list<irep_idt> result;
114
+ node_indext src_idx, dest_idx;
115
+ if (!get_node_index (src, src_idx))
116
+ throw " unable to find src function in call graph" ;
117
+ if (!get_node_index (dest, dest_idx))
118
+ throw " unable to find destination function in call graph" ;
119
+
120
+ patht path;
121
+ shortest_path (src_idx, dest_idx, path);
122
+ for (const auto &n : path)
123
+ {
124
+ result.push_back (nodes[n].function_name );
125
+ }
126
+ return result;
127
+ }
128
+
129
+
110
130
std::unordered_set<irep_idt, irep_id_hash>
111
131
call_grapht::reachable_functions (irep_idt start_function)
112
132
{
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ class call_grapht: public grapht<call_graph_nodet>
46
46
call_grapht get_inverted () const ;
47
47
std::unordered_set<irep_idt, irep_id_hash>
48
48
reachable_functions (irep_idt start);
49
+ std::list<irep_idt>shortest_function_path (irep_idt src, irep_idt dest);
49
50
50
51
bool get_node_index (const irep_idt& function_name, node_indext &n) const
51
52
{
You can’t perform that action at this time.
0 commit comments