Skip to content

Commit 15edb03

Browse files
author
Daniel Kroening
committed
prevent half-constructed GOTO instructions
1 parent 309d207 commit 15edb03

File tree

4 files changed

+7
-14
lines changed

4 files changed

+7
-14
lines changed

jbmc/src/java_bytecode/remove_exceptions.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,6 @@ void remove_exceptionst::add_exception_dispatch_sequence(
306306
// Jump to the universal handler or function end, as appropriate.
307307
// This will appear after the GOTO-based dynamic dispatch below
308308
goto_programt::targett default_dispatch=goto_program.insert_after(instr_it);
309-
default_dispatch->make_goto();
310-
default_dispatch->source_location=instr_it->source_location;
311-
default_dispatch->function=instr_it->function;
312309

313310
// find the symbol corresponding to the caught exceptions
314311
symbol_exprt exc_thrown =
@@ -356,7 +353,9 @@ void remove_exceptionst::add_exception_dispatch_sequence(
356353
}
357354
}
358355

359-
default_dispatch->set_target(default_target);
356+
default_dispatch->make_goto(default_target);
357+
default_dispatch->source_location=instr_it->source_location;
358+
default_dispatch->function=instr_it->function;
360359

361360
// add dead instructions
362361
for(const auto &local : locals)

src/goto-instrument/accelerate/accelerate.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,12 @@ void acceleratet::insert_looping_path(
212212
++loop_body;
213213

214214
goto_programt::targett jump=program.insert_before(loop_body);
215-
jump->make_goto();
216-
jump->guard=side_effect_expr_nondett(bool_typet());
217-
jump->targets.push_back(loop_body);
215+
jump->make_goto(loop_body, side_effect_expr_nondett(bool_typet()));
218216

219217
program.destructive_insert(loop_body, looping_path);
220218

221219
jump=program.insert_before(loop_body);
222-
jump->make_goto();
223-
jump->guard=true_exprt();
224-
jump->targets.push_back(back_jump);
220+
jump->make_goto(back_jump, true_exprt());
225221

226222
for(goto_programt::targett t=loop_header;
227223
t!=loop_body;

src/goto-instrument/branch.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ void branch(
5656
t1->function=f_it->first;
5757

5858
goto_programt::targett t2=body.insert_after(t1);
59-
t2->make_goto();
60-
t2->targets=i_it->targets;
59+
t2->make_goto(i_it->get_target());
6160

6261
goto_programt::targett t3=body.insert_after(t2);
6362
t3->make_function_call(

src/goto-programs/goto_program.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ class goto_programt
237237
code.make_nil();
238238
}
239239

240-
void make_goto() { clear(GOTO); }
241240
void make_return() { clear(RETURN); }
242241
void make_skip() { clear(SKIP); }
243242
void make_location(const source_locationt &l)
@@ -256,7 +255,7 @@ class goto_programt
256255

257256
void make_goto(targett _target)
258257
{
259-
make_goto();
258+
clear(GOTO);
260259
targets.push_back(_target);
261260
}
262261

0 commit comments

Comments
 (0)