Skip to content

Commit 254b4d4

Browse files
authored
Merge pull request #2642 from diffblue/remove_asm_fix
remove_asm now guarantees that functions called exist
2 parents 9c10f38 + 26009a3 commit 254b4d4

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

src/goto-programs/remove_asm.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,22 @@ Date: December 2014
2525
class remove_asmt
2626
{
2727
public:
28-
explicit remove_asmt(symbol_tablet &_symbol_table)
29-
: symbol_table(_symbol_table)
28+
remove_asmt(symbol_tablet &_symbol_table, goto_functionst &_goto_functions)
29+
: symbol_table(_symbol_table), goto_functions(_goto_functions)
3030
{
3131
}
3232

33-
void process_function(goto_functionst::goto_functiont &);
33+
void operator()()
34+
{
35+
for(auto &f : goto_functions.function_map)
36+
process_function(f.second);
37+
}
3438

3539
protected:
3640
symbol_tablet &symbol_table;
41+
goto_functionst &goto_functions;
42+
43+
void process_function(goto_functionst::goto_functiont &);
3744

3845
void process_instruction(
3946
goto_programt::instructiont &instruction,
@@ -102,6 +109,14 @@ void remove_asmt::gcc_asm_function_call(
102109

103110
symbol_table.add(symbol);
104111
}
112+
113+
if(
114+
goto_functions.function_map.find(function_identifier) ==
115+
goto_functions.function_map.end())
116+
{
117+
auto &f = goto_functions.function_map[function_identifier];
118+
f.type = fkt_type;
119+
}
105120
}
106121

107122
/// removes assembler
@@ -303,21 +318,11 @@ void remove_asmt::process_function(
303318
remove_skip(goto_function.body);
304319
}
305320

306-
/// removes assembler
307-
void remove_asm(
308-
goto_functionst::goto_functiont &goto_function,
309-
symbol_tablet &symbol_table)
310-
{
311-
remove_asmt rem(symbol_table);
312-
rem.process_function(goto_function);
313-
}
314-
315321
/// removes assembler
316322
void remove_asm(goto_functionst &goto_functions, symbol_tablet &symbol_table)
317323
{
318-
remove_asmt rem(symbol_table);
319-
for(auto &f : goto_functions.function_map)
320-
rem.process_function(f.second);
324+
remove_asmt rem(symbol_table, goto_functions);
325+
rem();
321326
}
322327

323328
/// removes assembler

src/goto-programs/remove_asm.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ Date: December 2014
2020
class goto_modelt;
2121
class symbol_tablet;
2222

23-
void remove_asm(
24-
goto_functionst::goto_functiont &goto_function,
25-
symbol_tablet &symbol_table);
23+
void remove_asm(goto_functionst &, symbol_tablet &);
2624

27-
void remove_asm(goto_functionst &goto_functions, symbol_tablet &symbol_table);
28-
29-
void remove_asm(goto_modelt &goto_model);
25+
void remove_asm(goto_modelt &);
3026

3127
#endif // CPROVER_GOTO_PROGRAMS_REMOVE_ASM_H

0 commit comments

Comments
 (0)