Skip to content

Commit 2d24e4a

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 744c6f3 commit 2d24e4a

File tree

11 files changed

+793
-27
lines changed

11 files changed

+793
-27
lines changed

src/cbmc/cbmc_parse_options.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,34 @@ Author: Daniel Kroening, [email protected]
4646
#include <goto-checker/stop_on_fail_verifier.h>
4747
#include <goto-checker/stop_on_fail_verifier_with_fault_localization.h>
4848

49+
#include <goto-instrument/cover.h>
50+
#include <goto-instrument/full_slicer.h>
51+
#include <goto-instrument/nondet_static.h>
52+
#include <goto-instrument/reachability_slicer.h>
4953
#include <goto-programs/adjust_float_expressions.h>
5054
#include <goto-programs/initialize_goto_model.h>
5155
#include <goto-programs/instrument_preconditions.h>
5256
#include <goto-programs/link_to_library.h>
5357
#include <goto-programs/loop_ids.h>
5458
#include <goto-programs/mm_io.h>
5559
#include <goto-programs/read_goto_binary.h>
60+
#include <goto-programs/remove_complex.h>
5661
#include <goto-programs/remove_function_pointers.h>
5762
#include <goto-programs/remove_returns.h>
5863
#include <goto-programs/remove_vector.h>
5964
#include <goto-programs/remove_complex.h>
6065
#include <goto-programs/remove_unused_functions.h>
6166
#include <goto-programs/remove_skip.h>
67+
#include <goto-programs/remove_unused_functions.h>
68+
#include <goto-programs/remove_vector.h>
6269
#include <goto-programs/rewrite_union.h>
6370
#include <goto-programs/set_properties.h>
6471
#include <goto-programs/show_goto_functions.h>
65-
#include <goto-programs/show_symbol_table.h>
6672
#include <goto-programs/show_properties.h>
73+
#include <goto-programs/show_symbol_table.h>
6774
#include <goto-programs/string_abstraction.h>
6875
#include <goto-programs/string_instrumentation.h>
69-
70-
#include <goto-instrument/reachability_slicer.h>
71-
#include <goto-instrument/full_slicer.h>
72-
#include <goto-instrument/nondet_static.h>
73-
#include <goto-instrument/cover.h>
76+
#include <goto-programs/validate_goto_model.h>
7477

7578
#include <goto-symex/path_storage.h>
7679

@@ -550,7 +553,13 @@ int cbmc_parse_optionst::doit()
550553

551554
if(cmdline.isset("validate-goto-model"))
552555
{
553-
goto_model.validate(validation_modet::INVARIANT);
556+
goto_model_validation_optionst goto_model_validation_options;
557+
goto_model_validation_options.function_pointer_calls_removed = true;
558+
goto_model_validation_options.check_returns_removed = true;
559+
goto_model_validation_options.check_called_functions = true;
560+
goto_model_validation_options.check_last_instruction = true;
561+
goto_model.validate(
562+
validation_modet::INVARIANT, goto_model_validation_options);
554563
}
555564

556565
if(

src/goto-analyzer/goto_analyzer_parse_options.cpp

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

4445
#include <analyses/is_threaded.h>
4546
#include <analyses/goto_check.h>
@@ -405,7 +406,8 @@ int goto_analyzer_parse_optionst::doit()
405406

406407
if(cmdline.isset("validate-goto-model"))
407408
{
408-
goto_model.validate(validation_modet::INVARIANT);
409+
goto_model.validate(
410+
validation_modet::INVARIANT, goto_model_validation_optionst{});
409411
}
410412

411413
// show it?

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,26 @@ Author: Daniel Kroening, [email protected]
2525

2626
#include <goto-programs/class_hierarchy.h>
2727
#include <goto-programs/goto_convert_functions.h>
28-
#include <goto-programs/remove_calls_no_body.h>
29-
#include <goto-programs/remove_function_pointers.h>
30-
#include <goto-programs/remove_virtual_functions.h>
31-
#include <goto-programs/remove_skip.h>
3228
#include <goto-programs/goto_inline.h>
33-
#include <goto-programs/show_properties.h>
34-
#include <goto-programs/set_properties.h>
35-
#include <goto-programs/read_goto_binary.h>
36-
#include <goto-programs/write_goto_binary.h>
3729
#include <goto-programs/interpreter.h>
38-
#include <goto-programs/string_abstraction.h>
39-
#include <goto-programs/string_instrumentation.h>
40-
#include <goto-programs/loop_ids.h>
4130
#include <goto-programs/link_to_library.h>
4231
#include <goto-programs/remove_returns.h>
43-
#include <goto-programs/remove_unused_functions.h>
32+
#include <goto-programs/loop_ids.h>
4433
#include <goto-programs/parameter_assignments.h>
45-
#include <goto-programs/slice_global_inits.h>
34+
#include <goto-programs/read_goto_binary.h>
35+
#include <goto-programs/remove_calls_no_body.h>
36+
#include <goto-programs/remove_function_pointers.h>
37+
#include <goto-programs/remove_skip.h>
38+
#include <goto-programs/remove_unused_functions.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>
@@ -134,7 +135,8 @@ int goto_instrument_parse_optionst::doit()
134135

135136
if(validate_only || cmdline.isset("validate-goto-model"))
136137
{
137-
goto_model.validate(validation_modet::EXCEPTION);
138+
goto_model.validate(
139+
validation_modet::EXCEPTION, goto_model_validation_optionst{});
138140

139141
if(validate_only)
140142
{
@@ -147,7 +149,8 @@ int goto_instrument_parse_optionst::doit()
147149

148150
if(cmdline.isset("validate-goto-model"))
149151
{
150-
goto_model.validate(validation_modet::INVARIANT);
152+
goto_model.validate(
153+
validation_modet::INVARIANT, goto_model_validation_optionst{});
151154
}
152155

153156
{

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
@@ -111,8 +112,12 @@ class goto_functionst
111112
///
112113
/// The validation mode indicates whether well-formedness check failures are
113114
/// reported via DATA_INVARIANT violations or exceptions.
114-
void validate(const namespacet &ns, const validation_modet vm) const
115+
void validate(
116+
const namespacet &ns,
117+
const validation_modet vm,
118+
const goto_model_validation_optionst &goto_model_validation_options) const
115119
{
120+
validate_goto_model(*this, vm, goto_model_validation_options);
116121
for(const auto &entry : function_map)
117122
{
118123
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 override
97+
void validate(
98+
const validation_modet vm,
99+
const goto_model_validation_optionst &goto_model_validation_options) const override
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
@@ -194,7 +194,8 @@ goto_modelt initialize_goto_model(
194194

195195
if(options.is_set("validate-goto-model"))
196196
{
197-
goto_model.validate(validation_modet::EXCEPTION);
197+
goto_model.validate(
198+
validation_modet::EXCEPTION, goto_model_validation_optionst{});
198199
}
199200

200201
// stupid hack

0 commit comments

Comments
 (0)