Cppcheck
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ValueFlow::Value Class Reference

#include <vfvalue.h>

Classes

struct  compareVisitor
 
struct  decrement
 
struct  equalVisitor
 
struct  increment
 

Public Types

enum class  Bound { Upper , Lower , Point }
 
enum class  ValueType {
  INT , TOK , FLOAT , MOVED ,
  UNINIT , CONTAINER_SIZE , LIFETIME , BUFFER_SIZE ,
  ITERATOR_START , ITERATOR_END , SYMBOLIC
}
 
enum class  MoveKind { NonMovedVariable , MovedVariable , ForwardedVariable }
 kind of moved
More...
 
enum class  LifetimeKind {
  Object , SubObject , Lambda , Iterator ,
  Address
}
 
enum class  LifetimeScope {
  Local , Argument , SubFunction , ThisPointer ,
  ThisValue
}
 
enum class  ValueKind { Possible , Known , Inconclusive , Impossible }
 How known is this value. More...
 
using ErrorPathItem = std::pair< const Token *, std::string >
 
using ErrorPath = std::list< ErrorPathItem >
 

Public Member Functions

 Value (long long val=0, Bound b=Bound::Point)
 
 Value (const Token *c, long long val, Bound b=Bound::Point)
 
bool equalValue (const ValueFlow::Value &rhs) const
 
template<class Compare >
bool compareValue (const Value &rhs, Compare compare) const
 
bool operator== (const Value &rhs) const
 
bool operator!= (const Value &rhs) const
 
template<class T , REQUIRES("T must be an arithmetic type", std::is_arithmetic< T >) >
bool equalTo (const T &x) const
 
void decreaseRange ()
 
void invertBound ()
 
void invertRange ()
 
void assumeCondition (const Token *tok)
 
std::string infoString () const
 
std::string toString () const
 
bool isIntValue () const
 
bool isTokValue () const
 
bool isFloatValue () const
 
bool isMovedValue () const
 
bool isUninitValue () const
 
bool isContainerSizeValue () const
 
bool isLifetimeValue () const
 
bool isBufferSizeValue () const
 
bool isIteratorValue () const
 
bool isIteratorStartValue () const
 
bool isIteratorEndValue () const
 
bool isSymbolicValue () const
 
bool isLocalLifetimeValue () const
 
bool isArgumentLifetimeValue () const
 
bool isSubFunctionLifetimeValue () const
 
bool isNonValue () const
 
void setKnown ()
 
bool isKnown () const
 
void setPossible ()
 
bool isPossible () const
 
bool isImpossible () const
 
void setImpossible ()
 
void setInconclusive (bool inconclusive=true)
 
bool isInconclusive () const
 
void changeKnownToPossible ()
 
bool errorSeverity () const
 

Static Public Member Functions

static Value unknown ()
 
template<class T , class F >
static void visitValue (T &self, F f)
 
static const char * toString (MoveKind moveKind)
 
static const char * toString (LifetimeKind lifetimeKind)
 
static const char * toString (LifetimeScope lifetimeScope)
 
static const char * toString (Bound bound)
 
static bool sameToken (const Token *tok1, const Token *tok2)
 

Public Attributes

enum ValueFlow::Value::ValueType valueType = ValueType::INT
 
Bound bound = Bound::Point
 The value bound
More...
 
long long intvalue {}
 int value (or sometimes bool value?) More...
 
const Tokentokvalue {}
 token value - the token that has the value. More...
 
double floatValue {}
 float value More...
 
long long varvalue {}
 For calculated values - variable value that calculated value depends on. More...
 
const Tokencondition {}
 Condition that this value depends on. More...
 
ErrorPath errorPath
 
ErrorPath debugPath
 
nonneg int varId {}
 For calculated values - varId that calculated value depends on. More...
 
bool safe {}
 value relies on safe checking More...
 
bool conditional {}
 Conditional value. More...
 
bool macro {}
 Value is is from an expanded macro. More...
 
bool defaultArg {}
 Is this value passed as default parameter to the function? More...
 
int indirect {}
 
enum ValueFlow::Value::MoveKind moveKind = MoveKind::NonMovedVariable
 
MathLib::bigint path {}
 Path id. More...
 
long long wideintvalue {}
 int value before implicit truncation More...
 
std::vector< std::string > subexpressions
 
const Tokencapturetok {}
 
enum ValueFlow::Value::LifetimeKind lifetimeKind = LifetimeKind::Object
 
enum ValueFlow::Value::LifetimeScope lifetimeScope = LifetimeScope::Local
 
enum ValueFlow::Value::ValueKind valueKind = ValueKind::Possible
 

Detailed Description

Definition at line 40 of file vfvalue.h.

Member Typedef Documentation

◆ ErrorPath

Definition at line 43 of file vfvalue.h.

◆ ErrorPathItem

using ValueFlow::Value::ErrorPathItem = std::pair<const Token *, std::string>

Definition at line 42 of file vfvalue.h.

Member Enumeration Documentation

◆ Bound

Enumerator
Upper 
Lower 
Point 

Definition at line 44 of file vfvalue.h.

◆ LifetimeKind

Enumerator
Object 
SubObject 
Lambda 
Iterator 
Address 

Definition at line 317 of file vfvalue.h.

◆ LifetimeScope

Enumerator
Local 
Argument 
SubFunction 
ThisPointer 
ThisValue 

Definition at line 330 of file vfvalue.h.

◆ MoveKind

kind of moved

Enumerator
NonMovedVariable 
MovedVariable 
ForwardedVariable 

Definition at line 304 of file vfvalue.h.

◆ ValueKind

How known is this value.

Enumerator
Possible 

This value is possible, other unlisted values may also be possible.

Known 

Only listed values are possible.

Inconclusive 

Inconclusive.

Impossible 

Listed values are impossible.

Definition at line 338 of file vfvalue.h.

◆ ValueType

Enumerator
INT 
TOK 
FLOAT 
MOVED 
UNINIT 
CONTAINER_SIZE 
LIFETIME 
BUFFER_SIZE 
ITERATOR_START 
ITERATOR_END 
SYMBOLIC 

Definition at line 198 of file vfvalue.h.

Constructor & Destructor Documentation

◆ Value() [1/2]

ValueFlow::Value::Value ( long long  val = 0,
Bound  b = Bound::Point 
)
inlineexplicit

Definition at line 46 of file vfvalue.h.

◆ Value() [2/2]

ValueFlow::Value::Value ( const Token c,
long long  val,
Bound  b = Bound::Point 
)

Definition at line 28 of file vfvalue.cpp.

References errorPath, and Token::expressionString().

Member Function Documentation

◆ assumeCondition()

void ValueFlow::Value::assumeCondition ( const Token tok)

Definition at line 36 of file vfvalue.cpp.

References condition, errorPath, and Token::expressionString().

Referenced by setConditionalValue().

◆ changeKnownToPossible()

void ValueFlow::Value::changeKnownToPossible ( )
inline

◆ compareValue()

template<class Compare >
bool ValueFlow::Value::compareValue ( const Value rhs,
Compare  compare 
) const
inline

Definition at line 139 of file vfvalue.h.

References isSymbolicValue(), tokvalue, and valueType.

◆ decreaseRange()

void ValueFlow::Value::decreaseRange ( )
inline

Definition at line 173 of file vfvalue.h.

◆ equalTo()

template<class T , REQUIRES("T must be an arithmetic type", std::is_arithmetic< T >) >
bool ValueFlow::Value::equalTo ( const T &  x) const
inline

Definition at line 167 of file vfvalue.h.

Referenced by ValueFlowAnalyzer::isModified().

◆ equalValue()

bool ValueFlow::Value::equalValue ( const ValueFlow::Value rhs) const
inline

◆ errorSeverity()

bool ValueFlow::Value::errorSeverity ( ) const
inline

◆ infoString()

std::string ValueFlow::Value::infoString ( ) const

◆ invertBound()

void ValueFlow::Value::invertBound ( )
inline

Definition at line 180 of file vfvalue.h.

◆ invertRange()

void ValueFlow::Value::invertRange ( )
inline

Definition at line 187 of file vfvalue.h.

Referenced by ValueFlow::asImpossible(), and valueFlowForwardAssign().

◆ isArgumentLifetimeValue()

bool ValueFlow::Value::isArgumentLifetimeValue ( ) const
inline

Definition at line 252 of file vfvalue.h.

◆ isBufferSizeValue()

bool ValueFlow::Value::isBufferSizeValue ( ) const
inline

Definition at line 232 of file vfvalue.h.

Referenced by getBufferSizeValue().

◆ isContainerSizeValue()

bool ValueFlow::Value::isContainerSizeValue ( ) const
inline

◆ isFloatValue()

bool ValueFlow::Value::isFloatValue ( ) const
inline

◆ isImpossible()

bool ValueFlow::Value::isImpossible ( ) const
inline

◆ isInconclusive()

bool ValueFlow::Value::isInconclusive ( ) const
inline

◆ isIntValue()

bool ValueFlow::Value::isIntValue ( ) const
inline

◆ isIteratorEndValue()

bool ValueFlow::Value::isIteratorEndValue ( ) const
inline

◆ isIteratorStartValue()

bool ValueFlow::Value::isIteratorStartValue ( ) const
inline

◆ isIteratorValue()

bool ValueFlow::Value::isIteratorValue ( ) const
inline

◆ isKnown()

bool ValueFlow::Value::isKnown ( ) const
inline

◆ isLifetimeValue()

bool ValueFlow::Value::isLifetimeValue ( ) const
inline

◆ isLocalLifetimeValue()

bool ValueFlow::Value::isLocalLifetimeValue ( ) const
inline

Definition at line 248 of file vfvalue.h.

Referenced by CheckOther::checkComparePointers(), and valueFlowSubFunction().

◆ isMovedValue()

bool ValueFlow::Value::isMovedValue ( ) const
inline

Definition at line 220 of file vfvalue.h.

Referenced by ValueFlowAnalyzer::isModified().

◆ isNonValue()

bool ValueFlow::Value::isNonValue ( ) const
inline

Definition at line 260 of file vfvalue.h.

Referenced by removeOverlaps(), and SingleValueFlowAnalyzer::stopOnCondition().

◆ isPossible()

bool ValueFlow::Value::isPossible ( ) const
inline

◆ isSubFunctionLifetimeValue()

bool ValueFlow::Value::isSubFunctionLifetimeValue ( ) const
inline

Definition at line 256 of file vfvalue.h.

Referenced by valueFlowSubFunction().

◆ isSymbolicValue()

bool ValueFlow::Value::isSymbolicValue ( ) const
inline

◆ isTokValue()

bool ValueFlow::Value::isTokValue ( ) const
inline

◆ isUninitValue()

bool ValueFlow::Value::isUninitValue ( ) const
inline

◆ operator!=()

bool ValueFlow::Value::operator!= ( const Value rhs) const
inline

Definition at line 162 of file vfvalue.h.

◆ operator==()

bool ValueFlow::Value::operator== ( const Value rhs) const
inline

Definition at line 149 of file vfvalue.h.

References condition, conditional, defaultArg, indirect, valueKind, varId, and varvalue.

◆ sameToken()

bool ValueFlow::Value::sameToken ( const Token tok1,
const Token tok2 
)
static

Definition at line 158 of file vfvalue.cpp.

References Token::exprId().

Referenced by mergeAdjacent(), and removeContradiction().

◆ setImpossible()

void ValueFlow::Value::setImpossible ( )
inline

◆ setInconclusive()

void ValueFlow::Value::setInconclusive ( bool  inconclusive = true)
inline

◆ setKnown()

void ValueFlow::Value::setKnown ( )
inline

◆ setPossible()

void ValueFlow::Value::setPossible ( )
inline

◆ toString() [1/5]

std::string ValueFlow::Value::toString ( ) const

◆ toString() [2/5]

const char * ValueFlow::Value::toString ( Bound  bound)
static

Definition at line 184 of file vfvalue.cpp.

References bound, Lower, Point, and Upper.

◆ toString() [3/5]

const char * ValueFlow::Value::toString ( LifetimeKind  lifetimeKind)
static

Definition at line 142 of file vfvalue.cpp.

References Address, Iterator, Lambda, lifetimeKind, Object, and SubObject.

◆ toString() [4/5]

const char * ValueFlow::Value::toString ( LifetimeScope  lifetimeScope)
static

Definition at line 168 of file vfvalue.cpp.

References Argument, lifetimeScope, Local, SubFunction, ThisPointer, and ThisValue.

◆ toString() [5/5]

const char * ValueFlow::Value::toString ( MoveKind  moveKind)
static

Definition at line 130 of file vfvalue.cpp.

References ForwardedVariable, MovedVariable, moveKind, and NonMovedVariable.

◆ unknown()

static Value ValueFlow::Value::unknown ( )
inlinestatic

◆ visitValue()

template<class T , class F >
static void ValueFlow::Value::visitValue ( T &  self,
f 
)
inlinestatic

Definition at line 101 of file vfvalue.h.

References ValueType::FLOAT, and ValueType::INT.

Member Data Documentation

◆ bound

Bound ValueFlow::Value::bound = Bound::Point

◆ capturetok

const Token* ValueFlow::Value::capturetok {}

Definition at line 315 of file vfvalue.h.

Referenced by LifetimeStore::byVal().

◆ condition

const Token* ValueFlow::Value::condition {}

◆ conditional

bool ValueFlow::Value::conditional {}

◆ debugPath

ErrorPath ValueFlow::Value::debugPath

Definition at line 284 of file vfvalue.h.

Referenced by addToErrorPath(), and setSourceLocation().

◆ defaultArg

bool ValueFlow::Value::defaultArg {}

Is this value passed as default parameter to the function?

Definition at line 299 of file vfvalue.h.

Referenced by Settings::isEnabled(), CheckNullPointer::nullPointerError(), operator==(), and valueFlowFunctionDefaultParameter().

◆ errorPath

ErrorPath ValueFlow::Value::errorPath

◆ floatValue

double ValueFlow::Value::floatValue {}

◆ indirect

int ValueFlow::Value::indirect {}

◆ intvalue

long long ValueFlow::Value::intvalue {}

int value (or sometimes bool value?)

Definition at line 268 of file vfvalue.h.

Referenced by CheckCondition::alwaysTrueFalseError(), CheckNullPointer::arithmetic(), asFloat(), ConditionHandler::beforeCondition(), CheckBufferOverrun::bufferOverflow(), castValue(), CheckOther::checkCharVariable(), CheckBool::checkComparisonOfBoolExpressionWithInt(), CheckStl::checkDereferenceInvalidIterator2(), CheckType::checkIntegerOverflow(), CheckType::checkLongCast(), createBuiltinLibraryFunctions(), equalValue(), evalAssignment(), evaluate(), ValueFlowAnalyzer::evaluate(), execute(), extractForLoopValues(), CheckBufferOverrun::getBufferSize(), getCompareValue(), ProgramMemory::getContainerEmptyValue(), ProgramMemory::getContainerSizeValue(), getDimensionsEtc(), ProgramMemory::getIntValue(), indexValueString(), infoString(), insertNegateKnown(), CheckFunctions::invalidFunctionArgError(), isAdjacent(), isFalse(), isOppositeCond(), ValueFlow::isOutOfBounds(), isOutOfBoundsImpl(), isSameExpression(), ValueFlowAnalyzer::isSameSymbolicValue(), isTrue(), CheckOther::knownArgumentError(), CheckOther::knownPointerToBoolError(), makeConditionValue(), makeSymbolic(), CheckStl::negativeIndexError(), CheckStl::outOfBoundsError(), CheckBufferOverrun::pointerArithmeticError(), programMemoryParseCondition(), setConditionalValue(), setTokenValue(), setTokenValueCast(), ValueFlow::solveExprValue(), CheckBufferOverrun::stringNotZeroTerminated(), CheckType::tooBigBitwiseShiftError(), CheckType::tooBigSignedBitwiseShiftError(), toString(), truncateImplicitConversion(), truncateValues(), valueFlowAfterAssign(), valueFlowArrayElement(), valueFlowForwardAssign(), valueFlowForwardConst(), valueFlowImpossibleValues(), valueFlowIteratorInfer(), valueFlowSymbolicOperators(), ContainerExpressionAnalyzer::writeValue(), and ValueFlowAnalyzer::writeValue().

◆ lifetimeKind

enum ValueFlow::Value::LifetimeKind ValueFlow::Value::lifetimeKind = LifetimeKind::Object

◆ lifetimeScope

enum ValueFlow::Value::LifetimeScope ValueFlow::Value::lifetimeScope = LifetimeScope::Local

◆ macro

bool ValueFlow::Value::macro {}

Value is is from an expanded macro.

Definition at line 296 of file vfvalue.h.

◆ moveKind

enum ValueFlow::Value::MoveKind ValueFlow::Value::moveKind = MoveKind::NonMovedVariable

◆ path

MathLib::bigint ValueFlow::Value::path {}

◆ safe

bool ValueFlow::Value::safe {}

value relies on safe checking

Definition at line 290 of file vfvalue.h.

Referenced by ValueFlow::combineValueProperties(), Check::getMessageId(), and CheckType::integerOverflowError().

◆ subexpressions

std::vector<std::string> ValueFlow::Value::subexpressions

Definition at line 312 of file vfvalue.h.

Referenced by setTokenValue(), CheckUninitVar::uninitvarError(), and valueFlowUninit().

◆ tokvalue

const Token* ValueFlow::Value::tokvalue {}

◆ valueKind

enum ValueFlow::Value::ValueKind ValueFlow::Value::valueKind = ValueKind::Possible

◆ valueType

enum ValueFlow::Value::ValueType ValueFlow::Value::valueType = ValueType::INT

◆ varId

nonneg int ValueFlow::Value::varId {}

For calculated values - varId that calculated value depends on.

Definition at line 287 of file vfvalue.h.

Referenced by Token::addValue(), ValueFlow::combineValueProperties(), isCompatibleValues(), operator==(), valueFlowArrayElement(), and valueFlowForLoopSimplify().

◆ varvalue

long long ValueFlow::Value::varvalue {}

For calculated values - variable value that calculated value depends on.

Definition at line 277 of file vfvalue.h.

Referenced by ValueFlow::combineValueProperties(), isCompatibleValues(), operator==(), and valueFlowArrayElement().

◆ wideintvalue

long long ValueFlow::Value::wideintvalue {}

int value before implicit truncation

Definition at line 310 of file vfvalue.h.

Referenced by truncateImplicitConversion().


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