| 3257 | } |
| 3258 | |
| 3259 | bool CheckOtherImpl::testIfNonZeroExpressionIsPositive(const Token *tok, const ValueFlow::Value *&zeroValue, const Token *&nonZeroExpr) |
| 3260 | { |
| 3261 | if (!tok->isComparisonOp() || !tok->astOperand1() || !tok->astOperand2()) |
| 3262 | return false; |
| 3263 | |
| 3264 | const ValueFlow::Value *v1 = tok->astOperand1()->getValue(0); |
| 3265 | const ValueFlow::Value *v2 = tok->astOperand2()->getValue(0); |
| 3266 | |
| 3267 | if (Token::simpleMatch(tok, ">=") && v2 && v2->isKnown()) { |
| 3268 | zeroValue = v2; |
| 3269 | nonZeroExpr = tok->astOperand1(); |
| 3270 | } else if (Token::simpleMatch(tok, "<=") && v1 && v1->isKnown()) { |
| 3271 | zeroValue = v1; |
| 3272 | nonZeroExpr = tok->astOperand2(); |
| 3273 | } else { |
| 3274 | return false; |
| 3275 | } |
| 3276 | |
| 3277 | const ValueType* vt = nonZeroExpr->valueType(); |
| 3278 | return vt && (vt->pointer || vt->sign == ValueType::UNSIGNED); |
| 3279 | } |
| 3280 | |
| 3281 | void CheckOtherImpl::unsignedLessThanZeroError(const Token *tok, const ValueFlow::Value * v, const std::string &varname) |
| 3282 | { |
nothing calls this directly
no test coverage detected