Go to the documentation of this file.
21 collect_callsites(collect_callsites)
30 call_grapht(goto_model.goto_functions, collect_callsites)
40 collect_callsites(collect_callsites)
44 const irep_idt &function_name = f_it->first;
46 nodes.insert(function_name);
47 add(function_name, body);
57 if(i_it->is_function_call())
60 if(function_expr.
id()==ID_symbol)
63 call_task(i_it, callee);
77 bool collect_callsites):
78 collect_callsites(collect_callsites)
80 std::stack<irep_idt, std::vector<irep_idt>> pending_stack;
81 pending_stack.push(root);
83 while(!pending_stack.empty())
85 irep_idt function=pending_stack.top();
88 nodes.insert(
function);
91 const auto &it = goto_functions.
function_map.find(
function);
101 add(
function, callee, i_it);
103 pending_stack.push(callee);
117 bool collect_callsites):
118 call_grapht(goto_model.goto_functions, root, collect_callsites)
130 add(
function, callee, i_it);
142 edges.insert({caller, callee});
143 nodes.insert(caller);
144 nodes.insert(callee);
159 callsites[{caller, callee}].insert(callsite);
168 for(
const auto &caller_callee :
edges)
169 result.
add(caller_callee.second, caller_callee.first);
194 findit.first->second=new_index;
195 graph[new_index].function=
function;
197 return findit.first->second;
216 function_indices[function_name];
218 for(
const auto &edge :
edges)
220 auto a_index=function_indices[edge.first];
221 auto b_index=function_indices[edge.second];
256 out <<
"digraph call_graph {\n";
258 for(
const auto &edge :
edges)
260 out <<
" \"" << edge.first <<
"\" -> "
261 <<
"\"" << edge.second <<
"\" "
262 <<
" [arrowhead=\"vee\"";
273 for(
const auto &edge :
edges)
275 out << edge.first <<
" -> " << edge.second <<
"\n";
286 out <<
"<!-- XML call-graph representation does not document callsites yet."
287 " If you need this, edit call_grapht::output_xml -->\n";
288 for(
const auto &edge :
edges)
290 out <<
"<call_graph_edge caller=\"";
292 out <<
"\" callee=\"";
305 return findit->second;
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
static void forall_callsites(const goto_programt &body, std::function< void(goto_programt::const_targett, const irep_idt &)> call_task)
call_grapht get_inverted() const
Returns an inverted copy of this call graph.
Helper class that maintains a map from function name to grapht node index and adds nodes to the graph...
optionalt< node_indext > get_node_index(const irep_idt &function) const
Find the graph node by function name.
bool has_edge(node_indext i, node_indext j) const
call_grapht(bool collect_callsites=false)
Create empty call graph.
call_grapht::directed_grapht & graph
node_indext add_node(arguments &&... values)
std::unordered_map< irep_idt, node_indext > function_indices
Base class for all expressions.
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
function_mapt function_map
void output_xml(std::ostream &out) const
void output_dot(std::ostream &out) const
nodet::node_indext node_indext
const std::string & id2string(const irep_idt &d)
#define PRECONDITION(CONDITION)
const irep_idt & get_identifier() const
Directed graph representation of this call graph.
function_indicest(call_grapht::directed_grapht &graph)
static void escape_attribute(const std::string &s, std::ostream &out)
escaping for XML attributes, assuming that double quotes " are used consistently, not single quotes
std::unordered_map< irep_idt, node_indext > nodes_by_name
Maps function names onto node indices.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const irep_idt & id() const
const code_function_callt & to_code_function_call(const codet &code)
directed_grapht get_directed_graph() const
Returns a grapht representation of this call graph, suitable for use with generic grapht algorithms.
void add_edge(node_indext a, node_indext b)
nonstd::optional< T > optionalt
std::string format_callsites(const edget &edge) const
Prints callsites responsible for a graph edge as comma-separated location numbers,...
const edgest & out(node_indext n) const
A collection of goto functions.
A call graph (https://en.wikipedia.org/wiki/Call_graph) for a GOTO model or GOTO functions collection...
std::pair< irep_idt, irep_idt > edget
Type of a call graph edge in edgest
callsitest callsites
Map from call-graph edges to a set of callsites that make the given call.
node_indext operator[](const irep_idt &function)
void output(std::ostream &out) const
A generic container class for the GOTO intermediate representation of one function.
#define forall_goto_functions(it, functions)
call_grapht::directed_grapht::node_indext node_indext
instructionst::const_iterator const_targett
void add(const irep_idt &caller, const irep_idt &callee)
Add edge.
goto_programt::const_targett locationt
Type of a callsite stored in member callsites
API to expression classes.
edgest edges
Call graph, including duplicate key-value pairs when there are parallel edges (see grapht documentati...
#define forall_goto_program_instructions(it, program)