Temporarily disable followVariableExpressions(), there are problems that should be fixed.
This commit is contained in:
parent
d5a9332684
commit
a331206b44
|
@ -133,6 +133,7 @@ const Token * astIsVariableComparison(const Token *tok, const std::string &comp,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
static const Token * getVariableInitExpression(const Variable * var)
|
||||
{
|
||||
if (!var || !var->declEndToken())
|
||||
|
@ -146,6 +147,7 @@ static bool isInLoopCondition(const Token * tok)
|
|||
{
|
||||
return Token::Match(tok->astTop()->previous(), "for|while (");
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/// This takes a token that refers to a variable and it will return the token
|
||||
|
@ -153,6 +155,11 @@ static bool isInLoopCondition(const Token * tok)
|
|||
/// make such substitution then it will return the original token.
|
||||
static const Token * followVariableExpression(const Token * tok, bool cpp)
|
||||
{
|
||||
// DM: followVariableExpression is disabled for now because it cause problems.
|
||||
// See #8717 and #8722
|
||||
(void)cpp;
|
||||
return tok;
|
||||
/*
|
||||
if (!tok)
|
||||
return tok;
|
||||
// Skip array access
|
||||
|
@ -208,6 +215,7 @@ static const Token * followVariableExpression(const Token * tok, bool cpp)
|
|||
}
|
||||
}
|
||||
return varTok;
|
||||
*/
|
||||
}
|
||||
|
||||
static void followVariableExpressionError(const Token *tok1, const Token *tok2, ErrorPath* errors)
|
||||
|
|
|
@ -1245,7 +1245,7 @@ private:
|
|||
" if (a > x && a < y)\n"
|
||||
" return;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:8]: (warning) Logical conjunction always evaluates to false: a > x && a < y.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:8]: (warning) Logical conjunction always evaluates to false: a > x && a < y.\n", "", errout.str());
|
||||
|
||||
check("struct A {\n"
|
||||
" void f();\n"
|
||||
|
@ -1275,7 +1275,7 @@ private:
|
|||
" if (a > x && a < y)\n"
|
||||
" return;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (warning) Logical conjunction always evaluates to false: a > x && a < y.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:5]: (warning) Logical conjunction always evaluates to false: a > x && a < y.\n", "", errout.str());
|
||||
}
|
||||
|
||||
void secondAlwaysTrueFalseWhenFirstTrueError() {
|
||||
|
@ -1600,7 +1600,7 @@ private:
|
|||
" if(!b) {}\n"
|
||||
" }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (warning) Opposite inner 'if' condition leads to a dead code block.\n", "", errout.str());
|
||||
|
||||
check("void foo(unsigned u) {\n"
|
||||
" if (u != 0) {\n"
|
||||
|
|
|
@ -3916,13 +3916,13 @@ private:
|
|||
" const int i = sizeof(int);\n"
|
||||
" if ( i != sizeof (int)){}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) The expression 'i != sizeof(int)' is always false because 'i' and 'sizeof(int)' represent the same value.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) The expression 'i != sizeof(int)' is always false because 'i' and 'sizeof(int)' represent the same value.\n", "", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" const int i = sizeof(int);\n"
|
||||
" if ( sizeof (int) != i){}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) The expression 'sizeof(int) != i' is always false because 'sizeof(int)' and 'i' represent the same value.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) The expression 'sizeof(int) != i' is always false because 'sizeof(int)' and 'i' represent the same value.\n", "", errout.str());
|
||||
|
||||
check("void f(int a = 1) { if ( a != 1){}}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
@ -3931,21 +3931,21 @@ private:
|
|||
" int a = 1;\n"
|
||||
" if ( a != 1){} \n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) The expression 'a != 1' is always false.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) The expression 'a != 1' is always false.\n", "", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" int a = 1;\n"
|
||||
" int b = 1;\n"
|
||||
" if ( a != b){} \n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3] -> [test.cpp:4]: (style) The expression 'a != b' is always false because 'a' and 'b' represent the same value.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3] -> [test.cpp:4]: (style) The expression 'a != b' is always false because 'a' and 'b' represent the same value.\n", "", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" int a = 1;\n"
|
||||
" int b = a;\n"
|
||||
" if ( a != b){} \n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) The expression 'a != b' is always false because 'a' and 'b' represent the same value.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) The expression 'a != b' is always false because 'a' and 'b' represent the same value.\n", "", errout.str());
|
||||
|
||||
check("void use(int);\n"
|
||||
"void f() {\n"
|
||||
|
@ -3954,7 +3954,7 @@ private:
|
|||
" use(b);\n"
|
||||
" if ( a != 1){} \n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:6]: (style) The expression 'a != 1' is always false.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:6]: (style) The expression 'a != 1' is always false.\n", "", errout.str());
|
||||
|
||||
check("void use(int);\n"
|
||||
"void f() {\n"
|
||||
|
@ -3978,7 +3978,7 @@ private:
|
|||
" void f() {\n"
|
||||
" if ( a != 1){} \n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:3]: (style) The expression 'a != 1' is always false.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:3]: (style) The expression 'a != 1' is always false.\n", "", errout.str());
|
||||
|
||||
check("int a = 1;\n"
|
||||
" void f() {\n"
|
||||
|
@ -3990,7 +3990,7 @@ private:
|
|||
" static const int a = 1;\n"
|
||||
" if ( a != 1){} \n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) The expression 'a != 1' is always false.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) The expression 'a != 1' is always false.\n", "", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" static int a = 1;\n"
|
||||
|
@ -4003,7 +4003,7 @@ private:
|
|||
" if ( a != 1){\n"
|
||||
" a++;\n"
|
||||
" }}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) The expression 'a != 1' is always false.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) The expression 'a != 1' is always false.\n", "", errout.str());
|
||||
|
||||
check("void f(int b) {\n"
|
||||
" int a = 1;\n"
|
||||
|
@ -4082,7 +4082,7 @@ private:
|
|||
" int a = 1;\n"
|
||||
" while ( a != 1){}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) The expression 'a != 1' is always false.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) The expression 'a != 1' is always false.\n", "", errout.str());
|
||||
|
||||
check("void f() { int a = 1; while ( a != 1){ a++; }}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
@ -4098,7 +4098,7 @@ private:
|
|||
" if( i != 0 ) {}\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) The expression 'i != 0' is always false.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) The expression 'i != 0' is always false.\n", "", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" for(int i = 0; i < 10;) {\n"
|
||||
|
@ -4139,7 +4139,7 @@ private:
|
|||
" b++;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) The expression 'a != 1' is always false.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) The expression 'a != 1' is always false.\n", "", errout.str());
|
||||
}
|
||||
|
||||
void duplicateExpressionTernary() { // #6391
|
||||
|
|
Loading…
Reference in New Issue