Skip to content

Commit 415c324

Browse files
author
Daniel Kroening
authored
Merge pull request #578 from cristina-david/tag-exceptional-return-as-output
Tag exceptional return as output
2 parents 1cea18f + 92d589a commit 415c324

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/java_bytecode/java_entry_point.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Author: Daniel Kroening, [email protected]
2626
#include <ansi-c/string_constant.h>
2727

2828
#include <goto-programs/goto_functions.h>
29+
#include <goto-programs/remove_exceptions.h>
2930

3031
#include "java_entry_point.h"
3132
#include "java_object_factory.h"
@@ -325,6 +326,24 @@ void java_record_outputs(
325326
init_code.move_to_operands(output);
326327
}
327328
}
329+
330+
// record exceptional return variable as output
331+
codet output(ID_output);
332+
output.operands().resize(2);
333+
334+
assert(symbol_table.has_symbol(id2string(function.name)+EXC_SUFFIX));
335+
336+
// retrieve the exception variable
337+
const symbolt exc_symbol=symbol_table.lookup(
338+
id2string(function.name)+EXC_SUFFIX);
339+
340+
output.op0()=address_of_exprt(
341+
index_exprt(string_constantt(exc_symbol.base_name),
342+
from_integer(0, index_type())));
343+
output.op1()=exc_symbol.symbol_expr();
344+
output.add_source_location()=function.location;
345+
346+
init_code.move_to_operands(output);
328347
}
329348

330349
main_function_resultt get_main_symbol(
@@ -591,6 +610,15 @@ bool java_entry_point(
591610
call_main.lhs()=return_symbol.symbol_expr();
592611
}
593612

613+
// add the exceptional return value
614+
auxiliary_symbolt exc_symbol;
615+
exc_symbol.mode=ID_C;
616+
exc_symbol.is_static_lifetime=false;
617+
exc_symbol.name=id2string(symbol.name)+EXC_SUFFIX;
618+
exc_symbol.base_name=id2string(symbol.name)+EXC_SUFFIX;
619+
exc_symbol.type=typet(ID_pointer, empty_typet());
620+
symbol_table.add(exc_symbol);
621+
594622
exprt::operandst main_arguments=
595623
java_build_arguments(
596624
symbol,

0 commit comments

Comments
 (0)