ExprEngine: Execute false execution path even if there is no else, upon Z3 exception assume that value is in range (safe option)
This commit is contained in:
parent
6c0c9ba6d3
commit
05aae9569b
|
@ -594,12 +594,17 @@ bool ExprEngine::IntRange::isIntValueInRange(DataBase *dataBase, int value) cons
|
||||||
// Check the value against the constraints
|
// Check the value against the constraints
|
||||||
ExprData exprData;
|
ExprData exprData;
|
||||||
z3::solver solver(exprData.context);
|
z3::solver solver(exprData.context);
|
||||||
|
try {
|
||||||
z3::expr e = exprData.context.int_const(name.c_str());
|
z3::expr e = exprData.context.int_const(name.c_str());
|
||||||
exprData.valueExpr.emplace(name, e);
|
exprData.valueExpr.emplace(name, e);
|
||||||
for (auto constraint : dynamic_cast<const Data *>(dataBase)->constraints)
|
for (auto constraint : dynamic_cast<const Data *>(dataBase)->constraints)
|
||||||
solver.add(exprData.getConstraintExpr(constraint));
|
solver.add(exprData.getConstraintExpr(constraint));
|
||||||
solver.add(e == value);
|
solver.add(e == value);
|
||||||
return solver.check() == z3::sat;
|
return solver.check() == z3::sat;
|
||||||
|
} catch (const z3::exception &exception) {
|
||||||
|
//std::cout << exception << std::endl;
|
||||||
|
return true; // Safe option is to return true
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
// The value may or may not be in range
|
// The value may or may not be in range
|
||||||
return false;
|
return false;
|
||||||
|
@ -1093,6 +1098,8 @@ static void execute(const Token *start, const Token *end, Data &data)
|
||||||
if (Token::simpleMatch(thenEnd, "} else {")) {
|
if (Token::simpleMatch(thenEnd, "} else {")) {
|
||||||
const Token *elseStart = thenEnd->tokAt(2);
|
const Token *elseStart = thenEnd->tokAt(2);
|
||||||
execute(elseStart->next(), end, elseData);
|
execute(elseStart->next(), end, elseData);
|
||||||
|
} else {
|
||||||
|
execute(thenEnd, end, elseData);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue