| 225 | } |
| 226 | |
| 227 | void CheckTypeImpl::integerOverflowError(const Token *tok, const ValueFlow::Value &value, bool isOverflow) |
| 228 | { |
| 229 | const std::string expr(tok ? tok->expressionString() : ""); |
| 230 | const std::string type = isOverflow ? "overflow" : "underflow"; |
| 231 | |
| 232 | std::string msg; |
| 233 | if (value.condition) |
| 234 | msg = ValueFlow::eitherTheConditionIsRedundant(value.condition) + |
| 235 | " or there is signed integer " + type + " for expression '" + expr + "'."; |
| 236 | else |
| 237 | msg = "Signed integer " + type + " for expression '" + expr + "'."; |
| 238 | |
| 239 | if (value.safe) |
| 240 | msg = "Safe checks: " + msg; |
| 241 | |
| 242 | reportError(getErrorPath(tok, &value, "Integer " + type), |
| 243 | value.errorSeverity() ? Severity::error : Severity::warning, |
| 244 | getMessageId(value, "integerOverflow").c_str(), |
| 245 | msg, |
| 246 | CWE190, |
| 247 | value.isInconclusive() ? Certainty::inconclusive : Certainty::normal); |
| 248 | } |
| 249 | |
| 250 | //--------------------------------------------------------------------------- |
| 251 | // Checking for sign conversion when operand can be negative |
no test coverage detected