@@ -113,7 +113,7 @@ class goto_checkt
113
113
// / \param expr: the expression to be checked
114
114
// / \param guard: the condition for the check (extended with the (negation of
115
115
// / the) if-condition for recursively calls)
116
- void check_rec_if (const exprt &expr , guardt &guard);
116
+ void check_rec_if (const if_exprt &if_expr , guardt &guard);
117
117
118
118
// / Check that a member expression is valid:
119
119
// / - check the structure this expression is a member of (via pointer of its
@@ -123,13 +123,13 @@ class goto_checkt
123
123
// / - check all operands of the expression
124
124
// / \param expr: the expression to be checked
125
125
// / \param guard: the condition for the check (unmodified here)
126
- void check_rec_member (const exprt &expr , guardt &guard);
126
+ void check_rec_member (const member_exprt &member , guardt &guard);
127
127
128
128
// / Check that a division is valid: check for division by zero, overflow and
129
129
// / NaN (for floating point numbers).
130
130
// / \param expr: the expression to be checked
131
131
// / \param guard: the condition for the check (unmodified here)
132
- void check_rec_div (const exprt &expr , guardt &guard);
132
+ void check_rec_div (const div_exprt &div_expr , guardt &guard);
133
133
134
134
// / Check that an arithmetic operation is valid: overflow check, NaN-check
135
135
// / (for floating point numbers), and pointer overflow check.
@@ -1486,7 +1486,7 @@ void goto_checkt::add_guarded_claim(
1486
1486
// add the guard
1487
1487
exprt guarded_expr =
1488
1488
guard.is_true ()
1489
- ? simplified_expr
1489
+ ? std::move ( simplified_expr)
1490
1490
: implies_exprt{guard.as_expr (), std::move (simplified_expr)};
1491
1491
1492
1492
if (assertions.insert (guarded_expr).second )
@@ -1544,16 +1544,14 @@ void goto_checkt::check_rec_logical_op(const exprt &expr, guardt &guard)
1544
1544
op.pretty ());
1545
1545
1546
1546
check_rec (op, guard);
1547
- guard.add (expr.id () == ID_or ? not_exprt (op) : op);
1547
+ guard.add (expr.id () == ID_or ? boolean_negate (op) : op);
1548
1548
}
1549
1549
1550
1550
guard = std::move (old_guard);
1551
1551
}
1552
1552
1553
- void goto_checkt::check_rec_if (const exprt &expr , guardt &guard)
1553
+ void goto_checkt::check_rec_if (const if_exprt &if_expr , guardt &guard)
1554
1554
{
1555
- const if_exprt &if_expr = to_if_expr (expr);
1556
-
1557
1555
INVARIANT (
1558
1556
if_expr.cond ().is_boolean (),
1559
1557
" first argument of if must be boolean, but got " + if_expr.cond ().pretty ());
@@ -1575,9 +1573,8 @@ void goto_checkt::check_rec_if(const exprt &expr, guardt &guard)
1575
1573
}
1576
1574
}
1577
1575
1578
- void goto_checkt::check_rec_member (const exprt &expr , guardt &guard)
1576
+ void goto_checkt::check_rec_member (const member_exprt &member , guardt &guard)
1579
1577
{
1580
- const member_exprt &member = to_member_expr (expr);
1581
1578
const dereference_exprt &deref = to_dereference_expr (member.struct_op ());
1582
1579
1583
1580
check_rec (deref.pointer (), guard);
@@ -1594,7 +1591,7 @@ void goto_checkt::check_rec_member(const exprt &expr, guardt &guard)
1594
1591
if (member_offset_opt.has_value ())
1595
1592
{
1596
1593
pointer_typet new_pointer_type = to_pointer_type (deref.pointer ().type ());
1597
- new_pointer_type.subtype () = expr .type ();
1594
+ new_pointer_type.subtype () = member .type ();
1598
1595
1599
1596
const exprt char_pointer = typecast_exprt::conditional_cast (
1600
1597
deref.pointer (), pointer_type (char_type ()));
@@ -1613,21 +1610,18 @@ void goto_checkt::check_rec_member(const exprt &expr, guardt &guard)
1613
1610
1614
1611
return ;
1615
1612
}
1616
-
1617
- for (const auto &operand : expr.operands ())
1618
- check_rec (operand, guard);
1619
1613
}
1620
1614
1621
- void goto_checkt::check_rec_div (const exprt &expr , guardt &guard)
1615
+ void goto_checkt::check_rec_div (const div_exprt &div_expr , guardt &guard)
1622
1616
{
1623
- div_by_zero_check (to_div_expr (expr ), guard);
1617
+ div_by_zero_check (to_div_expr (div_expr ), guard);
1624
1618
1625
- if (expr .type ().id () == ID_signedbv)
1626
- integer_overflow_check (expr , guard);
1627
- else if (expr .type ().id () == ID_floatbv)
1619
+ if (div_expr .type ().id () == ID_signedbv)
1620
+ integer_overflow_check (div_expr , guard);
1621
+ else if (div_expr .type ().id () == ID_floatbv)
1628
1622
{
1629
- nan_check (expr , guard);
1630
- float_overflow_check (expr , guard);
1623
+ nan_check (div_expr , guard);
1624
+ float_overflow_check (div_expr , guard);
1631
1625
}
1632
1626
}
1633
1627
@@ -1666,15 +1660,14 @@ void goto_checkt::check_rec(const exprt &expr, guardt &guard)
1666
1660
}
1667
1661
else if (expr.id () == ID_if)
1668
1662
{
1669
- check_rec_if (expr, guard);
1663
+ check_rec_if (to_if_expr ( expr) , guard);
1670
1664
return ;
1671
1665
}
1672
1666
else if (
1673
1667
expr.id () == ID_member &&
1674
1668
to_member_expr (expr).struct_op ().id () == ID_dereference)
1675
1669
{
1676
- check_rec_member (expr, guard);
1677
- return ;
1670
+ check_rec_member (to_member_expr (expr), guard);
1678
1671
}
1679
1672
1680
1673
forall_operands (it, expr)
@@ -1686,7 +1679,7 @@ void goto_checkt::check_rec(const exprt &expr, guardt &guard)
1686
1679
}
1687
1680
else if (expr.id ()==ID_div)
1688
1681
{
1689
- check_rec_div (expr, guard);
1682
+ check_rec_div (to_div_expr ( expr) , guard);
1690
1683
}
1691
1684
else if (expr.id ()==ID_shl || expr.id ()==ID_ashr || expr.id ()==ID_lshr)
1692
1685
{
@@ -1808,15 +1801,10 @@ void goto_checkt::goto_check(
1808
1801
{
1809
1802
if (std::find (i.labels .begin (), i.labels .end (), label)!=i.labels .end ())
1810
1803
{
1811
- goto_program_instruction_typet type=
1812
- enable_assert_to_assume?ASSUME:ASSERT;
1813
-
1814
- goto_programt::targett t = new_code.add (goto_programt::instructiont (
1815
- static_cast <const codet &>(get_nil_irep ()),
1816
- i.source_location ,
1817
- type,
1818
- false_exprt (),
1819
- {}));
1804
+ auto t = new_code.add (
1805
+ enable_assert_to_assume
1806
+ ? goto_programt::make_assumption (false_exprt{}, i.source_location )
1807
+ : goto_programt::make_assertion (false_exprt{}, i.source_location ));
1820
1808
1821
1809
t->source_location .set_property_class (" error label" );
1822
1810
t->source_location .set_comment (" error label " +label);
0 commit comments