Revert "Fixed #8938 (FP identicalInnerCondition)"
This reverts commit 0edf0b5628
.
This bailout seems to cause many false negatives
This commit is contained in:
parent
de9c999d79
commit
175070ca50
|
@ -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
|
if (Token::Match(tok, "%type% (") && nonlocal && isNonConstFunctionCall(tok, mSettings->library)) // non const function call -> bailout if there are nonlocal variables
|
||||||
break;
|
break;
|
||||||
if (Token::Match(tok, "case|break|continue|return|throw") && tok->scope() == endToken->scope())
|
if (Token::Match(tok, "case|break|continue|return|throw") && tok->scope() == endToken->scope())
|
||||||
|
|
|
@ -1570,7 +1570,7 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
" }\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"
|
check("void foo(const int &i);\n"
|
||||||
"void bar(int i) {\n"
|
"void bar(int i) {\n"
|
||||||
|
@ -1580,7 +1580,7 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
" }\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"
|
check("void foo(int i);\n"
|
||||||
"void bar() {\n"
|
"void bar() {\n"
|
||||||
|
@ -1591,7 +1591,7 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
" }\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
|
check("class C { void f(int &i) const; };\n" // #7028 - variable is changed by const method
|
||||||
"void foo(C c, int i) {\n"
|
"void foo(C c, int i) {\n"
|
||||||
|
@ -1614,7 +1614,7 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
" }\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
|
// #5874 - array
|
||||||
|
@ -1661,15 +1661,6 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", errout.str());
|
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() {
|
void oppositeInnerConditionPointers() {
|
||||||
|
@ -1716,7 +1707,7 @@ private:
|
||||||
" if (!fred.isValid()) {}\n"
|
" if (!fred.isValid()) {}\n"
|
||||||
" }\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"
|
check("class Fred { public: bool isValid() const; void dostuff() const; };\n"
|
||||||
"void f() {\n"
|
"void f() {\n"
|
||||||
|
@ -1726,7 +1717,7 @@ private:
|
||||||
" if (!fred.isValid()) {}\n"
|
" if (!fred.isValid()) {}\n"
|
||||||
" }\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"
|
check("void f() {\n"
|
||||||
" Fred fred;\n"
|
" Fred fred;\n"
|
||||||
|
@ -2240,14 +2231,14 @@ private:
|
||||||
" if (abc) {}\n"
|
" if (abc) {}\n"
|
||||||
" if (x > 100) {}\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"
|
check("void f(int x) {\n"
|
||||||
" if (x > 100) { return; }\n"
|
" if (x > 100) { return; }\n"
|
||||||
" while (abc) { y = x; }\n"
|
" while (abc) { y = x; }\n"
|
||||||
" if (x > 100) {}\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
|
check("void f(int x) {\n" // #8217 - crash for incomplete code
|
||||||
" if (x > 100) { return; }\n"
|
" if (x > 100) { return; }\n"
|
||||||
|
@ -2262,7 +2253,7 @@ private:
|
||||||
" if (!num1tok) { *num1 = *num2; }\n"
|
" if (!num1tok) { *num1 = *num2; }\n"
|
||||||
" if (!i) {}\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
|
check("void C::f(Tree &coreTree) {\n" // daca
|
||||||
" if(!coreTree.build())\n"
|
" if(!coreTree.build())\n"
|
||||||
|
@ -2279,7 +2270,7 @@ private:
|
||||||
" coreTree.dostuff();\n"
|
" coreTree.dostuff();\n"
|
||||||
" if(!coreTree.build()) {}\n"
|
" if(!coreTree.build()) {}\n"
|
||||||
"}\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
|
check("void f(int x) {\n" // daca: labplot
|
||||||
" switch(type) {\n"
|
" switch(type) {\n"
|
||||||
|
|
Loading…
Reference in New Issue