Skip to content

Commit 96569c3

Browse files
committed
JBMC: remove return values on a per-function basis
1 parent a7595c1 commit 96569c3

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/jbmc/jbmc_parse_options.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,8 @@ int jbmc_parse_optionst::get_goto_program(
642642
}
643643

644644
void jbmc_parse_optionst::process_goto_function(
645-
goto_model_functiont &function)
645+
goto_model_functiont &function,
646+
const can_produce_functiont &available_functions)
646647
{
647648
symbol_tablet &symbol_table = function.get_symbol_table();
648649
goto_functionst::goto_functiont &goto_function = function.get_goto_function();
@@ -655,6 +656,14 @@ void jbmc_parse_optionst::process_goto_function(
655656
remove_instanceof(goto_function, symbol_table);
656657
// Java virtual functions -> explicit dispatch tables:
657658
remove_virtual_functions(function);
659+
660+
auto function_is_stub =
661+
[&symbol_table, &available_functions](const irep_idt &id) { // NOLINT(*)
662+
return symbol_table.lookup_ref(id).value.is_nil() &&
663+
!available_functions.can_produce_function(id);
664+
};
665+
666+
remove_returns(function, function_is_stub);
658667
}
659668

660669
catch(const char *e)
@@ -692,9 +701,6 @@ bool jbmc_parse_optionst::process_goto_functions(
692701
// instrument library preconditions
693702
instrument_preconditions(goto_model);
694703

695-
// remove returns, gcc vectors, complex
696-
remove_returns(goto_model);
697-
698704
// Similar removal of java nondet statements:
699705
// TODO Should really get this from java_bytecode_language somehow, but we
700706
// don't have an instance of that here.

src/jbmc/jbmc_parse_options.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Author: Daniel Kroening, [email protected]
1919
#include <analyses/goto_check.h>
2020

2121
#include <goto-programs/goto_trace.h>
22+
#include <goto-programs/lazy_goto_model.h>
2223

2324
#include <java_bytecode/java_bytecode_language.h>
2425

@@ -83,7 +84,9 @@ class jbmc_parse_optionst:
8384
const char **argv,
8485
const std::string &extra_options);
8586

86-
void process_goto_function(goto_model_functiont &function);
87+
void process_goto_function(
88+
goto_model_functiont &function,
89+
const can_produce_functiont &);
8790
bool process_goto_functions(goto_modelt &goto_model, const optionst &options);
8891

8992
protected:

0 commit comments

Comments
 (0)