Skip to content

Commit 90921d2

Browse files
Add jump to the end of the current function if a function call throws an exception for which there is no handler
1 parent 13c8f83 commit 90921d2

File tree

3 files changed

+5
-30
lines changed

3 files changed

+5
-30
lines changed
0 Bytes
Binary file not shown.

src/goto-programs/remove_exceptions.cpp

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -414,36 +414,12 @@ void remove_exceptionst::instrument_exceptions(
414414
return;
415415
Forall_goto_program_instructions(instr_it, goto_program)
416416
{
417-
// this flag is used to skip DEAD redeclaration
418-
if(!instr_it->labels.empty())
419-
skip_dead=false;
420-
421417
if(instr_it->is_decl())
422418
{
423419
code_declt decl=to_code_decl(instr_it->code);
424420
locals.push_back(decl.symbol());
425421
}
426-
else if(instr_it->is_dead())
427-
{
428-
code_deadt dead=to_code_dead(instr_it->code);
429-
auto it=std::find(locals.begin(),
430-
locals.end(),
431-
dead.symbol());
432-
// avoid DEAD re-declarations
433-
if(it==locals.end())
434-
{
435-
if(skip_dead)
436-
{
437-
// this DEAD has been already added by a throw
438-
instr_it->make_skip();
439-
}
440-
}
441-
else
442-
{
443-
locals.erase(it);
444-
}
445-
}
446-
// it's a CATCH but not a handler
422+
// it's a CATCH but not a handler (as it has no operands)
447423
else if(instr_it->type==CATCH && !instr_it->code.has_operands())
448424
{
449425
if(instr_it->targets.empty()) // pop
@@ -492,14 +468,13 @@ void remove_exceptionst::instrument_exceptions(
492468
}
493469
instr_it->make_skip();
494470
}
495-
// handler
471+
// CATCH handler
496472
else if(instr_it->type==CATCH && instr_it->code.has_operands())
497473
{
498474
instrument_exception_handler(func_it, instr_it);
499475
}
500476
else if(instr_it->type==THROW)
501477
{
502-
skip_dead=true;
503478
instrument_throw(func_it, instr_it, stack_catch, locals);
504479
}
505480
else if(instr_it->type==FUNCTION_CALL)

src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,7 +2083,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
20832083
// for each try-catch add a CATCH-PUSH instruction
20842084
// each CATCH-PUSH records a list of all the handler labels
20852085
// together with a list of all the exception ids
2086-
2086+
20872087
// be aware of different try-catch blocks with the same starting pc
20882088
std::size_t pos=0;
20892089
std::size_t end_pc=0;
@@ -2124,7 +2124,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
21242124
for(size_t i=0; i<exception_ids.size(); ++i)
21252125
result.get_sub()[i].id(exception_ids[i]);
21262126
catch_push_expr.set(ID_exception_list, result);
2127-
2127+
21282128
// add the labels corresponding to the handlers
21292129
irept labels(ID_label);
21302130
labels.get_sub().resize(handler_labels.size());
@@ -2324,7 +2324,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
23242324
break;
23252325
}
23262326
}
2327-
2327+
23282328
if(start_new_block)
23292329
{
23302330
code_labelt newlabel(label(std::to_string(address)), code_blockt());

0 commit comments

Comments
 (0)