CodeSonar C++ API
[For improved navigation, enable JavaScript.]
Public Member Functions | List of all members
cs::step_state Class Referenceabstract

Abstract base class for step visitors, as added with analysis::add_step_bottom_up_visitor(): subclass to define your own step visitors. More...

Public Member Functions

 step_state ()
 Constructor. More...
 
 step_state (const step_state &)
 Copy constructor. More...
 
virtual ~step_state ()
 Destructor, invoked by CodeSonar when the step_state is no longer needed. More...
 
virtual std::string as_repr () const
 Get a representation of a step_state object that includes information useful for debugging. More...
 
virtual std::string as_string () const
 Get a simple string representation of a step_state object. More...
 
virtual step_statecopy () const =0
 Dynamically allocate and return a new copy of a step_state. More...
 
virtual void transition (point source, edge_label label, point destination, step_xform since_entry, step_xform this_edge, step_path path)=0
 Perform any operations associated with a specified transition in the CFG, and update the step_state. More...
 

Detailed Description

Abstract base class for step visitors, as added with analysis::add_step_bottom_up_visitor(): subclass to define your own step visitors.

Step visitors are applied during CodeSonar's traversal of the program CFGs (control flow graphs) in the bottom-up phase.

The step_state keeps track of program state as CodeSonar explores the program procedures. For a subclass to be used in a step visitor, it must declare any additional data members the step visitor requires to keep track of program state and define the various member methods to operate appropriately on this additional data. CodeSonar will then do bookkeeping for the visitor, applying the various methods as shown in the following table.

step_state... definition must... applied by CodeSonar ...
copy() ensure your additional data members are copied correctly. to initial instance I (see below) to set up initial state every time the step traversal enters a function, and to the current state every time the step traversal encounters a CFG branch.
transition() perform any operations associated with a transition in the CFG, updating the additional data members as needed. when step traversal transitions over a CFG edge.
destructor clean up your additional data members. when a step_state object is no longer needed.

Once you have defined your step_state class, create an instance I of the class and add it to the analysis with a suitable analysis::add_step_bottom_up_visitor() invocation (step visitors can only be applied in the bottom-up phase). I must be appropriately initialized: CodeSonar will invoke I->copy() to create a fresh step_state (subclass) object every time the step traversal enters a function.

Do not subsequently delete I. CodeSonar may continue to use it indefinitely.

Constructor & Destructor Documentation

◆ step_state() [1/2]

cs::step_state::step_state ( )
inline

Constructor.

When you subclass step_state to create a step visitor class, provide a definition for this, making sure that it correctly handles any additional data members you have added.

◆ step_state() [2/2]

cs::step_state::step_state ( const step_state )
inline

Copy constructor.

When you subclass step_state to create a step visitor class, provide a definition for this, making sure that it correctly handles any additional data members you have added.

◆ ~step_state()

virtual cs::step_state::~step_state ( )
inlinevirtual

Destructor, invoked by CodeSonar when the step_state is no longer needed.

When you subclass step_state to create a step visitor class, provide a definition for this, making sure that it cleans up any additional data members you have added.

Member Function Documentation

◆ as_repr()

virtual std::string cs::step_state::as_repr ( ) const
inlinevirtual

Get a representation of a step_state object that includes information useful for debugging.

Returns
The string representation.

◆ as_string()

virtual std::string cs::step_state::as_string ( ) const
inlinevirtual

Get a simple string representation of a step_state object.

Returns
The string representation.

◆ copy()

virtual step_state* cs::step_state::copy ( ) const
pure virtual

Dynamically allocate and return a new copy of a step_state.

Returns
A new copy of the step state.

CodeSonar will invoke this:

  • On initial instance I to set up initial state every time the step traversal enters a function.
  • On the current state every time the step traversal encounters a CFG branch.

When you subclass step_state to create a step visitor class, provide a definition for this, making sure that it correctly handles any additional data members you have added.

Because you will also be implementing the copy constructor, the copy() definition will typically be able to take the following form.

class my_step_state public step_state{
// ...
public :
// ...
step_state *copy() const {
return new my_step_state(*this);
}
// ...

◆ transition()

virtual void cs::step_state::transition ( point  source,
edge_label  label,
point  destination,
step_xform  since_entry,
step_xform  this_edge,
step_path  path 
)
pure virtual

Perform any operations associated with a specified transition in the CFG, and update the step_state.

Parameters
[in]sourceThe point being transitioned from.
[in]labelThe label on the edge between source and destination.
[in]destinationThe point being transitioned to.
[in]since_entryThe transformation the program has undergone between the function entry point and destination. Do not attempt to use this step_xform object after transition() has returned.
[in]this_edgeThe transformation the program undergoes between source and destination. Do not attempt to use this step_xform object after transition() has returned.
[in]pathThe full step path from the function entry point to destination.
Returns
void

This will be invoked by CodeSonar every time the step traversal moves from source to destination over the edge labeled label.

When you subclass step_state to create a step visitor class, provide a definition for this, making sure that it correctly handles any additional data members you have added. (If you don't, the step visitor won't do anything!)


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