| 3231 | } |
| 3232 | |
| 3233 | bool CheckOtherImpl::comparisonNonZeroExpressionLessThanZero(const Token *tok, const ValueFlow::Value *&zeroValue, const Token *&nonZeroExpr, bool suppress) |
| 3234 | { |
| 3235 | if (!tok->isComparisonOp() || !tok->astOperand1() || !tok->astOperand2()) |
| 3236 | return false; |
| 3237 | |
| 3238 | const ValueFlow::Value *v1 = tok->astOperand1()->getValue(0); |
| 3239 | const ValueFlow::Value *v2 = tok->astOperand2()->getValue(0); |
| 3240 | |
| 3241 | if (Token::Match(tok, "<|<=") && v2 && v2->isKnown()) { |
| 3242 | zeroValue = v2; |
| 3243 | nonZeroExpr = tok->astOperand1(); |
| 3244 | } else if (Token::Match(tok, ">|>=") && v1 && v1->isKnown()) { |
| 3245 | zeroValue = v1; |
| 3246 | nonZeroExpr = tok->astOperand2(); |
| 3247 | } else { |
| 3248 | return false; |
| 3249 | } |
| 3250 | |
| 3251 | if (const Variable* var = nonZeroExpr->variable()) |
| 3252 | if (var->typeStartToken()->isTemplateArg()) |
| 3253 | return suppress; |
| 3254 | |
| 3255 | const ValueType* vt = nonZeroExpr->valueType(); |
| 3256 | return vt && (vt->pointer || vt->sign == ValueType::UNSIGNED); |
| 3257 | } |
| 3258 | |
| 3259 | bool CheckOtherImpl::testIfNonZeroExpressionIsPositive(const Token *tok, const ValueFlow::Value *&zeroValue, const Token *&nonZeroExpr) |
| 3260 | { |
nothing calls this directly
no test coverage detected