-
Notifications
You must be signed in to change notification settings - Fork 274
Goto programs validation #3191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Goto programs validation #3191
Changes from 9 commits
5fddbcd
8bd353c
2ec4b83
4cd976f
a3b5513
6cc09c9
ca11166
ab3cb60
1fb1129
971c788
b5b1f64
a1de5dc
6ba2cf4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,24 +53,25 @@ Author: Daniel Kroening, [email protected] | |
#include <goto-programs/loop_ids.h> | ||
#include <goto-programs/mm_io.h> | ||
#include <goto-programs/read_goto_binary.h> | ||
#include <goto-programs/remove_complex.h> | ||
#include <goto-programs/remove_function_pointers.h> | ||
#include <goto-programs/remove_returns.h> | ||
#include <goto-programs/remove_vector.h> | ||
#include <goto-programs/remove_complex.h> | ||
#include <goto-programs/remove_unused_functions.h> | ||
#include <goto-programs/remove_skip.h> | ||
#include <goto-programs/remove_unused_functions.h> | ||
#include <goto-programs/remove_vector.h> | ||
#include <goto-programs/rewrite_union.h> | ||
#include <goto-programs/set_properties.h> | ||
#include <goto-programs/show_goto_functions.h> | ||
#include <goto-programs/show_symbol_table.h> | ||
#include <goto-programs/show_properties.h> | ||
#include <goto-programs/show_symbol_table.h> | ||
#include <goto-programs/string_abstraction.h> | ||
#include <goto-programs/string_instrumentation.h> | ||
#include <goto-programs/validate_goto_model.h> | ||
|
||
#include <goto-instrument/reachability_slicer.h> | ||
#include <goto-instrument/cover.h> | ||
#include <goto-instrument/full_slicer.h> | ||
#include <goto-instrument/nondet_static.h> | ||
#include <goto-instrument/cover.h> | ||
#include <goto-instrument/reachability_slicer.h> | ||
|
||
#include <goto-symex/path_storage.h> | ||
|
||
|
@@ -550,7 +551,10 @@ int cbmc_parse_optionst::doit() | |
|
||
if(cmdline.isset("validate-goto-model")) | ||
{ | ||
goto_model.validate(validation_modet::INVARIANT); | ||
goto_model.validate( | ||
validation_modet::INVARIANT, | ||
goto_model_validation_optionst{ | ||
goto_model_validation_optionst::set_optionst::all_true}); | ||
} | ||
|
||
if( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ Author: Daniel Kroening, [email protected] | |
#include <goto-programs/set_properties.h> | ||
#include <goto-programs/show_properties.h> | ||
#include <goto-programs/show_symbol_table.h> | ||
#include <goto-programs/validate_goto_model.h> | ||
|
||
#include <analyses/is_threaded.h> | ||
#include <analyses/goto_check.h> | ||
|
@@ -405,7 +406,10 @@ int goto_analyzer_parse_optionst::doit() | |
|
||
if(cmdline.isset("validate-goto-model")) | ||
{ | ||
goto_model.validate(validation_modet::INVARIANT); | ||
goto_model.validate( | ||
validation_modet::INVARIANT, | ||
goto_model_validation_optionst{ | ||
goto_model_validation_optionst::set_optionst::all_true}); | ||
} | ||
|
||
// show it? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,25 +25,26 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include <goto-programs/class_hierarchy.h> | ||
#include <goto-programs/goto_convert_functions.h> | ||
#include <goto-programs/remove_calls_no_body.h> | ||
#include <goto-programs/remove_function_pointers.h> | ||
#include <goto-programs/remove_virtual_functions.h> | ||
#include <goto-programs/remove_skip.h> | ||
#include <goto-programs/goto_inline.h> | ||
#include <goto-programs/show_properties.h> | ||
#include <goto-programs/set_properties.h> | ||
#include <goto-programs/read_goto_binary.h> | ||
#include <goto-programs/write_goto_binary.h> | ||
#include <goto-programs/interpreter.h> | ||
#include <goto-programs/string_abstraction.h> | ||
#include <goto-programs/string_instrumentation.h> | ||
#include <goto-programs/loop_ids.h> | ||
#include <goto-programs/link_to_library.h> | ||
#include <goto-programs/loop_ids.h> | ||
#include <goto-programs/parameter_assignments.h> | ||
#include <goto-programs/read_goto_binary.h> | ||
#include <goto-programs/remove_calls_no_body.h> | ||
#include <goto-programs/remove_function_pointers.h> | ||
#include <goto-programs/remove_returns.h> | ||
#include <goto-programs/remove_skip.h> | ||
#include <goto-programs/remove_unused_functions.h> | ||
#include <goto-programs/parameter_assignments.h> | ||
#include <goto-programs/slice_global_inits.h> | ||
#include <goto-programs/remove_virtual_functions.h> | ||
#include <goto-programs/set_properties.h> | ||
#include <goto-programs/show_properties.h> | ||
#include <goto-programs/show_symbol_table.h> | ||
#include <goto-programs/slice_global_inits.h> | ||
#include <goto-programs/string_abstraction.h> | ||
#include <goto-programs/string_instrumentation.h> | ||
#include <goto-programs/validate_goto_model.h> | ||
#include <goto-programs/write_goto_binary.h> | ||
|
||
#include <pointer-analysis/value_set_analysis.h> | ||
#include <pointer-analysis/goto_program_dereference.h> | ||
|
@@ -134,7 +135,10 @@ int goto_instrument_parse_optionst::doit() | |
|
||
if(validate_only || cmdline.isset("validate-goto-model")) | ||
{ | ||
goto_model.validate(validation_modet::EXCEPTION); | ||
goto_model.validate( | ||
validation_modet::EXCEPTION, | ||
goto_model_validation_optionst{ | ||
goto_model_validation_optionst::set_optionst::all_true}); | ||
|
||
if(validate_only) | ||
{ | ||
|
@@ -147,7 +151,10 @@ int goto_instrument_parse_optionst::doit() | |
|
||
if(cmdline.isset("validate-goto-model")) | ||
{ | ||
goto_model.validate(validation_modet::INVARIANT); | ||
goto_model.validate( | ||
validation_modet::INVARIANT, | ||
goto_model_validation_optionst{ | ||
goto_model_validation_optionst::set_optionst::all_true}); | ||
} | ||
|
||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include "abstract_goto_model.h" | ||
#include "goto_functions.h" | ||
#include "validate_goto_model.h" | ||
|
||
// A model is a pair consisting of a symbol table | ||
// and the CFGs for the functions. | ||
|
@@ -94,12 +95,20 @@ class goto_modelt : public abstract_goto_modelt | |
/// | ||
/// The validation mode indicates whether well-formedness check failures are | ||
/// reported via DATA_INVARIANT violations or exceptions. | ||
void validate(const validation_modet vm) const override | ||
void validate( | ||
const validation_modet vm, | ||
const goto_model_validation_optionst &goto_model_validation_options) | ||
const override | ||
{ | ||
symbol_table.validate(vm); | ||
|
||
// Does a number of checks at the function_mapt level to ensure the | ||
// goto_program is well formed. Does not call any validate methods | ||
// (at the goto_functiont level or below) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⛏️ Is there a way to condense this comment and turn it into a name for this function? |
||
validate_goto_model(goto_functions, vm, goto_model_validation_options); | ||
|
||
const namespacet ns(symbol_table); | ||
goto_functions.validate(ns, vm); | ||
goto_functions.validate(ns, vm, goto_model_validation_options); | ||
} | ||
}; | ||
|
||
|
@@ -142,12 +151,20 @@ class wrapper_goto_modelt : public abstract_goto_modelt | |
/// | ||
/// The validation mode indicates whether well-formedness check failures are | ||
/// reported via DATA_INVARIANT violations or exceptions. | ||
void validate(const validation_modet vm) const override | ||
void validate( | ||
const validation_modet vm, | ||
const goto_model_validation_optionst &goto_model_validation_options) | ||
const override | ||
{ | ||
symbol_table.validate(vm); | ||
|
||
// Does a number of checks at the function_mapt level to ensure the | ||
// goto_program is well formed. Does not call any validate methods | ||
// (at the goto_functiont level or below) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⛏️ ... especially if you need to explain it twice? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, the name is the same as the command line parameter "validate_goto_model". |
||
validate_goto_model(goto_functions, vm, goto_model_validation_options); | ||
|
||
const namespacet ns(symbol_table); | ||
goto_functions.validate(ns, vm); | ||
goto_functions.validate(ns, vm, goto_model_validation_options); | ||
} | ||
|
||
private: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -674,7 +674,8 @@ bool goto_programt::instructiont::equals(const instructiont &other) const | |
|
||
void goto_programt::instructiont::validate( | ||
const namespacet &ns, | ||
const validation_modet vm) const | ||
const validation_modet vm, | ||
const goto_model_validation_optionst &goto_model_validation_options) const | ||
{ | ||
validate_full_code(code, ns, vm); | ||
validate_full_expr(guard, ns, vm); | ||
|
@@ -776,6 +777,27 @@ void goto_programt::instructiont::validate( | |
} | ||
}; | ||
|
||
// this option is always set to false until all source locations | ||
// are reliably set correctly (future work) | ||
if(goto_model_validation_options.check_source_location) | ||
{ | ||
DATA_CHECK( | ||
vm, | ||
source_location.is_not_nil(), | ||
"each instruction source location must not be nil"); | ||
|
||
DATA_CHECK( | ||
vm, | ||
code.source_location().is_not_nil(), | ||
"each instruction code field, must have non nil source location"); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the comma There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that not every instruction has a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Action taken (after team chat). In commit message (reproduced here in case it helps): Removed previously disabled checks : |
||
DATA_CHECK( | ||
vm, | ||
source_location == code.source_location(), | ||
"instruction source location and" | ||
" instruction code field source location must be the same"); | ||
} | ||
|
||
const symbolt *table_symbol; | ||
switch(type) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ Author: Daniel Kroening, [email protected] | |
#include <sstream> | ||
#include <string> | ||
|
||
#include "validate_goto_model.h" | ||
#include <util/invariant.h> | ||
#include <util/namespace.h> | ||
#include <util/source_location.h> | ||
|
@@ -554,7 +555,11 @@ class goto_programt | |
/// | ||
/// The validation mode indicates whether well-formedness check failures are | ||
/// reported via DATA_INVARIANT violations or exceptions. | ||
void validate(const namespacet &ns, const validation_modet vm) const; | ||
void validate( | ||
const namespacet &ns, | ||
const validation_modet vm, | ||
const goto_model_validation_optionst &goto_model_validation_options) | ||
const; | ||
|
||
/// Apply given transformer to all expressions; no return value | ||
/// means no change needed. | ||
|
@@ -814,11 +819,14 @@ class goto_programt | |
/// | ||
/// The validation mode indicates whether well-formedness check failures are | ||
/// reported via DATA_INVARIANT violations or exceptions. | ||
void validate(const namespacet &ns, const validation_modet vm) const | ||
void validate( | ||
const namespacet &ns, | ||
const validation_modet vm, | ||
const goto_model_validation_optionst &goto_model_validation_options) const | ||
{ | ||
for(const instructiont &ins : instructions) | ||
{ | ||
ins.validate(ns, vm); | ||
ins.validate(ns, vm, goto_model_validation_options); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given how often that all_true option is used, simply make that the default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for INVARIANT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Also for INVARIANT.