@@ -531,9 +531,7 @@ void goto_convertt::convert(
531
531
// make sure dest is never empty
532
532
if (dest.instructions .empty ())
533
533
{
534
- dest.add_instruction (SKIP);
535
- dest.instructions .back ().code .make_nil ();
536
- dest.instructions .back ().source_location =code.source_location ();
534
+ dest.add (goto_programt::make_skip (code.source_location ()));
537
535
}
538
536
}
539
537
@@ -1033,9 +1031,8 @@ void goto_convertt::convert_while(
1033
1031
1034
1032
// do the z label
1035
1033
goto_programt tmp_z;
1036
- goto_programt::targett z=tmp_z.add_instruction ();
1037
- z->make_skip ();
1038
- z->source_location =source_location;
1034
+ goto_programt::targett z =
1035
+ tmp_z.add (goto_programt::make_skip (source_location));
1039
1036
1040
1037
goto_programt tmp_branch;
1041
1038
generate_conditional_branch (
@@ -1107,9 +1104,8 @@ void goto_convertt::convert_dowhile(
1107
1104
1108
1105
// do the z label
1109
1106
goto_programt tmp_z;
1110
- goto_programt::targett z=tmp_z.add_instruction ();
1111
- z->make_skip ();
1112
- z->source_location =code.source_location ();
1107
+ goto_programt::targett z =
1108
+ tmp_z.add (goto_programt::make_skip (code.source_location ()));
1113
1109
1114
1110
// do the x label
1115
1111
goto_programt::targett x;
@@ -1187,8 +1183,7 @@ void goto_convertt::convert_switch(
1187
1183
1188
1184
// we first add a 'location' node for the switch statement,
1189
1185
// which would otherwise not be recorded
1190
- dest.add_instruction ()->make_location (
1191
- code.source_location ());
1186
+ dest.add (goto_programt::make_location (code.source_location ()));
1192
1187
1193
1188
// get the location of the end of the body, but
1194
1189
// default to location of switch, if none
@@ -1208,9 +1203,8 @@ void goto_convertt::convert_switch(
1208
1203
1209
1204
// do the z label
1210
1205
goto_programt tmp_z;
1211
- goto_programt::targett z=tmp_z.add_instruction ();
1212
- z->make_skip ();
1213
- z->source_location =body_end_location;
1206
+ goto_programt::targett z =
1207
+ tmp_z.add (goto_programt::make_skip (body_end_location));
1214
1208
1215
1209
// set the new targets -- continue stays as is
1216
1210
targets.set_break (z);
@@ -1250,17 +1244,12 @@ void goto_convertt::convert_switch(
1250
1244
case_number++;
1251
1245
guard_expr.add_source_location ()=source_location;
1252
1246
1253
- goto_programt::targett x=tmp_cases.add_instruction ();
1254
- x->make_goto (case_pair.first );
1255
- x->guard .swap (guard_expr);
1256
- x->source_location =source_location;
1247
+ tmp_cases.add (goto_programt::make_goto (
1248
+ case_pair.first , std::move (guard_expr), source_location));
1257
1249
}
1258
1250
1259
- {
1260
- goto_programt::targett d_jump=tmp_cases.add_instruction ();
1261
- d_jump->make_goto (targets.default_target );
1262
- d_jump->source_location =targets.default_target ->source_location ;
1263
- }
1251
+ tmp_cases.add (goto_programt::make_goto (
1252
+ targets.default_target , targets.default_target ->source_location ));
1264
1253
1265
1254
dest.destructive_append (sideeffects);
1266
1255
dest.destructive_append (tmp_cases);
@@ -1284,9 +1273,8 @@ void goto_convertt::convert_break(
1284
1273
code.source_location (), targets.break_stack_size , dest, mode);
1285
1274
1286
1275
// add goto
1287
- goto_programt::targett t=dest.add_instruction ();
1288
- t->make_goto (targets.break_target );
1289
- t->source_location =code.source_location ();
1276
+ dest.add (
1277
+ goto_programt::make_goto (targets.break_target , code.source_location ()));
1290
1278
}
1291
1279
1292
1280
void goto_convertt::convert_return (
@@ -1329,10 +1317,7 @@ void goto_convertt::convert_return(
1329
1317
new_code.find_source_location ());
1330
1318
1331
1319
// Now add a return node to set the return value.
1332
- goto_programt::targett t=dest.add_instruction ();
1333
- t->make_return ();
1334
- t->code =new_code;
1335
- t->source_location =new_code.source_location ();
1320
+ dest.add (goto_programt::make_return (new_code, new_code.source_location ()));
1336
1321
}
1337
1322
else
1338
1323
{
@@ -1347,9 +1332,8 @@ void goto_convertt::convert_return(
1347
1332
unwind_destructor_stack (code.source_location (), 0 , dest, mode);
1348
1333
1349
1334
// add goto to end-of-function
1350
- goto_programt::targett t=dest.add_instruction ();
1351
- t->make_goto (targets.return_target , true_exprt ());
1352
- t->source_location =new_code.source_location ();
1335
+ dest.add (goto_programt::make_goto (
1336
+ targets.return_target , new_code.source_location ()));
1353
1337
}
1354
1338
1355
1339
void goto_convertt::convert_continue (
@@ -1367,9 +1351,8 @@ void goto_convertt::convert_continue(
1367
1351
code.source_location (), targets.continue_stack_size , dest, mode);
1368
1352
1369
1353
// add goto
1370
- goto_programt::targett t=dest.add_instruction ();
1371
- t->make_goto (targets.continue_target );
1372
- t->source_location =code.source_location ();
1354
+ dest.add (
1355
+ goto_programt::make_goto (targets.continue_target , code.source_location ()));
1373
1356
}
1374
1357
1375
1358
void goto_convertt::convert_goto (const code_gotot &code, goto_programt &dest)
@@ -1529,11 +1512,8 @@ void goto_convertt::generate_ifthenelse(
1529
1512
{
1530
1513
// hmpf. Useless branch.
1531
1514
goto_programt tmp_z;
1532
- goto_programt::targett z=tmp_z.add_instruction ();
1533
- z->make_skip ();
1534
- goto_programt::targett v=dest.add_instruction ();
1535
- v->make_goto (z, guard);
1536
- v->source_location =source_location;
1515
+ goto_programt::targett z = tmp_z.add (goto_programt::make_skip ());
1516
+ dest.add (goto_programt::make_goto (z, guard, source_location));
1537
1517
dest.destructive_append (tmp_z);
1538
1518
return ;
1539
1519
}
@@ -1706,12 +1686,7 @@ void goto_convertt::generate_conditional_branch(
1706
1686
exprt cond=guard;
1707
1687
clean_expr (cond, dest, mode);
1708
1688
1709
- goto_programt tmp;
1710
- goto_programt::targett g=tmp.add_instruction ();
1711
- g->make_goto (target_true);
1712
- g->guard =cond;
1713
- g->source_location =source_location;
1714
- dest.destructive_append (tmp);
1689
+ dest.add (goto_programt::make_goto (target_true, cond, source_location));
1715
1690
}
1716
1691
}
1717
1692
@@ -1753,10 +1728,7 @@ void goto_convertt::generate_conditional_branch(
1753
1728
generate_conditional_branch (
1754
1729
boolean_negate (expr), target_false, source_location, dest, mode);
1755
1730
1756
- goto_programt::targett t_true=dest.add_instruction ();
1757
- t_true->make_goto (target_true);
1758
- t_true->guard =true_exprt ();
1759
- t_true->source_location =source_location;
1731
+ dest.add (goto_programt::make_goto (target_true, source_location));
1760
1732
1761
1733
return ;
1762
1734
}
@@ -1772,30 +1744,25 @@ void goto_convertt::generate_conditional_branch(
1772
1744
std::list<exprt> op;
1773
1745
collect_operands (guard, guard.id (), op);
1774
1746
1747
+ // true branch(es)
1775
1748
for (const auto &expr : op)
1776
1749
generate_conditional_branch (
1777
1750
expr, target_true, source_location, dest, mode);
1778
1751
1779
- goto_programt::targett t_false=dest.add_instruction ();
1780
- t_false->make_goto (target_false);
1781
- t_false->guard =true_exprt ();
1782
- t_false->source_location =guard.source_location ();
1752
+ // false branch
1753
+ dest.add (goto_programt::make_goto (target_false, guard.source_location ()));
1783
1754
1784
1755
return ;
1785
1756
}
1786
1757
1787
1758
exprt cond=guard;
1788
1759
clean_expr (cond, dest, mode);
1789
1760
1790
- goto_programt::targett t_true=dest.add_instruction ();
1791
- t_true->make_goto (target_true);
1792
- t_true->guard =cond;
1793
- t_true->source_location =source_location;
1761
+ // true branch
1762
+ dest.add (goto_programt::make_goto (target_true, cond, source_location));
1794
1763
1795
- goto_programt::targett t_false=dest.add_instruction ();
1796
- t_false->make_goto (target_false);
1797
- t_false->guard =true_exprt ();
1798
- t_false->source_location =source_location;
1764
+ // false branch
1765
+ dest.add (goto_programt::make_goto (target_false, source_location));
1799
1766
}
1800
1767
1801
1768
bool goto_convertt::get_string_constant (
@@ -1994,9 +1961,7 @@ void goto_convertt::generate_thread_block(
1994
1961
goto_programt::targett a=preamble.add_instruction (START_THREAD);
1995
1962
a->source_location =thread_body.source_location ();
1996
1963
a->targets .push_back (c);
1997
- goto_programt::targett b=preamble.add_instruction ();
1998
- b->source_location =thread_body.source_location ();
1999
- b->make_goto (z);
1964
+ preamble.add (goto_programt::make_goto (z, thread_body.source_location ()));
2000
1965
2001
1966
dest.destructive_append (preamble);
2002
1967
dest.destructive_append (body);
0 commit comments