From 175070ca50fefb684ab09fee04875426fcc7af6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 22 Jun 2019 21:57:19 +0200 Subject: [PATCH] Revert "Fixed #8938 (FP identicalInnerCondition)" This reverts commit 0edf0b562855f0c6d5569a3995cb380ed1d5fc6e. This bailout seems to cause many false negatives --- lib/checkcondition.cpp | 3 --- test/testcondition.cpp | 29 ++++++++++------------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index a2b4afbfa..49ca594f4 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -685,9 +685,6 @@ void CheckCondition::multiCondition2() } } } - if (Token::Match(tok, "%name% (")) - // TODO: This is a bailout to avoid fp - break; if (Token::Match(tok, "%type% (") && nonlocal && isNonConstFunctionCall(tok, mSettings->library)) // non const function call -> bailout if there are nonlocal variables break; if (Token::Match(tok, "case|break|continue|return|throw") && tok->scope() == endToken->scope()) diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 5f988761b..9ac8dfa42 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -1570,7 +1570,7 @@ private: " }\n" " }\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", "", errout.str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", errout.str()); check("void foo(const int &i);\n" "void bar(int i) {\n" @@ -1580,7 +1580,7 @@ private: " }\n" " }\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", "", errout.str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", errout.str()); check("void foo(int i);\n" "void bar() {\n" @@ -1591,7 +1591,7 @@ private: " }\n" " }\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:6]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", "", errout.str()); + ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:6]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", errout.str()); check("class C { void f(int &i) const; };\n" // #7028 - variable is changed by const method "void foo(C c, int i) {\n" @@ -1614,7 +1614,7 @@ private: " }\n" " }\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:7]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", "", errout.str()); + ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:7]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", errout.str()); // #5874 - array @@ -1661,15 +1661,6 @@ private: " }\n" "}"); ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", errout.str()); - - // #8938 - check("void Delete(SS_CELLCOORD upperleft) {\n" - " if ((upperleft.Col == -1) && (upperleft.Row == -1)) {\n" - " GetActiveCell(&(upperleft.Col), &(upperleft.Row));\n" - " if (upperleft.Row == -1) {}\n" - " }\n" - "}"); - ASSERT_EQUALS("", errout.str()); } void oppositeInnerConditionPointers() { @@ -1716,7 +1707,7 @@ private: " if (!fred.isValid()) {}\n" " }\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", "", errout.str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", errout.str()); check("class Fred { public: bool isValid() const; void dostuff() const; };\n" "void f() {\n" @@ -1726,7 +1717,7 @@ private: " if (!fred.isValid()) {}\n" " }\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:6]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", "", errout.str()); + ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:6]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", errout.str()); check("void f() {\n" " Fred fred;\n" @@ -2240,14 +2231,14 @@ private: " if (abc) {}\n" " if (x > 100) {}\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (warning) Identical condition 'x>100', second condition is always false\n", "", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (warning) Identical condition 'x>100', second condition is always false\n", errout.str()); check("void f(int x) {\n" " if (x > 100) { return; }\n" " while (abc) { y = x; }\n" " if (x > 100) {}\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (warning) Identical condition 'x>100', second condition is always false\n", "", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (warning) Identical condition 'x>100', second condition is always false\n", errout.str()); check("void f(int x) {\n" // #8217 - crash for incomplete code " if (x > 100) { return; }\n" @@ -2262,7 +2253,7 @@ private: " if (!num1tok) { *num1 = *num2; }\n" " if (!i) {}\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (warning) Identical condition '!i', second condition is always false\n", "", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (warning) Identical condition '!i', second condition is always false\n", errout.str()); check("void C::f(Tree &coreTree) {\n" // daca " if(!coreTree.build())\n" @@ -2279,7 +2270,7 @@ private: " coreTree.dostuff();\n" " if(!coreTree.build()) {}\n" "}\n"); - TODO_ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:6]: (warning) Identical condition '!coreTree.build()', second condition is always false\n", "", errout.str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:6]: (warning) Identical condition '!coreTree.build()', second condition is always false\n", errout.str()); check("void f(int x) {\n" // daca: labplot " switch(type) {\n"