@@ -16,6 +16,8 @@ Date: May 2016
1616#include < util/config.h>
1717#include < util/message.h>
1818#include < util/make_unique.h>
19+ #include < util/cmdline.h>
20+ #include < util/options.h>
1921
2022#include " cover_basic_blocks.h"
2123#include " cover_filter.h"
@@ -141,6 +143,28 @@ parse_coverage_criterion(const std::string &criterion_string)
141143 return c;
142144}
143145
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+
144168// / Applies instrumenters to given goto functions
145169// / \param goto_functions: the goto functions
146170// / \param instrumenters: the instrumenters
@@ -162,12 +186,12 @@ void instrument_cover_goals(
162186}
163187
164188// / Instruments goto functions based on given command line options
165- // / \param cmdline : the command line
189+ // / \param options : the options
166190// / \param symbol_table: the symbol table
167191// / \param goto_functions: the goto functions
168192// / \param message_handler: a message handler
169193bool instrument_cover_goals (
170- const cmdlinet &cmdline ,
194+ const optionst &options ,
171195 const symbol_tablet &symbol_table,
172196 goto_functionst &goto_functions,
173197 message_handlert &message_handler)
@@ -183,7 +207,7 @@ bool instrument_cover_goals(
183207
184208 cover_instrumenterst instrumenters;
185209
186- std::list<std::string> criteria_strings=cmdline. get_values (" cover" );
210+ optionst::value_listt criteria_strings = options. get_list_option (" cover" );
187211 bool keep_assertions=false ;
188212
189213 for (const auto &criterion_string : criteria_strings)
@@ -230,22 +254,15 @@ bool instrument_cover_goals(
230254
231255 // cover entry point function only
232256 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" );
241258 if (!cover_include_pattern.empty ())
242259 {
243260 function_filters.add (
244261 util_make_unique<include_pattern_filtert>(
245262 message_handler, cover_include_pattern));
246263 }
247264
248- if (cmdline. isset (" no-trivial-tests" ))
265+ if (options. get_bool_option (" no-trivial-tests" ))
249266 function_filters.add (
250267 util_make_unique<trivial_functions_filtert>(message_handler));
251268
@@ -257,7 +274,7 @@ bool instrument_cover_goals(
257274 function_filters.report_anomalies ();
258275 goal_filters.report_anomalies ();
259276
260- if (cmdline. isset (" cover-traces-must-terminate" ))
277+ if (options. get_bool_option (" cover-traces-must-terminate" ))
261278 {
262279 // instrument an additional goal in CPROVER_START. This will rephrase
263280 // the reachability problem by asking BMC to provide a solution that
@@ -279,16 +296,16 @@ bool instrument_cover_goals(
279296}
280297
281298// / Instruments a goto model based on given command line options
282- // / \param cmdline : the command line
299+ // / \param options : the options
283300// / \param goto_model: the goto model
284301// / \param message_handler: a message handler
285302bool instrument_cover_goals (
286- const cmdlinet &cmdline ,
303+ const optionst &options ,
287304 goto_modelt &goto_model,
288305 message_handlert &message_handler)
289306{
290307 return instrument_cover_goals (
291- cmdline ,
308+ options ,
292309 goto_model.symbol_table ,
293310 goto_model.goto_functions ,
294311 message_handler);
0 commit comments