Skip to content

Commit 0a28dd1

Browse files
authored
Merge pull request #4634 from svorenova/return-value-identifier
Add return_value_identifier function
2 parents 38b4a95 + 6acdb10 commit 0a28dd1

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/goto-programs/remove_returns.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,9 @@ bool remove_returnst::restore_returns(
295295
const irep_idt function_id=f_it->first;
296296

297297
// do we have X#return_value?
298-
const namespacet ns(symbol_table);
299-
auto rv_symbol = return_value_symbol(function_id, ns);
300-
auto rv_name = rv_symbol.get_identifier();
301-
298+
auto rv_name = return_value_identifier(function_id);
302299
symbol_tablet::symbolst::const_iterator rv_it=
303300
symbol_table.symbols.find(rv_name);
304-
305301
if(rv_it==symbol_table.symbols.end())
306302
return true;
307303

@@ -411,10 +407,15 @@ void restore_returns(goto_modelt &goto_model)
411407
rr.restore(goto_model.goto_functions);
412408
}
413409

410+
irep_idt return_value_identifier(const irep_idt &identifier)
411+
{
412+
return id2string(identifier) + RETURN_VALUE_SUFFIX;
413+
}
414+
414415
symbol_exprt
415416
return_value_symbol(const irep_idt &identifier, const namespacet &ns)
416417
{
417418
const symbolt &function_symbol = ns.lookup(identifier);
418419
const typet &return_type = to_code_type(function_symbol.type).return_type();
419-
return symbol_exprt(id2string(identifier) + RETURN_VALUE_SUFFIX, return_type);
420+
return symbol_exprt(return_value_identifier(identifier), return_type);
420421
}

src/goto-programs/remove_returns.h

+4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ void restore_returns(symbol_table_baset &, goto_functionst &);
9595

9696
void restore_returns(goto_modelt &);
9797

98+
/// produces the identifier that is used to store the return
99+
/// value of the function with the given identifier
100+
irep_idt return_value_identifier(const irep_idt &);
101+
98102
/// produces the symbol that is used to store the return
99103
/// value of the function with the given identifier
100104
symbol_exprt return_value_symbol(const irep_idt &, const namespacet &);

0 commit comments

Comments
 (0)