Cppcheck
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
Variables Class Reference

This class is used create a list of variables within a function. More...

Classes

class  VariableUsage
 Store information about variable usage. More...
 

Public Types

enum  VariableType {
  standard , array , pointer , reference ,
  pointerArray , referenceArray , pointerPointer , none
}
 

Public Member Functions

void clear ()
 
const std::map< nonneg int, VariableUsage > & varUsage () const
 
void addVar (const Variable *var, VariableType type, bool write_)
 
void allocateMemory (nonneg int varid, const Token *tok)
 
void read (nonneg int varid, const Token *tok)
 
void readAliases (nonneg int varid, const Token *tok)
 
void readAll (nonneg int varid, const Token *tok)
 
void write (nonneg int varid, const Token *tok)
 
void writeAliases (nonneg int varid, const Token *tok)
 
void writeAll (nonneg int varid, const Token *tok)
 
void use (nonneg int varid, const Token *tok)
 
void modified (nonneg int varid, const Token *tok)
 
VariableUsagefind (nonneg int varid)
 
void alias (nonneg int varid1, nonneg int varid2, bool replace)
 Alias the 2 given variables. More...
 
void erase (nonneg int varid)
 
void eraseAliases (nonneg int varid)
 
void eraseAll (nonneg int varid)
 
void clearAliases (nonneg int varid)
 

Private Attributes

std::map< nonneg int, VariableUsagemVarUsage
 

Detailed Description

This class is used create a list of variables within a function.

Definition at line 102 of file checkunusedvar.cpp.

Member Enumeration Documentation

◆ VariableType

Enumerator
standard 
array 
pointer 
reference 
pointerArray 
referenceArray 
pointerPointer 
none 

Definition at line 104 of file checkunusedvar.cpp.

Member Function Documentation

◆ addVar()

void Variables::addVar ( const Variable var,
VariableType  type,
bool  write_ 
)

◆ alias()

void Variables::alias ( nonneg int  varid1,
nonneg int  varid2,
bool  replace 
)

Alias the 2 given variables.

Either replace the existing aliases if they exist or merge them. You would replace an existing alias when this assignment is in the same scope as the previous assignment. You might merge the aliases when this assignment is in a different scope from the previous assignment depending on the relationship of the 2 scopes.

Definition at line 184 of file checkunusedvar.cpp.

References Variables::VariableUsage::_aliases, Variables::VariableUsage::_read, Variables::VariableUsage::_var, Variable::declarationId(), find(), Variables::VariableUsage::mType, pointer, replace(), and Variables::VariableUsage::use().

Referenced by doAssignment().

◆ allocateMemory()

void Variables::allocateMemory ( nonneg int  varid,
const Token tok 
)

◆ clear()

void Variables::clear ( )
inline

Definition at line 146 of file checkunusedvar.cpp.

References mVarUsage.

Referenced by CheckUnusedVar::checkFunctionVariableUsage_iterateScopes().

◆ clearAliases()

void Variables::clearAliases ( nonneg int  varid)

◆ erase()

void Variables::erase ( nonneg int  varid)
inline

◆ eraseAliases()

void Variables::eraseAliases ( nonneg int  varid)

Definition at line 244 of file checkunusedvar.cpp.

References Variables::VariableUsage::_aliases, erase(), and find().

Referenced by eraseAll().

◆ eraseAll()

void Variables::eraseAll ( nonneg int  varid)

◆ find()

Variables::VariableUsage * Variables::find ( nonneg int  varid)

◆ modified()

void Variables::modified ( nonneg int  varid,
const Token tok 
)

◆ read()

void Variables::read ( nonneg int  varid,
const Token tok 
)

◆ readAliases()

void Variables::readAliases ( nonneg int  varid,
const Token tok 
)

◆ readAll()

void Variables::readAll ( nonneg int  varid,
const Token tok 
)

◆ use()

void Variables::use ( nonneg int  varid,
const Token tok 
)

◆ varUsage()

const std::map<nonneg int, VariableUsage>& Variables::varUsage ( ) const
inline

Definition at line 149 of file checkunusedvar.cpp.

References mVarUsage.

Referenced by CheckUnusedVar::checkFunctionVariableUsage().

◆ write()

void Variables::write ( nonneg int  varid,
const Token tok 
)

◆ writeAliases()

void Variables::writeAliases ( nonneg int  varid,
const Token tok 
)

◆ writeAll()

void Variables::writeAll ( nonneg int  varid,
const Token tok 
)

Member Data Documentation

◆ mVarUsage

std::map<nonneg int, VariableUsage> Variables::mVarUsage
private

Definition at line 173 of file checkunusedvar.cpp.

Referenced by addVar(), clear(), erase(), find(), and varUsage().


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