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