Skip to content

Commit ea7646b

Browse files
Collect string solver function calls
Gather up function calls made by string solver into the list of needed functions
1 parent 0e71658 commit ea7646b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/java_bytecode/java_bytecode_language.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Author: Daniel Kroening, [email protected]
1414
#include <util/suffix.h>
1515
#include <util/config.h>
1616
#include <util/cmdline.h>
17+
#include <util/expr_iterator.h>
1718
#include <util/journalling_symbol_table.h>
1819
#include <util/string2int.h>
1920
#include <util/invariant.h>
@@ -408,6 +409,29 @@ bool java_bytecode_languaget::convert_single_method(
408409
string_preprocess.code_for_function(symbol, symbol_table);
409410
INVARIANT(
410411
generated_code.is_not_nil(), "Couldn't retrieve code for string method");
412+
// String solver can make calls to functions that haven't yet been seen.
413+
// Add these to the needed_lazy_methods collection
414+
if(needed_lazy_methods)
415+
{
416+
for(const_depth_iteratort it = generated_code.depth_cbegin();
417+
it != generated_code.depth_cend();
418+
++it)
419+
{
420+
if(it->id() == ID_code)
421+
{
422+
const auto fn_call = expr_try_dynamic_cast<code_function_callt>(*it);
423+
if(!fn_call)
424+
continue;
425+
// Only support non-virtual function calls for now, if string solver
426+
// starts to introduce virtual function calls then we will need to
427+
// duplicate the behavior of java_bytecode_convert_method where it
428+
// handles the invokevirtual instruction
429+
const symbol_exprt &fn_sym =
430+
expr_dynamic_cast<symbol_exprt>(fn_call->function());
431+
needed_lazy_methods->add_needed_method(fn_sym.get_identifier());
432+
}
433+
}
434+
}
411435
symbol.value = generated_code;
412436
return false;
413437
}

0 commit comments

Comments
 (0)