| 6160 | } |
| 6161 | |
| 6162 | static 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 | |
| 6189 | const Token* ValueFlow::solveExprValue(const Token* expr, |
| 6190 | const std::function<std::vector<MathLib::bigint>(const Token*)>& eval, |
no test coverage detected