@@ -69,36 +69,37 @@ void goto_symext::symex_allocate(
69
69
}
70
70
else
71
71
{
72
- exprt tmp_size=size;
73
- state.rename_level2 (tmp_size , ns); // to allow constant propagation
74
- simplify (tmp_size, ns);
72
+ // to allow constant propagation
73
+ level2t<exprt> tmp_size = state.rename_level2 (size , ns);
74
+ simplify (tmp_size. expr , ns);
75
75
76
76
// special treatment for sizeof(T)*x
77
77
{
78
- const auto tmp_type = c_sizeof_type_rec (tmp_size);
78
+ const auto tmp_type = c_sizeof_type_rec (tmp_size. expr );
79
79
80
80
if (tmp_type.has_value ())
81
81
{
82
82
// Did the size get multiplied?
83
83
auto elem_size = pointer_offset_size (*tmp_type, ns);
84
- const auto alloc_size = numeric_cast<mp_integer>(tmp_size);
84
+ const auto alloc_size = numeric_cast<mp_integer>(tmp_size. expr );
85
85
86
86
if (!elem_size.has_value () || *elem_size==0 )
87
87
{
88
88
}
89
89
else if (
90
- !alloc_size.has_value () && tmp_size.id () == ID_mult &&
91
- tmp_size.operands ().size () == 2 &&
92
- (tmp_size.op0 ().is_constant () || tmp_size.op1 ().is_constant ()))
90
+ !alloc_size.has_value () && tmp_size.expr .id () == ID_mult &&
91
+ tmp_size.expr .operands ().size () == 2 &&
92
+ (tmp_size.expr .op0 ().is_constant () ||
93
+ tmp_size.expr .op1 ().is_constant ()))
93
94
{
94
- exprt s= tmp_size.op0 ();
95
+ exprt s = tmp_size. expr .op0 ();
95
96
if (s.is_constant ())
96
97
{
97
- s= tmp_size.op1 ();
98
- PRECONDITION (*c_sizeof_type_rec (tmp_size.op0 ()) == *tmp_type);
98
+ s = tmp_size. expr .op1 ();
99
+ PRECONDITION (*c_sizeof_type_rec (tmp_size.expr . op0 ()) == *tmp_type);
99
100
}
100
101
else
101
- PRECONDITION (*c_sizeof_type_rec (tmp_size.op1 ()) == *tmp_type);
102
+ PRECONDITION (*c_sizeof_type_rec (tmp_size.expr . op1 ()) == *tmp_type);
102
103
103
104
object_type = array_typet (*tmp_type, s);
104
105
}
@@ -111,15 +112,15 @@ void goto_symext::symex_allocate(
111
112
mp_integer elements = *alloc_size / (*elem_size);
112
113
113
114
if (elements * (*elem_size) == *alloc_size)
114
- object_type =
115
- array_typet ( *tmp_type, from_integer (elements, tmp_size.type ()));
115
+ object_type = array_typet (
116
+ *tmp_type, from_integer (elements, tmp_size. expr .type ()));
116
117
}
117
118
}
118
119
}
119
120
}
120
121
121
122
if (!object_type.has_value ())
122
- object_type= array_typet (unsigned_char_type (), tmp_size);
123
+ object_type = array_typet (unsigned_char_type (), tmp_size. expr );
123
124
124
125
// we introduce a fresh symbol for the size
125
126
// to prevent any issues of the size getting ever changed
@@ -135,7 +136,7 @@ void goto_symext::symex_allocate(
135
136
size_symbol.base_name =
136
137
" dynamic_object_size" +std::to_string (dynamic_counter);
137
138
size_symbol.name =" symex_dynamic::" +id2string (size_symbol.base_name );
138
- size_symbol.type = tmp_size.type ();
139
+ size_symbol.type = tmp_size. expr .type ();
139
140
size_symbol.mode = mode;
140
141
size_symbol.type .set (ID_C_constant, true );
141
142
size_symbol.value = array_size;
@@ -161,14 +162,15 @@ void goto_symext::symex_allocate(
161
162
162
163
state.symbol_table .add (value_symbol);
163
164
164
- exprt zero_init=code. op1 ();
165
- state.rename_level2 (zero_init , ns); // to allow constant propagation
166
- simplify (zero_init, ns);
165
+ // to allow constant propagation
166
+ level2t<exprt> zero_init = state.rename_level2 (code. op1 () , ns);
167
+ simplify (zero_init. expr , ns);
167
168
168
169
INVARIANT (
169
- zero_init.is_constant (), " allocate expects constant as second argument" );
170
+ zero_init.expr .is_constant (),
171
+ " allocate expects constant as second argument" );
170
172
171
- if (!zero_init.is_zero () && !zero_init.is_false ())
173
+ if (!zero_init.expr . is_zero () && !zero_init. expr .is_false ())
172
174
{
173
175
const auto zero_value =
174
176
zero_initializer (*object_type, code.source_location (), ns);
@@ -231,10 +233,10 @@ void goto_symext::symex_gcc_builtin_va_arg_next(
231
233
if (lhs.is_nil ())
232
234
return ; // ignore
233
235
234
- exprt tmp=code. op0 ();
235
- state.rename_level2 (tmp , ns); // to allow constant propagation
236
- do_simplify (tmp);
237
- irep_idt id= get_symbol (tmp);
236
+ // to allow constant propagation
237
+ level2t<exprt> tmp = state.rename_level2 (code. op0 () , ns);
238
+ do_simplify (tmp. expr );
239
+ irep_idt id = get_symbol (tmp. expr );
238
240
239
241
const auto zero = zero_initializer (lhs.type (), code.source_location (), ns);
240
242
CHECK_RETURN (zero.has_value ());
@@ -309,11 +311,10 @@ void goto_symext::symex_printf(
309
311
{
310
312
PRECONDITION (!rhs.operands ().empty ());
311
313
312
- exprt tmp_rhs=rhs;
313
- state.rename_level2 (tmp_rhs, ns);
314
- do_simplify (tmp_rhs);
314
+ level2t<exprt> tmp_rhs = state.rename_level2 (rhs, ns);
315
+ do_simplify (tmp_rhs.expr );
315
316
316
- const exprt::operandst &operands= tmp_rhs.operands ();
317
+ const exprt::operandst &operands = tmp_rhs. expr .operands ();
317
318
std::list<exprt> args;
318
319
319
320
for (std::size_t i=1 ; i<operands.size (); i++)
@@ -334,20 +335,19 @@ void goto_symext::symex_input(
334
335
{
335
336
PRECONDITION (code.operands ().size () >= 2 );
336
337
337
- exprt id_arg=code.op0 ();
338
-
339
- state.rename_level2 (id_arg, ns);
338
+ level2t<exprt> id_arg = state.rename_level2 (code.op0 (), ns);
340
339
341
340
std::list<exprt> args;
342
341
343
342
for (std::size_t i=1 ; i<code.operands ().size (); i++)
344
343
{
345
344
args.push_back (code.operands ()[i]);
346
- state.rename_level2 (args.back (), ns);
347
- do_simplify (args.back ());
345
+ level2t<exprt> l2_arg = state.rename_level2 (args.back (), ns);
346
+ do_simplify (l2_arg.expr );
347
+ args.back () = std::move (l2_arg.expr );
348
348
}
349
349
350
- const irep_idt input_id= get_string_argument (id_arg, ns);
350
+ const irep_idt input_id = get_string_argument (id_arg. expr , ns);
351
351
352
352
target.input (state.guard .as_expr (), state.source , input_id, args);
353
353
}
@@ -357,21 +357,19 @@ void goto_symext::symex_output(
357
357
const codet &code)
358
358
{
359
359
PRECONDITION (code.operands ().size () >= 2 );
360
-
361
- exprt id_arg=code.op0 ();
362
-
363
- state.rename_level2 (id_arg, ns);
360
+ level2t<exprt> id_arg = state.rename_level2 (code.op0 (), ns);
364
361
365
362
std::list<exprt> args;
366
363
367
364
for (std::size_t i=1 ; i<code.operands ().size (); i++)
368
365
{
369
366
args.push_back (code.operands ()[i]);
370
- state.rename_level2 (args.back (), ns);
371
- do_simplify (args.back ());
367
+ level2t<exprt> l2_arg = state.rename_level2 (args.back (), ns);
368
+ do_simplify (l2_arg.expr );
369
+ args.back () = std::move (l2_arg.expr );
372
370
}
373
371
374
- const irep_idt output_id= get_string_argument (id_arg, ns);
372
+ const irep_idt output_id = get_string_argument (id_arg. expr , ns);
375
373
376
374
target.output (state.guard .as_expr (), state.source , output_id, args);
377
375
}
@@ -480,9 +478,8 @@ void goto_symext::symex_trace(
480
478
481
479
for (std::size_t j=2 ; j<code.arguments ().size (); j++)
482
480
{
483
- exprt var (code.arguments ()[j]);
484
- state.rename_level2 (var, ns);
485
- vars.push_back (var);
481
+ level2t<exprt> var = state.rename_level2 (code.arguments ()[j], ns);
482
+ vars.push_back (var.expr );
486
483
}
487
484
488
485
target.output (state.guard .as_expr (), state.source , event, vars);
0 commit comments