Cppcheck
|
#include "astutils.h"
#include "config.h"
#include "errortypes.h"
#include "findtoken.h"
#include "infer.h"
#include "library.h"
#include "mathlib.h"
#include "settings.h"
#include "symboldatabase.h"
#include "token.h"
#include "utils.h"
#include "valueflow.h"
#include "valueptr.h"
#include "vfvalue.h"
#include "checkclass.h"
#include <algorithm>
#include <cassert>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <list>
#include <set>
#include <type_traits>
#include <unordered_map>
#include <utility>
Go to the source code of this file.
Functions | |
const Token * | findExpression (const nonneg int exprid, const Token *start, const Token *end, const std::function< bool(const Token *)> &pred) |
static int | findArgumentPosRecursive (const Token *tok, const Token *tokToFind, bool &found, nonneg int depth=0) |
static int | findArgumentPos (const Token *tok, const Token *tokToFind) |
static int | getArgumentPos (const Token *ftok, const Token *tokToFind) |
std::vector< const Token * > | astFlatten (const Token *tok, const char *op) |
std::vector< Token * > | astFlatten (Token *tok, const char *op) |
nonneg int | astCount (const Token *tok, const char *op, int depth) |
bool | astHasToken (const Token *root, const Token *tok) |
bool | astHasVar (const Token *tok, nonneg int varid) |
bool | astHasExpr (const Token *tok, nonneg int exprid) |
static bool | astIsCharWithSign (const Token *tok, ValueType::Sign sign) |
bool | astIsSignedChar (const Token *tok) |
Is expression a 'signed char' if no promotion is used. More... | |
bool | astIsUnknownSignChar (const Token *tok) |
Is expression a 'char' if no promotion is used? More... | |
bool | astIsGenericChar (const Token *tok) |
Is expression a char according to valueType? More... | |
bool | astIsPrimitive (const Token *tok) |
bool | astIsIntegral (const Token *tok, bool unknown) |
Is expression of integral type? More... | |
bool | astIsUnsigned (const Token *tok) |
bool | astIsFloat (const Token *tok, bool unknown) |
Is expression of floating point type? More... | |
bool | astIsBool (const Token *tok) |
Is expression of boolean type? More... | |
bool | astIsPointer (const Token *tok) |
bool | astIsSmartPointer (const Token *tok) |
bool | astIsUniqueSmartPointer (const Token *tok) |
bool | astIsIterator (const Token *tok) |
bool | astIsContainer (const Token *tok) |
bool | astIsNonStringContainer (const Token *tok) |
bool | astIsContainerView (const Token *tok) |
bool | astIsContainerOwned (const Token *tok) |
bool | astIsContainerString (const Token *tok) |
static const Token * | getContainerFunction (const Token *tok) |
Library::Container::Action | astContainerAction (const Token *tok, const Token **ftok) |
Library::Container::Yield | astContainerYield (const Token *tok, const Token **ftok) |
Library::Container::Yield | astFunctionYield (const Token *tok, const Settings &settings, const Token **ftok) |
bool | astIsRangeBasedForDecl (const Token *tok) |
Is given token a range-declaration in a range-based for loop. More... | |
std::string | astCanonicalType (const Token *expr, bool pointedToType) |
Get canonical type of expression. More... | |
static bool | match (const Token *tok, const std::string &rhs) |
const Token * | astIsVariableComparison (const Token *tok, const std::string &comp, const std::string &rhs, const Token **vartok) |
Is given syntax tree a variable comparison against value. More... | |
bool | isVariableDecl (const Token *tok) |
bool | isStlStringType (const Token *tok) |
bool | isTemporary (const Token *tok, const Library *library, bool unknown) |
static bool | isFunctionCall (const Token *tok) |
static bool | hasToken (const Token *startTok, const Token *stopTok, const Token *tok) |
template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) > | |
static T * | previousBeforeAstLeftmostLeafGeneric (T *tok) |
const Token * | previousBeforeAstLeftmostLeaf (const Token *tok) |
Token * | previousBeforeAstLeftmostLeaf (Token *tok) |
template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) > | |
static T * | nextAfterAstRightmostLeafGeneric (T *tok) |
const Token * | nextAfterAstRightmostLeaf (const Token *tok) |
Token * | nextAfterAstRightmostLeaf (Token *tok) |
const Token * | astParentSkipParens (const Token *tok) |
Token * | astParentSkipParens (Token *tok) |
const Token * | getParentMember (const Token *tok) |
const Token * | getParentLifetime (const Token *tok) |
static std::vector< const Token * > | getParentMembers (const Token *tok) |
static const Token * | getParentLifetimeObject (const Token *tok) |
const Token * | getParentLifetime (const Token *tok, const Library &library) |
static bool | isInConstructorList (const Token *tok) |
std::vector< ValueType > | getParentValueTypes (const Token *tok, const Settings &settings, const Token **parent) |
bool | astIsLHS (const Token *tok) |
bool | astIsRHS (const Token *tok) |
template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) > | |
static T * | getCondTokImpl (T *tok) |
template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) > | |
static T * | getCondTokFromEndImpl (T *endBlock) |
template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) > | |
static T * | getInitTokImpl (T *tok) |
template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) > | |
static T * | getStepTokImpl (T *tok) |
Token * | getCondTok (Token *tok) |
const Token * | getCondTok (const Token *tok) |
Token * | getCondTokFromEnd (Token *endBlock) |
const Token * | getCondTokFromEnd (const Token *endBlock) |
Token * | getInitTok (Token *tok) |
const Token * | getInitTok (const Token *tok) |
Token * | getStepTok (Token *tok) |
const Token * | getStepTok (const Token *tok) |
const Token * | findNextTokenFromBreak (const Token *breakToken) |
For a "break" token, locate the next token to execute. More... | |
bool | extractForLoopValues (const Token *forToken, nonneg int &varid, bool &knownInitValue, MathLib::bigint &initValue, bool &partialCond, MathLib::bigint &stepValue, MathLib::bigint &lastValue) |
Extract for loop values: loopvar varid, init value, step value, last value (inclusive) More... | |
static const Token * | getVariableInitExpression (const Variable *var) |
const Token * | isInLoopCondition (const Token *tok) |
bool | precedes (const Token *tok1, const Token *tok2) |
If tok2 comes after tok1. More... | |
bool | succeeds (const Token *tok1, const Token *tok2) |
If tok1 comes after tok2. More... | |
bool | isAliasOf (const Token *tok, nonneg int varid, bool *inconclusive) |
If token is an alias if another variable. More... | |
bool | isAliasOf (const Token *tok, const Token *expr, int *indirect, bool *inconclusive) |
static bool | isAliased (const Token *startTok, const Token *endTok, nonneg int varid) |
bool | isAliased (const Variable *var) |
bool | exprDependsOnThis (const Token *expr, bool onVar, nonneg int depth) |
static bool | hasUnknownVars (const Token *startTok) |
bool | isStructuredBindingVariable (const Variable *var) |
static const Token * | followVariableExpression (const Settings &settings, const Token *tok, const Token *end=nullptr) |
This takes a token that refers to a variable and it will return the token to the expression that the variable is assigned to. More... | |
static void | followVariableExpressionError (const Token *tok1, const Token *tok2, ErrorPath *errors) |
SmallVector< ReferenceToken > | followAllReferences (const Token *tok, bool temporary, bool inconclusive, ErrorPath errors, int depth) |
const Token * | followReferences (const Token *tok, ErrorPath *errors) |
static bool | isSameLifetime (const Token *const tok1, const Token *const tok2) |
static bool | compareKnownValue (const Token *const tok1, const Token *const tok2, const std::function< bool(const ValueFlow::Value &, const ValueFlow::Value &, bool)> &compare) |
bool | isEqualKnownValue (const Token *const tok1, const Token *const tok2) |
static bool | isDifferentKnownValues (const Token *const tok1, const Token *const tok2) |
static bool | isSameConstantValue (bool macro, const Token *tok1, const Token *tok2) |
static bool | isForLoopCondition (const Token *const tok) |
static bool | isForLoopIncrement (const Token *const tok) |
bool | isUsedAsBool (const Token *const tok, const Settings &settings) |
Is token used as boolean, that is to say cast to a bool, or used as a condition in a if/while/for. More... | |
bool | compareTokenFlags (const Token *tok1, const Token *tok2, bool macro) |
Are the tokens' flags equal? More... | |
static bool | astIsBoolLike (const Token *tok, const Settings &settings) |
bool | isSameExpression (bool macro, const Token *tok1, const Token *tok2, const Settings &settings, bool pure, bool followVar, ErrorPath *errors) |
static bool | isZeroBoundCond (const Token *const cond) |
bool | isOppositeCond (bool isNot, const Token *const cond1, const Token *const cond2, const Settings &settings, bool pure, bool followVar, ErrorPath *errors) |
Are two conditions opposite. More... | |
bool | isOppositeExpression (const Token *const tok1, const Token *const tok2, const Settings &settings, bool pure, bool followVar, ErrorPath *errors) |
static bool | functionModifiesArguments (const Function *f) |
bool | isConstFunctionCall (const Token *ftok, const Library &library) |
bool | isConstExpression (const Token *tok, const Library &library) |
bool | isWithoutSideEffects (const Token *tok, bool checkArrayAccess, bool checkReference) |
bool | isUniqueExpression (const Token *tok) |
static bool | isEscaped (const Token *tok, bool functionsScope, const Library &library) |
static bool | isEscapedOrJump (const Token *tok, bool functionsScope, const Library &library) |
bool | isEscapeFunction (const Token *ftok, const Library *library) |
static bool | hasNoreturnFunction (const Token *tok, const Library &library, const Token **unknownFunc) |
bool | isReturnScope (const Token *const endToken, const Library &library, const Token **unknownFunc, bool functionScope) |
Is scope a return scope (scope will unconditionally return) More... | |
bool | isWithinScope (const Token *tok, const Variable *var, Scope::ScopeType type) |
Is tok within a scope of the given type, nested within var's scope? More... | |
bool | isVariableChangedByFunctionCall (const Token *tok, int indirect, nonneg int varid, const Settings &settings, bool *inconclusive) |
Is variable changed by function call? In case the answer of the question is inconclusive, e.g. More... | |
bool | isScopeBracket (const Token *tok) |
template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) > | |
static T * | getTokenArgumentFunctionImpl (T *tok, int &argn) |
const Token * | getTokenArgumentFunction (const Token *tok, int &argn) |
Return the token to the function and the argument number. More... | |
Token * | getTokenArgumentFunction (Token *tok, int &argn) |
std::vector< const Variable * > | getArgumentVars (const Token *tok, int argnr) |
static bool | isCPPCastKeyword (const Token *tok) |
static bool | isTrivialConstructor (const Token *tok) |
static bool | isArray (const Token *tok) |
bool | isVariableChangedByFunctionCall (const Token *tok, int indirect, const Settings &settings, bool *inconclusive) |
Is variable changed by function call? In case the answer of the question is inconclusive, e.g. More... | |
bool | isVariableChanged (const Token *tok, int indirect, const Settings &settings, int depth) |
bool | isVariableChanged (const Token *start, const Token *end, const nonneg int exprid, bool globalvar, const Settings &settings, int depth) |
Is variable changed in block of code? More... | |
bool | isVariableChanged (const Token *start, const Token *end, int indirect, const nonneg int exprid, bool globalvar, const Settings &settings, int depth) |
const Token * | findExpression (const Token *start, const nonneg int exprid) |
template<class F , class R = decltype(std::declval<F>()())> | |
static std::function< R()> | memoize (F f) |
template<class F , REQUIRES("F must be a function that returns a Token class", std::is_convertible< decltype(std::declval< F >()()), const Token * >) > | |
static bool | isExpressionChangedAt (const F &getExprTok, const Token *tok, int indirect, const nonneg int exprid, bool globalvar, const Settings &settings, int depth) |
bool | isExpressionChangedAt (const Token *expr, const Token *tok, int indirect, bool globalvar, const Settings &settings, int depth) |
Token * | findVariableChanged (Token *start, const Token *end, int indirect, const nonneg int exprid, bool globalvar, const Settings &settings, int depth) |
const Token * | findVariableChanged (const Token *start, const Token *end, int indirect, const nonneg int exprid, bool globalvar, const Settings &settings, int depth) |
bool | isVariableChanged (const Variable *var, const Settings &settings, int depth) |
bool | isVariablesChanged (const Token *start, const Token *end, int indirect, const std::vector< const Variable * > &vars, const Settings &settings) |
bool | isThisChanged (const Token *tok, int indirect, const Settings &settings) |
static const Token * | findThisChanged (const Token *start, const Token *end, int indirect, const Settings &settings) |
template<class Find > | |
static const Token * | findExpressionChangedImpl (const Token *expr, const Token *start, const Token *end, const Settings &settings, int depth, Find find) |
const Token * | findExpressionChanged (const Token *expr, const Token *start, const Token *end, const Settings &settings, int depth) |
const Token * | findExpressionChangedSkipDeadCode (const Token *expr, const Token *start, const Token *end, const Settings &settings, const std::function< std::vector< MathLib::bigint >(const Token *tok)> &evaluate, int depth) |
const Token * | getArgumentStart (const Token *ftok) |
int | numberOfArguments (const Token *ftok) |
Determines the number of arguments - if token is a function call or macro. More... | |
int | numberOfArgumentsWithoutAst (const Token *start) |
Get number of arguments without using AST. More... | |
std::vector< const Token * > | getArguments (const Token *ftok) |
Get arguments (AST) More... | |
int | getArgumentPos (const Variable *var, const Function *f) |
const Token * | getIteratorExpression (const Token *tok) |
bool | isIteratorPair (const std::vector< const Token * > &args) |
Are the arguments a pair of iterators/pointers? More... | |
const Token * | findLambdaStartToken (const Token *last) |
template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) > | |
static T * | findLambdaEndTokenGeneric (T *first) |
const Token * | findLambdaEndToken (const Token *first) |
find lambda function end token More... | |
Token * | findLambdaEndToken (Token *first) |
bool | isLikelyStream (const Token *stream) |
bool | isLikelyStreamRead (const Token *op) |
do we see a likely write of rhs through overloaded operator s >> x; a & x; More... | |
bool | isCPPCast (const Token *tok) |
bool | isConstVarExpression (const Token *tok, const std::function< bool(const Token *)> &skipPredicate) |
static ExprUsage | getFunctionUsage (const Token *tok, int indirect, const Settings &settings) |
bool | isLeafDot (const Token *tok) |
ExprUsage | getExprUsage (const Token *tok, int indirect, const Settings &settings) |
static void | getLHSVariablesRecursive (std::vector< const Variable * > &vars, const Token *tok) |
std::vector< const Variable * > | getLHSVariables (const Token *tok) |
static const Token * | getLHSVariableRecursive (const Token *tok) |
const Variable * | getLHSVariable (const Token *tok) |
const Token * | getLHSVariableToken (const Token *tok) |
const Token * | findAllocFuncCallToken (const Token *expr, const Library &library) |
Find a allocation function call in expression, so result of expression is allocated memory/resource. More... | |
bool | isNullOperand (const Token *expr) |
bool | isGlobalData (const Token *expr) |
bool | isUnevaluated (const Token *tok) |
std::string astCanonicalType | ( | const Token * | expr, |
bool | pointedToType | ||
) |
Get canonical type of expression.
const/static/etc are not included and neither *&. For example: Expression type Return std::string std::string int * int static const int int std::vector<T> std::vector
Definition at line 326 of file astutils.cpp.
References Token::Match(), and Token::typeDecl().
Referenced by Library::getFunctionName().
Library::Container::Action astContainerAction | ( | const Token * | tok, |
const Token ** | ftok | ||
) |
Definition at line 287 of file astutils.cpp.
References ValueType::container, Library::Container::getAction(), getContainerFunction(), Library::Container::NO_ACTION, Token::str(), and Token::valueType().
Referenced by CheckFunctions::checkLibraryMatchFunctions(), Library::getUseRetValType(), ValueFlow::isContainerSizeChanged(), ValueFlowAnalyzer::isModified(), and Library::isnoreturn().
Library::Container::Yield astContainerYield | ( | const Token * | tok, |
const Token ** | ftok | ||
) |
Definition at line 297 of file astutils.cpp.
References ValueType::container, getContainerFunction(), Library::Container::getYield(), Library::Container::NO_YIELD, Token::str(), and Token::valueType().
Referenced by CheckFunctions::checkLibraryMatchFunctions(), findIteratorYield(), Library::getUseRetValType(), ValueFlow::isContainerSizeChanged(), Library::isFunctionConst(), isLocalContainerBuffer(), Library::isnoreturn(), and isSameIteratorContainerExpression().
Definition at line 124 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), and Token::str().
Referenced by numberOfArguments().
Definition at line 110 of file astutils.cpp.
References astFlattenCopy().
Referenced by getArguments(), getConditions(), getParentMembers(), valueFlowAfterSwap(), and valueFlowLifetimeUserConstructor().
Definition at line 117 of file astutils.cpp.
References astFlattenCopy().
Library::Container::Yield astFunctionYield | ( | const Token * | tok, |
const Settings & | settings, | ||
const Token ** | ftok | ||
) |
Definition at line 307 of file astutils.cpp.
References Library::getFunction(), Settings::library, and Library::Container::NO_YIELD.
Referenced by findIteratorYield(), SymbolDatabase::setValueTypeInTokenList(), and valueFlowLifetime().
Definition at line 152 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), and Token::exprId().
Definition at line 134 of file astutils.cpp.
References Token::astParent().
Referenced by followAllReferences().
Definition at line 143 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), and Token::varId().
bool astIsBool | ( | const Token * | tok | ) |
Is expression of boolean type?
Definition at line 215 of file astutils.cpp.
References Token::isBoolean(), ValueType::pointer, ValueType::type, and Token::valueType().
Referenced by astIsBoolLike(), CheckBool::checkAssignBoolToFloat(), CheckBool::checkAssignBoolToPointer(), CheckBool::checkBitwiseOnBoolean(), CheckBool::checkComparisonOfBoolExpressionWithInt(), CheckBool::checkIncrementBoolean(), CheckFunctions::invalidFunctionUsage(), ConditionHandler::Condition::isBool(), isConvertedToBool(), SymbolicConditionHandler::isNegatedBool(), isUsedAsBool(), CheckLeakAutoVar::ret(), ConditionHandler::skipNotAndCasts(), CheckStl::useStlAlgorithm(), valueFlowArrayBool(), valueFlowConditionExpressions(), and valueFlowImpossibleValues().
Definition at line 1551 of file astutils.cpp.
References astIsBool(), and isUsedAsBool().
Referenced by isSameExpression().
|
static |
Definition at line 161 of file astutils.cpp.
References ValueType::pointer, sign(), ValueType::sign, ValueType::type, and Token::valueType().
Referenced by astIsSignedChar(), and astIsUnknownSignChar().
bool astIsContainer | ( | const Token * | tok | ) |
Definition at line 244 of file astutils.cpp.
References astIsIterator(), and getLibraryContainer().
Referenced by CheckBufferOverrun::arrayIndex(), astIsContainerOwned(), CheckStl::checkIteratorPair(), CheckUnusedVar::checkStructMemberUsage(), CheckOther::checkVariableScope(), SymbolDatabase::createSymbolDatabaseSetVariablePointers(), Library::getContainerFromAction(), Library::getContainerFromYield(), getContainerSizeFromConstructorArgs(), getLifetimeTokens(), getParentValueTypes(), CheckStl::invalidContainer(), isConstFunctionCall(), isContainerSizeChangedByFunction(), ValueFlowAnalyzer::isGlobalModified(), isMapFind(), ValueFlowAnalyzer::isModified(), ContainerExpressionAnalyzer::isModified(), isVariableChanged(), ContainerExpressionAnalyzer::isWritable(), CheckStl::mismatchingContainerIterator(), ContainerConditionHandler::parse(), setTokenValue(), Token::typeDecl(), CheckStl::useStlAlgorithm(), valueFlowAfterAssign(), valueFlowArrayElement(), valueFlowContainerSize(), valueFlowIterators(), valueFlowLifetime(), and ContainerExpressionAnalyzer::writeValue().
bool astIsContainerOwned | ( | const Token * | tok | ) |
Definition at line 260 of file astutils.cpp.
References astIsContainer(), and astIsContainerView().
Referenced by hasUniqueOwnership(), isSameIteratorContainerExpression(), valueFlowImpossibleValues(), valueFlowLifetime(), and valueFlowLifetimeConstructor().
bool astIsContainerString | ( | const Token * | tok | ) |
Definition at line 264 of file astutils.cpp.
References ValueType::container, Library::Container::stdStringLike, and Token::valueType().
Referenced by valueFlowContainerSetTokValue().
bool astIsContainerView | ( | const Token * | tok | ) |
Definition at line 254 of file astutils.cpp.
References astIsIterator(), getLibraryContainer(), and Library::Container::view.
Referenced by astIsContainerOwned(), CheckAutoVariables::checkVarLifetimeScope(), FwdAnalysis::unusedValue(), and valueFlowLifetime().
bool astIsFloat | ( | const Token * | tok, |
bool | unknown | ||
) |
Is expression of floating point type?
Definition at line 207 of file astutils.cpp.
References ValueType::pointer, ValueType::type, and Token::valueType().
Referenced by ConditionHandler::afterCondition(), CheckBool::checkAssignBoolToFloat(), CheckOther::checkDuplicateExpression(), CheckCondition::checkIncorrectLogicOperator(), CheckStl::checkIteratorPair(), CheckFunctions::memsetInvalid2ndParam(), parseCompareEachInt(), and valueFlowSymbolicInfer().
bool astIsGenericChar | ( | const Token * | tok | ) |
Is expression a char according to valueType?
Definition at line 181 of file astutils.cpp.
References astIsPointer(), ValueType::type, and Token::valueType().
Referenced by getInitListSize(), and valueFlowGetStrLength().
bool astIsIntegral | ( | const Token * | tok, |
bool | unknown | ||
) |
Is expression of integral type?
Definition at line 194 of file astutils.cpp.
References ValueType::isIntegral(), ValueType::pointer, and Token::valueType().
Referenced by CheckStl::checkDereferenceInvalidIterator2(), CheckStl::checkIteratorPair(), CheckOther::checkKnownArgument(), getContainerSizeFromConstructorArgs(), getInitListSize(), isConstStatement(), isIntegralOrPointer(), isLikelyStream(), ValueFlowAnalyzer::isModified(), truncateImplicitConversion(), valueFlowSameExpressions(), and valueFlowSymbolicOperators().
bool astIsIterator | ( | const Token * | tok | ) |
Definition at line 239 of file astutils.cpp.
References ValueType::type, and Token::valueType().
Referenced by astIsContainer(), astIsContainerView(), astIsNonStringContainer(), findInsertValue(), getInitListSize(), isIteratorPair(), ContainerExpressionAnalyzer::isModified(), ContainerExpressionAnalyzer::isWritable(), CheckStl::knownEmptyContainerError(), ContainerExpressionAnalyzer::match(), CheckStl::mismatchingContainerIterator(), CheckStl::outOfBounds(), setTokenValue(), ExpressionAnalyzer::setupExprVarIds(), Token::typeDecl(), valueFlowInferCondition(), valueFlowLifetime(), valueFlowLifetimeConstructor(), and valueFlowLifetimeFunction().
bool astIsLHS | ( | const Token * | tok | ) |
Definition at line 784 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), and Token::astParent().
Referenced by ConditionHandler::afterCondition(), ValueFlowAnalyzer::analyzeToken(), assignExpr(), CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), CheckUninitVar::checkScopeForVariable(), CheckStl::eraseIteratorOutOfBounds(), findTokensSkipDeadCodeImpl(), getContainerFunction(), getExprUsage(), getInvalidMethod(), SubExpressionAnalyzer::internalMatch(), CheckStl::invalidContainer(), ValueFlow::isContainerSizeChanged(), ValueFlowAnalyzer::isModified(), ContainerExpressionAnalyzer::isModified(), isUsedAsBool(), isVariableChanged(), ValueFlowAnalyzer::isWritable(), ContainerExpressionAnalyzer::isWritable(), CheckStl::mismatchingContainerIterator(), valueFlowAfterAssign(), valueFlowLifetime(), valueFlowSmartPointer(), valueFlowSymbolicOperators(), and ContainerExpressionAnalyzer::writeValue().
bool astIsNonStringContainer | ( | const Token * | tok | ) |
Definition at line 248 of file astutils.cpp.
References astIsIterator(), getLibraryContainer(), and Library::Container::stdStringLike.
Referenced by valueFlowLifetimeFunction().
bool astIsPointer | ( | const Token * | tok | ) |
Definition at line 220 of file astutils.cpp.
References ValueType::pointer, and Token::valueType().
Referenced by ValueFlowAnalyzer::analyzeMatch(), astIsGenericChar(), CheckBool::checkAssignBoolToPointer(), CheckOther::checkComparePointers(), CheckOther::checkKnownArgument(), CheckOther::checkKnownPointerToBool(), getContainerSizeFromConstructorArgs(), getFunctionUsage(), getInitListSize(), getLibraryContainer(), getParentValueTypes(), hasUniqueOwnership(), isAliasOf(), isDecayedPointer(), isIntegralOrPointer(), isIteratorPair(), isNullablePointer(), isVariableChanged(), lifetimeType(), setTokenValue(), ExpressionAnalyzer::setupExprVarIds(), valueFlowImpossibleValues(), valueFlowInferCondition(), valueFlowLifetime(), and valueFlowLifetimeFunction().
bool astIsPrimitive | ( | const Token * | tok | ) |
Definition at line 186 of file astutils.cpp.
References ValueType::isPrimitive(), and Token::valueType().
Referenced by getCastTypeStartToken(), ValueFlowAnalyzer::isGlobalModified(), and isVariableChangedByFunctionCall().
bool astIsRangeBasedForDecl | ( | const Token * | tok | ) |
Is given token a range-declaration in a range-based for loop.
Definition at line 321 of file astutils.cpp.
References Token::astParent(), and Token::simpleMatch().
Referenced by CheckOther::checkConstPointer(), CheckOther::checkConstVariable(), CheckOther::checkPassByReference(), CheckClass::initializeVarList(), and Token::typeDecl().
bool astIsRHS | ( | const Token * | tok | ) |
Definition at line 797 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), and Token::astParent().
Referenced by ValueFlowAnalyzer::analyzeLifetime(), CheckUninitVar::checkLoopBodyRecursive(), CheckAutoVariables::checkVarLifetimeScope(), getExprUsage(), getParentMember(), CheckStl::invalidContainer(), isAssignedToNonLocal(), isDeadTemporary(), isInConstructorList(), CheckNullPointer::isPointerDeRef(), isUsedAsBool(), isVariableChanged(), setTokenValue(), ValueFlow::solveExprValue(), CheckUninitVar::uninitvarError(), valueFlowArray(), and valueFlowLifetimeFunction().
bool astIsSignedChar | ( | const Token * | tok | ) |
Is expression a 'signed char' if no promotion is used.
Definition at line 171 of file astutils.cpp.
References astIsCharWithSign().
Referenced by CheckOther::checkCharVariable().
bool astIsSmartPointer | ( | const Token * | tok | ) |
Definition at line 225 of file astutils.cpp.
References ValueType::smartPointerTypeToken, and Token::valueType().
Referenced by ValueFlowAnalyzer::analyzeMatch(), CheckAssert::assertWithSideEffects(), astIsUniqueSmartPointer(), isConstFunctionCall(), isNullablePointer(), isVariableChanged(), ExpressionAnalyzer::setupExprVarIds(), Token::typeDecl(), and valueFlowSmartPointer().
bool astIsUniqueSmartPointer | ( | const Token * | tok | ) |
Definition at line 230 of file astutils.cpp.
References astIsSmartPointer(), ValueType::smartPointer, Library::SmartPointer::unique, and Token::valueType().
Referenced by hasUniqueOwnership(), and valueFlowLifetime().
bool astIsUnknownSignChar | ( | const Token * | tok | ) |
Is expression a 'char' if no promotion is used?
Definition at line 176 of file astutils.cpp.
References astIsCharWithSign().
Referenced by CheckOther::checkCharVariable().
bool astIsUnsigned | ( | const Token * | tok | ) |
Definition at line 202 of file astutils.cpp.
References ValueType::sign, ValueType::UNSIGNED, and Token::valueType().
Referenced by minUnsignedValue(), setTokenValue(), and valueFlowImpossibleValues().
const Token* astIsVariableComparison | ( | const Token * | tok, |
const std::string & | comp, | ||
const std::string & | rhs, | ||
const Token ** | vartok | ||
) |
Is given syntax tree a variable comparison against value.
Definition at line 351 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::isComparisonOp(), match(), Token::str(), and Token::varId().
Referenced by CheckLeakAutoVar::checkScope(), CheckUninitVar::checkScopeForVariable(), ifvar(), and notvar().
Definition at line 557 of file astutils.cpp.
Referenced by astParentSkipParens(), CheckNullPointer::isPointerDeRef(), CheckStl::outOfBounds(), and valueFlowLifetime().
Definition at line 561 of file astutils.cpp.
References Token::astParent(), astParentSkipParens(), Token::link(), Token::Match(), nextAfterAstRightmostLeaf(), Token::previous(), and Token::simpleMatch().
|
static |
Definition at line 1393 of file astutils.cpp.
References ValueFlow::Value::isKnown(), isSameLifetime(), and Token::values().
Referenced by isDifferentKnownValues(), and isEqualKnownValue().
Are the tokens' flags equal?
Definition at line 1537 of file astutils.cpp.
References Token::isComplex(), Token::isExpandedMacro(), Token::isLong(), Token::isSigned(), Token::isTemplateArg(), and Token::isUnsigned().
Referenced by SymbolDatabase::createSymbolDatabaseExprIds(), and isSameExpression().
Definition at line 1105 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), contains(), Scope::findAssociatedScopes(), Scope::function, Token::function(), Scope::functionOf, Scope::isClassOrStruct(), Variable::isPrivate(), Variable::isProtected(), Variable::isPublic(), Variable::isStatic(), Token::Match(), Scope::nestedIn, Token::scope(), Token::simpleMatch(), Token::str(), Function::token, and Token::variable().
Referenced by ValueFlowAnalyzer::analyze(), CheckOther::checkRedundantCopy(), ExpressionAnalyzer::ExpressionAnalyzer(), findExpressionChangedImpl(), findThisChanged(), getLifetimeTokens(), isConstFunctionCall(), isDanglingSubFunction(), valueFlowLifetime(), and valueFlowLifetimeFunction().
bool extractForLoopValues | ( | const Token * | forToken, |
nonneg int & | varid, | ||
bool & | knownInitValue, | ||
MathLib::bigint & | initValue, | ||
bool & | partialCond, | ||
MathLib::bigint & | stepValue, | ||
MathLib::bigint & | lastValue | ||
) |
Extract for loop values: loopvar varid, init value, step value, last value (inclusive)
Definition at line 926 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), getMinValue(), ValueFlow::Value::intvalue, Token::isBinaryOp(), Token::isUnaryOp(), ValueFlow::makeIntegralInferModel(), Token::Match(), Token::next(), none, op1_and_op2, Token::simpleMatch(), Token::str(), and visitAstNodes().
Referenced by valueFlowForLoop().
Find a allocation function call in expression, so result of expression is allocated memory/resource.
Definition at line 3501 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), Library::getAllocFuncInfo(), Token::isCast(), Token::Match(), Token::previous(), and Token::simpleMatch().
Referenced by CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), and CheckUninitVar::checkScope().
Definition at line 90 of file astutils.cpp.
References findArgumentPosRecursive().
Referenced by getArgumentPos().
|
static |
Definition at line 68 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), and Token::str().
Referenced by findArgumentPos().
const Token* findExpression | ( | const nonneg int | exprid, |
const Token * | start, | ||
const Token * | end, | ||
const std::function< bool(const Token *)> & | pred | ||
) |
Definition at line 50 of file astutils.cpp.
References Token::next(), and precedes().
Referenced by CheckOther::checkInnerScope(), and findVariableChanged().
Definition at line 2774 of file astutils.cpp.
References Scope::bodyEnd, Scope::bodyStart, Function::functionScope, Scope::nestedInFunction(), Token::next(), and Token::scope().
const Token* findExpressionChanged | ( | const Token * | expr, |
const Token * | start, | ||
const Token * | end, | ||
const Settings & | settings, | ||
int | depth | ||
) |
Definition at line 3028 of file astutils.cpp.
References findExpressionChangedImpl().
Referenced by ConditionHandler::beforeCondition(), CheckOther::checkDuplicateExpression(), CheckUnusedVar::checkFunctionVariableUsage(), CheckCondition::duplicateCondition(), followVariableExpression(), isSameExpression(), isSimpleExpr(), isVariableChanged(), CheckCondition::multiCondition(), CheckCondition::multiCondition2(), and programMemoryParseCondition().
|
static |
Definition at line 2952 of file astutils.cpp.
References exprDependsOnThis(), Token::exprId(), findAstNode(), findThisChanged(), isExpressionChangedAt(), Token::isIncompleteConstant(), Token::isIncompleteVar(), precedes(), Token::valueType(), and Token::variable().
Referenced by findExpressionChanged(), and findExpressionChangedSkipDeadCode().
const Token* findExpressionChangedSkipDeadCode | ( | const Token * | expr, |
const Token * | start, | ||
const Token * | end, | ||
const Settings & | settings, | ||
const std::function< std::vector< MathLib::bigint >(const Token *tok)> & | evaluate, | ||
int | depth | ||
) |
Definition at line 3037 of file astutils.cpp.
References evaluate(), findExpressionChangedImpl(), and Settings::library.
Referenced by findVarBound(), and ProgramMemoryState::removeModifiedVars().
find lambda function end token
first | The [ token |
Definition at line 3195 of file astutils.cpp.
References findLambdaEndTokenGeneric().
Referenced by Function::addArguments(), CheckAutoVariables::autoVariables(), CheckUnusedVar::checkFunctionVariableUsage(), FwdAnalysis::checkRecursive(), CheckAutoVariables::checkVarLifetimeScope(), SymbolDatabase::createSymbolDatabaseFindAllScopes(), Token::findExpressionStartEndTokens(), Function::findReturns(), CheckMemoryLeak::functionReturnType(), CheckClass::initializationListUsage(), nextAfterAstRightmostLeafGeneric(), CheckUnusedFunctions::parseTokens(), CheckBool::returnValueOfFunctionReturningBool(), and CheckVaarg::va_list_usage().
Definition at line 3199 of file astutils.cpp.
References findLambdaEndTokenGeneric().
|
static |
Definition at line 3158 of file astutils.cpp.
References Token::link(), Token::Match(), and Token::str().
Referenced by findLambdaEndToken().
Definition at line 3145 of file astutils.cpp.
References Token::astParent(), Token::isCpp(), Token::link(), Token::simpleMatch(), and Token::str().
Referenced by isExecutableScope().
For a "break" token, locate the next token to execute.
The token will be either a "}" or a ";".
Definition at line 912 of file astutils.cpp.
References Scope::bodyEnd, Scope::isLoopScope(), Token::linkAt(), Scope::nestedIn, Token::next(), Token::scope(), Token::simpleMatch(), and Scope::type.
Referenced by FwdAnalysis::check(), FwdAnalysis::checkRecursive(), and CheckVaarg::va_list_usage().
|
static |
Definition at line 2938 of file astutils.cpp.
References exprDependsOnThis(), isThisChanged(), Token::next(), and precedes().
Referenced by findExpressionChangedImpl().
const Token* findVariableChanged | ( | const Token * | start, |
const Token * | end, | ||
int | indirect, | ||
const nonneg int | exprid, | ||
bool | globalvar, | ||
const Settings & | settings, | ||
int | depth | ||
) |
Definition at line 2872 of file astutils.cpp.
References findVariableChanged().
Token* findVariableChanged | ( | Token * | start, |
const Token * | end, | ||
int | indirect, | ||
const nonneg int | exprid, | ||
bool | globalvar, | ||
const Settings & | settings, | ||
int | depth | ||
) |
Definition at line 2856 of file astutils.cpp.
References findExpression(), isExpressionChangedAt(), memoize(), Token::next(), and precedes().
Referenced by CheckBufferOverrun::arrayIndex(), bifurcateVariableChanged(), findVariableChanged(), and isVariableChanged().
SmallVector<ReferenceToken> followAllReferences | ( | const Token * | tok, |
bool | temporary, | ||
bool | inconclusive, | ||
ErrorPath | errors, | ||
int | depth | ||
) |
Definition at line 1236 of file astutils.cpp.
References astHasToken(), Token::astOperand1(), Token::astOperand2(), Variable::declarationId(), Variable::declEndToken(), Token::expressionString(), Function::findReturns(), Token::function(), getArgumentPos(), getArguments(), inconclusive, Variable::isArgument(), Variable::isConst(), Variable::isReference(), Variable::isRValueReference(), isStructuredBindingVariable(), isTemporary(), Token::Match(), Variable::nameToken(), Token::previous(), Function::returnsReference(), Token::simpleMatch(), ReferenceToken::token, Token::variable(), and Token::varId().
Referenced by ValueFlowAnalyzer::analyze(), followReferences(), isAliasOf(), valueFlowForwardConst(), and valueFlowLifetime().
Definition at line 1369 of file astutils.cpp.
References followAllReferences().
Referenced by isSameExpression().
|
static |
This takes a token that refers to a variable and it will return the token to the expression that the variable is assigned to.
If its not valid to make such substitution then it will return the original token.
Definition at line 1166 of file astutils.cpp.
References Token::astParent(), Scope::bodyEnd, Token::exprId(), Token::fileIndex(), findExpressionChanged(), getVariableInitExpression(), hasUnknownVars(), isAliased(), Variable::isArgument(), Variable::isConst(), ValueType::isFloat(), isInLoopCondition(), ValueType::isIntegral(), Token::isLiteral(), Variable::isLocal(), Variable::isStatic(), isStructuredBindingVariable(), Token::isUnaryOp(), isVariableChanged(), Variable::isVolatile(), Token::Match(), Token::next(), nextAfterAstRightmostLeaf(), precedes(), Variable::scope(), Token::scope(), Variable::valueType(), Token::valueType(), Token::variable(), and Token::varId().
Referenced by isSameExpression().
|
static |
Definition at line 1222 of file astutils.cpp.
References Token::expressionString(), and Token::str().
Referenced by isSameExpression().
|
static |
Definition at line 1960 of file astutils.cpp.
References Function::argumentList.
Referenced by isConstFunctionCall().
Definition at line 98 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), findArgumentPos(), Token::link(), Token::Match(), and Token::next().
Referenced by followAllReferences(), LifetimeStore::fromFunctionArg(), getLifetimeTokens(), and getTokenArgumentFunctionImpl().
Definition at line 3087 of file astutils.cpp.
References Function::argumentList.
Get arguments (AST)
Definition at line 3083 of file astutils.cpp.
References astFlatten(), and getArgumentStart().
Referenced by ValueFlowAnalyzer::analyzeCondition(), CheckBufferOverrun::argumentSize(), CheckBufferOverrun::bufferOverflow(), CheckLeakAutoVar::changeAllocStatusIfRealloc(), CheckClass::checkConstFunc(), CheckMemoryLeakNoVar::checkForUnreleasedInputArgument(), CheckOther::checkOverlappingWrite(), CheckMemoryLeakInFunction::checkReallocUsage(), FwdAnalysis::checkRecursive(), CheckClass::checkUselessOverride(), CheckStl::eraseIteratorOutOfBounds(), Scope::findFunction(), followAllReferences(), LifetimeStore::fromFunctionArg(), Lambda::getCaptures(), getContainerSizeFromConstructor(), CTU::getFileInfo(), getInitListSize(), getLifetimeTokens(), CheckMemoryLeak::getReallocationType(), CheckFunctions::invalidFunctionUsage(), isConstFunctionCall(), isConstVarExpression(), CheckMemoryLeak::isOpenDevNull(), CheckMemoryLeak::isReopenStandardStream(), ContainerExpressionAnalyzer::isWritable(), CheckStl::knownEmptyContainer(), CheckFunctions::memsetInvalid2ndParam(), CheckFunctions::memsetZeroBytes(), CheckStl::mismatchingContainerIterator(), CheckStl::mismatchingContainers(), CheckNullPointer::nullConstantDereference(), CheckString::overlappingStrcmp(), CheckNullPointer::parseFunctionCall(), FwdAnalysis::possiblyAliased(), SymbolDatabase::setValueTypeInTokenList(), CheckString::sprintfOverlappingData(), CheckBufferOverrun::stringNotZeroTerminated(), CheckStl::uselessCalls(), valueFlowArrayElement(), valueFlowContainerSize(), valueFlowDynamicBufferSize(), valueFlowFunctionReturn(), valueFlowLibraryFunction(), valueFlowLifetimeClassConstructor(), valueFlowLifetimeConstructor(), valueFlowLifetimeFunction(), valueFlowSmartPointer(), and valueFlowSubFunction().
Definition at line 3048 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::link(), Token::Match(), Token::next(), and Token::simpleMatch().
Referenced by getArguments(), getLifetimeTokens(), and numberOfArguments().
Definition at line 2368 of file astutils.cpp.
References Type::classScope, Token::function(), Scope::functionList, Token::Match(), numberOfArguments(), Scope::numConstructors, Token::previous(), Token::simpleMatch(), Token::typeOf(), Token::variable(), and Scope::varlist.
Referenced by getFunctionUsage(), getParentValueTypes(), isVariableChangedByFunctionCall(), and Token::typeOf().
Definition at line 884 of file astutils.cpp.
References getCondTokImpl().
Definition at line 880 of file astutils.cpp.
References getCondTokImpl().
Referenced by findTokensSkipDeadCodeImpl(), PathAnalysis::forwardRange(), getCondTokFromEndImpl(), getCondTokImpl(), CheckFunctions::useStandardLibrary(), and CheckStl::useStlAlgorithm().
Definition at line 893 of file astutils.cpp.
References getCondTokFromEndImpl().
Definition at line 889 of file astutils.cpp.
References getCondTokFromEndImpl().
Referenced by fillProgramMemoryFromAssignments(), fillProgramMemoryFromConditions(), findTokensSkipDeadCodeImpl(), getCondTokFromEndImpl(), SingleValueFlowAnalyzer::updateScope(), and MultiValueFlowAnalyzer::updateScope().
|
static |
Definition at line 832 of file astutils.cpp.
References getCondTok(), getCondTokFromEnd(), and Token::simpleMatch().
Referenced by getCondTokFromEnd().
|
static |
Definition at line 812 of file astutils.cpp.
References getCondTok(), and Token::simpleMatch().
Referenced by getCondTok().
Definition at line 276 of file astutils.cpp.
References astIsLHS(), Token::astParent(), ValueType::container, Token::Match(), Token::next(), and Token::valueType().
Referenced by astContainerAction(), and astContainerYield().
Definition at line 3374 of file astutils.cpp.
References astIsLHS(), astIsRHS(), Token::astOperand1(), Token::astParent(), getFunctionUsage(), Token::isCast(), Token::isConstOp(), isLeafDot(), isLikelyStreamRead(), Token::isUnaryOp(), isUsedAsBool(), Token::Match(), NotUsed, precedes(), Token::simpleMatch(), Token::str(), Used, Token::valueType(), and Token::variable().
Referenced by CheckOther::checkAccessOfMovedVariable(), and CheckUninitVar::valueFlowUninit().
|
static |
Definition at line 3295 of file astutils.cpp.
References astIsPointer(), Token::astParent(), Scope::bodyEnd, Scope::bodyStart, Token::function(), Scope::functionList, Function::functionScope, getArgumentVars(), getTokenArgumentFunction(), Function::hasBody(), Inconclusive, Token::isControlFlowKeyword(), Library::isnullargbad(), Library::isuninitargbad(), Settings::library, Token::Match(), Token::next(), None, NotUsed, PassedByReference, Token::str(), Used, and Token::variable().
Referenced by getExprUsage().
Definition at line 901 of file astutils.cpp.
References getInitTokImpl().
Definition at line 898 of file astutils.cpp.
References getInitTokImpl().
Referenced by ConditionHandler::afterCondition(), CheckFunctions::useStandardLibrary(), and CheckStl::useStlAlgorithm().
|
static |
Definition at line 849 of file astutils.cpp.
References Token::Match(), and Token::simpleMatch().
Referenced by getInitTok().
Definition at line 3097 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::isName(), Token::isUnaryOp(), Token::linkAt(), Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), and Token::str().
Referenced by CheckStl::checkIteratorPair(), and isIteratorPair().
Definition at line 3473 of file astutils.cpp.
References Token::astOperand1(), getLHSVariableRecursive(), Token::isAssignmentOp(), and Token::variable().
Referenced by isVariableChanged().
Definition at line 3458 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), and Token::variable().
Referenced by getLHSVariable(), and getLHSVariableToken().
Definition at line 3445 of file astutils.cpp.
References Token::astOperand1(), getLHSVariablesRecursive(), and Token::Match().
Referenced by valueFlowAfterAssign(), and valueFlowSymbolic().
|
static |
Definition at line 3424 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), and Token::variable().
Referenced by getLHSVariables().
Definition at line 3487 of file astutils.cpp.
References Token::astOperand1(), getLHSVariableRecursive(), Token::Match(), and Token::variable().
Referenced by Token::typeOf(), and valueFlowForwardLifetime().
Definition at line 596 of file astutils.cpp.
References getParentMember(), Variable::isArgument(), Variable::isLocal(), Token::previous(), Token::simpleMatch(), and Token::variable().
Referenced by CheckOther::checkComparePointers(), CheckAutoVariables::checkVarLifetimeScope(), and valueFlowForwardLifetime().
Definition at line 642 of file astutils.cpp.
References getParentMembers().
Definition at line 635 of file astutils.cpp.
References Token::astOperand1(), and Token::simpleMatch().
Definition at line 576 of file astutils.cpp.
References astIsRHS(), Token::astOperand1(), Token::astOperand2(), Token::astParent(), and Token::simpleMatch().
Referenced by getParentLifetime().
Definition at line 615 of file astutils.cpp.
References astFlatten(), Token::astParent(), and Token::simpleMatch().
Referenced by getParentLifetime().
std::vector<ValueType> getParentValueTypes | ( | const Token * | tok, |
const Settings & | settings, | ||
const Token ** | parent | ||
) |
Definition at line 712 of file astutils.cpp.
References astIsContainer(), astIsPointer(), Token::astParent(), ValueType::containerTypeToken, Token::eType, Token::function(), getArgumentVars(), getTokenArgumentFunction(), isInConstructorList(), Token::Match(), numberOfArguments(), Scope::numConstructors, ValueType::parseDecl(), Token::simpleMatch(), Token::tokType(), Token::typeOf(), Token::valueType(), and Scope::varlist.
Referenced by getLifetimeTokens(), isConvertedToIntegral(), isConvertedToView(), ValueFlow::isLifetimeBorrowed(), isUsedAsBool(), and valueFlowLifetimeConstructor().
Definition at line 908 of file astutils.cpp.
References getStepTokImpl().
Definition at line 905 of file astutils.cpp.
References getStepTokImpl().
Referenced by ConditionHandler::afterCondition(), CheckFunctions::useStandardLibrary(), and CheckStl::useStlAlgorithm().
|
static |
Definition at line 865 of file astutils.cpp.
References Token::Match(), and Token::simpleMatch().
Referenced by getStepTok().
Return the token to the function and the argument number.
Definition at line 2360 of file astutils.cpp.
References getTokenArgumentFunctionImpl().
Referenced by CheckOther::checkConstPointer(), CheckOther::checkConstVariable(), CheckOther::checkInnerScope(), CheckOther::checkKnownArgument(), CheckLeakAutoVar::checkTokenInsideExpression(), getFunctionUsage(), getOutparamAllocation(), getParentValueTypes(), isContainerSizeChangedByFunction(), isMacroUsage(), isVariableChangedByFunctionCall(), and Token::typeOf().
Definition at line 2364 of file astutils.cpp.
References getTokenArgumentFunctionImpl().
|
static |
Definition at line 2287 of file astutils.cpp.
References getArgumentPos(), Token::Match(), and Token::simpleMatch().
Referenced by getTokenArgumentFunction().
Definition at line 975 of file astutils.cpp.
References Token::astOperand2(), Variable::declarationId(), Variable::declEndToken(), Token::Match(), and Token::tokAt().
Referenced by followVariableExpression().
|
static |
Definition at line 2172 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::function(), Library::functions, Library::getFunctionName(), Token::isConstOp(), Library::isnoreturn(), Token::Match(), Token::previous(), Token::simpleMatch(), and Token::str().
Referenced by isReturnScope().
Definition at line 494 of file astutils.cpp.
References Token::next().
Referenced by nextAfterAstRightmostLeafGeneric().
|
static |
Definition at line 1140 of file astutils.cpp.
References op1_and_op2, Token::variable(), Token::varId(), and visitAstNodes().
Referenced by followVariableExpression().
Definition at line 1080 of file astutils.cpp.
References isAliasOf(), Token::Match(), Token::next(), and precedes().
Referenced by followVariableExpression(), and isAliased().
bool isAliased | ( | const Variable * | var | ) |
Definition at line 1093 of file astutils.cpp.
References Scope::bodyEnd, Variable::declarationId(), Variable::declEndToken(), isAliased(), and Variable::scope().
Definition at line 1038 of file astutils.cpp.
References astIsPointer(), Token::exprId(), findAstNode(), and followAllReferences().
If token is an alias if another variable.
Definition at line 1017 of file astutils.cpp.
References inconclusive, Token::values(), and Token::varId().
Referenced by isAliased(), and isExpressionChangedAt().
|
static |
Definition at line 2427 of file astutils.cpp.
References Token::astOperand2(), Token::simpleMatch(), and Token::variable().
Referenced by isVariableChangedByFunctionCall().
Definition at line 2049 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::eIncDecOp, Token::isAssignmentOp(), isConstFunctionCall(), isLikelyStreamRead(), Token::isName(), Token::next(), Token::str(), Token::tokType(), and Token::variable().
Referenced by CheckBool::checkBitwiseOnBoolean(), CheckOther::checkDuplicateExpression(), SymbolicConditionHandler::parse(), ConditionHandler::traverseCondition(), CheckFunctions::useStandardLibrary(), CheckStl::useStlAlgorithm(), valueFlowConditionExpressions(), and valueFlowSymbolic().
Definition at line 1969 of file astutils.cpp.
References astIsContainer(), astIsSmartPointer(), Token::astOperand1(), exprDependsOnThis(), Library::Container::FIND_CONST, Token::function(), functionModifiesArguments(), Library::Container::getAction(), getArguments(), Library::getFunction(), Library::Container::getYield(), Variable::isConst(), isUnevaluated(), Token::Match(), Token::next(), Library::Container::NO_YIELD, Token::originalName(), Token::previous(), Function::returnsConst(), Function::returnsVoid(), Token::simpleMatch(), Token::str(), Token::tokAt(), and Token::variable().
Referenced by isConstExpression(), and ValueFlowAnalyzer::isGlobalModified().
bool isConstVarExpression | ( | const Token * | tok, |
const std::function< bool(const Token *)> & | skipPredicate | ||
) |
Definition at line 3252 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::function(), getArguments(), Token::hasKnownValue(), isCPPCast(), Token::isEnumerator(), Token::Match(), Token::previous(), Token::simpleMatch(), Token::str(), and Token::variable().
Referenced by CheckCondition::alwaysTrueFalse(), CheckOther::checkDuplicateExpression(), CheckOther::checkKnownArgument(), and isVariableChanged().
bool isCPPCast | ( | const Token * | tok | ) |
Definition at line 3247 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), isCPPCastKeyword(), Token::previous(), and Token::simpleMatch().
Referenced by CheckBool::checkComparisonOfFuncReturningBool(), CheckOther::checkKnownArgument(), CheckLeakAutoVar::checkTokenInsideExpression(), SymbolDatabase::createSymbolDatabaseIncompleteVars(), isConstStatement(), isConstVarExpression(), isTemporary(), isVoidStmt(), and CheckBufferOverrun::objectIndex().
|
static |
Definition at line 2409 of file astutils.cpp.
References endsWith(), and Token::str().
Referenced by isCPPCast(), and isVariableChangedByFunctionCall().
|
inlinestatic |
Definition at line 1425 of file astutils.cpp.
References compareKnownValue(), ValueFlow::Value::equalValue(), and ValueFlow::Value::isIteratorValue().
Referenced by isOppositeCond(), and isSameExpression().
Definition at line 1414 of file astutils.cpp.
References compareKnownValue(), ValueFlow::Value::equalValue(), and ValueFlow::Value::isIteratorValue().
Referenced by CheckOther::checkDuplicateExpression(), and isSameConstantValue().
Definition at line 2137 of file astutils.cpp.
References Library::isnoreturn(), Token::Match(), and Token::simpleMatch().
Referenced by isReturnScope().
|
static |
Definition at line 2146 of file astutils.cpp.
References Library::isnoreturn(), Token::Match(), and Token::simpleMatch().
Referenced by isReturnScope().
Definition at line 2155 of file astutils.cpp.
References Token::function(), Library::isnoreturn(), and Token::Match().
|
static |
Definition at line 2808 of file astutils.cpp.
References Token::exprId(), Token::function(), isAliasOf(), Token::isKeyword(), Token::isLiteral(), Token::isName(), Token::isStandardType(), isVariableChanged(), Token::Match(), and Token::varId().
Referenced by findExpressionChangedImpl(), findVariableChanged(), isExpressionChangedAt(), and CheckCondition::multiCondition2().
bool isExpressionChangedAt | ( | const Token * | expr, |
const Token * | tok, | ||
int | indirect, | ||
bool | globalvar, | ||
const Settings & | settings, | ||
int | depth | ||
) |
Definition at line 2844 of file astutils.cpp.
References Token::exprId(), and isExpressionChangedAt().
|
static |
Definition at line 1467 of file astutils.cpp.
References Token::astOperand1(), Token::astParent(), and Token::simpleMatch().
Referenced by isUsedAsBool().
|
static |
Definition at line 1478 of file astutils.cpp.
References Token::astOperand2(), Token::astParent(), and Token::simpleMatch().
Referenced by isUsedAsBool().
|
static |
Definition at line 483 of file astutils.cpp.
References Token::link(), Token::Match(), Token::next(), Token::simpleMatch(), and Token::tokAt().
Referenced by isVariableChanged().
bool isGlobalData | ( | const Token * | expr | ) |
Definition at line 3530 of file astutils.cpp.
References Token::astOperand1(), Token::isBinaryOp(), Token::isName(), Token::Match(), None, Token::originalName(), precedes(), Token::previous(), ValueType::reference, Token::str(), Token::valueType(), Token::variable(), Token::varId(), and visitAstNodes().
Referenced by FwdAnalysis::check(), and ExpressionAnalyzer::setupExprVarIds().
|
static |
Definition at line 693 of file astutils.cpp.
References astIsRHS(), Token::astOperand1(), Token::astOperand2(), Token::astParent(), Token::Match(), Token::previous(), and Token::simpleMatch().
Referenced by getParentValueTypes().
Definition at line 987 of file astutils.cpp.
References Token::astTop(), Token::Match(), and Token::previous().
Referenced by CheckOther::checkDuplicateExpression(), and followVariableExpression().
bool isIteratorPair | ( | const std::vector< const Token * > & | args | ) |
Are the arguments a pair of iterators/pointers?
Definition at line 3122 of file astutils.cpp.
References astIsIterator(), astIsPointer(), Token::exprId(), getIteratorExpression(), ValueFlow::getLifetimeObjValue(), and ValueFlow::Value::tokvalue.
Referenced by getContainerSizeFromConstructorArgs(), getInitListSize(), and valueFlowContainerSize().
bool isLeafDot | ( | const Token * | tok | ) |
Definition at line 3362 of file astutils.cpp.
References Token::astOperand2(), Token::astParent(), and Token::simpleMatch().
Referenced by getExprUsage(), isSimpleExpr(), and CheckUninitVar::valueFlowUninit().
bool isLikelyStream | ( | const Token * | stream | ) |
Definition at line 3204 of file astutils.cpp.
References astIsIntegral(), Token::astParent(), Token::isCpp(), and Token::Match().
Referenced by ValueFlowAnalyzer::analyzeCondition(), isConstStatement(), isTemporary(), and isVariableChanged().
bool isLikelyStreamRead | ( | const Token * | op | ) |
do we see a likely write of rhs through overloaded operator s >> x; a & x;
Definition at line 3221 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::astParent(), Token::isBinaryOp(), Token::isCpp(), Token::Match(), and Token::str().
Referenced by CheckClass::checkConstFunc(), CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), getExprUsage(), CheckClass::initializeVarList(), isConstExpression(), CheckUninitVar::isMemberVariableAssignment(), ContainerExpressionAnalyzer::isModified(), isVariableChanged(), CheckUninitVar::isVariableUsage(), CheckCondition::multiCondition2(), and valueFlowGlobalStaticVar().
bool isNullOperand | ( | const Token * | expr | ) |
Definition at line 3516 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::astParent(), Token::isCast(), Token::isCpp(), MathLib::isInt(), MathLib::isNullValue(), Token::Match(), ValueType::pointer, Token::str(), and Token::valueType().
Referenced by CheckUnusedVar::checkFunctionVariableUsage(), CheckOther::checkRedundantAssignment(), and CheckOther::constStatementError().
bool isOppositeCond | ( | bool | isNot, |
const Token *const | cond1, | ||
const Token *const | cond2, | ||
const Settings & | settings, | ||
bool | pure, | ||
bool | followVar, | ||
ErrorPath * | errors = nullptr |
||
) |
Are two conditions opposite.
isNot | do you want to know if cond1 is !cond2 or if cond1 and cond2 are non-overlapping. true: cond1==!cond2 false: cond1==true => cond2==false |
cond1 | condition1 |
cond2 | condition2 |
settings | settings |
pure | boolean |
Definition at line 1785 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::astSibling(), Library::Container::EMPTY, ValueFlow::Value::intvalue, Token::isComparisonOp(), Library::isContainerYield(), isDifferentKnownValues(), isSameExpression(), isUsedAsBool(), isZeroBoundCond(), op1, op2, Library::Container::SIZE, and Token::str().
Referenced by CheckCondition::checkIncorrectLogicOperator(), isOppositeExpression(), OppositeExpressionAnalyzer::match(), and CheckCondition::multiCondition().
bool isOppositeExpression | ( | const Token *const | tok1, |
const Token *const | tok2, | ||
const Settings & | settings, | ||
bool | pure, | ||
bool | followVar, | ||
ErrorPath * | errors | ||
) |
Definition at line 1947 of file astutils.cpp.
References Token::astOperand1(), Token::astParent(), Token::eBitOp, isOppositeCond(), isSameExpression(), and Token::isUnaryOp().
Referenced by CheckOther::checkDuplicateExpression().
bool isReturnScope | ( | const Token *const | endToken, |
const Library & | library, | ||
const Token ** | unknownFunc, | ||
bool | functionScope | ||
) |
Is scope a return scope (scope will unconditionally return)
Definition at line 2202 of file astutils.cpp.
References Token::astTop(), Token::findsimplematch(), hasNoreturnFunction(), isEscaped(), isEscapedOrJump(), Token::isIncompleteVar(), Token::isName(), Token::link(), Token::Match(), Token::previous(), Token::simpleMatch(), Token::str(), and Token::tokAt().
Referenced by ConditionHandler::afterCondition(), FwdAnalysis::checkRecursive(), SymbolDatabase::createSymbolDatabaseEscapeFunctions(), findTokensSkipDeadCodeImpl(), and CheckStl::invalidContainer().
Definition at line 1436 of file astutils.cpp.
References Token::enumerator(), isEqualKnownValue(), Token::isExpandedMacro(), Token::isNumber(), Token::isTemplateArg(), Token::Match(), ValueType::pointer, ValueType::sign, ValueType::type, and Token::valueType().
Referenced by isSameExpression().
bool isSameExpression | ( | bool | macro, |
const Token * | tok1, | ||
const Token * | tok2, | ||
const Settings & | settings, | ||
bool | pure, | ||
bool | followVar, | ||
ErrorPath * | errors | ||
) |
Definition at line 1556 of file astutils.cpp.
References astIsBoolLike(), Token::astOperand1(), Token::astOperand2(), Token::astParent(), compareTokenFlags(), ValueType::constness, Token::eIncDecOp, Token::enumerator(), findExpressionChanged(), followReferences(), followVariableExpression(), followVariableExpressionError(), Token::function(), ValueFlow::Value::intvalue, Token::isAssignmentOp(), Token::isAttributeConst(), Token::isAttributePure(), Token::isBinaryOp(), Token::isCpp(), isDifferentKnownValues(), Library::isFunctionConst(), Token::isName(), isSameConstantValue(), Settings::library, Token::link(), Token::Match(), Token::next(), Token::originalName(), ValueType::pointer, precedes(), Token::previous(), Token::simpleMatch(), Token::str(), Token::tokAt(), Token::tokType(), ValueType::type, Token::valueType(), Token::variable(), Token::varId(), and ValueType::VOID.
Referenced by CheckCondition::alwaysTrueFalse(), CheckOther::checkDuplicateBranch(), CheckCondition::checkDuplicateConditionalAssign(), CheckOther::checkDuplicateExpression(), CheckOther::checkEvaluationOrder(), CheckStl::checkFindInsert(), CheckCondition::checkIncorrectLogicOperator(), CheckCondition::checkInvalidTestForOverflow(), CheckOther::checkKnownArgument(), CheckOther::checkOverlappingWrite(), FwdAnalysis::checkRecursive(), CheckCondition::duplicateCondition(), findInsertValue(), FwdAnalysis::hasOperand(), CheckStl::isContainerSize(), isOppositeCond(), isOppositeExpression(), CheckCondition::isOverlappingCond(), isSameIteratorContainerExpression(), SameExpressionAnalyzer::match(), CheckStl::mismatchingContainers(), CheckCondition::multiCondition2(), CheckString::overlappingStrcmp(), FwdAnalysis::possiblyAliased(), CheckString::sprintfOverlappingData(), CheckBufferOverrun::stringNotZeroTerminated(), and valueFlowSameExpressions().
Definition at line 1382 of file astutils.cpp.
References ValueFlow::getLifetimeObjValue(), ValueFlow::Value::isLifetimeValue(), and ValueFlow::Value::tokvalue.
Referenced by compareKnownValue().
bool isScopeBracket | ( | const Token * | tok | ) |
Definition at line 2273 of file astutils.cpp.
References Token::Match(), Token::scope(), and Token::str().
Referenced by valueFlowForwardLifetime().
bool isStlStringType | ( | const Token * | tok | ) |
Definition at line 409 of file astutils.cpp.
References Token::linkAt(), Token::Match(), and Token::simpleMatch().
Referenced by CheckStl::string_c_str().
bool isStructuredBindingVariable | ( | const Variable * | var | ) |
Definition at line 1153 of file astutils.cpp.
References Token::astParent(), Token::Match(), Variable::nameToken(), Token::previous(), Token::simpleMatch(), and Token::str().
Referenced by CheckOther::checkConstVariable(), followAllReferences(), and followVariableExpression().
Definition at line 415 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::astParent(), ValueType::container, Token::function(), Token::isCast(), Token::isCpp(), isCPPCast(), isLikelyStream(), Token::isUnaryOp(), Token::link(), Token::Match(), Token::next(), None, Token::originalName(), ValueType::pointer, Token::previous(), ValueType::reference, Function::returnsReference(), Library::returnValueType(), Token::simpleMatch(), Library::Container::stdStringLike, Token::type(), and Token::valueType().
Referenced by CheckOther::checkRedundantCopy(), followAllReferences(), getLifetimeTokens(), isDeadTemporary(), isEscapedReference(), and isSameIteratorContainerExpression().
Definition at line 2922 of file astutils.cpp.
References Token::astOperand1(), Token::function(), Token::isKeyword(), isVariableChanged(), Token::Match(), Token::previous(), Token::simpleMatch(), and Token::tokAt().
Referenced by findThisChanged(), and ValueFlowAnalyzer::isThisModified().
|
static |
Definition at line 2416 of file astutils.cpp.
References ValueType::isPrimitive(), Token::typeOf(), and Token::valueType().
Referenced by isVariableChangedByFunctionCall().
bool isUnevaluated | ( | const Token * | tok | ) |
Definition at line 3612 of file astutils.cpp.
References Token::Match().
Referenced by CheckUninitVar::checkExpr(), CheckIO::checkFileUsage(), CheckUninitVar::checkIfForWhileHead(), CheckUninitVar::checkLoopBodyRecursive(), CheckUninitVar::checkRhs(), CheckLeakAutoVar::checkScope(), CheckUninitVar::checkScopeForVariable(), isConstFunctionCall(), CheckNullPointer::isPointerDeRef(), CheckNullPointer::nullConstantDereference(), CheckNullPointer::nullPointerByDeRefAndChec(), and CheckUninitVar::valueFlowUninit().
bool isUniqueExpression | ( | const Token * | tok | ) |
Definition at line 2087 of file astutils.cpp.
References Function::argumentList, Token::astOperand1(), Token::astOperand2(), Scope::function, Token::function(), Scope::functionList, Variable::isArray(), Variable::isClass(), Variable::isEnumType(), Variable::isFloatingType(), Variable::isPointer(), Type::name(), Variable::name(), Function::nestedIn, Function::retDef, Function::retType, Variable::scope(), Token::stringifyList(), Function::tokenDef, Type::type(), Variable::type(), Function::type, Token::variable(), and Scope::varlist.
Referenced by CheckOther::checkDuplicateExpression().
Is token used as boolean, that is to say cast to a bool, or used as a condition in a if/while/for.
Definition at line 1489 of file astutils.cpp.
References astIsBool(), astIsLHS(), astIsRHS(), Token::astOperand1(), Token::astParent(), Token::astSibling(), getParentValueTypes(), Token::hasKnownIntValue(), Token::isCast(), isForLoopCondition(), isForLoopIncrement(), Token::isInitComma(), Token::isKeyword(), Token::isNumber(), Token::isUnaryOp(), Token::Match(), Token::simpleMatch(), Token::str(), and Token::values().
Referenced by CheckCondition::alwaysTrueFalse(), astIsBoolLike(), CheckString::checkIncorrectStringCompare(), CheckOther::checkKnownPointerToBool(), getExprUsage(), isOppositeCond(), and valueFlowInferCondition().
bool isVariableChanged | ( | const Token * | start, |
const Token * | end, | ||
const nonneg int | exprid, | ||
bool | globalvar, | ||
const Settings & | settings, | ||
int | depth | ||
) |
Is variable changed in block of code?
Definition at line 2764 of file astutils.cpp.
References findVariableChanged().
bool isVariableChanged | ( | const Token * | start, |
const Token * | end, | ||
int | indirect, | ||
const nonneg int | exprid, | ||
bool | globalvar, | ||
const Settings & | settings, | ||
int | depth | ||
) |
Definition at line 2769 of file astutils.cpp.
References findVariableChanged().
Definition at line 2546 of file astutils.cpp.
References astIsContainer(), astIsLHS(), astIsPointer(), astIsRHS(), astIsSmartPointer(), Token::astOperand1(), Token::astParent(), Library::Container::AT_INDEX, Library::Container::BUFFER, Library::Container::BUFFER_NT, Library::Container::CHANGE, Library::Container::CHANGE_CONTENT, Library::Container::CHANGE_INTERNAL, Library::Container::CLEAR, ValueType::container, contains(), Token::eIncDecOp, Library::Container::EMPTY, Library::Container::END_ITERATOR, Library::Container::ERASE, Library::Container::FIND, Token::function(), Library::Container::getAction(), getLHSVariable(), Library::Container::getYield(), inconclusive, Library::Container::INSERT, Token::isArithmeticalOp(), Token::isBinaryOp(), Token::isCast(), Variable::isConst(), Function::isConst(), ValueType::isConst(), isConstVarExpression(), Token::isCpp(), isFunctionCall(), Library::isFunctionConst(), Token::isIncDecOp(), isLikelyStream(), isLikelyStreamRead(), Variable::isLocal(), Variable::isPointer(), Variable::isReference(), Token::isUnaryOp(), isVariableChangedByFunctionCall(), Library::Container::ITEM, Library::Container::ITERATOR, Settings::library, Token::link(), Token::Match(), Variable::nameToken(), Token::next(), Library::Container::POP, Token::previous(), Library::Container::PUSH, Library::Container::RESIZE, Token::simpleMatch(), Library::Container::SIZE, Library::Container::START_ITERATOR, Library::Container::stdAssociativeLike, Token::str(), Token::tokAt(), Token::tokType(), Token::valueType(), and Token::variable().
Referenced by ConditionHandler::afterCondition(), CheckCondition::assignIfParseScope(), CheckOther::checkConstPointer(), CheckOther::checkConstVariable(), CheckOther::checkDuplicateExpression(), CheckOther::checkPassByReference(), CheckOther::checkRedundantCopy(), CheckAutoVariables::checkVarLifetimeScope(), ExpressionAnalyzer::ExpressionAnalyzer(), fillProgramMemoryFromAssignments(), followVariableExpression(), getUnsafeFunction(), ValueFlowAnalyzer::isAliasModified(), isExpressionChangedAt(), CheckUnusedVar::isFunctionWithoutSideEffects(), ValueFlowAnalyzer::isModified(), isThisChanged(), isVariablesChanged(), removeModifiedVars(), singleAssignInScope(), singleConditionalInScope(), singleMemberCallInScope(), valueFlowContainerSize(), valueFlowForLoopSimplify(), valueFlowLifetimeFunction(), and CheckUninitVar::valueFlowUninit().
Definition at line 2877 of file astutils.cpp.
References Scope::bodyEnd, Variable::declarationId(), Variable::declEndToken(), findExpressionChanged(), Token::Match(), Variable::nameToken(), Token::next(), nextAfterAstRightmostLeafGeneric(), Variable::scope(), Token::simpleMatch(), and Token::tokAt().
bool isVariableChangedByFunctionCall | ( | const Token * | tok, |
int | indirect, | ||
const Settings & | settings, | ||
bool * | inconclusive | ||
) |
Is variable changed by function call? In case the answer of the question is inconclusive, e.g.
because the function declaration is not known the return value is false and the output parameter inconclusive is set to true
tok | token of variable in function call |
settings | program settings |
inconclusive | pointer to output variable which indicates that the answer of the question is inconclusive |
Definition at line 2438 of file astutils.cpp.
References astIsPrimitive(), Token::astParent(), Library::ArgumentChecks::DIR_IN, Library::ArgumentChecks::DIR_INOUT, Library::ArgumentChecks::DIR_OUT, Token::eType, Token::function(), Library::getArgDirection(), getArgumentVars(), getTokenArgumentFunction(), inconclusive, isArray(), Token::isCpp(), isCPPCastKeyword(), ValueType::isIntegral(), Token::isKeyword(), Token::isName(), Library::isnullargbad(), isTrivialConstructor(), Library::isuninitargbad(), Settings::library, Token::link(), Token::Match(), Token::next(), ValueType::pointer, Token::previous(), Token::simpleMatch(), startsWith(), Token::str(), Token::tokAt(), Token::tokType(), ValueType::UNKNOWN_TYPE, Token::valueType(), and Token::variable().
bool isVariableChangedByFunctionCall | ( | const Token * | tok, |
int | indirect, | ||
nonneg int | varid, | ||
const Settings & | settings, | ||
bool * | inconclusive | ||
) |
Is variable changed by function call? In case the answer of the question is inconclusive, e.g.
because the function declaration is not known the return value is false and the output parameter inconclusive is set to true
tok | ast tree |
varid | Variable Id |
settings | program settings |
inconclusive | pointer to output variable which indicates that the answer of the question is inconclusive |
Definition at line 2263 of file astutils.cpp.
References Token::astOperand1(), Token::astOperand2(), inconclusive, and Token::varId().
Referenced by CheckOther::checkAccessOfMovedVariable(), CheckOther::checkConstPointer(), CheckOther::checkConstVariable(), CheckClass::initializeVarList(), isContainerSizeChangedByFunction(), ValueFlowAnalyzer::isModified(), isVariableChanged(), and CheckUninitVar::valueFlowUninit().
bool isVariableDecl | ( | const Token * | tok | ) |
Definition at line 396 of file astutils.cpp.
References Variable::declEndToken(), Token::Match(), Variable::nameToken(), Token::next(), and Token::variable().
Referenced by CheckStl::invalidContainer(), valueFlowForwardLifetime(), valueFlowLifetimeClassConstructor(), and valueFlowLifetimeConstructor().
bool isVariablesChanged | ( | const Token * | start, |
const Token * | end, | ||
int | indirect, | ||
const std::vector< const Variable * > & | vars, | ||
const Settings & | settings | ||
) |
Definition at line 2896 of file astutils.cpp.
References isVariableChanged(), Token::Match(), and Token::next().
Referenced by CheckFunctions::invalidFunctionUsage(), and CheckCondition::multiCondition2().
bool isWithinScope | ( | const Token * | tok, |
const Variable * | var, | ||
Scope::ScopeType | type | ||
) |
Is tok within a scope of the given type, nested within var's scope?
Definition at line 2250 of file astutils.cpp.
References Scope::nestedIn, Variable::scope(), Token::scope(), and Scope::type.
Referenced by CheckOther::checkVariableScope().
bool isWithoutSideEffects | ( | const Token * | tok, |
bool | checkArrayAccess, | ||
bool | checkReference | ||
) |
Definition at line 2071 of file astutils.cpp.
References Token::astOperand2(), Variable::isClass(), Token::isCpp(), Variable::isPointer(), Variable::isReference(), Variable::isStlType(), CheckClass::stl_containers_not_const, Token::variable(), and Token::varId().
Referenced by CheckCondition::alwaysTrueFalse(), CheckOther::checkDuplicateExpression(), and isConstStatement().
|
static |
Definition at line 1767 of file astutils.cpp.
References Token::astOperand2(), isZero(), and Token::str().
Referenced by isOppositeCond().
|
static |
Definition at line 342 of file astutils.cpp.
References Token::hasKnownIntValue(), Token::str(), Token::values(), and Token::varId().
Referenced by SymbolDatabase::addClassFunction(), addHeaders(), astIsVariableComparison(), getConfigs(), Function::getOverriddenFunctionRecursive(), TemplateSimplifier::getTemplateInstantiations(), Highlighter::highlightBlock(), and usingNamespace().
|
static |
Definition at line 2792 of file astutils.cpp.
Referenced by findVariableChanged().
Definition at line 548 of file astutils.cpp.
References nextAfterAstRightmostLeafGeneric().
Referenced by astParentSkipParens(), CheckCondition::checkDuplicateConditionalAssign(), CheckOther::checkIncompleteStatement(), CheckOther::checkMisusedScopedObject(), CheckAutoVariables::checkVarLifetimeScope(), endOfExpression(), findEndOfFunctionCallForParameter(), Scope::findFunction(), findTokensSkipDeadCodeImpl(), followVariableExpression(), PathAnalysis::forwardRange(), getSingleExpressionInBlock(), isDeadTemporary(), skipLocalVars(), Token::typeDecl(), valueFlowAfterAssign(), valueFlowContainerSize(), valueFlowForLoopSimplify(), valueFlowForwardAssign(), valueFlowForwardLifetime(), and valueFlowSymbolic().
Definition at line 552 of file astutils.cpp.
References nextAfterAstRightmostLeafGeneric().
|
static |
Definition at line 524 of file astutils.cpp.
References findLambdaEndToken(), hasToken(), Token::Match(), and precedes().
Referenced by isVariableChanged(), and nextAfterAstRightmostLeaf().
int numberOfArguments | ( | const Token * | ftok | ) |
Determines the number of arguments - if token is a function call or macro.
ftok | start token which is supposed to be the function/macro name. |
Definition at line 3063 of file astutils.cpp.
References astCount(), and getArgumentStart().
Referenced by CheckLeakAutoVar::changeAllocStatusIfRealloc(), CheckMemoryLeak::getAllocationType(), getArgumentVars(), getParentValueTypes(), CheckMemoryLeak::getReallocationType(), TemplateSimplifier::instantiateMatch(), CheckMemoryLeak::isOpenDevNull(), CheckMemoryLeak::isReopenStandardStream(), and CheckFunctions::memsetZeroBytes().
int numberOfArgumentsWithoutAst | ( | const Token * | start | ) |
Get number of arguments without using AST.
Definition at line 3067 of file astutils.cpp.
References Token::next(), Token::nextArgument(), Token::simpleMatch(), and Token::str().
Referenced by Library::matchArguments().
If tok2 comes after tok1.
Definition at line 994 of file astutils.cpp.
References Token::index().
Referenced by CheckCondition::alwaysTrueFalse(), CheckClass::checkConst(), CheckMemoryLeakNoVar::checkForUnusedReturnValue(), CheckUnusedVar::checkFunctionVariableUsage(), FwdAnalysis::checkRecursive(), CheckMemoryLeakStructMember::checkStructVariable(), CheckClass::constructors(), SymbolDatabase::createSymbolDatabaseExprIds(), findExpression(), findExpressionChangedImpl(), Token::findExpressionStartEndTokens(), findStartToken(), findThisChanged(), findTokensImpl(), findTokensSkipDeadCodeImpl(), findVariableChanged(), followVariableExpression(), PathAnalysis::forwardRange(), ProgramMemoryState::get(), getEnableIfReturnType(), getExprUsage(), isAliased(), isDeadScope(), isDeadTemporary(), isGlobalData(), isSameExpression(), nextAfterAstRightmostLeafGeneric(), CheckLeakAutoVar::ret(), CheckStl::useStlAlgorithm(), and valueFlowForwardConst().
Definition at line 514 of file astutils.cpp.
References previousBeforeAstLeftmostLeafGeneric().
Referenced by CheckClass::checkConstFunc(), ProgramMemoryState::get(), isConstStatement(), and Token::typeDecl().
Definition at line 518 of file astutils.cpp.
References previousBeforeAstLeftmostLeafGeneric().
|
static |
Definition at line 504 of file astutils.cpp.
Referenced by previousBeforeAstLeftmostLeaf().
If tok1 comes after tok2.
Definition at line 1006 of file astutils.cpp.
References Token::index().
Referenced by CheckLeakAutoVar::checkScope(), SymbolDatabase::createSymbolDatabaseFindAllScopes(), Token::findExpressionStartEndTokens(), isConstStatement(), and CheckLeakAutoVar::ret().