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

Classes

struct  ConditionState
 

Public Types

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 }
 

Public Member Functions

 ValueFlowAnalyzer (const TokenList &t, const Settings &s)
 
virtual const ValueFlow::ValuegetValue (const Token *tok) const =0
 
virtual ValueFlow::ValuegetValue (const Token *tok)=0
 
virtual void makeConditional ()=0
 
virtual void addErrorPath (const Token *tok, const std::string &s)=0
 
virtual bool match (const Token *tok) const =0
 
virtual bool internalMatch (const Token *) const
 
virtual bool isAlias (const Token *tok, bool &inconclusive) const =0
 
virtual ProgramState getProgramState () const =0
 
virtual int getIndirect (const Token *tok) const
 
virtual bool isGlobal () 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
 
virtual bool useSymbolicValues () 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...
 
ValuePtr< Analyzerreanalyze (Token *, const std::string &) const override
 Return analyzer for expression at token. More...
 
- Public Member Functions inherited from Analyzer
std::vector< MathLib::bigintevaluate (const Token *tok, const Token *ctx=nullptr) const
 
virtual bool lowerToPossible ()=0
 Lower any values to possible. More...
 
virtual bool lowerToInconclusive ()=0
 Lower any values to inconclusive. More...
 
virtual bool updateScope (const Token *endBlock, bool modified) const =0
 If the analysis is unsure whether to update a scope, this will return true if the analysis should bifurcate the scope. More...
 
virtual bool isConditional () const =0
 If the value is conditional. More...
 
virtual bool stopOnCondition (const Token *condTok) const =0
 If analysis should stop on the condition. More...
 
virtual bool invalid () const
 
virtual ~Analyzer ()=default
 
 Analyzer (const Analyzer &)=default
 

Static Public Member Functions

static const std::string & getAssign (const Token *tok, Direction d)
 

Public Attributes

const TokenListtokenlist
 
const Settingssettings
 
ProgramMemoryState pms
 

Additional Inherited Members

- Protected Member Functions inherited from Analyzer
 Analyzer ()=default
 

Detailed Description

Definition at line 2500 of file valueflow.cpp.

Member Typedef Documentation

◆ ProgramState

Definition at line 2522 of file valueflow.cpp.

Constructor & Destructor Documentation

◆ ValueFlowAnalyzer()

ValueFlowAnalyzer::ValueFlowAnalyzer ( const TokenList t,
const Settings s 
)
inlineexplicit

Definition at line 2505 of file valueflow.cpp.

Member Function Documentation

◆ addErrorPath()

virtual void ValueFlowAnalyzer::addErrorPath ( const Token tok,
const std::string &  s 
)
pure virtual

Implemented in MultiValueFlowAnalyzer, and SingleValueFlowAnalyzer.

Referenced by assume().

◆ analyze()

Action ValueFlowAnalyzer::analyze ( const Token tok,
Direction  d 
) const
inlineoverridevirtual

◆ analyzeCondition()

ConditionState ValueFlowAnalyzer::analyzeCondition ( const Token tok,
int  depth = 20 
) const
inline

◆ analyzeLifetime()

Action ValueFlowAnalyzer::analyzeLifetime ( const Token tok) const
inline

◆ analyzeMatch()

Action ValueFlowAnalyzer::analyzeMatch ( const Token tok,
Direction  d 
) const
inline

◆ analyzeToken()

Action ValueFlowAnalyzer::analyzeToken ( const Token ref,
const Token tok,
Direction  d,
bool  inconclusiveRef 
) const
inline

◆ assume()

void ValueFlowAnalyzer::assume ( const Token tok,
bool  state,
unsigned int  flags 
)
inlineoverridevirtual

◆ dependsOnThis()

virtual bool ValueFlowAnalyzer::dependsOnThis ( ) const
inlinevirtual

Reimplemented in ExpressionAnalyzer.

Definition at line 2536 of file valueflow.cpp.

Referenced by analyze(), and analyzeMatch().

◆ evaluate()

std::vector<MathLib::bigint> ValueFlowAnalyzer::evaluate ( Evaluate  e,
const Token tok,
const Token ctx = nullptr 
) const
inlineoverridevirtual

◆ evaluateInt() [1/2]

std::vector<MathLib::bigint> ValueFlowAnalyzer::evaluateInt ( const Token tok) const
inline

Definition at line 3027 of file valueflow.cpp.

References evaluateInt(), and getProgramState().

◆ evaluateInt() [2/2]

template<class F >
std::vector<MathLib::bigint> ValueFlowAnalyzer::evaluateInt ( const Token tok,
getProgramMemory 
) const
inline

◆ findMatch()

const Token* ValueFlowAnalyzer::findMatch ( const Token tok) const
inline

Definition at line 2848 of file valueflow.cpp.

References findAstNode(), and match().

Referenced by isSameSymbolicValue().

◆ getAssign()

static const std::string& ValueFlowAnalyzer::getAssign ( const Token tok,
Direction  d 
)
inlinestatic

Definition at line 2745 of file valueflow.cpp.

References Analyzer::Forward, invertAssign(), and Token::str().

Referenced by isWritable(), and writeValue().

◆ getIndirect()

virtual int ValueFlowAnalyzer::getIndirect ( const Token tok) const
inlinevirtual

◆ getProgramState()

virtual ProgramState ValueFlowAnalyzer::getProgramState ( ) const
pure virtual

◆ getSettings()

const Settings& ValueFlowAnalyzer::getSettings ( ) const
inline

◆ getSymbols()

std::unordered_map<nonneg int, const Token*> ValueFlowAnalyzer::getSymbols ( const Token tok) const
inline

Definition at line 2574 of file valueflow.cpp.

References match(), and Token::values().

Referenced by analyzeCondition().

◆ getValue() [1/2]

virtual const ValueFlow::Value* ValueFlowAnalyzer::getValue ( const Token tok) const
pure virtual

◆ getValue() [2/2]

virtual ValueFlow::Value* ValueFlowAnalyzer::getValue ( const Token tok)
pure virtual

◆ internalMatch()

virtual bool ValueFlowAnalyzer::internalMatch ( const Token ) const
inlinevirtual

Reimplemented in SubExpressionAnalyzer.

Definition at line 2516 of file valueflow.cpp.

Referenced by analyze().

◆ internalUpdate()

virtual void ValueFlowAnalyzer::internalUpdate ( Token ,
const ValueFlow::Value ,
Direction   
)
inlinevirtual

Reimplemented in SubExpressionAnalyzer.

Definition at line 3102 of file valueflow.cpp.

Referenced by update().

◆ isAlias()

virtual bool ValueFlowAnalyzer::isAlias ( const Token tok,
bool &  inconclusive 
) const
pure virtual

◆ isAliasModified()

virtual Action ValueFlowAnalyzer::isAliasModified ( const Token tok,
int  indirect = -1 
) const
inlinevirtual

◆ isCPP()

bool ValueFlowAnalyzer::isCPP ( ) const
inline

Definition at line 2543 of file valueflow.cpp.

References TokenList::isCPP(), and tokenlist.

◆ isGlobal()

virtual bool ValueFlowAnalyzer::isGlobal ( ) const
inlinevirtual

Reimplemented in ExpressionAnalyzer, and SingleValueFlowAnalyzer.

Definition at line 2533 of file valueflow.cpp.

Referenced by analyze(), and analyzeMatch().

◆ isGlobalModified()

Action ValueFlowAnalyzer::isGlobalModified ( const Token tok) const
inline

◆ isModified()

virtual Action ValueFlowAnalyzer::isModified ( const Token tok) const
inlinevirtual

◆ isSameSymbolicValue()

bool ValueFlowAnalyzer::isSameSymbolicValue ( const Token tok,
ValueFlow::Value value = nullptr 
) const
inline

◆ isThisModified()

virtual Action ValueFlowAnalyzer::isThisModified ( const Token tok) const
inlinevirtual

Definition at line 2719 of file valueflow.cpp.

References getSettings(), Analyzer::Action::Invalid, isThisChanged(), and Analyzer::Action::None.

Referenced by analyze().

◆ isVariable()

virtual bool ValueFlowAnalyzer::isVariable ( ) const
inlinevirtual

Reimplemented in ExpressionAnalyzer.

Definition at line 2539 of file valueflow.cpp.

Referenced by analyze().

◆ isWritable()

virtual Action ValueFlowAnalyzer::isWritable ( const Token tok,
Direction  d 
) const
inlinevirtual

◆ makeConditional()

virtual void ValueFlowAnalyzer::makeConditional ( )
pure virtual

Implemented in MultiValueFlowAnalyzer, and SingleValueFlowAnalyzer.

Referenced by assume().

◆ match()

virtual bool ValueFlowAnalyzer::match ( const Token tok) const
pure virtual

◆ reanalyze()

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

Return analyzer for expression at token.

Implements Analyzer.

Reimplemented in SingleValueFlowAnalyzer, and SubExpressionAnalyzer.

Definition at line 3133 of file valueflow.cpp.

◆ update()

void ValueFlowAnalyzer::update ( Token tok,
Action  a,
Direction  d 
)
inlineoverridevirtual

◆ updateState()

void ValueFlowAnalyzer::updateState ( const Token tok)
inlineoverridevirtual

Update the state of the program at the token.

Implements Analyzer.

Definition at line 3095 of file valueflow.cpp.

References ProgramMemoryState::addState(), getProgramState(), pms, and ProgramMemoryState::removeModifiedVars().

◆ useSymbolicValues()

virtual bool ValueFlowAnalyzer::useSymbolicValues ( ) const
inlinevirtual

Reimplemented in SingleValueFlowAnalyzer.

Definition at line 2844 of file valueflow.cpp.

Referenced by isSameSymbolicValue().

◆ writeValue()

virtual void ValueFlowAnalyzer::writeValue ( ValueFlow::Value value,
const Token tok,
Direction  d 
) const
inlinevirtual

Member Data Documentation

◆ pms

ProgramMemoryState ValueFlowAnalyzer::pms

Definition at line 2503 of file valueflow.cpp.

Referenced by assume(), evaluate(), and updateState().

◆ settings

const Settings& ValueFlowAnalyzer::settings

◆ tokenlist

const TokenList& ValueFlowAnalyzer::tokenlist

Definition at line 2501 of file valueflow.cpp.

Referenced by isCPP(), and SingleValueFlowAnalyzer::reanalyze().


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