Skip to content

Commit f56e3c5

Browse files
author
Sonny Martin
committed
Validation checks for Goto Programs
There are several checks, implemented with separate methods, and some flagged as optional. NB use of validate_goto_model(*this, vm) in goto_functions.h is to avoid circular inclusion as function_mapt is a nested type and so cannot be forward declared.
1 parent 87b3b02 commit f56e3c5

11 files changed

+811
-32
lines changed

src/cbmc/cbmc_parse_options.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,32 @@ Author: Daniel Kroening, [email protected]
3030

3131
#include <cpp/cprover_library.h>
3232

33+
#include <goto-instrument/cover.h>
34+
#include <goto-instrument/full_slicer.h>
35+
#include <goto-instrument/nondet_static.h>
36+
#include <goto-instrument/reachability_slicer.h>
3337
#include <goto-programs/adjust_float_expressions.h>
3438
#include <goto-programs/initialize_goto_model.h>
3539
#include <goto-programs/instrument_preconditions.h>
3640
#include <goto-programs/link_to_library.h>
3741
#include <goto-programs/loop_ids.h>
3842
#include <goto-programs/mm_io.h>
3943
#include <goto-programs/read_goto_binary.h>
44+
#include <goto-programs/remove_asm.h>
45+
#include <goto-programs/remove_complex.h>
4046
#include <goto-programs/remove_function_pointers.h>
4147
#include <goto-programs/remove_returns.h>
42-
#include <goto-programs/remove_vector.h>
43-
#include <goto-programs/remove_complex.h>
44-
#include <goto-programs/remove_asm.h>
45-
#include <goto-programs/remove_unused_functions.h>
4648
#include <goto-programs/remove_skip.h>
49+
#include <goto-programs/remove_unused_functions.h>
50+
#include <goto-programs/remove_vector.h>
4751
#include <goto-programs/rewrite_union.h>
4852
#include <goto-programs/set_properties.h>
4953
#include <goto-programs/show_goto_functions.h>
50-
#include <goto-programs/show_symbol_table.h>
5154
#include <goto-programs/show_properties.h>
55+
#include <goto-programs/show_symbol_table.h>
5256
#include <goto-programs/string_abstraction.h>
5357
#include <goto-programs/string_instrumentation.h>
54-
55-
#include <goto-instrument/reachability_slicer.h>
56-
#include <goto-instrument/full_slicer.h>
57-
#include <goto-instrument/nondet_static.h>
58-
#include <goto-instrument/cover.h>
58+
#include <goto-programs/validate_goto_model.h>
5959

6060
#include <pointer-analysis/add_failed_symbols.h>
6161

@@ -532,7 +532,13 @@ int cbmc_parse_optionst::doit()
532532

533533
if(cmdline.isset("validate-goto-model"))
534534
{
535-
goto_model.validate(validation_modet::INVARIANT);
535+
goto_model_validation_optionst goto_model_validation_options;
536+
goto_model_validation_options.function_pointer_calls_removed = true;
537+
goto_model_validation_options.check_returns_removed = true;
538+
goto_model_validation_options.check_called_functions = true;
539+
goto_model_validation_options.check_last_instruction = true;
540+
goto_model.validate(
541+
validation_modet::INVARIANT, goto_model_validation_options);
536542
}
537543

538544
return bmct::do_language_agnostic_bmc(

src/goto-analyzer/goto_analyzer_parse_options.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Author: Daniel Kroening, [email protected]
3939
#include <goto-programs/set_properties.h>
4040
#include <goto-programs/show_properties.h>
4141
#include <goto-programs/show_symbol_table.h>
42+
#include <goto-programs/validate_goto_model.h>
4243

4344
#include <analyses/is_threaded.h>
4445
#include <analyses/goto_check.h>
@@ -408,7 +409,8 @@ int goto_analyzer_parse_optionst::doit()
408409

409410
if(cmdline.isset("validate-goto-model"))
410411
{
411-
goto_model.validate(validation_modet::INVARIANT);
412+
goto_model.validate(
413+
validation_modet::INVARIANT, goto_model_validation_optionst{});
412414
}
413415

414416
// show it?

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,27 @@ Author: Daniel Kroening, [email protected]
2424

2525
#include <goto-programs/class_hierarchy.h>
2626
#include <goto-programs/goto_convert_functions.h>
27-
#include <goto-programs/remove_calls_no_body.h>
28-
#include <goto-programs/remove_function_pointers.h>
29-
#include <goto-programs/remove_virtual_functions.h>
30-
#include <goto-programs/remove_skip.h>
3127
#include <goto-programs/goto_inline.h>
32-
#include <goto-programs/show_properties.h>
33-
#include <goto-programs/set_properties.h>
34-
#include <goto-programs/read_goto_binary.h>
35-
#include <goto-programs/write_goto_binary.h>
3628
#include <goto-programs/interpreter.h>
37-
#include <goto-programs/string_abstraction.h>
38-
#include <goto-programs/string_instrumentation.h>
39-
#include <goto-programs/loop_ids.h>
4029
#include <goto-programs/link_to_library.h>
41-
#include <goto-programs/remove_returns.h>
30+
#include <goto-programs/loop_ids.h>
31+
#include <goto-programs/parameter_assignments.h>
32+
#include <goto-programs/read_goto_binary.h>
4233
#include <goto-programs/remove_asm.h>
34+
#include <goto-programs/remove_calls_no_body.h>
35+
#include <goto-programs/remove_function_pointers.h>
36+
#include <goto-programs/remove_returns.h>
37+
#include <goto-programs/remove_skip.h>
4338
#include <goto-programs/remove_unused_functions.h>
44-
#include <goto-programs/parameter_assignments.h>
45-
#include <goto-programs/slice_global_inits.h>
39+
#include <goto-programs/remove_virtual_functions.h>
40+
#include <goto-programs/set_properties.h>
41+
#include <goto-programs/show_properties.h>
4642
#include <goto-programs/show_symbol_table.h>
43+
#include <goto-programs/slice_global_inits.h>
44+
#include <goto-programs/string_abstraction.h>
45+
#include <goto-programs/string_instrumentation.h>
46+
#include <goto-programs/validate_goto_model.h>
47+
#include <goto-programs/write_goto_binary.h>
4748

4849
#include <pointer-analysis/value_set_analysis.h>
4950
#include <pointer-analysis/goto_program_dereference.h>
@@ -130,7 +131,8 @@ int goto_instrument_parse_optionst::doit()
130131

131132
if(validate_only || cmdline.isset("validate-goto-model"))
132133
{
133-
goto_model.validate(validation_modet::EXCEPTION);
134+
goto_model.validate(
135+
validation_modet::EXCEPTION, goto_model_validation_optionst{});
134136

135137
if(validate_only)
136138
{
@@ -143,7 +145,8 @@ int goto_instrument_parse_optionst::doit()
143145

144146
if(cmdline.isset("validate-goto-model"))
145147
{
146-
goto_model.validate(validation_modet::INVARIANT);
148+
goto_model.validate(
149+
validation_modet::INVARIANT, goto_model_validation_optionst{});
147150
}
148151

149152
{

src/goto-programs/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ SRC = adjust_float_expressions.cpp \
6464
string_abstraction.cpp \
6565
string_instrumentation.cpp \
6666
system_library_symbols.cpp \
67+
validate_goto_model.cpp \
6768
vcd_goto_trace.cpp \
6869
wp.cpp \
6970
write_goto_binary.cpp \

src/goto-programs/goto_functions.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Date: June 2003
1616

1717
#include "goto_function.h"
1818

19+
#include "validate_goto_model.h"
1920
#include <util/cprover_prefix.h>
2021

2122
/// A collection of goto functions
@@ -122,8 +123,12 @@ class goto_functionst
122123
///
123124
/// The validation mode indicates whether well-formedness check failures are
124125
/// reported via DATA_INVARIANT violations or exceptions.
125-
void validate(const namespacet &ns, const validation_modet vm) const
126+
void validate(
127+
const namespacet &ns,
128+
const validation_modet vm,
129+
const goto_model_validation_optionst &goto_model_validation_options) const
126130
{
131+
validate_goto_model(*this, vm, goto_model_validation_options);
127132
for(const auto &entry : function_map)
128133
{
129134
const goto_functiont &goto_function = entry.second;

src/goto-programs/goto_model.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,14 @@ class goto_modelt : public abstract_goto_modelt
9494
///
9595
/// The validation mode indicates whether well-formedness check failures are
9696
/// reported via DATA_INVARIANT violations or exceptions.
97-
void validate(const validation_modet vm) const
97+
void validate(
98+
const validation_modet vm,
99+
const goto_model_validation_optionst &goto_model_validation_options) const
98100
{
99101
symbol_table.validate(vm);
100102

101103
const namespacet ns(symbol_table);
102-
goto_functions.validate(ns, vm);
104+
goto_functions.validate(ns, vm, goto_model_validation_options);
103105
}
104106
};
105107

src/goto-programs/initialize_goto_model.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ goto_modelt initialize_goto_model(
167167

168168
if(cmdline.isset("validate-goto-model"))
169169
{
170-
goto_model.validate(validation_modet::EXCEPTION);
170+
goto_model.validate(
171+
validation_modet::EXCEPTION, goto_model_validation_optionst{});
171172
}
172173

173174
// stupid hack

0 commit comments

Comments
 (0)