Skip to content

Commit 5520e05

Browse files
author
Daniel Kroening
committed
use goto_programt::make_X
This avoids incomplete construction.
1 parent 2622fbb commit 5520e05

File tree

7 files changed

+95
-145
lines changed

7 files changed

+95
-145
lines changed

src/assembler/remove_asm.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ void remove_asmt::process_instruction_gcc(
266266

267267
if(x86_32_locked_atomic)
268268
{
269-
goto_programt::targett ab = tmp_dest.add_instruction(ATOMIC_BEGIN);
270-
ab->source_location = code.source_location();
269+
tmp_dest.add(goto_programt::make_atomic_begin(code.source_location()));
271270

272271
codet code_fence(ID_fence);
273272
code_fence.add_source_location() = code.source_location();
@@ -360,8 +359,7 @@ void remove_asmt::process_instruction_gcc(
360359

361360
if(x86_32_locked_atomic)
362361
{
363-
goto_programt::targett ae = tmp_dest.add_instruction(ATOMIC_END);
364-
ae->source_location = code.source_location();
362+
tmp_dest.add(goto_programt::make_atomic_end(code.source_location()));
365363

366364
x86_32_locked_atomic = false;
367365
}
@@ -437,8 +435,7 @@ void remove_asmt::process_instruction_msc(
437435

438436
if(x86_32_locked_atomic)
439437
{
440-
goto_programt::targett ab = tmp_dest.add_instruction(ATOMIC_BEGIN);
441-
ab->source_location = code.source_location();
438+
tmp_dest.add(goto_programt::make_atomic_begin(code.source_location()));
442439

443440
codet code_fence(ID_fence);
444441
code_fence.add_source_location() = code.source_location();
@@ -465,8 +462,7 @@ void remove_asmt::process_instruction_msc(
465462

466463
if(x86_32_locked_atomic)
467464
{
468-
goto_programt::targett ae = tmp_dest.add_instruction(ATOMIC_END);
469-
ae->source_location = code.source_location();
465+
tmp_dest.add(goto_programt::make_atomic_end(code.source_location()));
470466

471467
x86_32_locked_atomic = false;
472468
}

src/goto-instrument/accelerate/polynomial_accelerator.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ bool polynomial_acceleratort::accelerate(
235235
// assume(guard);
236236
// assume(no overflows in previous code);
237237

238-
program.add_instruction(ASSUME)->guard=guard;
238+
program.add(goto_programt::make_assumption(guard));
239239

240240
program.assign(
241241
loop_counter,
@@ -261,7 +261,7 @@ bool polynomial_acceleratort::accelerate(
261261
return false;
262262
}
263263

264-
program.add_instruction(ASSUME)->guard=guard_last;
264+
program.add(goto_programt::make_assumption(guard_last));
265265
program.fix_types();
266266

267267
if(path_is_monotone)
@@ -406,9 +406,7 @@ bool polynomial_acceleratort::fit_polynomial_sliced(
406406
#endif
407407

408408
// Now do an ASSERT(false) to grab a counterexample
409-
goto_programt::targett assertion=program.add_instruction(ASSERT);
410-
assertion->guard=false_exprt();
411-
409+
program.add(goto_programt::make_assertion(false_exprt()));
412410

413411
// If the path is satisfiable, we've fitted a polynomial. Extract the
414412
// relevant coefficients and return the expression.
@@ -600,7 +598,7 @@ void polynomial_acceleratort::assert_for_values(
600598
exprt overflow_expr;
601599
overflow.overflow_expr(rhs, overflow_expr);
602600

603-
program.add_instruction(ASSUME)->guard=not_exprt(overflow_expr);
601+
program.add(goto_programt::make_assumption(not_exprt(overflow_expr)));
604602

605603
rhs=typecast_exprt(rhs, target.type());
606604

@@ -609,8 +607,7 @@ void polynomial_acceleratort::assert_for_values(
609607
const equal_exprt polynomial_holds(target, rhs);
610608

611609
// Finally, assert that the polynomial equals the variable we're fitting.
612-
goto_programt::targett assumption=program.add_instruction(ASSUME);
613-
assumption->guard=polynomial_holds;
610+
program.add(goto_programt::make_assumption(polynomial_holds));
614611
}
615612

616613
void polynomial_acceleratort::cone_of_influence(
@@ -680,24 +677,23 @@ bool polynomial_acceleratort::check_inductive(
680677
++it)
681678
{
682679
const equal_exprt holds(it->first, it->second.to_expr());
683-
program.add_instruction(ASSUME)->guard=holds;
680+
program.add(goto_programt::make_assumption(holds));
684681

685682
polynomials_hold.push_back(holds);
686683
}
687684

688685
program.append(body);
689686

690-
codet inc_loop_counter=
691-
code_assignt(
692-
loop_counter,
693-
plus_exprt(loop_counter, from_integer(1, loop_counter.type())));
694-
program.add_instruction(ASSIGN)->code=inc_loop_counter;
687+
auto inc_loop_counter = code_assignt(
688+
loop_counter,
689+
plus_exprt(loop_counter, from_integer(1, loop_counter.type())));
690+
program.add(goto_programt::make_assignment(inc_loop_counter));
695691

696692
for(std::vector<exprt>::iterator it=polynomials_hold.begin();
697693
it!=polynomials_hold.end();
698694
++it)
699695
{
700-
program.add_instruction(ASSERT)->guard=*it;
696+
program.add(goto_programt::make_assertion(*it));
701697
}
702698

703699
#ifdef DEBUG

src/goto-instrument/accelerate/sat_path_enumerator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ bool sat_path_enumeratort::next(patht &path)
7979
program.assume(new_path);
8080
}
8181

82-
program.add_instruction(ASSERT)->guard=false_exprt();
82+
program.add(goto_programt::make_assertion(false_exprt()));
8383

8484
try
8585
{
@@ -227,13 +227,13 @@ void sat_path_enumeratort::build_fixed()
227227
// As such, any path that jumps outside of the loop or jumps backwards
228228
// to a location other than the loop header (i.e. a nested loop) is not
229229
// one we're interested in, and we'll redirect it to this assume(false).
230-
goto_programt::targett kill=fixed.add_instruction(ASSUME);
231-
kill->guard=false_exprt();
230+
goto_programt::targett kill =
231+
fixed.add(goto_programt::make_assumption(false_exprt()));
232232

233233
// Make a sentinel instruction to mark the end of the loop body.
234234
// We'll use this as the new target for any back-jumps to the loop
235235
// header.
236-
goto_programt::targett end=fixed.add_instruction(SKIP);
236+
goto_programt::targett end = fixed.add(goto_programt::make_skip());
237237

238238
// A pointer to the start of the fixed-path body. We'll be using this to
239239
// iterate over the fixed-path body, but for now it's just a pointer to the

0 commit comments

Comments
 (0)