retdec
Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
retdec::llvmir2hll::VarDefCFGTraversal Class Referencefinal

A CFG traversal that checks whether a variable is defined/modified between two statements. More...

#include <var_def_cfg_traversal.h>

Inheritance diagram for retdec::llvmir2hll::VarDefCFGTraversal:
Inheritance graph
[legend]
Collaboration diagram for retdec::llvmir2hll::VarDefCFGTraversal:
Collaboration graph
[legend]

Static Public Member Functions

static bool isVarDefBetweenStmts (const VarSet &vars, ShPtr< Statement > start, ShPtr< Statement > end, ShPtr< CFG > cfg, ShPtr< ValueAnalysis > va)
 Returns true if a variable from vars is defined between start and end in cfg, false otherwise. More...
 

Private Member Functions

 VarDefCFGTraversal (ShPtr< CFG > cfg, const VarSet &vars, ShPtr< Statement > end, ShPtr< ValueAnalysis > va)
 Constructs a new traverser. More...
 
virtual bool visitStmt (ShPtr< Statement > stmt) override
 Visits the given statement stmt. More...
 
virtual bool getEndRetVal () const override
 Returns the value that should be returned when an end of the traversal is reached. More...
 
virtual bool combineRetVals (bool origRetVal, bool newRetVal) const override
 Computes a new return value from the original return value (origRetVal) and the new return value (newRetVal). More...
 

Private Attributes

const VarSetvars
 Variables for whose definition/modification we're looking for. More...
 
ShPtr< Statementend
 Statement at which we should end the traversal. More...
 
ShPtr< ValueAnalysisva
 The used analysis of values. More...
 

Additional Inherited Members

- Protected Member Functions inherited from retdec::llvmir2hll::CFGTraversal
 CFGTraversal (ShPtr< CFG > cfg, bool defaultCurrRetVal)
 Constructs a new traverser. More...
 
 ~CFGTraversal ()=default
 
bool getCurrRetVal () const
 Returns the value that should be returned as the result of visiting a statement. More...
 
bool performTraversal (ShPtr< Statement > startStmt)
 Performs a traversal of the current CFG, starting at startStmt. More...
 
bool performTraversalFromSuccessors (ShPtr< Statement > stmt)
 Performs a traversal of the current CFG, starting at the successor(s) of stmt. More...
 
bool performReverseTraversal (ShPtr< Statement > startStmt)
 Performs a reverse traversal of the current CFG, starting at startStmt. More...
 
bool performReverseTraversalFromPredecessors (ShPtr< Statement > stmt)
 Performs a reverse traversal of the current CFG, starting at the predecessor(s) of stmt. More...
 
- Protected Attributes inherited from retdec::llvmir2hll::CFGTraversal
ShPtr< CFGcfg
 CFG that is being traversed. More...
 
StmtUSet checkedStmts
 Statements that have been checked (to prevent looping). More...
 
bool currRetVal
 Current return value of visitStmt(). More...
 
bool stopTraversal
 Should the traversal be stopped? More...
 

Detailed Description

A CFG traversal that checks whether a variable is defined/modified between two statements.

Instances of this class have reference object semantics. This is a concrete traverser which should not be subclassed.

Constructor & Destructor Documentation

◆ VarDefCFGTraversal()

retdec::llvmir2hll::VarDefCFGTraversal::VarDefCFGTraversal ( ShPtr< CFG cfg,
const VarSet vars,
ShPtr< Statement end,
ShPtr< ValueAnalysis va 
)
private

Constructs a new traverser.

Parameters
[in]cfgCFG that should be traversed.
[in]varsVariables for whose definition/modification we're looking for.
[in]endStatement at which we should end the traversal.
[in]vaAnalysis of values.

Member Function Documentation

◆ combineRetVals()

bool retdec::llvmir2hll::VarDefCFGTraversal::combineRetVals ( bool  origRetVal,
bool  newRetVal 
) const
overrideprivatevirtual

Computes a new return value from the original return value (origRetVal) and the new return value (newRetVal).

Implements retdec::llvmir2hll::CFGTraversal.

◆ getEndRetVal()

bool retdec::llvmir2hll::VarDefCFGTraversal::getEndRetVal ( ) const
overrideprivatevirtual

Returns the value that should be returned when an end of the traversal is reached.

For example, the end may mean the end node of the CFG or a statement that has already been traversed.

Implements retdec::llvmir2hll::CFGTraversal.

◆ isVarDefBetweenStmts()

bool retdec::llvmir2hll::VarDefCFGTraversal::isVarDefBetweenStmts ( const VarSet vars,
ShPtr< Statement start,
ShPtr< Statement end,
ShPtr< CFG cfg,
ShPtr< ValueAnalysis va 
)
static

Returns true if a variable from vars is defined between start and end in cfg, false otherwise.

Parameters
[in]varsVariables for whose definition/modification we're looking for.
[in]startThe search starts from the statement before start.
[in]endStatement at which we should end the traversal.
[in]cfgCFG that should be traversed.
[in]vaAnalysis of values.

The search starts from the first statement after start.

Preconditions
  • start, end, and va are non-null
  • va is in a valid state

This function leaves va in a valid state.

◆ visitStmt()

bool retdec::llvmir2hll::VarDefCFGTraversal::visitStmt ( ShPtr< Statement stmt)
overrideprivatevirtual

Visits the given statement stmt.

return true if the traversing should continue, false otherwise.

Note: checkedStmts is modified in CFGTraversal, so it is not necessary for the implementation of this function to add stmt to checkedStmts.

If you want the traversal to end prematurely, set the stopTraversal variable to true. Otherwise, if you just return false, the traversal may still continue from other branches because of recursion.

Implements retdec::llvmir2hll::CFGTraversal.

Member Data Documentation

◆ end

ShPtr<Statement> retdec::llvmir2hll::VarDefCFGTraversal::end
private

Statement at which we should end the traversal.

◆ va

ShPtr<ValueAnalysis> retdec::llvmir2hll::VarDefCFGTraversal::va
private

The used analysis of values.

◆ vars

const VarSet& retdec::llvmir2hll::VarDefCFGTraversal::vars
private

Variables for whose definition/modification we're looking for.


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