Reach.CallGraph (Reach v2.7.0)

Copy Markdown View Source

Builds call graph edges between function definitions.

Summary

Functions

Builds a call graph from a list of IR nodes (typically a whole module).

Collects all function definitions as {function_id, ir_node} pairs.

Finds which function definition contains a given node, based on the IR tree.

Types

function_id()

@type function_id() :: {module(), atom(), non_neg_integer()}

Functions

build(ir_nodes, opts \\ [])

@spec build(
  [Reach.IR.Node.t()],
  keyword()
) :: Graph.t()

Builds a call graph from a list of IR nodes (typically a whole module).

Returns a Graph.t() where vertices are {module, function, arity} tuples and edges are labeled with the call site node ID.

collect_function_defs(all_nodes, module_name)

@spec collect_function_defs([Reach.IR.Node.t()], module() | nil) :: [
  {function_id(), Reach.IR.Node.t()}
]

Collects all function definitions as {function_id, ir_node} pairs.

find_enclosing_function(ir_nodes, target_id)

@spec find_enclosing_function([Reach.IR.Node.t()], Reach.IR.Node.id()) ::
  function_id() | nil

Finds which function definition contains a given node, based on the IR tree.