Skip to content

Commit 9d8cef4

Browse files
author
klaas
committed
Turns some checks into DATA_INVARIANTs
1 parent f1ff824 commit 9d8cef4

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/solvers/flattening/bv_pointers.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@ literalt bv_pointerst::convert_rest(const exprt &expr)
4747
}
4848
else if(expr.id()==ID_is_dynamic_object)
4949
{
50-
if(operands.size()==1 &&
51-
operands[0].type().id()==ID_pointer)
52-
{
53-
// we postpone
54-
literalt l=prop.new_variable();
50+
DATA_INVARIANT(operands.size() == 1 &&
51+
operands[0].type().id() == ID_pointer,
52+
std::string("is_dynamic_object_exprt should have one") +
53+
"operand, which should have pointer type.");
54+
// we postpone
55+
literalt l=prop.new_variable();
5556

56-
postponed_list.push_back(postponedt());
57-
postponed_list.back().op=convert_bv(operands[0]);
58-
postponed_list.back().bv.push_back(l);
59-
postponed_list.back().expr=expr;
57+
postponed_list.push_back(postponedt());
58+
postponed_list.back().op=convert_bv(operands[0]);
59+
postponed_list.back().bv.push_back(l);
60+
postponed_list.back().expr=expr;
6061

61-
return l;
62-
}
62+
return l;
6363
}
6464
else if(expr.id()==ID_lt || expr.id()==ID_le ||
6565
expr.id()==ID_gt || expr.id()==ID_ge)

src/util/simplify_expr_pointer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,10 @@ bool simplify_exprt::simplify_pointer_object(exprt &expr)
510510

511511
bool simplify_exprt::simplify_is_dynamic_object(exprt &expr)
512512
{
513-
// This should hold as a result of the expr ID being is_dynamic_object.
514-
PRECONDITION(expr.operands().size() == 1);
513+
DATA_INVARIANT(expr.operands().size() == 1 &&
514+
expr.op0().type().id() == ID_pointer,
515+
std::string("is_dynamic_object_exprt should have one") +
516+
"operand, which should have pointer type.");
515517

516518
exprt &op=expr.op0();
517519

0 commit comments

Comments
 (0)