Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/forwardanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,13 @@ struct ForwardTraversal {
// If we are in a loop then jump to the end
if (out)
*out = loopEnds.back();
} else if (Token::Match(tok, "return|throw") || isEscapeFunction(tok, &settings->library)) {
traverseRecursive(tok->astOperand1(), f, traverseUnknown);
} else if (Token::Match(tok, "return|throw")) {
traverseRecursive(tok->astOperand2(), f, traverseUnknown);
traverseRecursive(tok->astOperand1(), f, traverseUnknown);
return Break(Analyzer::Terminate::Escape);
} else if (Token::Match(tok, "%name% (") && isEscapeFunction(tok, &settings->library)) {
// Traverse the parameters of the function before escaping
traverseRecursive(tok->next()->astOperand2(), f, traverseUnknown);
return Break(Analyzer::Terminate::Escape);
} else if (isUnevaluated(tok)) {
if (out)
Expand Down
6 changes: 6 additions & 0 deletions test/testvalueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3472,6 +3472,12 @@ class TestValueFlow : public TestFixture {
" if (x == 42) {}\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 6U, 11));

code = "void f() {\n"
" int x = 1;\n"
" exit(x);\n"
"}\n";
ASSERT_EQUALS(true, testValueOfXKnown(code, 3U, 1));
}

void valueFlowForwardTernary() {
Expand Down