Cppcheck
Public Member Functions | Public Attributes | List of all members
SingleValueFlowAnalyzer Struct Reference
Inheritance diagram for SingleValueFlowAnalyzer:
ValueFlowAnalyzer Analyzer ExpressionAnalyzer ContainerExpressionAnalyzer OppositeExpressionAnalyzer SameExpressionAnalyzer SubExpressionAnalyzer MemberExpressionAnalyzer

Public Member Functions

 SingleValueFlowAnalyzer (ValueFlow::Value v, const TokenList &t, const Settings &s)
 
const std::unordered_map< nonneg int, const Variable * > & getVars () const
 
const std::unordered_map< nonneg int, const Variable * > & getAliasedVars () const
 
const ValueFlow::ValuegetValue (const Token *) const override
 
ValueFlow::ValuegetValue (const Token *) override
 
void makeConditional () override
 
bool useSymbolicValues () const override
 
void addErrorPath (const Token *tok, const std::string &s) override
 
bool isAlias (const Token *tok, bool &inconclusive) const override
 
bool isGlobal () const override
 
bool lowerToPossible () override
 Lower any values to possible. More...
 
bool lowerToInconclusive () override
 Lower any values to inconclusive. More...
 
bool isConditional () const override
 If the value is conditional. More...
 
bool stopOnCondition (const Token *condTok) const override
 If analysis should stop on the condition. More...
 
bool updateScope (const Token *endBlock, bool) const override
 If the analysis is unsure whether to update a scope, this will return true if the analysis should bifurcate the scope. More...
 
ValuePtr< Analyzerreanalyze (Token *tok, const std::string &msg) const override
 Return analyzer for expression at token. More...
 
- Public Member Functions inherited from ValueFlowAnalyzer
 ValueFlowAnalyzer (const TokenList &t, const Settings &s)
 
virtual bool match (const Token *tok) const =0
 
virtual bool internalMatch (const Token *) const
 
virtual ProgramState getProgramState () const =0
 
virtual int getIndirect (const Token *tok) const
 
virtual bool dependsOnThis () const
 
virtual bool isVariable () const
 
bool isCPP () const
 
const SettingsgetSettings () const
 
Action analyzeLifetime (const Token *tok) const
 
std::unordered_map< nonneg int, const Token * > getSymbols (const Token *tok) const
 
ConditionState analyzeCondition (const Token *tok, int depth=20) const
 
virtual Action isModified (const Token *tok) const
 
virtual Action isAliasModified (const Token *tok, int indirect=-1) const
 
virtual Action isThisModified (const Token *tok) const
 
Action isGlobalModified (const Token *tok) const
 
virtual Action isWritable (const Token *tok, Direction d) const
 
virtual void writeValue (ValueFlow::Value *value, const Token *tok, Direction d) const
 
const TokenfindMatch (const Token *tok) const
 
bool isSameSymbolicValue (const Token *tok, ValueFlow::Value *value=nullptr) const
 
Action analyzeMatch (const Token *tok, Direction d) const
 
Action analyzeToken (const Token *ref, const Token *tok, Direction d, bool inconclusiveRef) const
 
Action analyze (const Token *tok, Direction d) const override
 Analyze a token. More...
 
template<class F >
std::vector< MathLib::bigintevaluateInt (const Token *tok, F getProgramMemory) const
 
std::vector< MathLib::bigintevaluateInt (const Token *tok) const
 
std::vector< MathLib::bigintevaluate (Evaluate e, const Token *tok, const Token *ctx=nullptr) const override
 Try to evaluate the value of a token(most likely a condition) More...
 
void assume (const Token *tok, bool state, unsigned int flags) override
 The condition that will be assumed during analysis. More...
 
void updateState (const Token *tok) override
 Update the state of the program at the token. More...
 
virtual void internalUpdate (Token *, const ValueFlow::Value &, Direction)
 
void update (Token *tok, Action a, Direction d) override
 Update the state of the value. More...
 
- Public Member Functions inherited from Analyzer
std::vector< MathLib::bigintevaluate (const Token *tok, const Token *ctx=nullptr) const
 
virtual bool invalid () const
 
virtual ~Analyzer ()=default
 
 Analyzer (const Analyzer &)=default
 

Public Attributes

std::unordered_map< nonneg int, const Variable * > varids
 
std::unordered_map< nonneg int, const Variable * > aliases
 
ValueFlow::Value value
 
- Public Attributes inherited from ValueFlowAnalyzer
const TokenListtokenlist
 
const Settingssettings
 
ProgramMemoryState pms
 

Additional Inherited Members

- Public Types inherited from ValueFlowAnalyzer
using ProgramState = ProgramMemory::Map
 
- Public Types inherited from Analyzer
enum class  Terminate {
  None , Bail , Escape , Modified ,
  Inconclusive , Conditional
}
 
enum class  Direction { Forward , Reverse }
 
enum class  Evaluate { Integral , ContainerEmpty }
 
- Static Public Member Functions inherited from ValueFlowAnalyzer
static const std::string & getAssign (const Token *tok, Direction d)
 
- Protected Member Functions inherited from Analyzer
 Analyzer ()=default
 

Detailed Description

Definition at line 3138 of file valueflow.cpp.

Constructor & Destructor Documentation

◆ SingleValueFlowAnalyzer()

SingleValueFlowAnalyzer::SingleValueFlowAnalyzer ( ValueFlow::Value  v,
const TokenList t,
const Settings s 
)
inline

Definition at line 3143 of file valueflow.cpp.

Member Function Documentation

◆ addErrorPath()

void SingleValueFlowAnalyzer::addErrorPath ( const Token tok,
const std::string &  s 
)
inlineoverridevirtual

Implements ValueFlowAnalyzer.

Definition at line 3173 of file valueflow.cpp.

References ValueFlow::Value::errorPath, and value.

◆ getAliasedVars()

const std::unordered_map<nonneg int, const Variable*>& SingleValueFlowAnalyzer::getAliasedVars ( ) const
inline

Definition at line 3149 of file valueflow.cpp.

References aliases.

Referenced by isAlias().

◆ getValue() [1/2]

const ValueFlow::Value* SingleValueFlowAnalyzer::getValue ( const Token ) const
inlineoverridevirtual

Implements ValueFlowAnalyzer.

Definition at line 3153 of file valueflow.cpp.

References value.

Referenced by ContainerExpressionAnalyzer::isWritable().

◆ getValue() [2/2]

ValueFlow::Value* SingleValueFlowAnalyzer::getValue ( const Token )
inlineoverridevirtual

Implements ValueFlowAnalyzer.

Definition at line 3156 of file valueflow.cpp.

References value.

◆ getVars()

const std::unordered_map<nonneg int, const Variable*>& SingleValueFlowAnalyzer::getVars ( ) const
inline

Definition at line 3145 of file valueflow.cpp.

References varids.

Referenced by isAlias(), isGlobal(), and updateScope().

◆ isAlias()

bool SingleValueFlowAnalyzer::isAlias ( const Token tok,
bool &  inconclusive 
) const
inlineoverridevirtual

◆ isConditional()

bool SingleValueFlowAnalyzer::isConditional ( ) const
inlineoverridevirtual

If the value is conditional.

Implements Analyzer.

Definition at line 3216 of file valueflow.cpp.

References ValueFlow::Value::condition, ValueFlow::Value::conditional, ValueFlow::Value::isImpossible(), ValueFlow::Value::isKnown(), and value.

Referenced by stopOnCondition(), and updateScope().

◆ isGlobal()

bool SingleValueFlowAnalyzer::isGlobal ( ) const
inlineoverridevirtual

Reimplemented from ValueFlowAnalyzer.

Reimplemented in ExpressionAnalyzer.

Definition at line 3195 of file valueflow.cpp.

References getVars().

◆ lowerToInconclusive()

bool SingleValueFlowAnalyzer::lowerToInconclusive ( )
inlineoverridevirtual

Lower any values to inconclusive.

Implements Analyzer.

Definition at line 3209 of file valueflow.cpp.

References ValueFlow::Value::isImpossible(), ValueFlow::Value::setInconclusive(), and value.

◆ lowerToPossible()

bool SingleValueFlowAnalyzer::lowerToPossible ( )
inlineoverridevirtual

Lower any values to possible.

Implements Analyzer.

Definition at line 3203 of file valueflow.cpp.

References ValueFlow::Value::changeKnownToPossible(), ValueFlow::Value::isImpossible(), and value.

◆ makeConditional()

void SingleValueFlowAnalyzer::makeConditional ( )
inlineoverridevirtual

Implements ValueFlowAnalyzer.

Definition at line 3160 of file valueflow.cpp.

References ValueFlow::Value::conditional, and value.

◆ reanalyze()

ValuePtr<Analyzer> SingleValueFlowAnalyzer::reanalyze ( Token tok,
const std::string &  msg 
) const
inlineoverridevirtual

Return analyzer for expression at token.

Reimplemented from ValueFlowAnalyzer.

Reimplemented in SubExpressionAnalyzer.

Definition at line 3261 of file valueflow.cpp.

References ValueFlow::Value::errorPath, makeAnalyzer(), ValueFlowAnalyzer::settings, ValueFlowAnalyzer::tokenlist, and value.

◆ stopOnCondition()

bool SingleValueFlowAnalyzer::stopOnCondition ( const Token condTok) const
inlineoverridevirtual

◆ updateScope()

bool SingleValueFlowAnalyzer::updateScope ( const Token endBlock,
bool  modified 
) const
inlineoverridevirtual

If the analysis is unsure whether to update a scope, this will return true if the analysis should bifurcate the scope.

Implements Analyzer.

Definition at line 3238 of file valueflow.cpp.

References bifurcate(), Scope::eElse, Scope::eFor, Scope::eIf, Scope::eLambda, Scope::eWhile, getCondTokFromEnd(), ValueFlowAnalyzer::getSettings(), getVars(), isConditional(), ValueFlow::Value::isImpossible(), ValueFlow::Value::isKnown(), ValueFlow::Value::isLifetimeValue(), Token::scope(), Scope::type, and value.

◆ useSymbolicValues()

bool SingleValueFlowAnalyzer::useSymbolicValues ( ) const
inlineoverridevirtual

Reimplemented from ValueFlowAnalyzer.

Definition at line 3164 of file valueflow.cpp.

References ValueFlow::Value::isLifetimeValue(), ValueFlow::Value::isUninitValue(), and value.

Member Data Documentation

◆ aliases

std::unordered_map<nonneg int, const Variable*> SingleValueFlowAnalyzer::aliases

Definition at line 3140 of file valueflow.cpp.

Referenced by getAliasedVars().

◆ value

ValueFlow::Value SingleValueFlowAnalyzer::value

◆ varids

std::unordered_map<nonneg int, const Variable*> SingleValueFlowAnalyzer::varids

Definition at line 3139 of file valueflow.cpp.

Referenced by getVars(), and ExpressionAnalyzer::setupExprVarIds().


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