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

Function findVarBound

lib/valueflow.cpp:3878–3902  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3876}
3877
3878static ValueFlow::Value::Bound findVarBound(const Variable* var,
3879 const Token* start,
3880 const Token* end,
3881 const Settings& settings)
3882{
3883 ValueFlow::Value::Bound result = ValueFlow::Value::Bound::Point;
3884 const Token* next = start;
3885 while ((next = findExpressionChangedSkipDeadCode(
3886 var->nameToken(), next->next(), end, settings, &evaluateKnownValues))) {
3887 ValueFlow::Value::Bound b = ValueFlow::Value::Bound::Point;
3888 if (next->varId() != var->declarationId())
3889 return ValueFlow::Value::Bound::Point;
3890 if (Token::simpleMatch(next->astParent(), "++"))
3891 b = ValueFlow::Value::Bound::Lower;
3892 else if (Token::simpleMatch(next->astParent(), "--"))
3893 b = ValueFlow::Value::Bound::Upper;
3894 else
3895 return ValueFlow::Value::Bound::Point;
3896 if (result == ValueFlow::Value::Bound::Point)
3897 result = b;
3898 else if (result != b)
3899 return ValueFlow::Value::Bound::Point;
3900 }
3901 return result;
3902}
3903
3904static bool isInitialVarAssign(const Token* tok)
3905{

Callers 1

valueFlowForwardAssignFunction · 0.85

Calls 5

nextMethod · 0.80
astParentMethod · 0.80
simpleMatchFunction · 0.70
nameTokenMethod · 0.45

Tested by

no test coverage detected