retdec
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
retdec::llvmir2hll::UsedVars Class Reference

Used variables for a value (expression, statement). More...

#include <used_vars_visitor.h>

Collaboration diagram for retdec::llvmir2hll::UsedVars:
Collaboration graph
[legend]

Public Types

using var_iterator = VarSet::const_iterator
 Variables iterator. More...
 

Public Member Functions

 UsedVars (const UsedVars &other)=default
 
UsedVarsoperator= (const UsedVars &other)=default
 
bool operator== (const UsedVars &other) const
 Returns true if the current object is equal to other, false otherwise. More...
 
bool operator!= (const UsedVars &other) const
 Returns true if the current object is not equal to other, false otherwise. More...
 
VarSet getReadVars () const
 Returns the variables that are read. More...
 
VarSet getWrittenVars () const
 Returns the variables that are written into. More...
 
VarSet getAllVars () const
 Returns read variables merged with written-into variables. More...
 
std::size_t getCount (bool read=true, bool written=true) const
 Returns the number of used variables. More...
 
std::size_t getNumOfUses (ShPtr< Variable > var) const
 Returns the number of uses of var. More...
 
bool isUsed (ShPtr< Variable > var, bool read=true, bool written=true) const
 Returns true if var is used, false otherwise. More...
 
Used Variables Accessors
var_iterator read_begin () const
 Returns an iterator to the first read variable. More...
 
var_iterator read_end () const
 Returns an iterator past the last read variable. More...
 
var_iterator written_begin () const
 Returns an iterator to the first written variable. More...
 
var_iterator written_end () const
 Returns an iterator past the last written variable. More...
 
var_iterator all_begin () const
 Returns an iterator to the first variable. More...
 
var_iterator all_end () const
 Returns an iterator past the last variable. More...
 

Private Types

using VarCountMap = std::map< ShPtr< Variable >, std::size_t >
 Mapping of a variable into a count. More...
 

Private Member Functions

 UsedVars ()
 Constructs a new UsedVars object. More...
 
void clear ()
 Clears all private containers. More...
 

Private Attributes

VarSet readVars
 Set of variables that are read. More...
 
VarSet writtenVars
 Set of variables into which something is written. More...
 
VarSet allVars
 Set of all variables (read or written). More...
 
VarCountMap numOfVarUses
 Number of uses of a variable. More...
 

Friends

class UsedVarsVisitor
 

Detailed Description

Used variables for a value (expression, statement).

See UsedVarsVisitor for a way of creating instances of this class.

Instances of this class have value object semantics.

Member Typedef Documentation

◆ var_iterator

using retdec::llvmir2hll::UsedVars::var_iterator = VarSet::const_iterator

Variables iterator.

◆ VarCountMap

using retdec::llvmir2hll::UsedVars::VarCountMap = std::map<ShPtr<Variable>, std::size_t>
private

Mapping of a variable into a count.

Constructor & Destructor Documentation

◆ UsedVars() [1/2]

retdec::llvmir2hll::UsedVars::UsedVars ( const UsedVars other)
default

◆ UsedVars() [2/2]

retdec::llvmir2hll::UsedVars::UsedVars ( )
private

Constructs a new UsedVars object.

Member Function Documentation

◆ all_begin()

UsedVars::var_iterator retdec::llvmir2hll::UsedVars::all_begin ( ) const

Returns an iterator to the first variable.

◆ all_end()

UsedVars::var_iterator retdec::llvmir2hll::UsedVars::all_end ( ) const

Returns an iterator past the last variable.

◆ clear()

void retdec::llvmir2hll::UsedVars::clear ( )
private

Clears all private containers.

◆ getAllVars()

VarSet retdec::llvmir2hll::UsedVars::getAllVars ( ) const

Returns read variables merged with written-into variables.

◆ getCount()

std::size_t retdec::llvmir2hll::UsedVars::getCount ( bool  read = true,
bool  written = true 
) const

Returns the number of used variables.

Parameters
[in]readInclude the number of variables that are read.
[in]writtenInclude the number of written-into variables.

If a variable is both read and written, it is counted only once.

◆ getNumOfUses()

std::size_t retdec::llvmir2hll::UsedVars::getNumOfUses ( ShPtr< Variable var) const

Returns the number of uses of var.

Preconditions
  • var is non-null

◆ getReadVars()

VarSet retdec::llvmir2hll::UsedVars::getReadVars ( ) const

Returns the variables that are read.

◆ getWrittenVars()

VarSet retdec::llvmir2hll::UsedVars::getWrittenVars ( ) const

Returns the variables that are written into.

◆ isUsed()

bool retdec::llvmir2hll::UsedVars::isUsed ( ShPtr< Variable var,
bool  read = true,
bool  written = true 
) const

Returns true if var is used, false otherwise.

Parameters
[in]varVariable that is looked up.
[in]readConsider variables that are read.
[in]writtenConsider written-into variables.

◆ operator!=()

bool retdec::llvmir2hll::UsedVars::operator!= ( const UsedVars other) const

Returns true if the current object is not equal to other, false otherwise.

◆ operator=()

UsedVars& retdec::llvmir2hll::UsedVars::operator= ( const UsedVars other)
default

◆ operator==()

bool retdec::llvmir2hll::UsedVars::operator== ( const UsedVars other) const

Returns true if the current object is equal to other, false otherwise.

◆ read_begin()

UsedVars::var_iterator retdec::llvmir2hll::UsedVars::read_begin ( ) const

Returns an iterator to the first read variable.

◆ read_end()

UsedVars::var_iterator retdec::llvmir2hll::UsedVars::read_end ( ) const

Returns an iterator past the last read variable.

◆ written_begin()

UsedVars::var_iterator retdec::llvmir2hll::UsedVars::written_begin ( ) const

Returns an iterator to the first written variable.

◆ written_end()

UsedVars::var_iterator retdec::llvmir2hll::UsedVars::written_end ( ) const

Returns an iterator past the last written variable.

Friends And Related Function Documentation

◆ UsedVarsVisitor

friend class UsedVarsVisitor
friend

Member Data Documentation

◆ allVars

VarSet retdec::llvmir2hll::UsedVars::allVars
private

Set of all variables (read or written).

◆ numOfVarUses

VarCountMap retdec::llvmir2hll::UsedVars::numOfVarUses
private

Number of uses of a variable.

◆ readVars

VarSet retdec::llvmir2hll::UsedVars::readVars
private

Set of variables that are read.

◆ writtenVars

VarSet retdec::llvmir2hll::UsedVars::writtenVars
private

Set of variables into which something is written.


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