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

Function parseBinaryIntOp

lib/valueflow.cpp:6162–6187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6160}
6161
6162static const Token* parseBinaryIntOp(const Token* expr,
6163 const std::function<std::vector<MathLib::bigint>(const Token*)>& eval,
6164 MathLib::bigint& known)
6165{
6166 if (!expr)
6167 return nullptr;
6168 if (!expr->astOperand1() || !expr->astOperand2())
6169 return nullptr;
6170 if (expr->astOperand1()->exprId() == 0 && expr->astOperand2()->exprId() == 0)
6171 return nullptr;
6172 std::vector<MathLib::bigint> x1 = eval(expr->astOperand1());
6173 if (expr->astOperand1()->exprId() == 0 && x1.empty())
6174 return nullptr;
6175 std::vector<MathLib::bigint> x2 = eval(expr->astOperand2());
6176 if (expr->astOperand2()->exprId() == 0 && x2.empty())
6177 return nullptr;
6178 const Token* varTok = nullptr;
6179 if (!x1.empty() && x2.empty()) {
6180 varTok = expr->astOperand2();
6181 known = x1.front();
6182 } else if (x1.empty() && !x2.empty()) {
6183 varTok = expr->astOperand1();
6184 known = x2.front();
6185 }
6186 return varTok;
6187}
6188
6189const Token* ValueFlow::solveExprValue(const Token* expr,
6190 const std::function<std::vector<MathLib::bigint>(const Token*)>& eval,

Callers 1

solveExprValueMethod · 0.85

Calls 4

astOperand1Method · 0.80
astOperand2Method · 0.80
frontMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected