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

Method overlappingInnerConditionError

lib/checkcondition.cpp:879–892  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

877}
878
879void CheckConditionImpl::overlappingInnerConditionError(const Token *tok1, const Token* tok2, ErrorPath errorPath)
880{
881 if (diag(tok1, tok2))
882 return;
883 const std::string s1(tok1 ? tok1->expressionString() : "x");
884 const std::string s2(tok2 ? tok2->expressionString() : "x");
885 const std::string innerSmt = innerSmtString(tok2);
886 errorPath.emplace_back(tok1, "outer condition: " + s1);
887 errorPath.emplace_back(tok2, "overlapping inner condition: " + s2);
888
889 const std::string msg("Overlapping inner '" + innerSmt + "' condition is always true.\n"
890 "Overlapping inner '" + innerSmt + "' condition is always true (outer condition is '" + s1 + "' and inner condition is '" + s2 + "').");
891 reportError(std::move(errorPath), Severity::warning, "overlappingInnerCondition", msg, CWE398, Certainty::normal);
892}
893
894void CheckConditionImpl::identicalInnerConditionError(const Token *tok1, const Token* tok2, ErrorPath errorPath)
895{

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