ValueFlow: Improved abstract interpretation
This commit is contained in:
parent
591209ffac
commit
aa05bf0f16
|
@ -688,16 +688,19 @@ static void execute(const Token *expr,
|
|||
}
|
||||
|
||||
else if (expr->str() == "&&") {
|
||||
execute(expr->astOperand1(), programMemory, result, error);
|
||||
if (*error || *result == 0)
|
||||
bool error1 = false;
|
||||
execute(expr->astOperand1(), programMemory, result, &error1);
|
||||
if (!error1 && *result == 0)
|
||||
*result = 0;
|
||||
else {
|
||||
execute(expr->astOperand2(), programMemory, result, error);
|
||||
// If there is an error, assume the result is not important
|
||||
if (*error) {
|
||||
*error = false;
|
||||
bool error2 = false;
|
||||
execute(expr->astOperand2(), programMemory, result, &error2);
|
||||
if (error1 && error2)
|
||||
*error = true;
|
||||
if (error2)
|
||||
*result = 1;
|
||||
}
|
||||
else
|
||||
*result = !!*result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1846,7 +1846,8 @@ private:
|
|||
" data[x] = 0;\n"
|
||||
" }"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: data\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: data\n"
|
||||
"[test.cpp:5]: (error) Array 'data[2]' accessed at index 10, which is out of bounds.\n", errout.str());
|
||||
}
|
||||
|
||||
void array_index_for_continue() {
|
||||
|
|
Loading…
Reference in New Issue