22 collect_callsites(collect_callsites)
31 call_grapht(goto_model.goto_functions, collect_callsites)
41 collect_callsites(collect_callsites)
47 nodes.insert(function_name);
48 add(function_name, body);
58 if(
i_it->is_function_call())
63 "call graph computation requires function pointer removal");
78 bool collect_callsites):
79 collect_callsites(collect_callsites)
89 nodes.insert(function);
92 const auto &it = goto_functions.
function_map.find(function);
118 bool collect_callsites):
119 call_grapht(goto_model.goto_functions, root, collect_callsites)
144 nodes.insert(caller);
198 return findit.first->second;
217 function_indices[function_name];
219 for(
const auto &edge :
edges)
221 auto a_index=function_indices[edge.first];
222 auto b_index=function_indices[edge.second];
249 ret+=std::to_string(loc->location_number);
257 out <<
"digraph call_graph {\n";
259 for(
const auto &edge :
edges)
261 out <<
" \"" << edge.first <<
"\" -> "
262 <<
"\"" << edge.second <<
"\" "
263 <<
" [arrowhead=\"vee\"";
274 for(
const auto &edge :
edges)
276 out << edge.first <<
" -> " << edge.second <<
"\n";
287 out <<
"<!-- XML call-graph representation does not document callsites yet."
288 " If you need this, edit call_grapht::output_xml -->\n";
289 for(
const auto &edge :
edges)
291 out <<
"<call_graph_edge caller=\"";
293 out <<
"\" callee=\"";
299std::optional<std::size_t>
304 return std::optional<node_indext>();
static void forall_callsites(const goto_programt &body, std::function< void(goto_programt::const_targett, const irep_idt &)> call_task)
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Directed graph representation of this call graph.
std::optional< node_indext > get_node_index(const irep_idt &function) const
Find the graph node by function name.
std::unordered_map< irep_idt, node_indext > nodes_by_name
Maps function names onto node indices.
A call graph (https://en.wikipedia.org/wiki/Call_graph) for a GOTO model or GOTO functions collection...
void add(const irep_idt &caller, const irep_idt &callee)
Add edge.
std::pair< irep_idt, irep_idt > edget
Type of a call graph edge in edgest
edgest edges
Call graph, including duplicate key-value pairs when there are parallel edges (see grapht documentati...
call_grapht get_inverted() const
Returns an inverted copy of this call graph.
void output_dot(std::ostream &out) const
std::string format_callsites(const edget &edge) const
Prints callsites responsible for a graph edge as comma-separated location numbers,...
directed_grapht get_directed_graph() const
Returns a grapht representation of this call graph, suitable for use with generic grapht algorithms.
call_grapht(bool collect_callsites=false)
Create empty call graph.
void output(std::ostream &out) const
callsitest callsites
Map from call-graph edges to a set of callsites that make the given call.
void output_xml(std::ostream &out) const
goto_programt::const_targett locationt
Type of a callsite stored in member callsites
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
Helper class that maintains a map from function name to grapht node index and adds nodes to the graph...
std::unordered_map< irep_idt, node_indext > function_indices
call_grapht::directed_grapht::node_indext node_indext
call_grapht::directed_grapht & graph
node_indext operator[](const irep_idt &function)
function_indicest(call_grapht::directed_grapht &graph)
A collection of goto functions.
function_mapt function_map
A generic container class for the GOTO intermediate representation of one function.
instructionst::const_iterator const_targett
nodet::node_indext node_indext
node_indext add_node(arguments &&... values)
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
#define forall_goto_program_instructions(it, program)
const std::string & id2string(const irep_idt &d)
#define PRECONDITION_WITH_DIAGNOSTICS(CONDITION,...)
#define PRECONDITION(CONDITION)
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.