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

Method oppositeInnerConditionError

lib/checkcondition.cpp:864–877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

862}
863
864void CheckConditionImpl::oppositeInnerConditionError(const Token *tok1, const Token* tok2, ErrorPath errorPath)
865{
866 if (diag(tok1, tok2))
867 return;
868 const std::string s1(tok1 ? tok1->expressionString() : "x");
869 const std::string s2(tok2 ? tok2->expressionString() : "!x");
870 const std::string innerSmt = innerSmtString(tok2);
871 errorPath.emplace_back(tok1, "outer condition: " + s1);
872 errorPath.emplace_back(tok2, "opposite inner condition: " + s2);
873
874 const std::string msg("Opposite inner '" + innerSmt + "' condition leads to a dead code block.\n"
875 "Opposite inner '" + innerSmt + "' condition leads to a dead code block (outer condition is '" + s1 + "' and inner condition is '" + s2 + "').");
876 reportError(std::move(errorPath), Severity::warning, "oppositeInnerCondition", msg, CWE398, Certainty::normal);
877}
878
879void CheckConditionImpl::overlappingInnerConditionError(const Token *tok1, const Token* tok2, ErrorPath errorPath)
880{

Callers 1

getErrorMessagesMethod · 0.80

Calls 4

innerSmtStringFunction · 0.85
diagFunction · 0.70
reportErrorFunction · 0.70
expressionStringMethod · 0.45

Tested by

no test coverage detected