Skip to content

Commit

Permalink
Assign parameter names to abstract functions that we're giving a stub…
Browse files Browse the repository at this point in the history
… body
  • Loading branch information
smowton committed Jul 31, 2018
1 parent 4348968 commit 264bc6f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class patternt
/// \return Assigns parameter names (side-effects on `ftype`) to function stub
/// parameters, which are initially nameless as method conversion hasn't
/// happened. Also creates symbols in `symbol_table`.
static void assign_parameter_names(
void assign_parameter_names(
code_typet &ftype,
const irep_idt &name_prefix,
symbol_table_baset &symbol_table)
Expand Down
5 changes: 5 additions & 0 deletions cbmc/jbmc/src/java_bytecode/java_bytecode_convert_method.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ void java_bytecode_convert_method_lazy(
symbol_tablet &symbol_table,
message_handlert &);

void assign_parameter_names(
code_typet &ftype,
const irep_idt &name_prefix,
symbol_table_baset &symbol_table);

#endif // CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_CONVERT_METHOD_H
19 changes: 17 additions & 2 deletions src/driver/sec_driver_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <analyses/local_may_alias.h>

#include <java_bytecode/convert_java_nondet.h>
#include <java_bytecode/java_bytecode_convert_method.h>
#include <java_bytecode/remove_exceptions.h>
#include <java_bytecode/remove_instanceof.h>
#include <java_bytecode/remove_java_new.h>
Expand Down Expand Up @@ -659,17 +660,31 @@ bool sec_driver_parse_optionst::generate_function_body(
goto_functiont &function,
bool body_available)
{
const symbolt *symbol = symbol_table.lookup(function_name);

// Provide a simple stub implementation for any function we don't have a
// bytecode implementation for:
if(body_available || !can_generate_function_body(function_name))
{
const symbolt *symbol = symbol_table.lookup(function_name);
if(symbol == nullptr || !symbol->type.get_bool(ID_C_abstract))
return false;
}

if(symbol_table.lookup_ref(function_name).mode == ID_java)
if(symbol->mode == ID_java)
{
code_typet code_type = to_code_type(symbol->type);

// Note this may invalidate pointer `symbol` by adding to the symtab, so:
symbol = nullptr;

if(
code_type.parameters().size() != 0 &&
code_type.parameters()[0].get_identifier().empty())
{
assign_parameter_names(code_type, function_name, symbol_table);
symbol_table.get_writeable_ref(function_name).type = code_type;
}

java_generate_simple_method_stub(
function_name,
symbol_table,
Expand Down

0 comments on commit 264bc6f

Please sign in to comment.