Skip to content

Commit 88460bb

Browse files
Petr BauchPetr Bauch
Petr Bauch
authored and
Petr Bauch
committed
Fix based on comments
1 parent 8ffed53 commit 88460bb

10 files changed

+169
-138
lines changed

src/goto-harness/function_call_harness_generator.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ void function_call_harness_generatort::generate(
125125
body.add(goto_programt::make_end_function());
126126
}
127127

128-
void function_call_harness_generatort::validate_options()
128+
void function_call_harness_generatort::validate_options(
129+
const goto_modelt &goto_model)
129130
{
130131
if(p_impl->function == ID_empty)
131132
throw invalid_command_line_argument_exceptiont{

src/goto-harness/function_call_harness_generator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class function_call_harness_generatort : public goto_harness_generatort
3333
const std::string &option,
3434
const std::list<std::string> &values) override;
3535

36-
void validate_options() override;
36+
void validate_options(const goto_modelt &goto_model) override;
3737

3838
private:
3939
struct implt;

src/goto-harness/goto_harness_generator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class goto_harness_generatort
3535
const std::list<std::string> &values) = 0;
3636

3737
/// Check if options are in a sane state, throw otherwise
38-
virtual void validate_options() = 0;
38+
virtual void validate_options(const goto_modelt &goto_model) = 0;
3939

4040
/// Returns the only value of a single element list,
4141
/// throws an exception if not passed a single element list

src/goto-harness/goto_harness_generator_factory.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ void goto_harness_generator_factoryt::register_generator(
3131
std::unique_ptr<goto_harness_generatort>
3232
goto_harness_generator_factoryt::factory(
3333
const std::string &generator_name,
34-
const generator_optionst &generator_options)
34+
const generator_optionst &generator_options,
35+
const goto_modelt &goto_model)
3536
{
3637
auto it = generators.find(generator_name);
3738

@@ -42,7 +43,7 @@ goto_harness_generator_factoryt::factory(
4243
{
4344
generator->handle_option(option.first, option.second);
4445
}
45-
generator->validate_options();
46+
generator->validate_options(goto_model);
4647

4748
return generator;
4849
}

src/goto-harness/goto_harness_generator_factory.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class goto_harness_generator_factoryt
4848
/// throws if no generator with the supplied name is registered.
4949
std::unique_ptr<goto_harness_generatort> factory(
5050
const std::string &generator_name,
51-
const generator_optionst &generator_options);
51+
const generator_optionst &generator_options,
52+
const goto_modelt &goto_model);
5253

5354
private:
5455
std::map<std::string, build_generatort> generators;

src/goto-harness/goto_harness_parse_options.cpp

+20-5
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ int goto_harness_parse_optionst::doit()
5050

5151
auto factory_options = collect_generate_factory_options();
5252

53-
// Initialise harness generator
54-
auto harness_generator =
55-
factory.factory(got_harness_config.harness_type, factory_options);
56-
CHECK_RETURN(harness_generator != nullptr);
57-
5853
// This just sets up the defaults (and would interpret options such as --32).
5954
config.set(cmdline);
6055

@@ -67,8 +62,28 @@ int goto_harness_parse_optionst::doit()
6762
got_harness_config.in_file + "'"};
6863
}
6964
auto goto_model = std::move(read_goto_binary_result.value());
65+
66+
// This has to be called after the defaults are set up (as per the
67+
// config.set(cmdline) above) otherwise, e.g. the architecture specification
68+
// will be unknown.
7069
config.set_from_symbol_table(goto_model.symbol_table);
7170

71+
if(goto_model.symbol_table.has_symbol(
72+
got_harness_config.harness_function_name))
73+
{
74+
throw invalid_command_line_argument_exceptiont(
75+
"harness function `" +
76+
id2string(got_harness_config.harness_function_name) +
77+
"` already in "
78+
"the symbol table",
79+
"--" GOTO_HARNESS_GENERATOR_HARNESS_FUNCTION_NAME_OPT);
80+
}
81+
82+
// Initialise harness generator
83+
auto harness_generator = factory.factory(
84+
got_harness_config.harness_type, factory_options, goto_model);
85+
CHECK_RETURN(harness_generator != nullptr);
86+
7287
harness_generator->generate(
7388
goto_model, got_harness_config.harness_function_name);
7489

0 commit comments

Comments
 (0)