Skip to content

Commit 0f4b854

Browse files
author
thk123
committed
Refactored method for generating return symbol name to languaget
The name for the return symbol is now generated by languaget. This is so the name is consistent across different language implementations.
1 parent 31f4a29 commit 0f4b854

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

src/ansi-c/ansi_c_language.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ irep_idt ansi_c_languaget::generate_opaque_stub_body(
9595
if(return_type.id()!=ID_nil)
9696
{
9797
auxiliary_symbolt return_symbol;
98-
std::ostringstream return_symbol_name_builder;
99-
return_symbol_name_builder << "to_return_" << symbol.name;
100-
return_symbol.name=return_symbol_name_builder.str();
98+
return_symbol.name=get_stub_return_symbol_name(symbol.name);
10199
return_symbol.base_name=return_symbol.name;
102100
return_symbol.mode=ID_C;
103101
return_symbol.type=return_type;

src/util/language.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,28 @@ parameter_symbolt languaget::build_stub_parameter_symbol(
224224
return parameter_symbolt();
225225
}
226226

227+
/*******************************************************************\
228+
229+
Function: languaget::get_stub_return_symbol_name
230+
231+
Inputs:
232+
function_id - the function that has a return value
233+
234+
Outputs: the identifier to use for the symbol that will store the
235+
return value of this function.
236+
237+
Purpose: To get the name of the symbol to be used for the return value
238+
of the function. Generates a name like to_return_function_name
239+
240+
\*******************************************************************/
241+
242+
irep_idt languaget::get_stub_return_symbol_name(const irep_idt &function_id)
243+
{
244+
std::ostringstream return_symbol_name_builder;
245+
return_symbol_name_builder << "to_return_" << function_id;
246+
return return_symbol_name_builder.str();
247+
}
248+
227249

228250
/*******************************************************************\
229251

src/util/language.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ class languaget:public messaget
114114
const symbolt &function_symbol,
115115
size_t parameter_index,
116116
const code_typet::parametert &parameter);
117+
118+
static irep_idt get_stub_return_symbol_name(const irep_idt &function_id);
119+
117120
private:
118121
bool is_symbol_opaque_function(const symbolt &symbol);
119122
void generate_opaque_parameter_symbols(

0 commit comments

Comments
 (0)