Skip to content

Commit 71353e8

Browse files
author
Daniel Kroening
committed
remove_exceptions now takes function identifier
1 parent 1f1d21a commit 71353e8

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

jbmc/src/java_bytecode/remove_exceptions.cpp

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ class remove_exceptionst
9898
}
9999

100100
void operator()(goto_functionst &goto_functions);
101-
void operator()(goto_programt &goto_program);
101+
void operator()(
102+
const irep_idt &function_identifier, goto_programt &goto_program);
102103

103104
protected:
104105
symbol_table_baset &symbol_table;
@@ -122,24 +123,28 @@ class remove_exceptionst
122123
std::size_t &universal_catch);
123124

124125
void add_exception_dispatch_sequence(
126+
const irep_idt &function_identifier,
125127
goto_programt &goto_program,
126128
const goto_programt::targett &instr_it,
127129
const stack_catcht &stack_catch,
128130
const std::vector<exprt> &locals);
129131

130132
bool instrument_throw(
133+
const irep_idt &function_identifier,
131134
goto_programt &goto_program,
132135
const goto_programt::targett &,
133136
const stack_catcht &,
134137
const std::vector<exprt> &);
135138

136139
bool instrument_function_call(
140+
const irep_idt &function_identifier,
137141
goto_programt &goto_program,
138142
const goto_programt::targett &,
139143
const stack_catcht &,
140144
const std::vector<exprt> &);
141145

142146
void instrument_exceptions(
147+
const irep_idt &function_identifier,
143148
goto_programt &goto_program);
144149
};
145150

@@ -295,6 +300,7 @@ goto_programt::targett remove_exceptionst::find_universal_exception(
295300
/// \param stack_catch: exception handlers currently registered
296301
/// \param locals: local variables to kill on a function-exit edge
297302
void remove_exceptionst::add_exception_dispatch_sequence(
303+
const irep_idt &function_identifier,
298304
goto_programt &goto_program,
299305
const goto_programt::targett &instr_it,
300306
const remove_exceptionst::stack_catcht &stack_catch,
@@ -345,7 +351,7 @@ void remove_exceptionst::add_exception_dispatch_sequence(
345351
t_exc->guard=check;
346352

347353
if(remove_added_instanceof)
348-
remove_instanceof(t_exc, goto_program, symbol_table, message_handler);
354+
remove_instanceof(function_identifier, t_exc, goto_program, symbol_table, message_handler);
349355
}
350356
}
351357
}
@@ -368,6 +374,7 @@ void remove_exceptionst::add_exception_dispatch_sequence(
368374
/// instruments each throw with conditional GOTOS to the corresponding
369375
/// exception handlers
370376
bool remove_exceptionst::instrument_throw(
377+
const irep_idt &function_identifier,
371378
goto_programt &goto_program,
372379
const goto_programt::targett &instr_it,
373380
const remove_exceptionst::stack_catcht &stack_catch,
@@ -379,6 +386,7 @@ bool remove_exceptionst::instrument_throw(
379386
uncaught_exceptions_domaint::get_exception_symbol(instr_it->code);
380387

381388
add_exception_dispatch_sequence(
389+
function_identifier,
382390
goto_program, instr_it, stack_catch, locals);
383391

384392
// find the symbol where the thrown exception should be stored:
@@ -399,6 +407,7 @@ bool remove_exceptionst::instrument_throw(
399407
/// instruments each function call that may escape exceptions with conditional
400408
/// GOTOS to the corresponding exception handlers
401409
bool remove_exceptionst::instrument_function_call(
410+
const irep_idt &function_identifier,
402411
goto_programt &goto_program,
403412
const goto_programt::targett &instr_it,
404413
const stack_catcht &stack_catch,
@@ -433,6 +442,7 @@ bool remove_exceptionst::instrument_function_call(
433442
else
434443
{
435444
add_exception_dispatch_sequence(
445+
function_identifier,
436446
goto_program, instr_it, stack_catch, locals);
437447

438448
// add a null check (so that instanceof can be applied)
@@ -453,6 +463,7 @@ bool remove_exceptionst::instrument_function_call(
453463
/// handlers. Additionally, it re-computes the live-range of local variables in
454464
/// order to add DEAD instructions.
455465
void remove_exceptionst::instrument_exceptions(
466+
const irep_idt &function_identifier,
456467
goto_programt &goto_program)
457468
{
458469
stack_catcht stack_catch; // stack of try-catch blocks
@@ -549,12 +560,12 @@ void remove_exceptionst::instrument_exceptions(
549560
else if(instr_it->type==THROW)
550561
{
551562
did_something |=
552-
instrument_throw(goto_program, instr_it, stack_catch, locals);
563+
instrument_throw(function_identifier, goto_program, instr_it, stack_catch, locals);
553564
}
554565
else if(instr_it->type==FUNCTION_CALL)
555566
{
556567
did_something |=
557-
instrument_function_call(goto_program, instr_it, stack_catch, locals);
568+
instrument_function_call(function_identifier, goto_program, instr_it, stack_catch, locals);
558569
}
559570
}
560571

@@ -565,12 +576,14 @@ void remove_exceptionst::instrument_exceptions(
565576
void remove_exceptionst::operator()(goto_functionst &goto_functions)
566577
{
567578
Forall_goto_functions(it, goto_functions)
568-
instrument_exceptions(it->second.body);
579+
instrument_exceptions(it->first, it->second.body);
569580
}
570581

571-
void remove_exceptionst::operator()(goto_programt &goto_program)
582+
void remove_exceptionst::operator()(
583+
const irep_idt &function_identifier,
584+
goto_programt &goto_program)
572585
{
573-
instrument_exceptions(goto_program);
586+
instrument_exceptions(function_identifier, goto_program);
574587
}
575588

576589
/// removes throws/CATCH-POP/CATCH-PUSH
@@ -610,6 +623,7 @@ void remove_exceptions(
610623
/// should be lowered to class-identifier comparisons (using
611624
/// remove_instanceof).
612625
void remove_exceptions(
626+
const irep_idt &function_identifier,
613627
goto_programt &goto_program,
614628
symbol_table_baset &symbol_table,
615629
message_handlert &message_handler,
@@ -623,7 +637,7 @@ void remove_exceptions(
623637
any_function_may_throw,
624638
type == remove_exceptions_typest::REMOVE_ADDED_INSTANCEOF,
625639
message_handler);
626-
remove_exceptions(goto_program);
640+
remove_exceptions(function_identifier, goto_program);
627641
}
628642

629643
/// removes throws/CATCH-POP/CATCH-PUSH

jbmc/src/java_bytecode/remove_exceptions.h

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

3434
void remove_exceptions(
35+
const irep_idt &function_identifier,
3536
goto_programt &goto_program,
3637
symbol_table_baset &symbol_table,
3738
message_handlert &message_handler,

0 commit comments

Comments
 (0)