cprover
natural_loops_templatet< P, T > Class Template Reference

Main driver for working out if a class (normally goto_programt) has any natural loops. More...

#include <natural_loops.h>

+ Inheritance diagram for natural_loops_templatet< P, T >:
+ Collaboration diagram for natural_loops_templatet< P, T >:

Public Types

typedef std::set< T > natural_loopt
 
typedef std::map< T, natural_looptloop_mapt
 

Public Member Functions

void operator() (P &program)
 
void output (std::ostream &) const
 Print all natural loops that were found. More...
 
const cfg_dominators_templatet< P, T, false > & get_dominator_info () const
 
 natural_loops_templatet ()
 
 natural_loops_templatet (P &program)
 

Public Attributes

loop_mapt loop_map
 

Protected Types

typedef cfg_dominators_templatet< P, T, false >::cfgt::nodet nodet
 

Protected Member Functions

void compute (P &program)
 Finds all back-edges and computes the natural loops. More...
 
void compute_natural_loop (T, T)
 Computes the natural loop for a given back-edge (see Muchnick section 7.4) More...
 

Protected Attributes

cfg_dominators_templatet< P, T, false > cfg_dominators
 

Detailed Description

template<class P, class T>
class natural_loops_templatet< P, T >

Main driver for working out if a class (normally goto_programt) has any natural loops.

compute takes an entire goto_programt, iterates over the instructions and for any backwards jumps attempts to find out if it's a natural loop.

All instructions in a natural loop are stored into loop_map, keyed by their head - the target of the backwards goto jump.

Template Parameters
Pthe program representation and needs: [field] instruction which is an iterable of type T.
Titerator of the particular node type, ex: std::list<...>::iterator. The object this iterator holds needs: [function] is_backwards_goto() returning a bool. [function] get_target() which returns an object that needs: [field] location_number which returns an unsigned int.

Definition at line 46 of file natural_loops.h.

Member Typedef Documentation

◆ loop_mapt

template<class P, class T>
typedef std::map<T, natural_loopt> natural_loops_templatet< P, T >::loop_mapt

Definition at line 52 of file natural_loops.h.

◆ natural_loopt

template<class P, class T>
typedef std::set<T> natural_loops_templatet< P, T >::natural_loopt

Definition at line 49 of file natural_loops.h.

◆ nodet

template<class P, class T>
typedef cfg_dominators_templatet<P, T, false>::cfgt::nodet natural_loops_templatet< P, T >::nodet
protected

Definition at line 79 of file natural_loops.h.

Constructor & Destructor Documentation

◆ natural_loops_templatet() [1/2]

template<class P, class T>
natural_loops_templatet< P, T >::natural_loops_templatet ( )
inline

Definition at line 68 of file natural_loops.h.

◆ natural_loops_templatet() [2/2]

template<class P, class T>
natural_loops_templatet< P, T >::natural_loops_templatet ( P &  program)
inlineexplicit

Definition at line 72 of file natural_loops.h.

Member Function Documentation

◆ compute()

template<class P, class T >
void natural_loops_templatet< P, T >::compute ( P &  program)
protected

Finds all back-edges and computes the natural loops.

Definition at line 106 of file natural_loops.h.

◆ compute_natural_loop()

template<class P , class T>
void natural_loops_templatet< P, T >::compute_natural_loop ( m,
n 
)
protected

Computes the natural loop for a given back-edge (see Muchnick section 7.4)

Definition at line 143 of file natural_loops.h.

◆ get_dominator_info()

template<class P, class T>
const cfg_dominators_templatet<P, T, false>& natural_loops_templatet< P, T >::get_dominator_info ( ) const
inline

Definition at line 63 of file natural_loops.h.

◆ operator()()

template<class P, class T>
void natural_loops_templatet< P, T >::operator() ( P &  program)
inline

Definition at line 56 of file natural_loops.h.

◆ output()

template<class P , class T >
void natural_loops_templatet< P, T >::output ( std::ostream &  out) const

Print all natural loops that were found.

Definition at line 178 of file natural_loops.h.

Member Data Documentation

◆ cfg_dominators

template<class P, class T>
cfg_dominators_templatet<P, T, false> natural_loops_templatet< P, T >::cfg_dominators
protected

Definition at line 78 of file natural_loops.h.

◆ loop_map

template<class P, class T>
loop_mapt natural_loops_templatet< P, T >::loop_map

Definition at line 54 of file natural_loops.h.


The documentation for this class was generated from the following file: