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

Function minUnsignedValue

lib/valueflow.cpp:1024–1045  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1022}
1023
1024static std::vector<MathLib::bigint> minUnsignedValue(const Token* tok, int depth = 8)
1025{
1026 std::vector<MathLib::bigint> result;
1027 if (!tok)
1028 return result;
1029 if (depth < 0)
1030 return result;
1031 if (const ValueFlow::Value* v = tok->getKnownValue(ValueFlow::Value::ValueType::INT)) {
1032 result = {v->intvalue};
1033 } else if (!Token::Match(tok, "-|%|&|^") && tok->isConstOp() && tok->astOperand1() && tok->astOperand2()) {
1034 std::vector<MathLib::bigint> op1 = minUnsignedValue(tok->astOperand1(), depth - 1);
1035 if (!op1.empty()) {
1036 std::vector<MathLib::bigint> op2 = minUnsignedValue(tok->astOperand2(), depth - 1);
1037 if (!op2.empty()) {
1038 result = calculate<std::vector<MathLib::bigint>>(tok->str(), op1.front(), op2.front());
1039 }
1040 }
1041 }
1042 if (result.empty() && astIsUnsigned(tok))
1043 result = {0};
1044 return result;
1045}
1046
1047static bool isConvertedToIntegral(const Token* tok, const Settings& settings)
1048{

Callers 1

Calls 8

astIsUnsignedFunction · 0.85
getKnownValueMethod · 0.80
isConstOpMethod · 0.80
astOperand1Method · 0.80
astOperand2Method · 0.80
frontMethod · 0.80
emptyMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected