@@ -300,10 +300,9 @@ void string_abstractiont::make_decl_and_def(goto_programt &dest,
300
300
{
301
301
const symbolt &symbol=ns.lookup (identifier);
302
302
symbol_exprt sym_expr=symbol.symbol_expr ();
303
+ code_declt decl{sym_expr, ref_instr->source_location ()};
303
304
304
- goto_programt::targett decl1 =
305
- dest.add (goto_programt::make_decl (sym_expr, ref_instr->source_location ()));
306
- decl1->code_nonconst ().add_source_location () = ref_instr->source_location ();
305
+ dest.add (goto_programt::make_decl (decl, ref_instr->source_location ()));
307
306
308
307
exprt val=symbol.value ;
309
308
// initialize pointers with suitable objects
@@ -316,11 +315,9 @@ void string_abstractiont::make_decl_and_def(goto_programt &dest,
316
315
// may still be nil (structs, then assignments have been done already)
317
316
if (val.is_not_nil ())
318
317
{
319
- goto_programt::targett assignment1 =
320
- dest.add (goto_programt::make_assignment (
321
- code_assignt (sym_expr, val), ref_instr->source_location ()));
322
- assignment1->code_nonconst ().add_source_location () =
323
- ref_instr->source_location ();
318
+ code_assignt assignment{sym_expr, val, ref_instr->source_location ()};
319
+ dest.add (
320
+ goto_programt::make_assignment (assignment, ref_instr->source_location ()));
324
321
}
325
322
}
326
323
@@ -376,11 +373,9 @@ exprt string_abstractiont::make_val_or_dummy_rec(goto_programt &dest,
376
373
377
374
member_exprt member (symbol.symbol_expr (), it2->get_name (), it2->type ());
378
375
379
- goto_programt::targett assignment1 =
380
- dest.add (goto_programt::make_assignment (
381
- code_assignt (member, sym_expr), ref_instr->source_location ()));
382
- assignment1->code_nonconst ().add_source_location () =
383
- ref_instr->source_location ();
376
+ code_assignt assignment{member, sym_expr, ref_instr->source_location ()};
377
+ dest.add (goto_programt::make_assignment (
378
+ code_assignt (member, sym_expr), ref_instr->source_location ()));
384
379
}
385
380
386
381
++seen;
@@ -423,9 +418,8 @@ symbol_exprt string_abstractiont::add_dummy_symbol_and_value(
423
418
symbol_exprt sym_expr=new_symbol.symbol_expr ();
424
419
425
420
// make sure it is declared before the recursive call
426
- goto_programt::targett decl =
427
- dest.add (goto_programt::make_decl (sym_expr, ref_instr->source_location ()));
428
- decl->code_nonconst ().add_source_location () = ref_instr->source_location ();
421
+ code_declt decl{sym_expr, ref_instr->source_location ()};
422
+ dest.add (goto_programt::make_decl (decl, ref_instr->source_location ()));
429
423
430
424
// set the value - may be nil
431
425
if (
@@ -448,12 +442,10 @@ symbol_exprt string_abstractiont::add_dummy_symbol_and_value(
448
442
449
443
if (new_symbol.value .is_not_nil ())
450
444
{
451
- goto_programt::targett assignment1 =
452
- dest.add (goto_programt::make_assignment (
453
- code_assignt (sym_expr, new_symbol.value ),
454
- ref_instr->source_location ()));
455
- assignment1->code_nonconst ().add_source_location () =
456
- ref_instr->source_location ();
445
+ code_assignt assignment{
446
+ sym_expr, new_symbol.value , ref_instr->source_location ()};
447
+ dest.add (
448
+ goto_programt::make_assignment (assignment, ref_instr->source_location ()));
457
449
}
458
450
459
451
symbol_table.insert (std::move (new_symbol));
@@ -1026,8 +1018,12 @@ void string_abstractiont::build_new_symbol(const symbolt &symbol,
1026
1018
if (symbol.is_static_lifetime )
1027
1019
{
1028
1020
goto_programt::targett dummy_loc =
1029
- initialization.add (goto_programt::instructiont ());
1030
- dummy_loc->source_location_nonconst () = symbol.location ;
1021
+ initialization.add (goto_programt::instructiont{
1022
+ codet{ID_nil},
1023
+ symbol.location ,
1024
+ goto_program_instruction_typet::NO_INSTRUCTION_TYPE,
1025
+ {},
1026
+ {}});
1031
1027
make_decl_and_def (initialization, dummy_loc, identifier, symbol.name );
1032
1028
initialization.instructions .erase (dummy_loc);
1033
1029
}
@@ -1128,11 +1124,9 @@ goto_programt::targett string_abstractiont::abstract_pointer_assign(
1128
1124
1129
1125
if (lhs.type ().id ()==ID_pointer && !unknown)
1130
1126
{
1131
- goto_programt::instructiont assignment;
1132
- assignment = goto_programt::make_assignment (
1133
- code_assignt (new_lhs, new_rhs), target->source_location ());
1134
- assignment.code_nonconst ().add_source_location () =
1135
- target->source_location ();
1127
+ goto_programt::instructiont assignment = goto_programt::make_assignment (
1128
+ code_assignt (new_lhs, new_rhs, target->source_location ()),
1129
+ target->source_location ());
1136
1130
dest.insert_before_swap (target, assignment);
1137
1131
1138
1132
return std::next (target);
@@ -1220,18 +1214,14 @@ goto_programt::targett string_abstractiont::char_assign(
1220
1214
i1.is_not_nil (),
1221
1215
" failed to create is_zero-component for the left-hand-side" );
1222
1216
1223
- goto_programt::targett assignment1 = tmp.add (goto_programt::make_assignment (
1224
- code_assignt (i1, from_integer (1 , i1.type ())), target->source_location ()));
1225
- assignment1->code_nonconst ().add_source_location () =
1226
- target->source_location ();
1217
+ tmp.add (goto_programt::make_assignment (
1218
+ code_assignt (i1, from_integer (1 , i1.type ()), target->source_location ()),
1219
+ target->source_location ()));
1227
1220
1228
- goto_programt::targett assignment2 = tmp.add (goto_programt::make_assignment (
1229
- code_assignt (lhs, rhs), target->source_location ()));
1230
- assignment2->code_nonconst ().add_source_location () =
1231
- target->source_location ();
1232
-
1233
- move_lhs_arithmetic (
1234
- assignment2->code_nonconst ().op0 (), assignment2->code_nonconst ().op1 ());
1221
+ code_assignt assignment{lhs, rhs, target->source_location ()};
1222
+ move_lhs_arithmetic (assignment.lhs (), assignment.rhs ());
1223
+ tmp.add (
1224
+ goto_programt::make_assignment (assignment, target->source_location ()));
1235
1225
1236
1226
dest.insert_before_swap (target, tmp);
1237
1227
++target;
@@ -1326,32 +1316,23 @@ goto_programt::targett string_abstractiont::value_assignments_string_struct(
1326
1316
// copy all the values
1327
1317
goto_programt tmp;
1328
1318
1329
- {
1330
- goto_programt::targett assignment = tmp.add (goto_programt::make_assignment (
1331
- member (lhs, whatt::IS_ZERO),
1332
- member (rhs, whatt::IS_ZERO),
1333
- target->source_location ()));
1334
- assignment->code_nonconst ().add_source_location () =
1335
- target->source_location ();
1336
- }
1337
-
1338
- {
1339
- goto_programt::targett assignment = tmp.add (goto_programt::make_assignment (
1340
- member (lhs, whatt::LENGTH),
1341
- member (rhs, whatt::LENGTH),
1342
- target->source_location ()));
1343
- assignment->code_nonconst ().add_source_location () =
1344
- target->source_location ();
1345
- }
1346
-
1347
- {
1348
- goto_programt::targett assignment = tmp.add (goto_programt::make_assignment (
1349
- member (lhs, whatt::SIZE),
1350
- member (rhs, whatt::SIZE),
1351
- target->source_location ()));
1352
- assignment->code_nonconst ().add_source_location () =
1353
- target->source_location ();
1354
- }
1319
+ tmp.add (goto_programt::make_assignment (
1320
+ code_assignt{member (lhs, whatt::IS_ZERO),
1321
+ member (rhs, whatt::IS_ZERO),
1322
+ target->source_location ()},
1323
+ target->source_location ()));
1324
+
1325
+ tmp.add (goto_programt::make_assignment (
1326
+ code_assignt{member (lhs, whatt::LENGTH),
1327
+ member (rhs, whatt::LENGTH),
1328
+ target->source_location ()},
1329
+ target->source_location ()));
1330
+
1331
+ tmp.add (goto_programt::make_assignment (
1332
+ code_assignt{member (lhs, whatt::SIZE),
1333
+ member (rhs, whatt::SIZE),
1334
+ target->source_location ()},
1335
+ target->source_location ()));
1355
1336
1356
1337
goto_programt::targett last=target;
1357
1338
++last;
0 commit comments