@@ -16,6 +16,8 @@ Date: May 2016
16
16
#include < util/config.h>
17
17
#include < util/message.h>
18
18
#include < util/make_unique.h>
19
+ #include < util/cmdline.h>
20
+ #include < util/options.h>
19
21
20
22
#include " cover_basic_blocks.h"
21
23
#include " cover_filter.h"
@@ -141,6 +143,28 @@ parse_coverage_criterion(const std::string &criterion_string)
141
143
return c;
142
144
}
143
145
146
+ // / Parses coverage-related command line options
147
+ // / \param cmdline: the command line
148
+ // / \param options: the options
149
+ void parse_cover_options (const cmdlinet &cmdline, optionst &options)
150
+ {
151
+ options.set_option (" cover" , cmdline.get_values (" cover" ));
152
+ std::string cover_include_pattern =
153
+ cmdline.get_value (" cover-include-pattern" );
154
+ if (cmdline.isset (" cover-function-only" ))
155
+ {
156
+ std::regex special_characters (
157
+ " \\ .|\\\\ |\\ *|\\ +|\\ ?|\\ {|\\ }|\\ [|\\ ]|\\ (|\\ )|\\ ^|\\ $|\\ |" );
158
+ cover_include_pattern =
159
+ " .*" + std::regex_replace (config.main , special_characters, " \\ $&" ) + " .*" ;
160
+ }
161
+ options.set_option (" cover-include-pattern" , cover_include_pattern);
162
+ options.set_option (" no-trivial-tests" , cmdline.isset (" no-trivial-tests" ));
163
+ options.set_option (
164
+ " cover-traces-must-terminate" ,
165
+ cmdline.isset (" cover-traces-must-terminate" ));
166
+ }
167
+
144
168
// / Applies instrumenters to given goto functions
145
169
// / \param goto_functions: the goto functions
146
170
// / \param instrumenters: the instrumenters
@@ -162,12 +186,12 @@ void instrument_cover_goals(
162
186
}
163
187
164
188
// / Instruments goto functions based on given command line options
165
- // / \param cmdline : the command line
189
+ // / \param options : the options
166
190
// / \param symbol_table: the symbol table
167
191
// / \param goto_functions: the goto functions
168
192
// / \param message_handler: a message handler
169
193
bool instrument_cover_goals (
170
- const cmdlinet &cmdline ,
194
+ const optionst &options ,
171
195
const symbol_tablet &symbol_table,
172
196
goto_functionst &goto_functions,
173
197
message_handlert &message_handler)
@@ -183,7 +207,7 @@ bool instrument_cover_goals(
183
207
184
208
cover_instrumenterst instrumenters;
185
209
186
- std::list<std::string> criteria_strings=cmdline. get_values (" cover" );
210
+ optionst::value_listt criteria_strings = options. get_list_option (" cover" );
187
211
bool keep_assertions=false ;
188
212
189
213
for (const auto &criterion_string : criteria_strings)
@@ -230,22 +254,15 @@ bool instrument_cover_goals(
230
254
231
255
// cover entry point function only
232
256
std::string cover_include_pattern =
233
- cmdline.get_value (" cover-include-pattern" );
234
- if (cmdline.isset (" cover-function-only" ))
235
- {
236
- std::regex special_characters (
237
- " \\ .|\\\\ |\\ *|\\ +|\\ ?|\\ {|\\ }|\\ [|\\ ]|\\ (|\\ )|\\ ^|\\ $|\\ |" );
238
- cover_include_pattern =
239
- " .*" + std::regex_replace (config.main , special_characters, " \\ $&" ) + " .*" ;
240
- }
257
+ options.get_option (" cover-include-pattern" );
241
258
if (!cover_include_pattern.empty ())
242
259
{
243
260
function_filters.add (
244
261
util_make_unique<include_pattern_filtert>(
245
262
message_handler, cover_include_pattern));
246
263
}
247
264
248
- if (cmdline. isset (" no-trivial-tests" ))
265
+ if (options. get_bool_option (" no-trivial-tests" ))
249
266
function_filters.add (
250
267
util_make_unique<trivial_functions_filtert>(message_handler));
251
268
@@ -257,7 +274,7 @@ bool instrument_cover_goals(
257
274
function_filters.report_anomalies ();
258
275
goal_filters.report_anomalies ();
259
276
260
- if (cmdline. isset (" cover-traces-must-terminate" ))
277
+ if (options. get_bool_option (" cover-traces-must-terminate" ))
261
278
{
262
279
// instrument an additional goal in CPROVER_START. This will rephrase
263
280
// the reachability problem by asking BMC to provide a solution that
@@ -279,16 +296,16 @@ bool instrument_cover_goals(
279
296
}
280
297
281
298
// / Instruments a goto model based on given command line options
282
- // / \param cmdline : the command line
299
+ // / \param options : the options
283
300
// / \param goto_model: the goto model
284
301
// / \param message_handler: a message handler
285
302
bool instrument_cover_goals (
286
- const cmdlinet &cmdline ,
303
+ const optionst &options ,
287
304
goto_modelt &goto_model,
288
305
message_handlert &message_handler)
289
306
{
290
307
return instrument_cover_goals (
291
- cmdline ,
308
+ options ,
292
309
goto_model.symbol_table ,
293
310
goto_model.goto_functions ,
294
311
message_handler);
0 commit comments