@@ -32,32 +32,33 @@ void pointer_arithmetict::read(const exprt &src)
32
32
}
33
33
else if (src.id ()==ID_minus)
34
34
{
35
- assert (src.operands ().size ()==2 );
36
- read (src.op0 ());
37
- const unary_minus_exprt o (src.op1 (), src.op1 ().type ());
38
- add_to_offset (o);
35
+ auto const &minus_src = to_minus_expr (src);
36
+ read (minus_src.op0 ());
37
+ const unary_minus_exprt unary_minus (
38
+ minus_src.op1 (), minus_src.op1 ().type ());
39
+ add_to_offset (unary_minus);
39
40
}
40
41
else if (src.id ()==ID_address_of)
41
42
{
42
- assert (src. operands (). size ()== 1 );
43
- if (src. op0 ().id ()== ID_index)
43
+ auto const &address_of_src = to_address_of_expr (src);
44
+ if (address_of_src. op ().id () == ID_index)
44
45
{
45
- const index_exprt &index_expr=
46
- to_index_expr (src.op0 ());
46
+ const index_exprt &index_expr = to_index_expr (address_of_src.op ());
47
47
48
48
if (index_expr.index ().is_zero ())
49
- make_pointer (src );
49
+ make_pointer (address_of_src );
50
50
else
51
51
{
52
52
add_to_offset (index_expr.index ());
53
53
// produce &x[0] + i instead of &x[i]
54
- exprt new_src=src;
55
- new_src.op0 ().op1 ()=from_integer (0 , index_expr.index ().type ());
56
- make_pointer (new_src);
54
+ auto new_address_of_src = address_of_src;
55
+ new_address_of_src.op ().op1 () =
56
+ from_integer (0 , index_expr.index ().type ());
57
+ make_pointer (new_address_of_src);
57
58
}
58
59
}
59
60
else
60
- make_pointer (src );
61
+ make_pointer (address_of_src );
61
62
}
62
63
else
63
64
make_pointer (src);
0 commit comments