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

Method integerOverflowError

lib/checktype.cpp:227–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227void 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

Callers 1

getErrorMessagesMethod · 0.80

Calls 4

getMessageIdFunction · 0.85
reportErrorFunction · 0.70
expressionStringMethod · 0.45
isInconclusiveMethod · 0.45

Tested by

no test coverage detected