Fix #14660 Handle reverse conditions in isOppositeCond function#8408
Fix #14660 Handle reverse conditions in isOppositeCond function#8408danmar merged 3 commits intodanmar:mainfrom
Conversation
Signed-off-by: Francois Berder <fberder@outlook.fr>
|
Please file a ticket for this. |
not sure if you have a trac account. let us know if you want us to file a ticket for you.. |
Indeed, I do not have a trac account and I cannot create one myself so please file a ticket for me. |
|
|
Let me know if you want to squash the commits and include a reference to the ticket number in the commit message. |
|
We always squash, and the PR title becomes the commit message, so it's all good. |
| ASSERT_EQUALS("", errout_str()); | ||
|
|
||
| check("void f1(const std::string &s) { if(42 < s.size()) if(s.empty()) {}}"); | ||
| ASSERT_EQUALS("[test.cpp:1:39] -> [test.cpp:1:61]: (warning) Opposite inner 'if' condition leads to a dead code block. [oppositeInnerCondition]\n", errout_str()); |
There was a problem hiding this comment.
hmm I feel it's out of scope for this PR but I feel the warning message is a bit obfuscated. The "leads to a dead code block" is true but it's an indirect consequence. I think it would be better to try to describe the direct consequence that inner condition s.empty() is always false.
I also feel that sometimes opposite inner conditions doesn't necessarily lead to dead code.. i.e.: if (x < 0 || s.empty()) I don't know if we warn but imho it should be OK to warn if the message is clear..



No description provided.