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

Method comparisonError

lib/checkcondition.cpp:424–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422}
423
424void CheckConditionImpl::comparisonError(const Token *tok, const std::string &bitop, MathLib::bigint value1, const std::string &op, MathLib::bigint value2, bool result)
425{
426 std::ostringstream expression;
427 expression << std::hex << "(X " << bitop << " 0x" << value1 << ") " << op << " 0x" << value2;
428
429 const std::string errmsg("Expression '" + expression.str() + "' is always " + bool_to_string(result) + ".\n"
430 "The expression '" + expression.str() + "' is always " + bool_to_string(result) +
431 ". Check carefully constants and operators used, these errors might be hard to "
432 "spot sometimes. In case of complex expression it might help to split it to "
433 "separate expressions.");
434
435 reportError(tok, Severity::style, "comparisonError", errmsg, CWE398, Certainty::normal);
436}
437
438bool CheckConditionImpl::isOverlappingCond(const Token * const cond1, const Token * const cond2, bool pure) const
439{

Callers 1

getErrorMessagesMethod · 0.80

Calls 3

bool_to_stringFunction · 0.85
reportErrorFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected