Skip to content

Commit

Permalink
Provide function name in goto_model_functiont
Browse files Browse the repository at this point in the history
This is necessary because not all functions work with goto_programt::get_function_id,
e.g. those with empty bodies.
  • Loading branch information
smowton committed Jan 26, 2018
1 parent f17e2c8 commit 3440018
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/goto-programs/goto_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ class goto_model_functiont
goto_model_functiont(
journalling_symbol_tablet &symbol_table,
goto_functionst &goto_functions,
const irep_idt &function_id,
goto_functionst::goto_functiont &goto_function):
symbol_table(symbol_table),
goto_functions(goto_functions),
function_id(function_id),
goto_function(goto_function)
{
}
Expand Down Expand Up @@ -117,9 +119,17 @@ class goto_model_functiont
return goto_function;
}

/// Get function id
/// \return `goto_function`'s name (its key in `goto_functions`)
const irep_idt &get_function_id()
{
return function_id;
}

private:
journalling_symbol_tablet &symbol_table;
goto_functionst &goto_functions;
irep_idt function_id;
goto_functionst::goto_functiont &goto_function;
};

Expand Down
3 changes: 2 additions & 1 deletion src/goto-programs/lazy_goto_functions_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class lazy_goto_functions_mapt final

typedef
std::function<void(
const irep_idt &name,
goto_functionst::goto_functiont &function,
journalling_symbol_tablet &function_symbols)>
post_process_functiont;
Expand Down Expand Up @@ -128,7 +129,7 @@ class lazy_goto_functions_mapt final
if(processed_functions.count(name)==0)
{
// Run function-pass conversions
post_process_function(function, journalling_table);
post_process_function(name, function, journalling_table);
// Assign procedure-local location numbers for now
function.body.compute_location_numbers();
processed_functions.insert(name);
Expand Down
4 changes: 4 additions & 0 deletions src/goto-programs/lazy_goto_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ lazy_goto_modelt::lazy_goto_modelt(
language_files,
symbol_table,
[this] (
const irep_idt &function_name,
goto_functionst::goto_functiont &function,
journalling_symbol_tablet &journalling_symbol_table) -> void
{
goto_model_functiont model_function(
journalling_symbol_table,
goto_model->goto_functions,
function_name,
function);
this->post_process_function(model_function, *this);
},
Expand All @@ -54,12 +56,14 @@ lazy_goto_modelt::lazy_goto_modelt(lazy_goto_modelt &&other)
language_files,
symbol_table,
[this] (
const irep_idt &function_name,
goto_functionst::goto_functiont &function,
journalling_symbol_tablet &journalling_symbol_table) -> void
{
goto_model_functiont model_function(
journalling_symbol_table,
goto_model->goto_functions,
function_name,
function);
this->post_process_function(model_function, *this);
},
Expand Down

0 comments on commit 3440018

Please sign in to comment.