@@ -132,6 +132,28 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
132
132
133
133
cbmc_parse_optionst::set_default_options (options);
134
134
135
+ if (cmdline.isset (" cover" ) && cmdline.isset (" unwinding-assertions" ))
136
+ {
137
+ error () << " --cover and --unwinding-assertions must not be given together"
138
+ << eom;
139
+ exit (CPROVER_EXIT_USAGE_ERROR);
140
+ }
141
+
142
+ if (cmdline.isset (" partial-loops" ) && cmdline.isset (" unwinding-assertions" ))
143
+ {
144
+ error () << " --partial-loops and --unwinding-assertions must not be given "
145
+ << " together" << eom;
146
+ exit (CPROVER_EXIT_USAGE_ERROR);
147
+ }
148
+
149
+ if (cmdline.isset (" reachability-slice" ) &&
150
+ cmdline.isset (" reachability-slice-fb" ))
151
+ {
152
+ error () << " --reachability-slice and --reachability-slice-fb must not be "
153
+ << " given together" << eom;
154
+ exit (CPROVER_EXIT_USAGE_ERROR);
155
+ }
156
+
135
157
if (cmdline.isset (" paths" ))
136
158
options.set_option (" paths" , true );
137
159
@@ -165,6 +187,24 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
165
187
if (cmdline.isset (" cpp11" ))
166
188
config.cpp .set_cpp11 ();
167
189
190
+ if (cmdline.isset (" property" ))
191
+ options.set_option (" property" , cmdline.get_values (" property" ));
192
+
193
+ if (cmdline.isset (" drop-unused-functions" ))
194
+ options.set_option (" drop-unused-functions" , true );
195
+
196
+ if (cmdline.isset (" string-abstraction" ))
197
+ options.set_option (" string-abstraction" , true );
198
+
199
+ if (cmdline.isset (" reachability-slice-fb" ))
200
+ options.set_option (" reachability-slice-fb" , true );
201
+
202
+ if (cmdline.isset (" reachability-slice" ))
203
+ options.set_option (" reachability-slice" , true );
204
+
205
+ if (cmdline.isset (" nondet-static" ))
206
+ options.set_option (" nondet-static" , true );
207
+
168
208
if (cmdline.isset (" no-simplify" ))
169
209
options.set_option (" simplify" , false );
170
210
@@ -227,21 +267,6 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
227
267
if (cmdline.isset (" partial-loops" ))
228
268
options.set_option (" partial-loops" , true );
229
269
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
270
// remove unused equations
246
271
if (cmdline.isset (" slice-formula" ))
247
272
options.set_option (" slice-formula" , true );
@@ -532,7 +557,8 @@ int cbmc_parse_optionst::doit()
532
557
return CPROVER_EXIT_SUCCESS;
533
558
}
534
559
535
- int get_goto_program_ret=get_goto_program (options);
560
+ int get_goto_program_ret =
561
+ get_goto_program (goto_model, options, cmdline, *this , ui_message_handler);
536
562
537
563
if (get_goto_program_ret!=-1 )
538
564
return get_goto_program_ret;
@@ -585,25 +611,29 @@ bool cbmc_parse_optionst::set_properties()
585
611
}
586
612
587
613
int cbmc_parse_optionst::get_goto_program (
588
- const optionst &options)
614
+ goto_modelt &goto_model,
615
+ const optionst &options,
616
+ const cmdlinet &cmdline,
617
+ messaget &log,
618
+ ui_message_handlert &ui_message_handler)
589
619
{
590
620
if (cmdline.args .empty ())
591
621
{
592
- error () << " Please provide a program to verify" << eom;
622
+ log. error () << " Please provide a program to verify" << log. eom ;
593
623
return CPROVER_EXIT_INCORRECT_TASK;
594
624
}
595
625
596
626
try
597
627
{
598
- goto_model= initialize_goto_model (cmdline, get_message_handler () );
628
+ goto_model = initialize_goto_model (cmdline, ui_message_handler );
599
629
600
630
if (cmdline.isset (" show-symbol-table" ))
601
631
{
602
632
show_symbol_table (goto_model, ui_message_handler.get_ui ());
603
633
return CPROVER_EXIT_SUCCESS;
604
634
}
605
635
606
- if (process_goto_program (options))
636
+ if (cbmc_parse_optionst:: process_goto_program (goto_model, options, log ))
607
637
return CPROVER_EXIT_INTERNAL_ERROR;
608
638
609
639
// show it?
@@ -620,36 +650,36 @@ int cbmc_parse_optionst::get_goto_program(
620
650
{
621
651
show_goto_functions (
622
652
goto_model,
623
- get_message_handler () ,
653
+ ui_message_handler ,
624
654
ui_message_handler.get_ui (),
625
655
cmdline.isset (" list-goto-functions" ));
626
656
return CPROVER_EXIT_SUCCESS;
627
657
}
628
658
629
- status () << config.object_bits_info () << eom;
659
+ log. status () << config.object_bits_info () << log. eom ;
630
660
}
631
661
632
662
catch (const char *e)
633
663
{
634
- error () << e << eom;
664
+ log. error () << e << log. eom ;
635
665
return CPROVER_EXIT_EXCEPTION;
636
666
}
637
667
638
668
catch (const std::string &e)
639
669
{
640
- error () << e << eom;
670
+ log. error () << e << log. eom ;
641
671
return CPROVER_EXIT_EXCEPTION;
642
672
}
643
673
644
674
catch (int e)
645
675
{
646
- error () << " Numeric exception : " << e << eom;
676
+ log. error () << " Numeric exception : " << e << log. eom ;
647
677
return CPROVER_EXIT_EXCEPTION;
648
678
}
649
679
650
680
catch (const std::bad_alloc &)
651
681
{
652
- error () << " Out of memory" << eom;
682
+ log. error () << " Out of memory" << log. eom ;
653
683
return CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY;
654
684
}
655
685
@@ -714,7 +744,9 @@ void cbmc_parse_optionst::preprocessing()
714
744
}
715
745
716
746
bool cbmc_parse_optionst::process_goto_program (
717
- const optionst &options)
747
+ goto_modelt &goto_model,
748
+ const optionst &options,
749
+ messaget &log)
718
750
{
719
751
try
720
752
{
@@ -723,17 +755,17 @@ bool cbmc_parse_optionst::process_goto_program(
723
755
remove_asm (goto_model);
724
756
725
757
// add the library
726
- link_to_library (goto_model, get_message_handler ());
758
+ link_to_library (goto_model, log. get_message_handler ());
727
759
728
- if (cmdline. isset (" string-abstraction" ))
729
- string_instrumentation (goto_model, get_message_handler ());
760
+ if (options. get_bool_option (" string-abstraction" ))
761
+ string_instrumentation (goto_model, log. get_message_handler ());
730
762
731
763
// remove function pointers
732
- status () << " Removal of function pointers and virtual functions" << eom;
764
+ log. status () << " Removal of function pointers and virtual functions" << eom;
733
765
remove_function_pointers (
734
- get_message_handler (),
766
+ log. get_message_handler (),
735
767
goto_model,
736
- cmdline. isset (" pointer-check" ));
768
+ options. get_bool_option (" pointer-check" ));
737
769
// remove catch and throw (introduces instanceof)
738
770
remove_exceptions (goto_model);
739
771
@@ -749,27 +781,26 @@ bool cbmc_parse_optionst::process_goto_program(
749
781
rewrite_union (goto_model);
750
782
751
783
// add generic checks
752
- status () << " Generic Property Instrumentation" << eom;
784
+ log. status () << " Generic Property Instrumentation" << eom;
753
785
goto_check (options, goto_model);
754
786
755
787
// checks don't know about adjusted float expressions
756
788
adjust_float_expressions (goto_model);
757
789
758
790
// ignore default/user-specified initialization
759
791
// of variables with static lifetime
760
- if (cmdline. isset (" nondet-static" ))
792
+ if (options. get_bool_option (" nondet-static" ))
761
793
{
762
- status () << " Adding nondeterministic initialization "
763
- " of static/global variables" << eom;
794
+ log.status () << " Adding nondeterministic initialization "
795
+ " of static/global variables"
796
+ << eom;
764
797
nondet_static (goto_model);
765
798
}
766
799
767
- if (cmdline. isset (" string-abstraction" ))
800
+ if (options. get_bool_option (" string-abstraction" ))
768
801
{
769
- status () << " String Abstraction" << eom;
770
- string_abstraction (
771
- goto_model,
772
- get_message_handler ());
802
+ log.status () << " String Abstraction" << eom;
803
+ string_abstraction (goto_model, log.get_message_handler ());
773
804
}
774
805
775
806
// add failed symbols
@@ -782,21 +813,21 @@ bool cbmc_parse_optionst::process_goto_program(
782
813
// add loop ids
783
814
goto_model.goto_functions .compute_loop_numbers ();
784
815
785
- if (cmdline. isset (" drop-unused-functions" ))
816
+ if (options. get_bool_option (" drop-unused-functions" ))
786
817
{
787
818
// 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 ());
819
+ log. status () << " Removing unused functions" << eom;
820
+ remove_unused_functions (goto_model, log. get_message_handler ());
790
821
}
791
822
792
823
// remove skips such that trivial GOTOs are deleted and not considered
793
824
// for coverage annotation:
794
825
remove_skip (goto_model);
795
826
796
827
// instrument cover goals
797
- if (cmdline. isset (" cover" ))
828
+ if (options. is_set (" cover" ))
798
829
{
799
- if (instrument_cover_goals (options, goto_model, get_message_handler ()))
830
+ if (instrument_cover_goals (options, goto_model, log. get_message_handler ()))
800
831
return true ;
801
832
}
802
833
@@ -808,37 +839,39 @@ bool cbmc_parse_optionst::process_goto_program(
808
839
label_properties (goto_model);
809
840
810
841
// reachability slice?
811
- if (cmdline. isset (" reachability-slice-fb" ))
842
+ if (options. get_bool_option (" reachability-slice-fb" ))
812
843
{
813
- if (cmdline. isset (" reachability-slice" ))
844
+ if (options. get_bool_option (" reachability-slice" ))
814
845
{
815
- error () << " --reachability-slice and --reachability-slice-fb "
816
- << " must not be given together" << eom;
846
+ log. error () << " --reachability-slice and --reachability-slice-fb "
847
+ << " must not be given together" << eom;
817
848
return true ;
818
849
}
819
850
820
- status () << " Performing a forwards-backwards reachability slice" << eom;
821
- if (cmdline.isset (" property" ))
822
- reachability_slicer (goto_model, cmdline.get_values (" property" ), true );
851
+ log.status () << " Performing a forwards-backwards reachability slice"
852
+ << eom;
853
+ if (options.is_set (" property" ))
854
+ reachability_slicer (
855
+ goto_model, options.get_list_option (" property" ), true );
823
856
else
824
857
reachability_slicer (goto_model, true );
825
858
}
826
859
827
- if (cmdline. isset (" reachability-slice" ))
860
+ if (options. get_bool_option (" reachability-slice" ))
828
861
{
829
- status () << " Performing a reachability slice" << eom;
830
- if (cmdline. isset (" property" ))
831
- reachability_slicer (goto_model, cmdline. get_values (" property" ));
862
+ log. status () << " Performing a reachability slice" << eom;
863
+ if (options. is_set (" property" ))
864
+ reachability_slicer (goto_model, options. get_list_option (" property" ));
832
865
else
833
866
reachability_slicer (goto_model);
834
867
}
835
868
836
869
// full slice?
837
- if (cmdline. isset (" full-slice" ))
870
+ if (options. get_bool_option (" full-slice" ))
838
871
{
839
- status () << " Performing a full slice" << eom;
840
- if (cmdline. isset (" property" ))
841
- property_slicer (goto_model, cmdline. get_values (" property" ));
872
+ log. status () << " Performing a full slice" << eom;
873
+ if (options. is_set (" property" ))
874
+ property_slicer (goto_model, options. get_list_option (" property" ));
842
875
else
843
876
full_slicer (goto_model);
844
877
}
@@ -849,25 +882,25 @@ bool cbmc_parse_optionst::process_goto_program(
849
882
850
883
catch (const char *e)
851
884
{
852
- error () << e << eom;
885
+ log. error () << e << eom;
853
886
return true ;
854
887
}
855
888
856
889
catch (const std::string &e)
857
890
{
858
- error () << e << eom;
891
+ log. error () << e << eom;
859
892
return true ;
860
893
}
861
894
862
895
catch (int e)
863
896
{
864
- error () << " Numeric exception : " << e << eom;
897
+ log. error () << " Numeric exception : " << e << eom;
865
898
return true ;
866
899
}
867
900
868
901
catch (const std::bad_alloc &)
869
902
{
870
- error () << " Out of memory" << eom;
903
+ log. error () << " Out of memory" << eom;
871
904
exit (CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY);
872
905
return true ;
873
906
}
0 commit comments