parent
f093692551
commit
c666f74755
|
@ -1545,10 +1545,10 @@ static bool evalAssignment(ValueFlow::Value &lhsValue, const std::string &assign
|
||||||
|
|
||||||
static bool isEscapeScope(const Token* tok, TokenList * tokenlist)
|
static bool isEscapeScope(const Token* tok, TokenList * tokenlist)
|
||||||
{
|
{
|
||||||
if(!Token::simpleMatch(tok, "{"))
|
if (!Token::simpleMatch(tok, "{"))
|
||||||
return false;
|
return false;
|
||||||
return Token::findmatch(tok, "return|continue|break|throw|goto", tok->link()) ||
|
return Token::findmatch(tok, "return|continue|break|throw|goto", tok->link()) ||
|
||||||
(tokenlist && tokenlist->getSettings()->library.isScopeNoReturn(tok->link(), nullptr));
|
(tokenlist && tokenlist->getSettings()->library.isScopeNoReturn(tok->link(), nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool valueFlowForward(Token * const startToken,
|
static bool valueFlowForward(Token * const startToken,
|
||||||
|
@ -1867,7 +1867,7 @@ static bool valueFlowForward(Token * const startToken,
|
||||||
if ((!read || number_of_if == 0) &&
|
if ((!read || number_of_if == 0) &&
|
||||||
Token::simpleMatch(tok2, "if (") &&
|
Token::simpleMatch(tok2, "if (") &&
|
||||||
!(Token::simpleMatch(end, "} else {") &&
|
!(Token::simpleMatch(end, "} else {") &&
|
||||||
isEscapeScope(end->tokAt(2), tokenlist))) {
|
isEscapeScope(end->tokAt(2), tokenlist))) {
|
||||||
++number_of_if;
|
++number_of_if;
|
||||||
tok2 = end;
|
tok2 = end;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1584,20 +1584,20 @@ private:
|
||||||
ASSERT_EQUALS(false, testValueOfX(code, 9U, 0));
|
ASSERT_EQUALS(false, testValueOfX(code, 9U, 0));
|
||||||
|
|
||||||
code = "void f(int i) {\n"
|
code = "void f(int i) {\n"
|
||||||
" bool x = false;\n"
|
" bool x = false;\n"
|
||||||
" if (i == 0) { x = true; }\n"
|
" if (i == 0) { x = true; }\n"
|
||||||
" else if (x && i == 1) {}\n"
|
" else if (x && i == 1) {}\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
ASSERT_EQUALS(true, testValueOfX(code, 4U, 0));
|
ASSERT_EQUALS(true, testValueOfX(code, 4U, 0));
|
||||||
|
|
||||||
code = "void f(int i) {\n"
|
code = "void f(int i) {\n"
|
||||||
" bool x = false;\n"
|
" bool x = false;\n"
|
||||||
" while(i > 0) {\n"
|
" while(i > 0) {\n"
|
||||||
" i++;\n"
|
" i++;\n"
|
||||||
" if (i == 0) { x = true; }\n"
|
" if (i == 0) { x = true; }\n"
|
||||||
" else if (x && i == 1) {}\n"
|
" else if (x && i == 1) {}\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
ASSERT_EQUALS(false, testValueOfX(code, 6U, 0));
|
ASSERT_EQUALS(false, testValueOfX(code, 6U, 0));
|
||||||
|
|
||||||
// multivariables
|
// multivariables
|
||||||
|
|
Loading…
Reference in New Issue