Skip to content

Commit e0e1811

Browse files
author
Daniel Kroening
committed
remove_exceptions now takes function identifier
1 parent 4af678a commit e0e1811

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

jbmc/src/java_bytecode/remove_exceptions.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ class remove_exceptionst
107107
}
108108

109109
void operator()(goto_functionst &goto_functions);
110-
void operator()(goto_programt &goto_program);
110+
void operator()(
111+
const irep_idt &function_identifier, goto_programt &goto_program);
111112

112113
protected:
113114
symbol_table_baset &symbol_table;
@@ -132,24 +133,28 @@ class remove_exceptionst
132133
std::size_t &universal_catch);
133134

134135
void add_exception_dispatch_sequence(
136+
const irep_idt &function_identifier,
135137
goto_programt &goto_program,
136138
const goto_programt::targett &instr_it,
137139
const stack_catcht &stack_catch,
138140
const std::vector<symbol_exprt> &locals);
139141

140142
bool instrument_throw(
143+
const irep_idt &function_identifier,
141144
goto_programt &goto_program,
142145
const goto_programt::targett &,
143146
const stack_catcht &,
144147
const std::vector<symbol_exprt> &);
145148

146149
bool instrument_function_call(
150+
const irep_idt &function_identifier,
147151
goto_programt &goto_program,
148152
const goto_programt::targett &,
149153
const stack_catcht &,
150154
const std::vector<symbol_exprt> &);
151155

152156
void instrument_exceptions(
157+
const irep_idt &function_identifier,
153158
goto_programt &goto_program);
154159
};
155160

@@ -305,6 +310,7 @@ goto_programt::targett remove_exceptionst::find_universal_exception(
305310
/// \param stack_catch: exception handlers currently registered
306311
/// \param locals: local variables to kill on a function-exit edge
307312
void remove_exceptionst::add_exception_dispatch_sequence(
313+
const irep_idt &function_identifier,
308314
goto_programt &goto_program,
309315
const goto_programt::targett &instr_it,
310316
const remove_exceptionst::stack_catcht &stack_catch,
@@ -357,6 +363,7 @@ void remove_exceptionst::add_exception_dispatch_sequence(
357363
if(remove_added_instanceof)
358364
{
359365
remove_instanceof(
366+
function_identifier,
360367
t_exc,
361368
goto_program,
362369
symbol_table,
@@ -385,6 +392,7 @@ void remove_exceptionst::add_exception_dispatch_sequence(
385392
/// instruments each throw with conditional GOTOS to the corresponding
386393
/// exception handlers
387394
bool remove_exceptionst::instrument_throw(
395+
const irep_idt &function_identifier,
388396
goto_programt &goto_program,
389397
const goto_programt::targett &instr_it,
390398
const remove_exceptionst::stack_catcht &stack_catch,
@@ -396,6 +404,7 @@ bool remove_exceptionst::instrument_throw(
396404
uncaught_exceptions_domaint::get_exception_symbol(instr_it->code);
397405

398406
add_exception_dispatch_sequence(
407+
function_identifier,
399408
goto_program, instr_it, stack_catch, locals);
400409

401410
// find the symbol where the thrown exception should be stored:
@@ -416,6 +425,7 @@ bool remove_exceptionst::instrument_throw(
416425
/// instruments each function call that may escape exceptions with conditional
417426
/// GOTOS to the corresponding exception handlers
418427
bool remove_exceptionst::instrument_function_call(
428+
const irep_idt &function_identifier,
419429
goto_programt &goto_program,
420430
const goto_programt::targett &instr_it,
421431
const stack_catcht &stack_catch,
@@ -450,6 +460,7 @@ bool remove_exceptionst::instrument_function_call(
450460
else
451461
{
452462
add_exception_dispatch_sequence(
463+
function_identifier,
453464
goto_program, instr_it, stack_catch, locals);
454465

455466
// add a null check (so that instanceof can be applied)
@@ -470,6 +481,7 @@ bool remove_exceptionst::instrument_function_call(
470481
/// handlers. Additionally, it re-computes the live-range of local variables in
471482
/// order to add DEAD instructions.
472483
void remove_exceptionst::instrument_exceptions(
484+
const irep_idt &function_identifier,
473485
goto_programt &goto_program)
474486
{
475487
stack_catcht stack_catch; // stack of try-catch blocks
@@ -566,12 +578,12 @@ void remove_exceptionst::instrument_exceptions(
566578
else if(instr_it->type==THROW)
567579
{
568580
did_something |=
569-
instrument_throw(goto_program, instr_it, stack_catch, locals);
581+
instrument_throw(function_identifier, goto_program, instr_it, stack_catch, locals);
570582
}
571583
else if(instr_it->type==FUNCTION_CALL)
572584
{
573585
did_something |=
574-
instrument_function_call(goto_program, instr_it, stack_catch, locals);
586+
instrument_function_call(function_identifier, goto_program, instr_it, stack_catch, locals);
575587
}
576588
}
577589

@@ -582,12 +594,14 @@ void remove_exceptionst::instrument_exceptions(
582594
void remove_exceptionst::operator()(goto_functionst &goto_functions)
583595
{
584596
Forall_goto_functions(it, goto_functions)
585-
instrument_exceptions(it->second.body);
597+
instrument_exceptions(it->first, it->second.body);
586598
}
587599

588-
void remove_exceptionst::operator()(goto_programt &goto_program)
600+
void remove_exceptionst::operator()(
601+
const irep_idt &function_identifier,
602+
goto_programt &goto_program)
589603
{
590-
instrument_exceptions(goto_program);
604+
instrument_exceptions(function_identifier, goto_program);
591605
}
592606

593607
/// removes throws/CATCH-POP/CATCH-PUSH
@@ -631,6 +645,7 @@ void remove_exceptions(
631645
/// should be lowered to class-identifier comparisons (using
632646
/// remove_instanceof).
633647
void remove_exceptions(
648+
const irep_idt &function_identifier,
634649
goto_programt &goto_program,
635650
symbol_table_baset &symbol_table,
636651
const class_hierarchyt *class_hierarchy,
@@ -646,7 +661,7 @@ void remove_exceptions(
646661
any_function_may_throw,
647662
type == remove_exceptions_typest::REMOVE_ADDED_INSTANCEOF,
648663
message_handler);
649-
remove_exceptions(goto_program);
664+
remove_exceptions(function_identifier, goto_program);
650665
}
651666

652667
/// removes throws/CATCH-POP/CATCH-PUSH, replacing them with explicit exception

jbmc/src/java_bytecode/remove_exceptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ enum class remove_exceptions_typest
3333
};
3434

3535
void remove_exceptions(
36+
const irep_idt &function_identifier,
3637
goto_programt &goto_program,
3738
symbol_table_baset &symbol_table,
3839
const class_hierarchyt *class_hierarchy,

0 commit comments

Comments
 (0)