Skip to content

Commit 2300801

Browse files
committed
Pass c object factory parameters to function body generation
Parse the c object factory command line parameters when the function body generation is enabled, and pass the resulting c_object_factory_parameterst object along to an appropriate subclass of generate_function_bodiest.
1 parent 0f1a5a5 commit 2300801

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

src/goto-instrument/generate_function_bodies.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,13 @@ class havoc_generate_function_bodiest : public generate_function_bodiest,
157157
havoc_generate_function_bodiest(
158158
std::vector<irep_idt> globals_to_havoc,
159159
std::regex parameters_to_havoc,
160+
const c_object_factory_parameterst &object_factory_parameters,
160161
message_handlert &message_handler)
161162
: generate_function_bodiest(),
162163
messaget(message_handler),
163164
globals_to_havoc(std::move(globals_to_havoc)),
164-
parameters_to_havoc(std::move(parameters_to_havoc))
165+
parameters_to_havoc(std::move(parameters_to_havoc)),
166+
object_factory_parameters(object_factory_parameters)
165167
{
166168
}
167169

@@ -322,6 +324,7 @@ class havoc_generate_function_bodiest : public generate_function_bodiest,
322324
private:
323325
const std::vector<irep_idt> globals_to_havoc;
324326
std::regex parameters_to_havoc;
327+
const c_object_factory_parameterst &object_factory_parameters;
325328
};
326329

327330
class generate_function_bodies_errort : public std::runtime_error
@@ -337,13 +340,17 @@ class generate_function_bodies_errort : public std::runtime_error
337340
/// \see generate_function_bodies for the syntax of the options parameter
338341
std::unique_ptr<generate_function_bodiest> generate_function_bodies_factory(
339342
const std::string &options,
343+
const c_object_factory_parameterst &object_factory_parameters,
340344
const symbol_tablet &symbol_table,
341345
message_handlert &message_handler)
342346
{
343347
if(options.empty() || options == "nondet-return")
344348
{
345349
return util_make_unique<havoc_generate_function_bodiest>(
346-
std::vector<irep_idt>{}, std::regex{}, message_handler);
350+
std::vector<irep_idt>{},
351+
std::regex{},
352+
object_factory_parameters,
353+
message_handler);
347354
}
348355

349356
if(options == "assume-false")
@@ -412,7 +419,10 @@ std::unique_ptr<generate_function_bodiest> generate_function_bodies_factory(
412419
}
413420
}
414421
return util_make_unique<havoc_generate_function_bodiest>(
415-
std::move(globals_to_havoc), std::move(params_regex), message_handler);
422+
std::move(globals_to_havoc),
423+
std::move(params_regex),
424+
object_factory_parameters,
425+
message_handler);
416426
}
417427
throw generate_function_bodies_errort("Can't parse \"" + options + "\"");
418428
}

src/goto-instrument/generate_function_bodies.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Author: Diffblue Ltd.
1212
#include <memory>
1313
#include <regex>
1414

15+
#include <ansi-c/c_object_factory_parameters.h>
1516
#include <goto-programs/goto_function.h>
1617
#include <goto-programs/goto_model.h>
1718
#include <util/cmdline.h>
@@ -59,6 +60,7 @@ class generate_function_bodiest
5960

6061
std::unique_ptr<generate_function_bodiest> generate_function_bodies_factory(
6162
const std::string &options,
63+
const c_object_factory_parameterst &object_factory_parameters,
6264
const symbol_tablet &symbol_table,
6365
message_handlert &message_handler);
6466

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ Author: Daniel Kroening, kroening@kroening.com
6464
#include <analyses/is_threaded.h>
6565
#include <analyses/local_safe_pointers.h>
6666

67+
#include <ansi-c/ansi_c_language.h>
68+
#include <ansi-c/c_object_factory_parameters.h>
6769
#include <ansi-c/cprover_library.h>
6870
#include <cpp/cprover_library.h>
6971

@@ -1187,8 +1189,14 @@ void goto_instrument_parse_optionst::instrument_goto_program()
11871189

11881190
if(cmdline.isset("generate-function-body"))
11891191
{
1192+
optionst c_object_factory_options;
1193+
parse_c_object_factory_options(cmdline, c_object_factory_options);
1194+
c_object_factory_parameterst object_factory_parameters(
1195+
c_object_factory_options);
1196+
11901197
auto generate_implementation = generate_function_bodies_factory(
11911198
cmdline.get_value("generate-function-body-options"),
1199+
object_factory_parameters,
11921200
goto_model.symbol_table,
11931201
*message_handler);
11941202
generate_function_bodies(
@@ -1622,6 +1630,7 @@ void goto_instrument_parse_optionst::help()
16221630
// NOLINTNEXTLINE(whitespace/line_length)
16231631
" convert each call to an undefined function to assume(false)\n"
16241632
HELP_REPLACE_FUNCTION_BODY
1633+
HELP_ANSI_C_LANGUAGE
16251634
"\n"
16261635
"Loop transformations:\n"
16271636
" --k-induction <k> check loops with k-induction\n"

src/goto-instrument/goto_instrument_parse_options.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Author: Daniel Kroening, kroening@kroening.com
1212
#ifndef CPROVER_GOTO_INSTRUMENT_GOTO_INSTRUMENT_PARSE_OPTIONS_H
1313
#define CPROVER_GOTO_INSTRUMENT_GOTO_INSTRUMENT_PARSE_OPTIONS_H
1414

15+
#include <ansi-c/ansi_c_language.h>
16+
1517
#include <util/parse_options.h>
1618
#include <util/timestamper.h>
1719
#include <util/ui_message.h>
@@ -104,6 +106,7 @@ Author: Daniel Kroening, kroening@kroening.com
104106
OPT_REPLACE_CALLS \
105107
"(validate-goto-binary)" \
106108
OPT_VALIDATE \
109+
OPT_ANSI_C_LANGUAGE \
107110
// empty last line
108111

109112
// clang-format on

0 commit comments

Comments
 (0)