Cppcheck
|
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) |
ValueFlow::Value ValueFlow::asImpossible | ( | ValueFlow::Value | v | ) |
Definition at line 6269 of file valueflow.cpp.
References ValueFlow::Value::invertRange(), and ValueFlow::Value::setImpossible().
Referenced by insertImpossible(), programMemoryParseCondition(), and valueFlowForLoop().
void ValueFlow::combineValueProperties | ( | const Value & | value1, |
const Value & | value2, | ||
ValueFlow::Value & | result | ||
) |
Definition at line 424 of file valueflow.cpp.
References ValueFlow::Value::bound, ValueFlow::Value::condition, ValueFlow::Value::errorPath, ValueFlow::Value::isImpossible(), ValueFlow::Value::isInconclusive(), ValueFlow::Value::isIteratorValue(), ValueFlow::Value::isKnown(), ValueFlow::Value::isSymbolicValue(), ValueFlow::Value::Lower, ValueFlow::Value::path, ValueFlow::Value::Point, ValueFlow::Value::safe, ValueFlow::Value::setImpossible(), ValueFlow::Value::setInconclusive(), ValueFlow::Value::setKnown(), ValueFlow::Value::setPossible(), ValueFlow::Value::tokvalue, ValueFlow::Value::Upper, ValueFlow::Value::valueType, ValueFlow::Value::varId, and ValueFlow::Value::varvalue.
Referenced by createBuiltinLibraryFunctions(), evaluate(), and setTokenValue().
std::string ValueFlow::eitherTheConditionIsRedundant | ( | const Token * | condition | ) |
Definition at line 9680 of file valueflow.cpp.
References Token::expressionString(), Token::Match(), Token::next(), and Token::str().
Referenced by arrayIndexMessage(), CheckStl::dereferenceInvalidIteratorError(), CheckStl::eraseIteratorOutOfBoundsError(), CheckType::integerOverflowError(), CheckFunctions::invalidFunctionArgError(), CheckStl::negativeIndexError(), CheckNullPointer::nullPointerError(), CheckStl::outOfBoundsError(), CheckNullPointer::redundantConditionWarning(), and CheckOther::zerodivError().
const Token * ValueFlow::getEndOfExprScope | ( | const Token * | tok, |
const Scope * | defaultScope = nullptr , |
||
bool | smallest = true |
||
) |
Definition at line 3974 of file valueflow.cpp.
References op1_and_op2, Token::variable(), and visitAstNodes().
Referenced by ConditionHandler::afterCondition(), CheckUnusedVar::checkFunctionVariableUsage(), valueFlowAfterMove(), valueFlowForwardAssign(), valueFlowForwardLifetime(), and valueFlowSymbolic().
ValueFlow::Value ValueFlow::getLifetimeObjValue | ( | const Token * | tok, |
bool | inconclusive = false |
||
) |
Definition at line 3575 of file valueflow.cpp.
References getLifetimeObjValues(), and inconclusive.
Referenced by CheckOther::checkComparePointers(), isIteratorPair(), and isSameLifetime().
std::vector< ValueFlow::Value > ValueFlow::getLifetimeObjValues | ( | const Token * | tok, |
bool | inconclusive = false , |
||
MathLib::bigint | path = 0 |
||
) |
Definition at line 3528 of file valueflow.cpp.
References inconclusive, and Token::values().
Referenced by getAddressContainer(), getLifetimeIteratorValue(), getLifetimeObjValue(), and CheckBufferOverrun::objectIndex().
std::vector< ValueFlow::LifetimeToken > ValueFlow::getLifetimeTokens | ( | const Token * | tok, |
const Settings & | settings, | ||
bool | escape = false , |
||
Value::ErrorPath | errorPath = Value::ErrorPath{} |
||
) |
Definition at line 3735 of file valueflow.cpp.
References getLifetimeTokens().
Referenced by LifetimeStore::byRef(), LifetimeStore::byVal(), CheckAutoVariables::checkVarLifetimeScope(), getLifetimeToken(), and valueFlowLifetime().
Definition at line 3773 of file valueflow.cpp.
References getLifetimeVariable().
const Variable * ValueFlow::getLifetimeVariable | ( | const Token * | tok, |
Value::ErrorPath & | errorPath, | ||
const Settings & | settings, | ||
bool * | addressOf = nullptr |
||
) |
Definition at line 3765 of file valueflow.cpp.
References getLifetimeToken(), and Token::variable().
Referenced by LifetimeStore::byDerefCopy(), CheckAutoVariables::checkVarLifetimeScope(), getLifetimeVariable(), valueFlowLifetime(), valueFlowLifetimeFunction(), and valueFlowLifetimeUserConstructor().
size_t ValueFlow::getSizeOf | ( | const ValueType & | vt, |
const Settings & | settings, | ||
int | maxRecursion = 0 |
||
) |
Definition at line 1197 of file valueflow.cpp.
References accumulateStructMembers(), Scope::definedType, Scope::eUnion, getAlignOf(), None, Settings::platform, ValueType::pointer, ValueType::reference, Platform::sizeof_double, Platform::sizeof_float, Platform::sizeof_int, Platform::sizeof_long, Platform::sizeof_long_double, Platform::sizeof_long_long, Platform::sizeof_pointer, Platform::sizeof_short, Platform::sizeof_wchar_t, Scope::type, ValueType::type, and ValueType::typeScope.
Referenced by CheckOther::checkIncompleteArrayFill(), CheckOther::checkPassByReference(), CheckOther::checkRedundantCopy(), CheckClass::checkReturnByReference(), checkTypeCombination(), getAlignOf(), getBufAndOffset(), getSizeOfType(), Token::getStrSize(), isTruncated(), setTokenValue(), truncateImplicitConversion(), truncateValues(), valueFlowSetConstantValue(), and ValueFlowAnalyzer::writeValue().
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().
bool ValueFlow::isContainerSizeChanged | ( | const Token * | tok, |
int | indirect, | ||
const Settings & | settings, | ||
int | depth = 20 |
||
) |
Definition at line 8461 of file valueflow.cpp.
References astContainerAction(), astContainerYield(), astIsLHS(), Token::astParent(), Library::Container::CHANGE, Library::Container::CHANGE_CONTENT, Library::Container::CHANGE_INTERNAL, Library::Container::CLEAR, ValueType::container, Library::Container::ERASE, Library::Container::FIND, Library::Container::FIND_CONST, Library::Container::INSERT, isContainerSizeChangedByFunction(), Token::Match(), Library::Container::NO_ACTION, Library::Container::NO_YIELD, Library::Container::POP, Library::Container::PUSH, Library::Container::RESIZE, Token::simpleMatch(), Library::Container::stdAssociativeLike, and Token::valueType().
Referenced by isContainerSizeChanged(), and ContainerExpressionAnalyzer::isModified().
Definition at line 3907 of file valueflow.cpp.
References Token::astParent(), getParentValueTypes(), isDifferentType(), isLifetimeBorrowed(), isLifetimeOwned(), Token::str(), and Token::valueType().
Referenced by CheckAutoVariables::checkVarLifetimeScope(), setTokenValue(), valueFlowForwardLifetime(), valueFlowLifetimeClassConstructor(), valueFlowLifetimeFunction(), and valueFlowLifetimeUserConstructor().
std::vector< ValueFlow::Value > ValueFlow::isOutOfBounds | ( | const Value & | size, |
const Token * | indexTok, | ||
bool | possible = true |
||
) |
Definition at line 9757 of file valueflow.cpp.
References inferCondition(), ValueFlow::Value::intvalue, ValueFlow::Value::isKnown(), and isOutOfBoundsImpl().
Referenced by getOverrunIndexValues(), CheckBufferOverrun::objectIndex(), and CheckStl::outOfBounds().
std::string ValueFlow::lifetimeMessage | ( | const Token * | tok, |
const Value * | val, | ||
Value::ErrorPath & | errorPath | ||
) |
Definition at line 3490 of file valueflow.cpp.
References ValueFlow::Value::Address, Variable::isArgument(), Variable::isGlobal(), Variable::isLocal(), ValueFlow::Value::Iterator, ValueFlow::Value::Lambda, ValueFlow::Value::lifetimeKind, lifetimeType(), Variable::name(), Variable::nameToken(), ValueFlow::Value::Object, ValueFlow::Value::SubObject, ValueFlow::Value::tokvalue, and Token::variable().
Referenced by CheckAutoVariables::errorDanglingTemporaryLifetime(), CheckAutoVariables::errorDanglngLifetime(), CheckAutoVariables::errorInvalidLifetime(), CheckAutoVariables::errorReturnDanglingLifetime(), and CheckStl::invalidContainerError().
ValuePtr< InferModel > ValueFlow::makeIntegralInferModel | ( | ) |
Definition at line 6977 of file valueflow.cpp.
Referenced by extractForLoopValues().
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().
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().
void ValueFlow::setValues | ( | TokenList & | tokenlist, |
SymbolDatabase & | symboldatabase, | ||
ErrorLogger & | errorLogger, | ||
const Settings & | settings, | ||
TimerResultsIntf * | timerResults | ||
) |
Perform valueflow analysis.
Definition at line 9604 of file valueflow.cpp.
References Token::astOperand1(), Token::clearValueFlow(), TokenList::front(), Token::isInitComma(), Token::link(), Token::Match(), Token::next(), Token::str(), valueFlowAfterAssign(), valueFlowAfterMove(), valueFlowAfterSwap(), valueFlowArray(), valueFlowArrayBool(), valueFlowArrayElement(), valueFlowBitAnd(), valueFlowCondition(), valueFlowConditionExpressions(), valueFlowContainerSize(), valueFlowDebug(), valueFlowDynamicBufferSize(), valueFlowEnumValue(), valueFlowForLoop(), valueFlowFunctionDefaultParameter(), valueFlowFunctionReturn(), valueFlowGlobalConstVar(), valueFlowGlobalStaticVar(), valueFlowImpossibleValues(), valueFlowInferCondition(), valueFlowIteratorInfer(), valueFlowIterators(), valueFlowLifetime(), valueFlowNumber(), valueFlowPointerAlias(), valueFlowRightShift(), valueFlowSafeFunctions(), valueFlowSameExpressions(), valueFlowSmartPointer(), valueFlowString(), valueFlowSubFunction(), valueFlowSwitchVariable(), valueFlowSymbolic(), valueFlowSymbolicInfer(), valueFlowSymbolicOperators(), valueFlowUninit(), valueFlowUnknownFunctionReturn(), VFA, and VFA_CPP.
Referenced by CppCheck::checkClang(), and Tokenizer::simplifyTokens1().
const Token * ValueFlow::solveExprValue | ( | const Token * | expr, |
const std::function< std::vector< MathLib::bigint >(const Token *)> & | eval, | ||
ValueFlow::Value & | value | ||
) |
Definition at line 8392 of file valueflow.cpp.
References astIsRHS(), ValueFlow::Value::intvalue, ValueFlow::Value::isIntValue(), ValueFlow::Value::isIteratorValue(), ValueFlow::Value::isSymbolicValue(), Token::Match(), parseBinaryIntOp(), Token::simpleMatch(), and Token::str().
Referenced by solveExprValue().
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().