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

Method tooBigBitwiseShiftError

lib/checktype.cpp:113–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113void CheckTypeImpl::tooBigBitwiseShiftError(const Token *tok, int lhsbits, const ValueFlow::Value &rhsbits)
114{
115 constexpr char id[] = "shiftTooManyBits";
116
117 if (!tok) {
118 reportError(tok, Severity::error, id, "Shifting 32-bit value by 40 bits is undefined behaviour", CWE758, Certainty::normal);
119 return;
120 }
121
122 ErrorPath errorPath = getErrorPath(tok, &rhsbits, "Shift");
123
124 std::ostringstream errmsg;
125 errmsg << "Shifting " << lhsbits << "-bit value by " << rhsbits.intvalue << " bits is undefined behaviour";
126 if (rhsbits.condition)
127 errmsg << ". See condition at line " << rhsbits.condition->linenr() << ".";
128
129 reportError(std::move(errorPath), rhsbits.errorSeverity() ? Severity::error : Severity::warning, id, errmsg.str(), CWE758, rhsbits.isInconclusive() ? Certainty::inconclusive : Certainty::normal);
130}
131
132void CheckTypeImpl::tooBigSignedBitwiseShiftError(const Token *tok, int lhsbits, const ValueFlow::Value &rhsbits)
133{

Callers 1

getErrorMessagesMethod · 0.80

Calls 3

reportErrorFunction · 0.70
strMethod · 0.45
isInconclusiveMethod · 0.45

Tested by

no test coverage detected