Skip to content

Commit 3440018

Browse files
committed
Provide function name in goto_model_functiont
This is necessary because not all functions work with goto_programt::get_function_id, e.g. those with empty bodies.
1 parent f17e2c8 commit 3440018

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/goto-programs/goto_model.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ class goto_model_functiont
8686
goto_model_functiont(
8787
journalling_symbol_tablet &symbol_table,
8888
goto_functionst &goto_functions,
89+
const irep_idt &function_id,
8990
goto_functionst::goto_functiont &goto_function):
9091
symbol_table(symbol_table),
9192
goto_functions(goto_functions),
93+
function_id(function_id),
9294
goto_function(goto_function)
9395
{
9496
}
@@ -117,9 +119,17 @@ class goto_model_functiont
117119
return goto_function;
118120
}
119121

122+
/// Get function id
123+
/// \return `goto_function`'s name (its key in `goto_functions`)
124+
const irep_idt &get_function_id()
125+
{
126+
return function_id;
127+
}
128+
120129
private:
121130
journalling_symbol_tablet &symbol_table;
122131
goto_functionst &goto_functions;
132+
irep_idt function_id;
123133
goto_functionst::goto_functiont &goto_function;
124134
};
125135

src/goto-programs/lazy_goto_functions_map.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class lazy_goto_functions_mapt final
4949

5050
typedef
5151
std::function<void(
52+
const irep_idt &name,
5253
goto_functionst::goto_functiont &function,
5354
journalling_symbol_tablet &function_symbols)>
5455
post_process_functiont;
@@ -128,7 +129,7 @@ class lazy_goto_functions_mapt final
128129
if(processed_functions.count(name)==0)
129130
{
130131
// Run function-pass conversions
131-
post_process_function(function, journalling_table);
132+
post_process_function(name, function, journalling_table);
132133
// Assign procedure-local location numbers for now
133134
function.body.compute_location_numbers();
134135
processed_functions.insert(name);

src/goto-programs/lazy_goto_model.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ lazy_goto_modelt::lazy_goto_modelt(
2929
language_files,
3030
symbol_table,
3131
[this] (
32+
const irep_idt &function_name,
3233
goto_functionst::goto_functiont &function,
3334
journalling_symbol_tablet &journalling_symbol_table) -> void
3435
{
3536
goto_model_functiont model_function(
3637
journalling_symbol_table,
3738
goto_model->goto_functions,
39+
function_name,
3840
function);
3941
this->post_process_function(model_function, *this);
4042
},
@@ -54,12 +56,14 @@ lazy_goto_modelt::lazy_goto_modelt(lazy_goto_modelt &&other)
5456
language_files,
5557
symbol_table,
5658
[this] (
59+
const irep_idt &function_name,
5760
goto_functionst::goto_functiont &function,
5861
journalling_symbol_tablet &journalling_symbol_table) -> void
5962
{
6063
goto_model_functiont model_function(
6164
journalling_symbol_table,
6265
goto_model->goto_functions,
66+
function_name,
6367
function);
6468
this->post_process_function(model_function, *this);
6569
},

0 commit comments

Comments
 (0)