Skip to content

Commit 7e1ecc9

Browse files
Allow post-processing functions to run on a function-by-function basis
1 parent 0c05be6 commit 7e1ecc9

9 files changed

+68
-60
lines changed

src/goto-diff/goto_diff_parse_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ bool goto_diff_parse_optionst::process_goto_program(
396396

397397
// Remove inline assembler; this needs to happen before
398398
// adding the library.
399-
remove_asm(symbol_table, goto_functions);
399+
remove_asm(goto_model);
400400

401401
// add the library
402402
link_to_library(symbol_table, goto_functions, ui_message_handler);

src/goto-programs/remove_asm.cpp

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,20 @@ Date: December 2014
2525
class remove_asmt
2626
{
2727
public:
28-
inline remove_asmt(
29-
symbol_tablet &_symbol_table,
30-
goto_functionst &_goto_functions):
31-
symbol_table(_symbol_table),
32-
goto_functions(_goto_functions)
28+
explicit remove_asmt(symbol_tablet &_symbol_table)
29+
: symbol_table(_symbol_table)
3330
{
3431
}
3532

36-
void operator()();
33+
void process_function(goto_functionst::goto_functiont &);
3734

3835
protected:
3936
symbol_tablet &symbol_table;
40-
goto_functionst &goto_functions;
4137

4238
void process_instruction(
4339
goto_programt::instructiont &instruction,
4440
goto_programt &dest);
4541

46-
void process_function(
47-
goto_functionst::goto_functiont &);
48-
4942
void gcc_asm_function_call(
5043
const irep_idt &function_base_name,
5144
const codet &code,
@@ -305,24 +298,24 @@ void remove_asmt::process_function(
305298
}
306299

307300
/// removes assembler
308-
void remove_asmt::operator()()
301+
void remove_asm(
302+
goto_functionst::goto_functiont &goto_function,
303+
symbol_tablet &symbol_table)
309304
{
310-
Forall_goto_functions(it, goto_functions)
311-
{
312-
process_function(it->second);
313-
}
305+
remove_asmt rem(symbol_table);
306+
rem.process_function(goto_function);
314307
}
315308

316309
/// removes assembler
317-
void remove_asm(
318-
symbol_tablet &symbol_table,
319-
goto_functionst &goto_functions)
310+
void remove_asm(goto_functionst &goto_functions, symbol_tablet &symbol_table)
320311
{
321-
remove_asmt(symbol_table, goto_functions)();
312+
remove_asmt rem(symbol_table);
313+
for(auto &f : goto_functions.function_map)
314+
rem.process_function(f.second);
322315
}
323316

324317
/// removes assembler
325318
void remove_asm(goto_modelt &goto_model)
326319
{
327-
remove_asmt(goto_model.symbol_table, goto_model.goto_functions)();
320+
remove_asm(goto_model.goto_functions, goto_model.symbol_table);
328321
}

src/goto-programs/remove_asm.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ Date: December 2014
1717

1818
#include <goto-programs/goto_model.h>
1919

20-
void remove_asm(symbol_tablet &, goto_functionst &);
20+
void remove_asm(
21+
goto_functionst::goto_functiont &goto_function,
22+
symbol_tablet &symbol_table);
2123

22-
void remove_asm(goto_modelt &);
24+
void remove_asm(goto_functionst &goto_functions, symbol_tablet &symbol_table);
25+
26+
void remove_asm(goto_modelt &goto_model);
2327

2428
#endif // CPROVER_GOTO_PROGRAMS_REMOVE_ASM_H

src/goto-programs/remove_instanceof.cpp

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,19 @@ Author: Chris Smowton, [email protected]
2222
class remove_instanceoft
2323
{
2424
public:
25-
remove_instanceoft(
26-
symbol_tablet &_symbol_table,
27-
goto_functionst &_goto_functions):
28-
symbol_table(_symbol_table),
29-
ns(_symbol_table),
30-
goto_functions(_goto_functions)
25+
explicit remove_instanceoft(symbol_tablet &symbol_table)
26+
: symbol_table(symbol_table), ns(symbol_table)
3127
{
32-
class_hierarchy(_symbol_table);
28+
class_hierarchy(symbol_table);
3329
}
3430

35-
// Lower instanceof for all functions:
36-
void lower_instanceof();
31+
// Lower instanceof for a single functions
32+
bool lower_instanceof(goto_programt &);
3733

3834
protected:
3935
symbol_tablet &symbol_table;
4036
namespacet ns;
4137
class_hierarchyt class_hierarchy;
42-
goto_functionst &goto_functions;
43-
44-
bool lower_instanceof(goto_programt &);
4538

4639
bool lower_instanceof(goto_programt &, goto_programt::targett);
4740

@@ -174,33 +167,38 @@ bool remove_instanceoft::lower_instanceof(goto_programt &goto_program)
174167
return true;
175168
}
176169

177-
/// See function above
178-
/// \return Side-effects on this->goto_functions, replacing every instanceof in
179-
/// every function with an explicit test.
180-
void remove_instanceoft::lower_instanceof()
170+
171+
/// Replace every instanceof in the passed function with an explicit
172+
/// class-identifier test.
173+
/// Extra auxiliary variables may be introduced into symbol_table.
174+
/// \param function: The function to work on.
175+
/// \param symbol_table: The symbol table to add symbols to.
176+
void remove_instanceof(
177+
goto_functionst::goto_functiont &function,
178+
symbol_tablet &symbol_table)
181179
{
182-
bool changed=false;
183-
for(auto &f : goto_functions.function_map)
184-
changed=(lower_instanceof(f.second.body) || changed);
185-
if(changed)
186-
goto_functions.compute_location_numbers();
180+
remove_instanceoft rem(symbol_table);
181+
rem.lower_instanceof(function.body);
187182
}
188183

189-
/// See function above
190-
/// \par parameters: `goto_functions`, a function map, and the corresponding
191-
/// `symbol_table`.
192-
/// \return Side-effects on goto_functions, replacing every instanceof in every
193-
/// function with an explicit test. Extra auxiliary variables may be
194-
/// introduced into `symbol_table`.
184+
/// Replace every instanceof in every function with an explicit
185+
/// class-identifier test.
186+
/// Extra auxiliary variables may be introduced into symbol_table.
187+
/// \param goto_functions: The functions to work on.
188+
/// \param symbol_table: The symbol table to add symbols to.
195189
void remove_instanceof(
196-
symbol_tablet &symbol_table,
197-
goto_functionst &goto_functions)
190+
goto_functionst &goto_functions,
191+
symbol_tablet &symbol_table)
198192
{
199-
remove_instanceoft rem(symbol_table, goto_functions);
200-
rem.lower_instanceof();
193+
remove_instanceoft rem(symbol_table);
194+
bool changed=false;
195+
for(auto &f : goto_functions.function_map)
196+
changed=rem.lower_instanceof(f.second.body) || changed;
197+
if(changed)
198+
goto_functions.compute_location_numbers();
201199
}
202200

203201
void remove_instanceof(goto_modelt &goto_model)
204202
{
205-
remove_instanceof(goto_model.symbol_table, goto_model.goto_functions);
203+
remove_instanceof(goto_model.goto_functions, goto_model.symbol_table);
206204
}

src/goto-programs/remove_instanceof.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ Author: Chris Smowton, [email protected]
1717
#include "goto_model.h"
1818

1919
void remove_instanceof(
20-
symbol_tablet &symbol_table,
21-
goto_functionst &goto_functions);
20+
goto_functionst::goto_functiont &function,
21+
symbol_tablet &symbol_table);
22+
23+
void remove_instanceof(
24+
goto_functionst &goto_functions,
25+
symbol_tablet &symbol_table);
2226

2327
void remove_instanceof(goto_modelt &model);
2428

src/goto-symex/adjust_float_expressions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void adjust_float_expressions(
179179
}
180180
}
181181

182-
static void adjust_float_expressions(
182+
void adjust_float_expressions(
183183
goto_functionst::goto_functiont &goto_function,
184184
const namespacet &ns)
185185
{

src/goto-symex/adjust_float_expressions.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,20 @@ Author: Daniel Kroening, [email protected]
1212
#ifndef CPROVER_GOTO_SYMEX_ADJUST_FLOAT_EXPRESSIONS_H
1313
#define CPROVER_GOTO_SYMEX_ADJUST_FLOAT_EXPRESSIONS_H
1414

15+
#include <goto-programs/goto_functions.h>
16+
1517
class exprt;
1618
class namespacet;
17-
class goto_functionst;
1819
class goto_modelt;
1920

2021
void adjust_float_expressions(
2122
exprt &expr,
2223
const namespacet &ns);
2324

25+
void adjust_float_expressions(
26+
goto_functionst::goto_functiont &goto_function,
27+
const namespacet &ns);
28+
2429
void adjust_float_expressions(
2530
goto_functionst &goto_functions,
2631
const namespacet &ns);

src/goto-symex/rewrite_union.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void rewrite_union(
107107
}
108108
}
109109

110-
static void rewrite_union(
110+
void rewrite_union(
111111
goto_functionst::goto_functiont &goto_function,
112112
const namespacet &ns)
113113
{

src/goto-symex/rewrite_union.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ void rewrite_union(
2323
exprt &expr,
2424
const namespacet &ns);
2525

26+
void rewrite_union(
27+
goto_functionst::goto_functiont &goto_function,
28+
const namespacet &ns);
29+
2630
void rewrite_union(
2731
goto_functionst &goto_functions,
2832
const namespacet &ns);

0 commit comments

Comments
 (0)