ValueFlow: Set values to parameters to longjmp and setjmp (#4040)
* ValueFlow: Set values to parameters to longjmp and setjmp * Format
This commit is contained in:
parent
4fa2e3ac87
commit
4eed29502c
|
@ -123,9 +123,13 @@ struct ForwardTraversal {
|
|||
|
||||
template<class T, class F, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )>
|
||||
Progress traverseTok(T* tok, F f, bool traverseUnknown, T** out = nullptr) {
|
||||
if (Token::Match(tok, "asm|goto|setjmp|longjmp"))
|
||||
if (Token::Match(tok, "asm|goto"))
|
||||
return Break(Analyzer::Terminate::Bail);
|
||||
else if (Token::simpleMatch(tok, "continue")) {
|
||||
else if (Token::Match(tok, "setjmp|longjmp (")) {
|
||||
// Traverse the parameters of the function before escaping
|
||||
traverseRecursive(tok->next()->astOperand2(), f, traverseUnknown);
|
||||
return Break(Analyzer::Terminate::Bail);
|
||||
} else if (Token::simpleMatch(tok, "continue")) {
|
||||
if (loopEnds.empty())
|
||||
return Break(Analyzer::Terminate::Escape);
|
||||
// If we are in a loop then jump to the end
|
||||
|
|
|
@ -3486,6 +3486,12 @@ private:
|
|||
" exit(x);\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(true, testValueOfXKnown(code, 3U, 1));
|
||||
|
||||
code = "void f(jmp_buf env) {\n"
|
||||
" int x = 1;\n"
|
||||
" longjmp(env, x);\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(true, testValueOfXKnown(code, 3U, 1));
|
||||
}
|
||||
|
||||
void valueFlowForwardTernary() {
|
||||
|
|
Loading…
Reference in New Issue