ValueFlow: Set values to parameters to escape functions (#3994)
* ValueFlow: Set values to parameters to escape functions * Format
This commit is contained in:
parent
d97942d3c6
commit
99757c6d06
|
@ -131,9 +131,13 @@ struct ForwardTraversal {
|
||||||
// If we are in a loop then jump to the end
|
// If we are in a loop then jump to the end
|
||||||
if (out)
|
if (out)
|
||||||
*out = loopEnds.back();
|
*out = loopEnds.back();
|
||||||
} else if (Token::Match(tok, "return|throw") || isEscapeFunction(tok, &settings->library)) {
|
} else if (Token::Match(tok, "return|throw")) {
|
||||||
traverseRecursive(tok->astOperand1(), f, traverseUnknown);
|
|
||||||
traverseRecursive(tok->astOperand2(), f, traverseUnknown);
|
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);
|
return Break(Analyzer::Terminate::Escape);
|
||||||
} else if (isUnevaluated(tok)) {
|
} else if (isUnevaluated(tok)) {
|
||||||
if (out)
|
if (out)
|
||||||
|
|
|
@ -3472,6 +3472,12 @@ private:
|
||||||
" if (x == 42) {}\n"
|
" if (x == 42) {}\n"
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS(false, testValueOfX(code, 6U, 11));
|
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() {
|
void valueFlowForwardTernary() {
|
||||||
|
|
Loading…
Reference in New Issue