Skip to content

Commit bd38fc4

Browse files
committed
add command line option handling methods
1 parent 0668c0f commit bd38fc4

6 files changed

+26
-8
lines changed

src/goto-harness/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
SRC = \
22
function_call_harness_generator.cpp \
3+
goto_harness_generator.cpp \
34
goto_harness_generator_factory.cpp \
45
goto_harness_main.cpp \
56
goto_harness_parse_options.cpp \

src/goto-harness/function_call_harness_generator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ function_call_harness_generatort::~function_call_harness_generatort() = default;
3636

3737
void function_call_harness_generatort::handle_option(
3838
const std::string &option,
39-
const std::string &value)
39+
const std::list<std::string> &values)
4040
{
4141
if(option == FUNCTION_HARNESS_GENERATOR_FUNCTION_OPT)
4242
{
43-
p_impl->function = value;
43+
p_impl->function = require_exactly_one_value(option, values);
4444
}
4545
else
4646
{

src/goto-harness/function_call_harness_generator.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Author: Diffblue Ltd.
99
#ifndef CPROVER_GOTO_HARNESS_FUNCTION_CALL_HARNESS_GENERATOR_H
1010
#define CPROVER_GOTO_HARNESS_FUNCTION_CALL_HARNESS_GENERATOR_H
1111

12+
#include <list>
1213
#include <memory>
1314
#include <string>
1415

@@ -28,8 +29,9 @@ class function_call_harness_generatort : public goto_harness_generatort
2829
override;
2930

3031
protected:
31-
void
32-
handle_option(const std::string &option, const std::string &value) override;
32+
void handle_option(
33+
const std::string &option,
34+
const std::list<std::string> &values) override;
3335

3436
void validate_options() override;
3537

src/goto-harness/goto_harness_generator.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Author: Diffblue Ltd.
99
#ifndef CPROVER_GOTO_HARNESS_GOTO_HARNESS_GENERATOR_H
1010
#define CPROVER_GOTO_HARNESS_GOTO_HARNESS_GENERATOR_H
1111

12+
#include <list>
13+
#include <string>
14+
1215
#include <util/irep.h>
1316

1417
class goto_modelt;
@@ -27,11 +30,23 @@ class goto_harness_generatort
2730
/// Handle a command line argument. Should throw an exception if the option
2831
/// doesn't apply to this generator. Should only set options rather than
2932
/// immediately performing work
30-
virtual void
31-
handle_option(const std::string &option, const std::string &value) = 0;
33+
virtual void handle_option(
34+
const std::string &option,
35+
const std::list<std::string> &values) = 0;
3236

3337
/// Check if options are in a sane state, throw otherwise
3438
virtual void validate_options() = 0;
39+
40+
/// Returns the only value of a single element list,
41+
/// throws an exception if not passed a single element list
42+
static std::string require_exactly_one_value(
43+
const std::string &option,
44+
const std::list<std::string> &values);
45+
46+
/// Asserts that the list of values to an option passed is empty
47+
static void assert_no_values(
48+
const std::string &option,
49+
const std::list<std::string> &values);
3550
};
3651

3752
#endif // CPROVER_GOTO_HARNESS_GOTO_HARNESS_GENERATOR_H

src/goto-harness/goto_harness_generator_factory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class goto_harness_generator_factoryt
3535
using build_generatort =
3636
std::function<std::unique_ptr<goto_harness_generatort>()>;
3737

38-
using generator_optionst = std::map<std::string, std::string>;
38+
using generator_optionst = std::map<std::string, std::list<std::string>>;
3939

4040
/// register a new goto-harness generator with the given name.
4141
/// \param generator_name: name of newly registered generator

src/goto-harness/goto_harness_parse_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ goto_harness_parse_optionst::collect_generate_factory_options()
180180
{
181181
if(common_options.find(option) == common_options.end())
182182
{
183-
factory_options.insert({option, cmdline.get_value(option.c_str())});
183+
factory_options.insert({option, cmdline.get_values(option.c_str())});
184184
}
185185
}
186186

0 commit comments

Comments
 (0)