File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 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
107107 return result;
108108}
109109
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+
110130std::unordered_set<irep_idt, irep_id_hash>
111131call_grapht::reachable_functions (irep_idt start_function)
112132{
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ class call_grapht: public grapht<call_graph_nodet>
4646 call_grapht get_inverted () const ;
4747 std::unordered_set<irep_idt, irep_id_hash>
4848 reachable_functions (irep_idt start);
49+ std::list<irep_idt>shortest_function_path (irep_idt src, irep_idt dest);
4950
5051 bool get_node_index (const irep_idt& function_name, node_indext &n) const
5152 {
You can’t perform that action at this time.
0 commit comments