CBMC
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Private Types | List of all members
cfg_baset< T, P, I > Class Template Reference

A multi-procedural control flow graph (CFG) whose nodes store references to instructions in a GOTO program. More...

#include <cfg.h>

+ Inheritance diagram for cfg_baset< T, P, I >:
+ Collaboration diagram for cfg_baset< T, P, I >:

Classes

class   entry_mapt
 

Public Types

 
 
- Public Types inherited from grapht< N >
 
typedef nodet::edgest  edgest
 
typedef std::vector< nodetnodest
 
typedef nodet::edget  edget
 
typedef nodet::node_indext  node_indext
 
typedef std::list< node_indextpatht
 

Public Member Functions

  cfg_baset ()
 
 
void  operator() (const goto_functionst &goto_functions)
 
void  operator() (P &goto_program)
 
  Get the graph node index for program_point.
 
  Get the CFG graph node relating to program_point.
 
  Get the CFG graph node relating to program_point.
 
  Get a map from program points to their corresponding node indices.
 
- Public Member Functions inherited from grapht< N >
template<typename... arguments>
node_indext  add_node (arguments &&... values)
 
void  swap (grapht &other)
 
 
 
 
 
std::size_t  size () const
 
 
 
 
 
 
 
 
 
 
 
 
void  clear ()
 
 
 
 
  Run depth-first search on the graph, starting from a single source node.
 
std::vector< node_indextget_reachable (const std::vector< node_indext > &src, bool forwards) const
  Run depth-first search on the graph, starting from multiple source nodes.
 
  Removes any edges between nodes in a graph that are unreachable from a given start node.
 
void  disconnect_unreachable (const std::vector< node_indext > &src)
  Removes any edges between nodes in a graph that are unreachable from a vector of start nodes.
 
std::vector< typename N::node_indext >  depth_limited_search (typename N::node_indext src, std::size_t limit) const
  Run recursive depth-limited search on the graph, starting from multiple source nodes, to find the nodes reachable within n steps.
 
std::vector< typename N::node_indext >  depth_limited_search (std::vector< typename N::node_indext > &src, std::size_t limit) const
  Run recursive depth-limited search on the graph, starting from multiple source nodes, to find the nodes reachable within n steps.
 
  Ensure a graph is chordal (contains no 4+-cycles without an edge crossing the cycle) by adding extra edges.
 
std::size_t  connected_subgraphs (std::vector< node_indext > &subgraph_nr)
  Find connected subgraphs in an undirected graph.
 
std::size_t  SCCs (std::vector< node_indext > &subgraph_nr) const
  Computes strongly-connected components of a graph and yields a vector expressing a mapping from nodes to components indices.
 
 
std::list< node_indexttopsort () const
  Find a topological order of the nodes if graph is DAG, return empty list for non-DAG or empty graph.
 
 
 
void  output_dot (std::ostream &out) const
 
 
 

Static Public Member Functions

static I  get_first_node (P &program)
 
static I  get_last_node (P &program)
 
static bool  nodes_empty (P &program)
 

Public Attributes

 

Protected Member Functions

 
 
 
 
 
void  compute_edges (const goto_functionst &goto_functions, const goto_programt &goto_program, I PC)
 
void  compute_edges (const goto_functionst &goto_functions, P &goto_program)
 
 
- Protected Member Functions inherited from grapht< N >
std::vector< typename N::node_indext >  depth_limited_search (std::vector< typename N::node_indext > &src, std::size_t limit, std::vector< bool > &visited) const
  Run recursive depth-limited search on the graph, starting from multiple source nodes, to find the nodes reachable within n steps.
 
 
 

Private Types

 

Additional Inherited Members

- Protected Attributes inherited from grapht< N >
 

Detailed Description

template<class T, typename P = const goto_programt, typename I = goto_programt::const_targett>
class cfg_baset< T, P, I >

A multi-procedural control flow graph (CFG) whose nodes store references to instructions in a GOTO program.

An instance of cfg_baset<T> is a directed graph whose nodes inherit from a user-provided type T and store a pointer to an instruction of some goto program in the field PC. The field PC of every node points to the original GOTO instruction that gave rise to the node, and the field cfg_baset::entry_map maps every GOTO instruction to some CFG node.

The CFG is constructed on the operator() from either one goto_programt or multiple goto_programt objects (stored in a goto_functionst). The edges of the CFG are created on the method compute_edges(), and notably include:

  • Edges from location A to B if both A and B belong to the same goto_programt and A can flow into B.
  • An edge from each FUNCTION_CALL instruction and the first instruction of the called function, when that function body is available and its body is non-empty.
  • For each FUNCTION_CALL instruction found, an edge between the exit point of the called function and the instruction immediately after the FUNCTION_CALL, when the function body is available and its body is non-empty.

    Note that cfg_baset is the base class of many other subclasses and the specific edges constructed by operator() can be different in those.

Definition at line 86 of file cfg.h.

Member Typedef Documentation

◆  base_grapht

template<class T , typename P = const goto_programt, typename I = goto_programt::const_targett>
typedef grapht<cfg_base_nodet<T, I> > cfg_baset< T, P, I >::base_grapht
private

Definition at line 88 of file cfg.h.

◆  entryt

template<class T , typename P = const goto_programt, typename I = goto_programt::const_targett>

Definition at line 91 of file cfg.h.

◆  nodet

template<class T , typename P = const goto_programt, typename I = goto_programt::const_targett>

Definition at line 92 of file cfg.h.

Constructor & Destructor Documentation

◆  cfg_baset()

template<class T , typename P = const goto_programt, typename I = goto_programt::const_targett>
cfg_baset< T, P, I >::cfg_baset ( )
inline

Definition at line 199 of file cfg.h.

◆  ~cfg_baset()

template<class T , typename P = const goto_programt, typename I = goto_programt::const_targett>
virtual cfg_baset< T, P, I >::~cfg_baset ( )
inlinevirtual

Definition at line 203 of file cfg.h.

Member Function Documentation

◆  compute_edges() [1/3]

template<class T , typename P , typename I >
void cfg_baset< T, P, I >::compute_edges ( const goto_functionstgoto_functions )
protected

Definition at line 539 of file cfg.h.

◆  compute_edges() [2/3]

template<class T , typename P , typename I >
void cfg_baset< T, P, I >::compute_edges ( const goto_functionstgoto_functions,
const goto_programtgoto_program,
I  PC 
)
protected

Definition at line 453 of file cfg.h.

◆  compute_edges() [3/3]

template<class T , typename P , typename I >
void cfg_baset< T, P, I >::compute_edges ( const goto_functionstgoto_functions,
Pgoto_program 
)
protected

Definition at line 528 of file cfg.h.

◆  compute_edges_catch()

template<class T , typename P , typename I >
void cfg_baset< T, P, I >::compute_edges_catch ( const goto_programtgoto_program,
entrytentry 
)
protectedvirtual

Definition at line 332 of file cfg.h.

◆  compute_edges_function_call()

template<class T , typename P , typename I >
void cfg_baset< T, P, I >::compute_edges_function_call ( const goto_functionstgoto_functions,
const goto_programtgoto_program,
entrytentry 
)
protectedvirtual

Definition at line 387 of file cfg.h.

◆  compute_edges_goto()

template<class T , typename P , typename I >
void cfg_baset< T, P, I >::compute_edges_goto ( const goto_programtgoto_program,
entrytentry 
)
protectedvirtual

Definition at line 315 of file cfg.h.

◆  compute_edges_start_thread()

template<class T , typename P , typename I >
void cfg_baset< T, P, I >::compute_edges_start_thread ( const goto_programtgoto_program,
entrytentry 
)
protectedvirtual

Definition at line 360 of file cfg.h.

◆  compute_edges_throw()

template<class T , typename P , typename I >
void cfg_baset< T, P, I >::compute_edges_throw ( const goto_programtgoto_program,
entrytentry 
)
protectedvirtual

Definition at line 350 of file cfg.h.

◆  entries()

template<class T , typename P = const goto_programt, typename I = goto_programt::const_targett>
const entry_mapt & cfg_baset< T, P, I >::entries ( ) const
inline

Get a map from program points to their corresponding node indices.

Use the indices with operator[] similar to those returned by get_node_index.

Definition at line 259 of file cfg.h.

◆  get_first_node()

template<class T , typename P = const goto_programt, typename I = goto_programt::const_targett>
static I cfg_baset< T, P, I >::get_first_node ( Pprogram )
inlinestatic

Definition at line 264 of file cfg.h.

◆  get_last_node()

template<class T , typename P = const goto_programt, typename I = goto_programt::const_targett>
static I cfg_baset< T, P, I >::get_last_node ( Pprogram )
inlinestatic

Definition at line 268 of file cfg.h.

◆  get_node() [1/2]

template<class T , typename P = const goto_programt, typename I = goto_programt::const_targett>
nodet & cfg_baset< T, P, I >::get_node ( const goto_programt::const_targettprogram_point )
inline

Get the CFG graph node relating to program_point.

Definition at line 245 of file cfg.h.

◆  get_node() [2/2]

template<class T , typename P = const goto_programt, typename I = goto_programt::const_targett>
const nodet & cfg_baset< T, P, I >::get_node ( const goto_programt::const_targettprogram_point ) const
inline

Get the CFG graph node relating to program_point.

Definition at line 251 of file cfg.h.

◆  get_node_index()

template<class T , typename P = const goto_programt, typename I = goto_programt::const_targett>
entryt cfg_baset< T, P, I >::get_node_index ( const goto_programt::const_targettprogram_point ) const
inline

Get the graph node index for program_point.

Use this with operator[] to get the related graph node (e.g. cfg[cfg.get_node_index(i)], though in that particular case you should just use cfg.get_node(i)). Storing node indices saves a map lookup, so it can be worthwhile when you expect to repeatedly look up the same program point.

Definition at line 239 of file cfg.h.

◆  nodes_empty()

template<class T , typename P = const goto_programt, typename I = goto_programt::const_targett>
static bool cfg_baset< T, P, I >::nodes_empty ( Pprogram )
inlinestatic

Definition at line 272 of file cfg.h.

◆  operator()() [1/2]

template<class T , typename P = const goto_programt, typename I = goto_programt::const_targett>
void cfg_baset< T, P, I >::operator() ( const goto_functionstgoto_functions )
inline

Definition at line 207 of file cfg.h.

◆  operator()() [2/2]

template<class T , typename P = const goto_programt, typename I = goto_programt::const_targett>
void cfg_baset< T, P, I >::operator() ( Pgoto_program )
inline

Definition at line 222 of file cfg.h.

Member Data Documentation

◆  entry_map

template<class T , typename P = const goto_programt, typename I = goto_programt::const_targett>
entry_mapt cfg_baset< T, P, I >::entry_map

Definition at line 152 of file cfg.h.


The documentation for this class was generated from the following file:
  • /home/runner/work/cbmc/cbmc/src/goto-programs/cfg.h

AltStyle によって変換されたページ (->オリジナル) /