Cppcheck
Classes | Functions
ValueFlow Namespace Reference

Classes

struct  LifetimeToken
 
class  Value
 

Functions

const Value * valueFlowConstantFoldAST (Token *expr, const Settings &settings)
 Constant folding of expression. This can be used before the full ValueFlow has been executed (ValueFlow::setValues). More...
 
void setValues (TokenList &tokenlist, SymbolDatabase &symboldatabase, ErrorLogger &errorLogger, const Settings &settings, TimerResultsIntf *timerResults)
 Perform valueflow analysis. More...
 
std::string eitherTheConditionIsRedundant (const Token *condition)
 
size_t getSizeOf (const ValueType &vt, const Settings &settings, int maxRecursion=0)
 
const Value * findValue (const std::list< Value > &values, const Settings &settings, const std::function< bool(const Value &)> &pred)
 
std::vector< Value > isOutOfBounds (const Value &size, const Token *indexTok, bool possible=true)
 
Value asImpossible (Value v)
 
bool isContainerSizeChanged (const Token *tok, int indirect, const Settings &settings, int depth=20)
 
const Token * parseCompareInt (const Token *tok, Value &true_value, Value &false_value, const std::function< std::vector< MathLib::bigint >(const Token *)> &evaluate)
 
const Token * parseCompareInt (const Token *tok, Value &true_value, Value &false_value)
 
CPPCHECKLIB ValuePtr< InferModel > makeIntegralInferModel ()
 
const Token * solveExprValue (const Token *expr, const std::function< std::vector< MathLib::bigint >(const Token *)> &eval, Value &value)
 
std::vector< LifetimeToken > getLifetimeTokens (const Token *tok, const Settings &settings, bool escape=false, Value::ErrorPath errorPath=Value::ErrorPath{})
 
bool hasLifetimeToken (const Token *tok, const Token *lifetime, const Settings &settings)
 
const Variable * getLifetimeVariable (const Token *tok, Value::ErrorPath &errorPath, const Settings &settings, bool *addressOf=nullptr)
 
const Variable * getLifetimeVariable (const Token *tok, const Settings &settings)
 
bool isLifetimeBorrowed (const Token *tok, const Settings &settings)
 
std::string lifetimeMessage (const Token *tok, const Value *val, Value::ErrorPath &errorPath)
 
CPPCHECKLIB Value getLifetimeObjValue (const Token *tok, bool inconclusive=false)
 
CPPCHECKLIB std::vector< Value > getLifetimeObjValues (const Token *tok, bool inconclusive=false, MathLib::bigint path=0)
 
const Token * getEndOfExprScope (const Token *tok, const Scope *defaultScope=nullptr, bool smallest=true)
 
void combineValueProperties (const Value &value1, const Value &value2, Value &result)
 

Function Documentation

◆ asImpossible()

ValueFlow::Value ValueFlow::asImpossible ( ValueFlow::Value  v)

◆ combineValueProperties()

void ValueFlow::combineValueProperties ( const Value &  value1,
const Value &  value2,
ValueFlow::Value &  result 
)

◆ eitherTheConditionIsRedundant()

std::string ValueFlow::eitherTheConditionIsRedundant ( const Token *  condition)

◆ findValue()

const Value* ValueFlow::findValue ( const std::list< Value > &  values,
const Settings &  settings,
const std::function< bool(const Value &)> &  pred 
)

◆ getEndOfExprScope()

const Token * ValueFlow::getEndOfExprScope ( const Token *  tok,
const Scope *  defaultScope = nullptr,
bool  smallest = true 
)

◆ getLifetimeObjValue()

ValueFlow::Value ValueFlow::getLifetimeObjValue ( const Token *  tok,
bool  inconclusive = false 
)

◆ getLifetimeObjValues()

std::vector< ValueFlow::Value > ValueFlow::getLifetimeObjValues ( const Token *  tok,
bool  inconclusive = false,
MathLib::bigint  path = 0 
)

◆ getLifetimeTokens()

std::vector< ValueFlow::LifetimeToken > ValueFlow::getLifetimeTokens ( const Token *  tok,
const Settings &  settings,
bool  escape = false,
Value::ErrorPath  errorPath = Value::ErrorPath{} 
)

◆ getLifetimeVariable() [1/2]

const Variable * ValueFlow::getLifetimeVariable ( const Token *  tok,
const Settings &  settings 
)

Definition at line 3773 of file valueflow.cpp.

References getLifetimeVariable().

◆ getLifetimeVariable() [2/2]

const Variable * ValueFlow::getLifetimeVariable ( const Token *  tok,
Value::ErrorPath &  errorPath,
const Settings &  settings,
bool *  addressOf = nullptr 
)

◆ getSizeOf()

size_t ValueFlow::getSizeOf ( const ValueType &  vt,
const Settings &  settings,
int  maxRecursion = 0 
)

◆ hasLifetimeToken()

bool ValueFlow::hasLifetimeToken ( const Token *  tok,
const Token *  lifetime,
const Settings &  settings 
)

Definition at line 3742 of file valueflow.cpp.

References Token::exprId(), and getLifetimeTokens().

◆ isContainerSizeChanged()

bool ValueFlow::isContainerSizeChanged ( const Token *  tok,
int  indirect,
const Settings &  settings,
int  depth = 20 
)

◆ isLifetimeBorrowed()

bool ValueFlow::isLifetimeBorrowed ( const Token *  tok,
const Settings &  settings 
)

◆ isOutOfBounds()

std::vector< ValueFlow::Value > ValueFlow::isOutOfBounds ( const Value &  size,
const Token *  indexTok,
bool  possible = true 
)

◆ lifetimeMessage()

std::string ValueFlow::lifetimeMessage ( const Token *  tok,
const Value *  val,
Value::ErrorPath &  errorPath 
)

◆ makeIntegralInferModel()

ValuePtr< InferModel > ValueFlow::makeIntegralInferModel ( )

Definition at line 6977 of file valueflow.cpp.

Referenced by extractForLoopValues().

◆ parseCompareInt() [1/2]

const Token * ValueFlow::parseCompareInt ( const Token *  tok,
ValueFlow::Value &  true_value,
ValueFlow::Value &  false_value 
)

Definition at line 377 of file valueflow.cpp.

References Token::hasKnownIntValue(), and parseCompareInt().

◆ parseCompareInt() [2/2]

const Token * ValueFlow::parseCompareInt ( const Token *  tok,
ValueFlow::Value &  true_value,
ValueFlow::Value &  false_value,
const std::function< std::vector< MathLib::bigint >(const Token *)> &  evaluate 
)

Definition at line 350 of file valueflow.cpp.

References evaluate(), and parseCompareEachInt().

Referenced by parseCompareInt(), and programMemoryParseCondition().

◆ setValues()

void ValueFlow::setValues ( TokenList &  tokenlist,
SymbolDatabase &  symboldatabase,
ErrorLogger &  errorLogger,
const Settings &  settings,
TimerResultsIntf *  timerResults 
)

◆ solveExprValue()

const Token * ValueFlow::solveExprValue ( const Token *  expr,
const std::function< std::vector< MathLib::bigint >(const Token *)> &  eval,
ValueFlow::Value &  value 
)

◆ valueFlowConstantFoldAST()

const ValueFlow::Value * ValueFlow::valueFlowConstantFoldAST ( Token *  expr,
const Settings &  settings 
)

Constant folding of expression. This can be used before the full ValueFlow has been executed (ValueFlow::setValues).

Definition at line 9408 of file valueflow.cpp.

References Token::astOperand1(), Token::astOperand2(), Token::hasKnownValue(), valueFlowSetConstantValue(), and Token::values().

Referenced by Variable::arrayDimensions(), createTokenFromExpression(), and valueFlowEnumValue().