Skip to content

Commit 1fb1129

Browse files
author
Sonny Martin
committed
Rebase and address review comments
1 parent ab3cb60 commit 1fb1129

24 files changed

+328
-196
lines changed

jbmc/src/jbmc/jbmc_parse_options.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,10 @@ int jbmc_parse_optionst::doit()
550550

551551
if(cmdline.isset("validate-goto-model"))
552552
{
553-
goto_model.validate(validation_modet::INVARIANT);
553+
goto_model.validate(
554+
validation_modet::INVARIANT,
555+
goto_model_validation_optionst{
556+
goto_model_validation_optionst::set_optionst::all_true});
554557
}
555558

556559
if(
@@ -691,7 +694,10 @@ int jbmc_parse_optionst::doit()
691694

692695
if(cmdline.isset("validate-goto-model"))
693696
{
694-
lazy_goto_model.validate(validation_modet::INVARIANT);
697+
lazy_goto_model.validate(
698+
validation_modet::INVARIANT,
699+
goto_model_validation_optionst{
700+
goto_model_validation_optionst::set_optionst::all_true});
695701
}
696702

697703
// Provide show-goto-functions and similar dump functions after symex

src/cbmc/cbmc_parse_options.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ 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>
5349
#include <goto-programs/adjust_float_expressions.h>
5450
#include <goto-programs/initialize_goto_model.h>
5551
#include <goto-programs/instrument_preconditions.h>
@@ -60,9 +56,6 @@ Author: Daniel Kroening, [email protected]
6056
#include <goto-programs/remove_complex.h>
6157
#include <goto-programs/remove_function_pointers.h>
6258
#include <goto-programs/remove_returns.h>
63-
#include <goto-programs/remove_vector.h>
64-
#include <goto-programs/remove_complex.h>
65-
#include <goto-programs/remove_unused_functions.h>
6659
#include <goto-programs/remove_skip.h>
6760
#include <goto-programs/remove_unused_functions.h>
6861
#include <goto-programs/remove_vector.h>
@@ -75,6 +68,11 @@ Author: Daniel Kroening, [email protected]
7568
#include <goto-programs/string_instrumentation.h>
7669
#include <goto-programs/validate_goto_model.h>
7770

71+
#include <goto-instrument/cover.h>
72+
#include <goto-instrument/full_slicer.h>
73+
#include <goto-instrument/nondet_static.h>
74+
#include <goto-instrument/reachability_slicer.h>
75+
7876
#include <goto-symex/path_storage.h>
7977

8078
#include <pointer-analysis/add_failed_symbols.h>
@@ -553,12 +551,10 @@ int cbmc_parse_optionst::doit()
553551

554552
if(cmdline.isset("validate-goto-model"))
555553
{
556-
goto_model_validation_optionst goto_model_validation_options{true};
557-
// this option is temporarily disabled until all source locations
558-
// are reliably set correctly
559-
goto_model_validation_options.check_source_location = false;
560554
goto_model.validate(
561-
validation_modet::INVARIANT, goto_model_validation_options);
555+
validation_modet::INVARIANT,
556+
goto_model_validation_optionst{
557+
goto_model_validation_optionst::set_optionst::all_true});
562558
}
563559

564560
if(

src/goto-analyzer/goto_analyzer_parse_options.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,9 @@ int goto_analyzer_parse_optionst::doit()
407407
if(cmdline.isset("validate-goto-model"))
408408
{
409409
goto_model.validate(
410-
validation_modet::INVARIANT, goto_model_validation_optionst{});
410+
validation_modet::INVARIANT,
411+
goto_model_validation_optionst{
412+
goto_model_validation_optionst::set_optionst::all_true});
411413
}
412414

413415
// show it?

src/goto-cc/compile.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Date: June 2006
3535
#include <goto-programs/goto_convert.h>
3636
#include <goto-programs/goto_convert_functions.h>
3737
#include <goto-programs/read_goto_binary.h>
38+
#include <goto-programs/validate_goto_model.h>
3839
#include <goto-programs/write_goto_binary.h>
3940

4041
#include <langapi/language_file.h>
@@ -546,7 +547,10 @@ bool compilet::write_bin_object_file(
546547
if(validate_goto_model)
547548
{
548549
status() << "Validating goto model" << eom;
549-
src_goto_model.validate(validation_modet::INVARIANT);
550+
src_goto_model.validate(
551+
validation_modet::INVARIANT,
552+
goto_model_validation_optionst{
553+
goto_model_validation_optionst::set_optionst::all_true});
550554
}
551555

552556
statistics() << "Writing binary format object `"

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ Author: Daniel Kroening, [email protected]
2828
#include <goto-programs/goto_inline.h>
2929
#include <goto-programs/interpreter.h>
3030
#include <goto-programs/link_to_library.h>
31-
#include <goto-programs/remove_returns.h>
3231
#include <goto-programs/loop_ids.h>
3332
#include <goto-programs/parameter_assignments.h>
3433
#include <goto-programs/read_goto_binary.h>
3534
#include <goto-programs/remove_calls_no_body.h>
3635
#include <goto-programs/remove_function_pointers.h>
36+
#include <goto-programs/remove_returns.h>
3737
#include <goto-programs/remove_skip.h>
3838
#include <goto-programs/remove_unused_functions.h>
3939
#include <goto-programs/remove_virtual_functions.h>
@@ -136,7 +136,9 @@ int goto_instrument_parse_optionst::doit()
136136
if(validate_only || cmdline.isset("validate-goto-model"))
137137
{
138138
goto_model.validate(
139-
validation_modet::EXCEPTION, goto_model_validation_optionst{});
139+
validation_modet::EXCEPTION,
140+
goto_model_validation_optionst{
141+
goto_model_validation_optionst::set_optionst::all_true});
140142

141143
if(validate_only)
142144
{
@@ -150,7 +152,9 @@ int goto_instrument_parse_optionst::doit()
150152
if(cmdline.isset("validate-goto-model"))
151153
{
152154
goto_model.validate(
153-
validation_modet::INVARIANT, goto_model_validation_optionst{});
155+
validation_modet::INVARIANT,
156+
goto_model_validation_optionst{
157+
goto_model_validation_optionst::set_optionst::all_true});
154158
}
155159

156160
{

src/goto-programs/abstract_goto_model.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class abstract_goto_modelt
5757
// virtual void validate(const validation_modet vm) const = 0;
5858
virtual void validate(
5959
const validation_modet vm,
60-
const goto_model_validation_optionst &goto_model_validation_options) const = 0;
60+
const goto_model_validation_optionst &goto_model_validation_options)
61+
const = 0;
6162
};
6263

6364
#endif

src/goto-programs/goto_function.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,3 @@ void goto_functiont::validate(
7272

7373
validate_full_type(type, ns, vm);
7474
}
75-

src/goto-programs/goto_functions.h

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

1717
#include "goto_function.h"
1818

19-
#include "validate_goto_model.h"
2019
#include <util/cprover_prefix.h>
2120

2221
/// A collection of goto functions
@@ -117,7 +116,6 @@ class goto_functionst
117116
const validation_modet vm,
118117
const goto_model_validation_optionst &goto_model_validation_options) const
119118
{
120-
validate_goto_model(*this, vm, goto_model_validation_options);
121119
for(const auto &entry : function_map)
122120
{
123121
const goto_functiont &goto_function = entry.second;

src/goto-programs/goto_model.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Author: Daniel Kroening, [email protected]
1717

1818
#include "abstract_goto_model.h"
1919
#include "goto_functions.h"
20+
#include "validate_goto_model.h"
2021

2122
// A model is a pair consisting of a symbol table
2223
// and the CFGs for the functions.
@@ -96,10 +97,16 @@ class goto_modelt : public abstract_goto_modelt
9697
/// reported via DATA_INVARIANT violations or exceptions.
9798
void validate(
9899
const validation_modet vm,
99-
const goto_model_validation_optionst &goto_model_validation_options) const override
100+
const goto_model_validation_optionst &goto_model_validation_options)
101+
const override
100102
{
101103
symbol_table.validate(vm);
102104

105+
// Does a number of checks at the function_mapt level to ensure the
106+
// goto_program is well formed. Does not call any validate methods
107+
// (at the goto_functiont level or below)
108+
validate_goto_model(goto_functions, vm, goto_model_validation_options);
109+
103110
const namespacet ns(symbol_table);
104111
goto_functions.validate(ns, vm, goto_model_validation_options);
105112
}
@@ -146,12 +153,18 @@ class wrapper_goto_modelt : public abstract_goto_modelt
146153
/// reported via DATA_INVARIANT violations or exceptions.
147154
void validate(
148155
const validation_modet vm,
149-
const goto_model_validation_optionst &goto_model_validation_options) const override
156+
const goto_model_validation_optionst &goto_model_validation_options)
157+
const override
150158
{
151159
symbol_table.validate(vm);
152160

161+
// Does a number of checks at the function_mapt level to ensure the
162+
// goto_program is well formed. Does not call any validate methods
163+
// (at the goto_functiont level or below)
164+
validate_goto_model(goto_functions, vm, goto_model_validation_options);
165+
153166
const namespacet ns(symbol_table);
154-
goto_functions.validate(ns, vm, goto_model_validation_options);
167+
goto_functions.validate(ns, vm, goto_model_validation_options);
155168
}
156169

157170
private:

src/goto-programs/goto_program.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,8 @@ void goto_programt::instructiont::validate(
777777
}
778778
};
779779

780+
// this option is always set to false until all source locations
781+
// are reliably set correctly (future work)
780782
if(goto_model_validation_options.check_source_location)
781783
{
782784
DATA_CHECK(
@@ -787,13 +789,13 @@ void goto_programt::instructiont::validate(
787789
DATA_CHECK(
788790
vm,
789791
code.source_location().is_not_nil(),
790-
"each instruction \"code\" field, must have non nil source location");
792+
"each instruction code field, must have non nil source location");
791793

792794
DATA_CHECK(
793795
vm,
794796
source_location == code.source_location(),
795797
"instruction source location and"
796-
" instruction \"code\" field source location must be the same");
798+
" instruction code field source location must be the same");
797799
}
798800

799801
const symbolt *table_symbol;

src/goto-programs/initialize_goto_model.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,14 @@ goto_modelt initialize_goto_model(
194194

195195
if(options.is_set("validate-goto-model"))
196196
{
197+
goto_model_validation_optionst goto_model_validation_options{
198+
goto_model_validation_optionst ::set_optionst::all_false};
199+
200+
// temporarily disabled until regression tests fixed
201+
goto_model_validation_options.entry_point_exists = false;
202+
197203
goto_model.validate(
198-
validation_modet::EXCEPTION, goto_model_validation_optionst{});
204+
validation_modet::INVARIANT, goto_model_validation_options);
199205
}
200206

201207
// stupid hack

src/goto-programs/lazy_goto_model.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ class lazy_goto_modelt : public abstract_goto_modelt
249249
/// reported via DATA_INVARIANT violations or exceptions.
250250
void validate(
251251
const validation_modet vm,
252-
const goto_model_validation_optionst &goto_model_validation_options) const override
252+
const goto_model_validation_optionst &goto_model_validation_options)
253+
const override
253254
{
254255
goto_model->validate(vm, goto_model_validation_options);
255256
}

0 commit comments

Comments
 (0)