| 862 | } |
| 863 | |
| 864 | void 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 | |
| 879 | void CheckConditionImpl::overlappingInnerConditionError(const Token *tok1, const Token* tok2, ErrorPath errorPath) |
| 880 | { |
no test coverage detected