@@ -97,13 +97,7 @@ void cbmc_parse_optionst::set_default_options(optionst &options)
97
97
options.set_option (" simplify" , true );
98
98
options.set_option (" simplify-if" , true );
99
99
100
- // Default false
101
- options.set_option (" partial-loops" , false );
102
- options.set_option (" slice-formula" , false );
103
- options.set_option (" stop-on-fail" , false );
104
- options.set_option (" unwinding-assertions" , false );
105
-
106
- // Other
100
+ // Other default
107
101
options.set_option (" arrays-uf" , " auto" );
108
102
}
109
103
@@ -132,6 +126,28 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
132
126
133
127
cbmc_parse_optionst::set_default_options (options);
134
128
129
+ if (cmdline.isset (" cover" ) && cmdline.isset (" unwinding-assertions" ))
130
+ {
131
+ error () << " --cover and --unwinding-assertions must not be given together"
132
+ << eom;
133
+ exit (CPROVER_EXIT_USAGE_ERROR);
134
+ }
135
+
136
+ if (cmdline.isset (" partial-loops" ) && cmdline.isset (" unwinding-assertions" ))
137
+ {
138
+ error () << " --partial-loops and --unwinding-assertions must not be given "
139
+ << " together" << eom;
140
+ exit (CPROVER_EXIT_USAGE_ERROR);
141
+ }
142
+
143
+ if (cmdline.isset (" reachability-slice" ) &&
144
+ cmdline.isset (" reachability-slice-fb" ))
145
+ {
146
+ error () << " --reachability-slice and --reachability-slice-fb must not be "
147
+ << " given together" << eom;
148
+ exit (CPROVER_EXIT_USAGE_ERROR);
149
+ }
150
+
135
151
if (cmdline.isset (" paths" ))
136
152
options.set_option (" paths" , true );
137
153
@@ -165,6 +181,24 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
165
181
if (cmdline.isset (" cpp11" ))
166
182
config.cpp .set_cpp11 ();
167
183
184
+ if (cmdline.isset (" property" ))
185
+ options.set_option (" property" , cmdline.get_values (" property" ));
186
+
187
+ if (cmdline.isset (" drop-unused-functions" ))
188
+ options.set_option (" drop-unused-functions" , true );
189
+
190
+ if (cmdline.isset (" string-abstraction" ))
191
+ options.set_option (" string-abstraction" , true );
192
+
193
+ if (cmdline.isset (" reachability-slice-fb" ))
194
+ options.set_option (" reachability-slice-fb" , true );
195
+
196
+ if (cmdline.isset (" reachability-slice" ))
197
+ options.set_option (" reachability-slice" , true );
198
+
199
+ if (cmdline.isset (" nondet-static" ))
200
+ options.set_option (" nondet-static" , true );
201
+
168
202
if (cmdline.isset (" no-simplify" ))
169
203
options.set_option (" simplify" , false );
170
204
@@ -227,21 +261,6 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
227
261
if (cmdline.isset (" partial-loops" ))
228
262
options.set_option (" partial-loops" , true );
229
263
230
- if (options.is_set (" cover" ) && options.get_bool_option (" unwinding-assertions" ))
231
- {
232
- error () << " --cover and --unwinding-assertions "
233
- << " must not be given together" << eom;
234
- exit (CPROVER_EXIT_USAGE_ERROR);
235
- }
236
-
237
- if (options.get_bool_option (" partial-loops" ) &&
238
- options.get_bool_option (" unwinding-assertions" ))
239
- {
240
- error () << " --partial-loops and --unwinding-assertions "
241
- << " must not be given together" << eom;
242
- exit (CPROVER_EXIT_USAGE_ERROR);
243
- }
244
-
245
264
// remove unused equations
246
265
if (cmdline.isset (" slice-formula" ))
247
266
options.set_option (" slice-formula" , true );
@@ -532,7 +551,8 @@ int cbmc_parse_optionst::doit()
532
551
return CPROVER_EXIT_SUCCESS;
533
552
}
534
553
535
- int get_goto_program_ret=get_goto_program (options);
554
+ int get_goto_program_ret =
555
+ get_goto_program (goto_model, options, cmdline, *this , ui_message_handler);
536
556
537
557
if (get_goto_program_ret!=-1 )
538
558
return get_goto_program_ret;
@@ -585,25 +605,29 @@ bool cbmc_parse_optionst::set_properties()
585
605
}
586
606
587
607
int cbmc_parse_optionst::get_goto_program (
588
- const optionst &options)
608
+ goto_modelt &goto_model,
609
+ const optionst &options,
610
+ const cmdlinet &cmdline,
611
+ messaget &log,
612
+ ui_message_handlert &ui_message_handler)
589
613
{
590
614
if (cmdline.args .empty ())
591
615
{
592
- error () << " Please provide a program to verify" << eom;
616
+ log . error () << " Please provide a program to verify" << log . eom ;
593
617
return CPROVER_EXIT_INCORRECT_TASK;
594
618
}
595
619
596
620
try
597
621
{
598
- goto_model= initialize_goto_model (cmdline, get_message_handler () );
622
+ goto_model = initialize_goto_model (cmdline, ui_message_handler );
599
623
600
624
if (cmdline.isset (" show-symbol-table" ))
601
625
{
602
626
show_symbol_table (goto_model, ui_message_handler.get_ui ());
603
627
return CPROVER_EXIT_SUCCESS;
604
628
}
605
629
606
- if (process_goto_program (options))
630
+ if (cbmc_parse_optionst:: process_goto_program (goto_model, options, log ))
607
631
return CPROVER_EXIT_INTERNAL_ERROR;
608
632
609
633
// show it?
@@ -620,36 +644,36 @@ int cbmc_parse_optionst::get_goto_program(
620
644
{
621
645
show_goto_functions (
622
646
goto_model,
623
- get_message_handler () ,
647
+ ui_message_handler ,
624
648
ui_message_handler.get_ui (),
625
649
cmdline.isset (" list-goto-functions" ));
626
650
return CPROVER_EXIT_SUCCESS;
627
651
}
628
652
629
- status () << config.object_bits_info () << eom;
653
+ log . status () << config.object_bits_info () << log . eom ;
630
654
}
631
655
632
656
catch (const char *e)
633
657
{
634
- error () << e << eom;
658
+ log . error () << e << log . eom ;
635
659
return CPROVER_EXIT_EXCEPTION;
636
660
}
637
661
638
662
catch (const std::string &e)
639
663
{
640
- error () << e << eom;
664
+ log . error () << e << log . eom ;
641
665
return CPROVER_EXIT_EXCEPTION;
642
666
}
643
667
644
668
catch (int e)
645
669
{
646
- error () << " Numeric exception : " << e << eom;
670
+ log . error () << " Numeric exception : " << e << log . eom ;
647
671
return CPROVER_EXIT_EXCEPTION;
648
672
}
649
673
650
674
catch (const std::bad_alloc &)
651
675
{
652
- error () << " Out of memory" << eom;
676
+ log . error () << " Out of memory" << log . eom ;
653
677
return CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY;
654
678
}
655
679
@@ -714,7 +738,9 @@ void cbmc_parse_optionst::preprocessing()
714
738
}
715
739
716
740
bool cbmc_parse_optionst::process_goto_program (
717
- const optionst &options)
741
+ goto_modelt &goto_model,
742
+ const optionst &options,
743
+ messaget &log)
718
744
{
719
745
try
720
746
{
@@ -723,17 +749,17 @@ bool cbmc_parse_optionst::process_goto_program(
723
749
remove_asm (goto_model);
724
750
725
751
// add the library
726
- link_to_library (goto_model, get_message_handler ());
752
+ link_to_library (goto_model, log . get_message_handler ());
727
753
728
- if (cmdline. isset (" string-abstraction" ))
729
- string_instrumentation (goto_model, get_message_handler ());
754
+ if (options. get_bool_option (" string-abstraction" ))
755
+ string_instrumentation (goto_model, log . get_message_handler ());
730
756
731
757
// remove function pointers
732
- status () << " Removal of function pointers and virtual functions" << eom;
758
+ log . status () << " Removal of function pointers and virtual functions" << eom;
733
759
remove_function_pointers (
734
- get_message_handler (),
760
+ log . get_message_handler (),
735
761
goto_model,
736
- cmdline. isset (" pointer-check" ));
762
+ options. get_bool_option (" pointer-check" ));
737
763
// remove catch and throw (introduces instanceof)
738
764
remove_exceptions (goto_model);
739
765
@@ -749,27 +775,26 @@ bool cbmc_parse_optionst::process_goto_program(
749
775
rewrite_union (goto_model);
750
776
751
777
// add generic checks
752
- status () << " Generic Property Instrumentation" << eom;
778
+ log . status () << " Generic Property Instrumentation" << eom;
753
779
goto_check (options, goto_model);
754
780
755
781
// checks don't know about adjusted float expressions
756
782
adjust_float_expressions (goto_model);
757
783
758
784
// ignore default/user-specified initialization
759
785
// of variables with static lifetime
760
- if (cmdline. isset (" nondet-static" ))
786
+ if (options. get_bool_option (" nondet-static" ))
761
787
{
762
- status () << " Adding nondeterministic initialization "
763
- " of static/global variables" << eom;
788
+ log .status () << " Adding nondeterministic initialization "
789
+ " of static/global variables"
790
+ << eom;
764
791
nondet_static (goto_model);
765
792
}
766
793
767
- if (cmdline. isset (" string-abstraction" ))
794
+ if (options. get_bool_option (" string-abstraction" ))
768
795
{
769
- status () << " String Abstraction" << eom;
770
- string_abstraction (
771
- goto_model,
772
- get_message_handler ());
796
+ log .status () << " String Abstraction" << eom;
797
+ string_abstraction (goto_model, log .get_message_handler ());
773
798
}
774
799
775
800
// add failed symbols
@@ -782,21 +807,21 @@ bool cbmc_parse_optionst::process_goto_program(
782
807
// add loop ids
783
808
goto_model.goto_functions .compute_loop_numbers ();
784
809
785
- if (cmdline. isset (" drop-unused-functions" ))
810
+ if (options. get_bool_option (" drop-unused-functions" ))
786
811
{
787
812
// Entry point will have been set before and function pointers removed
788
- status () << " Removing unused functions" << eom;
789
- remove_unused_functions (goto_model, get_message_handler ());
813
+ log . status () << " Removing unused functions" << eom;
814
+ remove_unused_functions (goto_model, log . get_message_handler ());
790
815
}
791
816
792
817
// remove skips such that trivial GOTOs are deleted and not considered
793
818
// for coverage annotation:
794
819
remove_skip (goto_model);
795
820
796
821
// instrument cover goals
797
- if (cmdline. isset (" cover" ))
822
+ if (options. is_set (" cover" ))
798
823
{
799
- if (instrument_cover_goals (options, goto_model, get_message_handler ()))
824
+ if (instrument_cover_goals (options, goto_model, log . get_message_handler ()))
800
825
return true ;
801
826
}
802
827
@@ -808,37 +833,32 @@ bool cbmc_parse_optionst::process_goto_program(
808
833
label_properties (goto_model);
809
834
810
835
// reachability slice?
811
- if (cmdline. isset (" reachability-slice-fb" ))
836
+ if (options. get_bool_option (" reachability-slice-fb" ))
812
837
{
813
- if (cmdline.isset (" reachability-slice" ))
814
- {
815
- error () << " --reachability-slice and --reachability-slice-fb "
816
- << " must not be given together" << eom;
817
- return true ;
818
- }
819
-
820
- status () << " Performing a forwards-backwards reachability slice" << eom;
821
- if (cmdline.isset (" property" ))
822
- reachability_slicer (goto_model, cmdline.get_values (" property" ), true );
838
+ log .status () << " Performing a forwards-backwards reachability slice"
839
+ << eom;
840
+ if (options.is_set (" property" ))
841
+ reachability_slicer (
842
+ goto_model, options.get_list_option (" property" ), true );
823
843
else
824
844
reachability_slicer (goto_model, true );
825
845
}
826
846
827
- if (cmdline. isset (" reachability-slice" ))
847
+ if (options. get_bool_option (" reachability-slice" ))
828
848
{
829
- status () << " Performing a reachability slice" << eom;
830
- if (cmdline. isset (" property" ))
831
- reachability_slicer (goto_model, cmdline. get_values (" property" ));
849
+ log . status () << " Performing a reachability slice" << eom;
850
+ if (options. is_set (" property" ))
851
+ reachability_slicer (goto_model, options. get_list_option (" property" ));
832
852
else
833
853
reachability_slicer (goto_model);
834
854
}
835
855
836
856
// full slice?
837
- if (cmdline. isset (" full-slice" ))
857
+ if (options. get_bool_option (" full-slice" ))
838
858
{
839
- status () << " Performing a full slice" << eom;
840
- if (cmdline. isset (" property" ))
841
- property_slicer (goto_model, cmdline. get_values (" property" ));
859
+ log . status () << " Performing a full slice" << eom;
860
+ if (options. is_set (" property" ))
861
+ property_slicer (goto_model, options. get_list_option (" property" ));
842
862
else
843
863
full_slicer (goto_model);
844
864
}
@@ -849,25 +869,25 @@ bool cbmc_parse_optionst::process_goto_program(
849
869
850
870
catch (const char *e)
851
871
{
852
- error () << e << eom;
872
+ log . error () << e << eom;
853
873
return true ;
854
874
}
855
875
856
876
catch (const std::string &e)
857
877
{
858
- error () << e << eom;
878
+ log . error () << e << eom;
859
879
return true ;
860
880
}
861
881
862
882
catch (int e)
863
883
{
864
- error () << " Numeric exception : " << e << eom;
884
+ log . error () << " Numeric exception : " << e << eom;
865
885
return true ;
866
886
}
867
887
868
888
catch (const std::bad_alloc &)
869
889
{
870
- error () << " Out of memory" << eom;
890
+ log . error () << " Out of memory" << eom;
871
891
exit (CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY);
872
892
return true ;
873
893
}
0 commit comments