Skip to content

Commit 12cc79c

Browse files
author
Daniel Kroening
authored
Merge pull request #1275 from diffblue/goto-model-service-functions
variants of service functions for goto_modelt
2 parents 4f88473 + c7afb95 commit 12cc79c

18 files changed

+185
-64
lines changed

src/goto-instrument/cover.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,3 +1572,15 @@ bool instrument_cover_goals(
15721572
goto_functions.update();
15731573
return false;
15741574
}
1575+
1576+
bool instrument_cover_goals(
1577+
const cmdlinet &cmdline,
1578+
goto_modelt &goto_model,
1579+
message_handlert &message_handler)
1580+
{
1581+
return instrument_cover_goals(
1582+
cmdline,
1583+
goto_model.symbol_table,
1584+
goto_model.goto_functions,
1585+
message_handler);
1586+
}

src/goto-instrument/cover.h

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,41 +42,46 @@ enum class coverage_criteriont
4242
PATH, MCDC, ASSERTION, COVER };
4343

4444
bool consider_goals(
45-
const goto_programt &goto_program,
46-
coverage_goalst &goals);
45+
const goto_programt &,
46+
coverage_goalst &);
4747

4848
void instrument_cover_goals(
49-
const symbol_tablet &symbol_table,
50-
goto_functionst &goto_functions,
49+
const symbol_tablet &,
50+
goto_functionst &,
5151
coverage_criteriont,
5252
bool function_only=false);
5353

5454
void instrument_cover_goals(
55-
const symbol_tablet &symbol_table,
56-
goto_programt &goto_program,
55+
const symbol_tablet &,
56+
goto_programt &,
5757
coverage_criteriont,
5858
bool function_only=false);
5959

6060
void instrument_cover_goals(
61-
const symbol_tablet &symbol_table,
62-
goto_functionst &goto_functions,
61+
const symbol_tablet &,
62+
goto_functionst &,
6363
coverage_criteriont,
64-
coverage_goalst &goals,
64+
coverage_goalst &,
6565
bool function_only=false,
6666
bool ignore_trivial=false);
6767

6868
void instrument_cover_goals(
69-
const symbol_tablet &symbol_table,
70-
goto_programt &goto_program,
69+
const symbol_tablet &,
70+
goto_programt &,
7171
coverage_criteriont,
7272
coverage_goalst &goals,
7373
bool function_only=false,
7474
bool ignore_trivial=false);
7575

7676
bool instrument_cover_goals(
77-
const cmdlinet &cmdline,
78-
const symbol_tablet &symbol_table,
79-
goto_functionst &goto_functions,
80-
message_handlert &msgh);
77+
const cmdlinet &,
78+
const symbol_tablet &,
79+
goto_functionst &,
80+
message_handlert &);
81+
82+
bool instrument_cover_goals(
83+
const cmdlinet &,
84+
goto_modelt &,
85+
message_handlert &);
8186

8287
#endif // CPROVER_GOTO_INSTRUMENT_COVER_H

src/goto-instrument/full_slicer.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,13 @@ void full_slicer(
382382
full_slicert()(goto_functions, ns, a);
383383
}
384384

385+
void full_slicer(goto_modelt &goto_model)
386+
{
387+
assert_criteriont a;
388+
const namespacet ns(goto_model.symbol_table);
389+
full_slicert()(goto_model.goto_functions, ns, a);
390+
}
391+
385392
void property_slicer(
386393
goto_functionst &goto_functions,
387394
const namespacet &ns,
@@ -391,6 +398,14 @@ void property_slicer(
391398
full_slicert()(goto_functions, ns, p);
392399
}
393400

401+
void property_slicer(
402+
goto_modelt &goto_model,
403+
const std::list<std::string> &properties)
404+
{
405+
const namespacet ns(goto_model.symbol_table);
406+
property_slicer(goto_model.goto_functions, ns, properties);
407+
}
408+
394409
slicing_criteriont::~slicing_criteriont()
395410
{
396411
}

src/goto-instrument/full_slicer.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,21 @@ Author: Daniel Kroening, [email protected]
1212
#ifndef CPROVER_GOTO_INSTRUMENT_FULL_SLICER_H
1313
#define CPROVER_GOTO_INSTRUMENT_FULL_SLICER_H
1414

15-
#include <goto-programs/goto_functions.h>
15+
#include <goto-programs/goto_model.h>
1616

1717
void full_slicer(
18-
goto_functionst &goto_functions,
19-
const namespacet &ns);
18+
goto_functionst &,
19+
const namespacet &);
20+
21+
void full_slicer(goto_modelt &);
2022

2123
void property_slicer(
22-
goto_functionst &goto_functions,
23-
const namespacet &ns,
24+
goto_functionst &,
25+
const namespacet &,
26+
const std::list<std::string> &properties);
27+
28+
void property_slicer(
29+
goto_modelt &,
2430
const std::list<std::string> &properties);
2531

2632
class slicing_criteriont

src/goto-instrument/nondet_static.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Date: November 2011
1919
#include <util/cprover_prefix.h>
2020
#include <util/prefix.h>
2121

22+
#include <goto-programs/goto_model.h>
2223
#include <goto-programs/goto_functions.h>
2324

2425
void nondet_static(
@@ -70,7 +71,6 @@ void nondet_static(
7071
}
7172
}
7273

73-
7474
void nondet_static(
7575
const namespacet &ns,
7676
goto_functionst &goto_functions)
@@ -80,3 +80,9 @@ void nondet_static(
8080
// update counters etc.
8181
goto_functions.update();
8282
}
83+
84+
void nondet_static(goto_modelt &goto_model)
85+
{
86+
const namespacet ns(goto_model.symbol_table);
87+
nondet_static(ns, goto_model.goto_functions);
88+
}

src/goto-instrument/nondet_static.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ Date: November 2011
1717

1818
class goto_functionst;
1919
class namespacet;
20+
class goto_modelt;
2021

2122
void nondet_static(
22-
const namespacet &ns,
23-
goto_functionst &goto_functions);
23+
const namespacet &,
24+
goto_functionst &);
25+
26+
void nondet_static(goto_modelt &);
2427

2528
#endif // CPROVER_GOTO_INSTRUMENT_NONDET_STATIC_H

src/goto-programs/convert_nondet.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ Author: Reuben Thomas, [email protected]
99
/// \file
1010
/// Convert side_effect_expr_nondett expressions
1111

12-
#include "goto-programs/convert_nondet.h"
13-
#include "goto-programs/goto_convert.h"
14-
#include "goto-programs/goto_model.h"
15-
#include "goto-programs/remove_skip.h"
12+
#include "convert_nondet.h"
13+
#include "goto_convert.h"
14+
#include "goto_model.h"
15+
#include "remove_skip.h"
1616

17-
#include <memory>
18-
#include "java_bytecode/java_object_factory.h" // gen_nondet_init
17+
#include <java_bytecode/java_object_factory.h> // gen_nondet_init
18+
19+
#include <util/irep_ids.h>
1920

20-
#include "util/irep_ids.h"
21+
#include <memory>
2122

2223
/// Checks an instruction to see whether it contains an assignment from
2324
/// side_effect_expr_nondet. If so, replaces the instruction with a range of
@@ -111,7 +112,7 @@ static goto_programt::targett insert_nondet_init_code(
111112
/// \param symbol_table: The global symbol table.
112113
/// \param message_handler: Handles logging.
113114
/// \param max_nondet_array_length: Maximum size of new nondet arrays.
114-
static void convert_nondet(
115+
void convert_nondet(
115116
goto_programt &goto_program,
116117
symbol_tablet &symbol_table,
117118
message_handlert &message_handler,
@@ -132,8 +133,6 @@ static void convert_nondet(
132133
}
133134
}
134135

135-
136-
137136
void convert_nondet(
138137
goto_functionst &goto_functions,
139138
symbol_tablet &symbol_table,
@@ -155,3 +154,17 @@ void convert_nondet(
155154

156155
remove_skip(goto_functions);
157156
}
157+
158+
void convert_nondet(
159+
goto_modelt &goto_model,
160+
message_handlert &message_handler,
161+
size_t max_nondet_array_length,
162+
size_t max_nondet_tree_depth)
163+
{
164+
convert_nondet(
165+
goto_model.goto_functions,
166+
goto_model.symbol_table,
167+
message_handler,
168+
max_nondet_array_length,
169+
max_nondet_tree_depth);
170+
}

src/goto-programs/convert_nondet.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Author: Reuben Thomas, [email protected]
1616

1717
class goto_functionst;
1818
class symbol_tablet;
19+
class goto_modelt;
1920
class message_handlert;
2021

2122
/// Replace calls to nondet library functions with an internal nondet
@@ -27,10 +28,16 @@ class message_handlert;
2728
/// \param max_nondet_tree_depth: Maximum depth for object hierarchy on input
2829
/// parameterers.
2930
void convert_nondet(
30-
goto_functionst &goto_functions,
31-
symbol_tablet &symbol_table,
32-
message_handlert &message_handler,
33-
size_t max_nondet_array_length,
34-
size_t max_nondet_tree_depth);
31+
goto_functionst &,
32+
symbol_tablet &,
33+
message_handlert &,
34+
std::size_t max_nondet_array_length,
35+
std::size_t max_nondet_tree_depth);
36+
37+
void convert_nondet(
38+
goto_modelt &,
39+
message_handlert &,
40+
std::size_t max_nondet_array_length,
41+
std::size_t max_nondet_tree_depth);
3542

3643
#endif

src/goto-programs/remove_skip.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Author: Daniel Kroening, [email protected]
1010
/// Program Transformation
1111

1212
#include "remove_skip.h"
13+
#include "goto_model.h"
1314

1415
static bool is_skip(goto_programt::instructionst::iterator it)
1516
{
@@ -160,3 +161,9 @@ void remove_skip(goto_functionst &goto_functions)
160161
Forall_goto_functions(f_it, goto_functions)
161162
remove_skip(f_it->second.body);
162163
}
164+
165+
void remove_skip(goto_modelt &goto_model)
166+
{
167+
remove_skip(goto_model.goto_functions);
168+
}
169+

src/goto-programs/remove_skip.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ Author: Daniel Kroening, [email protected]
1414

1515
#include "goto_functions.h"
1616

17-
void remove_skip(goto_programt &goto_program);
18-
void remove_skip(goto_functionst &goto_functions);
17+
class goto_modelt;
18+
19+
void remove_skip(goto_programt &);
20+
void remove_skip(goto_functionst &);
21+
void remove_skip(goto_modelt &);
1922

2023
#endif // CPROVER_GOTO_PROGRAMS_REMOVE_SKIP_H

src/goto-programs/remove_unused_functions.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ Author: CM Wintersteiger
1313

1414
#include <util/message.h>
1515

16+
void remove_unused_functions(
17+
goto_modelt &goto_model,
18+
message_handlert &message_handler)
19+
{
20+
remove_unused_functions(goto_model.goto_functions, message_handler);
21+
}
22+
1623
void remove_unused_functions(
1724
goto_functionst &functions,
1825
message_handlert &message_handler)

src/goto-programs/remove_unused_functions.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ Author: CM Wintersteiger
1414

1515
#include <util/message.h>
1616

17-
#include <goto-programs/goto_functions.h>
17+
#include <goto-programs/goto_model.h>
1818

1919
void remove_unused_functions(
20-
goto_functionst &functions,
21-
message_handlert &message_handler);
20+
goto_functionst &,
21+
message_handlert &);
22+
23+
void remove_unused_functions(
24+
goto_modelt &,
25+
message_handlert &);
2226

2327
void find_used_functions(
2428
const irep_idt &current,

src/goto-programs/replace_java_nondet.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,6 @@ static void replace_java_nondet(goto_programt &goto_program)
235235
}
236236
}
237237

238-
239-
240238
void replace_java_nondet(goto_functionst &goto_functions)
241239
{
242240
for(auto &goto_program : goto_functions.function_map)
@@ -248,3 +246,9 @@ void replace_java_nondet(goto_functionst &goto_functions)
248246

249247
remove_skip(goto_functions);
250248
}
249+
250+
void replace_java_nondet(goto_modelt &goto_model)
251+
{
252+
replace_java_nondet(goto_model.goto_functions);
253+
}
254+

src/goto-programs/replace_java_nondet.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ Author: Reuben Thomas, [email protected]
1212
#ifndef CPROVER_GOTO_PROGRAMS_REPLACE_JAVA_NONDET_H
1313
#define CPROVER_GOTO_PROGRAMS_REPLACE_JAVA_NONDET_H
1414

15+
class goto_modelt;
1516
class goto_functionst;
1617

1718
/// Replace calls to nondet library functions with an internal nondet
1819
/// representation.
19-
/// \param goto_functions: The set of goto programs to modify.
20-
void replace_java_nondet(goto_functionst &goto_functions);
20+
/// \param goto_model: The goto program to modify.
21+
void replace_java_nondet(goto_modelt &);
22+
23+
void replace_java_nondet(goto_functionst &);
2124

2225
#endif

src/goto-programs/string_abstraction.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ void string_abstraction(
8282
string_abstraction(dest);
8383
}
8484

85+
void string_abstraction(
86+
goto_modelt &goto_model,
87+
message_handlert &message_handler)
88+
{
89+
string_abstraction(
90+
goto_model.symbol_table,
91+
message_handler,
92+
goto_model.goto_functions);
93+
}
94+
8595
string_abstractiont::string_abstractiont(
8696
symbol_tablet &_symbol_table,
8797
message_handlert &_message_handler):

0 commit comments

Comments
 (0)