MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / bifurcate

Function bifurcate

lib/vf_analyzers.cpp:826–856  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

824}
825
826static bool bifurcate(const Token* tok, const std::set<nonneg int>& varids, const Settings& settings, int depth)
827{
828 if (depth < 0)
829 return false;
830 if (!tok)
831 return true;
832 if (tok->hasKnownIntValue())
833 return true;
834 if (tok->isConstOp())
835 return bifurcate(tok->astOperand1(), varids, settings, depth) && bifurcate(tok->astOperand2(), varids, settings, depth);
836 if (tok->varId() != 0) {
837 if (varids.count(tok->varId()) > 0)
838 return true;
839 const Variable* var = tok->variable();
840 if (!var)
841 return false;
842 if (!var->isLocal() && !var->isArgument())
843 return false;
844 const Token* start = var->declEndToken();
845 if (!start)
846 return false;
847 if (start->strAt(-1) == ")" || start->strAt(-1) == "}")
848 return false;
849 if (Token::Match(start, "; %varid% =", var->declarationId()))
850 start = start->tokAt(2);
851 if (var->isConst() || !bifurcateVariableChanged(var, varids, start, tok, settings, depth))
852 return var->isArgument() || bifurcate(start->astOperand2(), varids, settings, depth - 1);
853 return false;
854 }
855 return false;
856}
857
858// Check if its an alias of the variable or is being aliased to this variable
859template<typename V>

Callers 3

bifurcateVariableChangedFunction · 0.85
updateScopeMethod · 0.85
updateScopeMethod · 0.85

Calls 9

bifurcateVariableChangedFunction · 0.85
isConstOpMethod · 0.80
astOperand1Method · 0.80
astOperand2Method · 0.80
variableMethod · 0.80
declEndTokenMethod · 0.80
isConstMethod · 0.80
hasKnownIntValueMethod · 0.45
tokAtMethod · 0.45

Tested by

no test coverage detected