@@ -300,10 +300,9 @@ void string_abstractiont::make_decl_and_def(goto_programt &dest,
300300{
301301 const symbolt &symbol=ns.lookup (identifier);
302302 symbol_exprt sym_expr=symbol.symbol_expr ();
303+ code_declt decl{sym_expr, ref_instr->source_location ()};
303304
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 ()));
307306
308307 exprt val=symbol.value ;
309308 // initialize pointers with suitable objects
@@ -316,11 +315,9 @@ void string_abstractiont::make_decl_and_def(goto_programt &dest,
316315 // may still be nil (structs, then assignments have been done already)
317316 if (val.is_not_nil ())
318317 {
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 ()));
324321 }
325322}
326323
@@ -376,11 +373,9 @@ exprt string_abstractiont::make_val_or_dummy_rec(goto_programt &dest,
376373
377374 member_exprt member (symbol.symbol_expr (), it2->get_name (), it2->type ());
378375
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 ()));
384379 }
385380
386381 ++seen;
@@ -423,9 +418,8 @@ symbol_exprt string_abstractiont::add_dummy_symbol_and_value(
423418 symbol_exprt sym_expr=new_symbol.symbol_expr ();
424419
425420 // 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 ()));
429423
430424 // set the value - may be nil
431425 if (
@@ -448,12 +442,10 @@ symbol_exprt string_abstractiont::add_dummy_symbol_and_value(
448442
449443 if (new_symbol.value .is_not_nil ())
450444 {
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 ()));
457449 }
458450
459451 symbol_table.insert (std::move (new_symbol));
@@ -1026,8 +1018,12 @@ void string_abstractiont::build_new_symbol(const symbolt &symbol,
10261018 if (symbol.is_static_lifetime )
10271019 {
10281020 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+ {}});
10311027 make_decl_and_def (initialization, dummy_loc, identifier, symbol.name );
10321028 initialization.instructions .erase (dummy_loc);
10331029 }
@@ -1128,11 +1124,9 @@ goto_programt::targett string_abstractiont::abstract_pointer_assign(
11281124
11291125 if (lhs.type ().id ()==ID_pointer && !unknown)
11301126 {
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 ());
11361130 dest.insert_before_swap (target, assignment);
11371131
11381132 return std::next (target);
@@ -1220,18 +1214,14 @@ goto_programt::targett string_abstractiont::char_assign(
12201214 i1.is_not_nil (),
12211215 " failed to create is_zero-component for the left-hand-side" );
12221216
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 ()));
12271220
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 ()));
12351225
12361226 dest.insert_before_swap (target, tmp);
12371227 ++target;
@@ -1326,32 +1316,23 @@ goto_programt::targett string_abstractiont::value_assignments_string_struct(
13261316 // copy all the values
13271317 goto_programt tmp;
13281318
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 ()));
13551336
13561337 goto_programt::targett last=target;
13571338 ++last;
0 commit comments