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

Method identicalInnerConditionError

lib/checkcondition.cpp:894–907  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

892}
893
894void CheckConditionImpl::identicalInnerConditionError(const Token *tok1, const Token* tok2, ErrorPath errorPath)
895{
896 if (diag(tok1, tok2))
897 return;
898 const std::string s1(tok1 ? tok1->expressionString() : "x");
899 const std::string s2(tok2 ? tok2->expressionString() : "x");
900 const std::string innerSmt = innerSmtString(tok2);
901 errorPath.emplace_back(tok1, "outer condition: " + s1);
902 errorPath.emplace_back(tok2, "identical inner condition: " + s2);
903
904 const std::string msg("Identical inner '" + innerSmt + "' condition is always true.\n"
905 "Identical inner '" + innerSmt + "' condition is always true (outer condition is '" + s1 + "' and inner condition is '" + s2 + "').");
906 reportError(std::move(errorPath), Severity::warning, "identicalInnerCondition", msg, CWE398, Certainty::normal);
907}
908
909void CheckConditionImpl::identicalConditionAfterEarlyExitError(const Token *cond1, const Token* cond2, ErrorPath errorPath)
910{

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