@@ -14,6 +14,7 @@ Author: Daniel Kroening, kroening@kroening.com
14
14
#include < util/suffix.h>
15
15
#include < util/config.h>
16
16
#include < util/cmdline.h>
17
+ #include < util/expr_iterator.h>
17
18
#include < util/journalling_symbol_table.h>
18
19
#include < util/string2int.h>
19
20
#include < util/invariant.h>
@@ -408,6 +409,29 @@ bool java_bytecode_languaget::convert_single_method(
408
409
string_preprocess.code_for_function (symbol, symbol_table);
409
410
INVARIANT (
410
411
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
+ }
411
435
symbol.value = generated_code;
412
436
return false ;
413
437
}
0 commit comments