Fix 10787: False positive: knownConditionTrueFalse with a conditional exit (#3804)
This commit is contained in:
parent
fa776051e9
commit
a639c59780
|
@ -1439,6 +1439,8 @@ void SymbolDatabase::createSymbolDatabaseEscapeFunctions()
|
|||
Function * function = scope.function;
|
||||
if (!function)
|
||||
continue;
|
||||
if (Token::findsimplematch(scope.bodyStart, "return", scope.bodyEnd))
|
||||
continue;
|
||||
function->isEscapeFunction(isReturnScope(scope.bodyEnd, &mSettings->library, nullptr, true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3133,6 +3133,19 @@ private:
|
|||
"}\n";
|
||||
ASSERT_EQUALS(true, testValueOfX(code, 8U, 1));
|
||||
ASSERT_EQUALS(false, testValueOfXImpossible(code, 8U, 1));
|
||||
|
||||
code = "void g(int i) {\n"
|
||||
" if (i == 1)\n"
|
||||
" return;\n"
|
||||
" abort();\n"
|
||||
"}\n"
|
||||
"int f(int x) {\n"
|
||||
" if (x != 0)\n"
|
||||
" g(x);\n"
|
||||
" return x;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(false, testValueOfXKnown(code, 9U, 0));
|
||||
ASSERT_EQUALS(true, testValueOfX(code, 9U, 0));
|
||||
}
|
||||
|
||||
void valueFlowAfterConditionExpr() {
|
||||
|
|
Loading…
Reference in New Issue