@@ -111,26 +111,26 @@ class goto_checkt
111
111
// / Check an if expression: check the if-condition alone, and then check the
112
112
// / true/false-cases with the guard extended with if-condition and it's
113
113
// / negation, respectively.
114
- // / \param expr : the expression to be checked
114
+ // / \param if_expr : the expression to be checked
115
115
// / \param guard: the condition for the check (extended with the (negation of
116
116
// / the) if-condition for recursively calls)
117
- void check_rec_if (const exprt &expr , guardt &guard);
117
+ void check_rec_if (const if_exprt &if_expr , guardt &guard);
118
118
119
119
// / Check that a member expression is valid:
120
120
// / - check the structure this expression is a member of (via pointer of its
121
121
// / dereference)
122
122
// / - run pointer-validity check on `*(s+member_offset)' instead of
123
123
// / `s->member' to avoid checking safety of `s'
124
124
// / - check all operands of the expression
125
- // / \param expr : the expression to be checked
125
+ // / \param member : the expression to be checked
126
126
// / \param guard: the condition for the check (unmodified here)
127
- void check_rec_member (const exprt &expr , guardt &guard);
127
+ void check_rec_member (const member_exprt &member , guardt &guard);
128
128
129
129
// / Check that a division is valid: check for division by zero, overflow and
130
130
// / NaN (for floating point numbers).
131
- // / \param expr : the expression to be checked
131
+ // / \param div_expr : the expression to be checked
132
132
// / \param guard: the condition for the check (unmodified here)
133
- void check_rec_div (const exprt &expr , guardt &guard);
133
+ void check_rec_div (const div_exprt &div_expr , guardt &guard);
134
134
135
135
// / Check that an arithmetic operation is valid: overflow check, NaN-check
136
136
// / (for floating point numbers), and pointer overflow check.
@@ -1487,7 +1487,7 @@ void goto_checkt::add_guarded_claim(
1487
1487
// add the guard
1488
1488
exprt guarded_expr =
1489
1489
guard.is_true ()
1490
- ? simplified_expr
1490
+ ? std::move ( simplified_expr)
1491
1491
: implies_exprt{guard.as_expr (), std::move (simplified_expr)};
1492
1492
1493
1493
if (assertions.insert (guarded_expr).second )
@@ -1545,16 +1545,14 @@ void goto_checkt::check_rec_logical_op(const exprt &expr, guardt &guard)
1545
1545
op.pretty ());
1546
1546
1547
1547
check_rec (op, guard);
1548
- guard.add (expr.id () == ID_or ? not_exprt (op) : op);
1548
+ guard.add (expr.id () == ID_or ? boolean_negate (op) : op);
1549
1549
}
1550
1550
1551
1551
guard = std::move (old_guard);
1552
1552
}
1553
1553
1554
- void goto_checkt::check_rec_if (const exprt &expr , guardt &guard)
1554
+ void goto_checkt::check_rec_if (const if_exprt &if_expr , guardt &guard)
1555
1555
{
1556
- const if_exprt &if_expr = to_if_expr (expr);
1557
-
1558
1556
INVARIANT (
1559
1557
if_expr.cond ().is_boolean (),
1560
1558
" first argument of if must be boolean, but got " + if_expr.cond ().pretty ());
@@ -1576,9 +1574,8 @@ void goto_checkt::check_rec_if(const exprt &expr, guardt &guard)
1576
1574
}
1577
1575
}
1578
1576
1579
- void goto_checkt::check_rec_member (const exprt &expr , guardt &guard)
1577
+ void goto_checkt::check_rec_member (const member_exprt &member , guardt &guard)
1580
1578
{
1581
- const member_exprt &member = to_member_expr (expr);
1582
1579
const dereference_exprt &deref = to_dereference_expr (member.struct_op ());
1583
1580
1584
1581
check_rec (deref.pointer (), guard);
@@ -1595,7 +1592,7 @@ void goto_checkt::check_rec_member(const exprt &expr, guardt &guard)
1595
1592
if (member_offset_opt.has_value ())
1596
1593
{
1597
1594
pointer_typet new_pointer_type = to_pointer_type (deref.pointer ().type ());
1598
- new_pointer_type.subtype () = expr .type ();
1595
+ new_pointer_type.subtype () = member .type ();
1599
1596
1600
1597
const exprt char_pointer = typecast_exprt::conditional_cast (
1601
1598
deref.pointer (), pointer_type (char_type ()));
@@ -1615,20 +1612,20 @@ void goto_checkt::check_rec_member(const exprt &expr, guardt &guard)
1615
1612
return ;
1616
1613
}
1617
1614
1618
- for (const auto &operand : expr .operands ())
1615
+ for (const auto &operand : member .operands ())
1619
1616
check_rec (operand, guard);
1620
1617
}
1621
1618
1622
- void goto_checkt::check_rec_div (const exprt &expr , guardt &guard)
1619
+ void goto_checkt::check_rec_div (const div_exprt &div_expr , guardt &guard)
1623
1620
{
1624
- div_by_zero_check (to_div_expr (expr ), guard);
1621
+ div_by_zero_check (to_div_expr (div_expr ), guard);
1625
1622
1626
- if (expr .type ().id () == ID_signedbv)
1627
- integer_overflow_check (expr , guard);
1628
- else if (expr .type ().id () == ID_floatbv)
1623
+ if (div_expr .type ().id () == ID_signedbv)
1624
+ integer_overflow_check (div_expr , guard);
1625
+ else if (div_expr .type ().id () == ID_floatbv)
1629
1626
{
1630
- nan_check (expr , guard);
1631
- float_overflow_check (expr , guard);
1627
+ nan_check (div_expr , guard);
1628
+ float_overflow_check (div_expr , guard);
1632
1629
}
1633
1630
}
1634
1631
@@ -1667,14 +1664,14 @@ void goto_checkt::check_rec(const exprt &expr, guardt &guard)
1667
1664
}
1668
1665
else if (expr.id () == ID_if)
1669
1666
{
1670
- check_rec_if (expr, guard);
1667
+ check_rec_if (to_if_expr ( expr) , guard);
1671
1668
return ;
1672
1669
}
1673
1670
else if (
1674
1671
expr.id () == ID_member &&
1675
1672
to_member_expr (expr).struct_op ().id () == ID_dereference)
1676
1673
{
1677
- check_rec_member (expr, guard);
1674
+ check_rec_member (to_member_expr ( expr) , guard);
1678
1675
return ;
1679
1676
}
1680
1677
@@ -1687,7 +1684,7 @@ void goto_checkt::check_rec(const exprt &expr, guardt &guard)
1687
1684
}
1688
1685
else if (expr.id ()==ID_div)
1689
1686
{
1690
- check_rec_div (expr, guard);
1687
+ check_rec_div (to_div_expr ( expr) , guard);
1691
1688
}
1692
1689
else if (expr.id ()==ID_shl || expr.id ()==ID_ashr || expr.id ()==ID_lshr)
1693
1690
{
@@ -1867,15 +1864,10 @@ void goto_checkt::goto_check(
1867
1864
{
1868
1865
if (std::find (i.labels .begin (), i.labels .end (), label)!=i.labels .end ())
1869
1866
{
1870
- goto_program_instruction_typet type=
1871
- enable_assert_to_assume?ASSUME:ASSERT;
1872
-
1873
- goto_programt::targett t = new_code.add (goto_programt::instructiont (
1874
- static_cast <const codet &>(get_nil_irep ()),
1875
- i.source_location ,
1876
- type,
1877
- false_exprt (),
1878
- {}));
1867
+ auto t = new_code.add (
1868
+ enable_assert_to_assume
1869
+ ? goto_programt::make_assumption (false_exprt{}, i.source_location )
1870
+ : goto_programt::make_assertion (false_exprt{}, i.source_location ));
1879
1871
1880
1872
t->source_location .set_property_class (" error label" );
1881
1873
t->source_location .set_comment (" error label " +label);
0 commit comments