@@ -165,6 +165,24 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
165
165
if (cmdline.isset (" cpp11" ))
166
166
config.cpp .set_cpp11 ();
167
167
168
+ if (cmdline.isset (" property" ))
169
+ options.set_option (" property" , cmdline.get_values (" property" ));
170
+
171
+ if (cmdline.isset (" reachability-slice-fb" ))
172
+ options.set_option (" reachability-slice-fb" , true );
173
+
174
+ if (cmdline.isset (" reachability-slice" ))
175
+ options.set_option (" reachability-slice" , true );
176
+
177
+ if (cmdline.isset (" bounds-check" ))
178
+ options.set_option (" bounds-check" , true );
179
+
180
+ if (cmdline.isset (" pointer-check" ))
181
+ options.set_option (" pointer-check" , true );
182
+
183
+ if (cmdline.isset (" nondet-static" ))
184
+ options.set_option (" nondet-static" , true );
185
+
168
186
if (cmdline.isset (" no-simplify" ))
169
187
options.set_option (" simplify" , false );
170
188
@@ -532,7 +550,8 @@ int cbmc_parse_optionst::doit()
532
550
return CPROVER_EXIT_SUCCESS;
533
551
}
534
552
535
- int get_goto_program_ret=get_goto_program (options);
553
+ int get_goto_program_ret =
554
+ get_goto_program (goto_model, options, cmdline, *this , ui_message_handler);
536
555
537
556
if (get_goto_program_ret!=-1 )
538
557
return get_goto_program_ret;
@@ -585,25 +604,29 @@ bool cbmc_parse_optionst::set_properties()
585
604
}
586
605
587
606
int cbmc_parse_optionst::get_goto_program (
588
- const optionst &options)
607
+ goto_modelt &goto_model,
608
+ const optionst &options,
609
+ const cmdlinet &cmdline,
610
+ messaget &log,
611
+ ui_message_handlert &ui_message_handler)
589
612
{
590
613
if (cmdline.args .empty ())
591
614
{
592
- error () << " Please provide a program to verify" << eom;
615
+ log. error () << " Please provide a program to verify" << log. eom ;
593
616
return CPROVER_EXIT_INCORRECT_TASK;
594
617
}
595
618
596
619
try
597
620
{
598
- goto_model= initialize_goto_model (cmdline, get_message_handler () );
621
+ goto_model = initialize_goto_model (cmdline, ui_message_handler );
599
622
600
623
if (cmdline.isset (" show-symbol-table" ))
601
624
{
602
625
show_symbol_table (goto_model, ui_message_handler.get_ui ());
603
626
return CPROVER_EXIT_SUCCESS;
604
627
}
605
628
606
- if (process_goto_program (options))
629
+ if (cbmc_parse_optionst:: process_goto_program (goto_model, options, log ))
607
630
return CPROVER_EXIT_INTERNAL_ERROR;
608
631
609
632
// show it?
@@ -620,36 +643,36 @@ int cbmc_parse_optionst::get_goto_program(
620
643
{
621
644
show_goto_functions (
622
645
goto_model,
623
- get_message_handler () ,
646
+ ui_message_handler ,
624
647
ui_message_handler.get_ui (),
625
648
cmdline.isset (" list-goto-functions" ));
626
649
return CPROVER_EXIT_SUCCESS;
627
650
}
628
651
629
- status () << config.object_bits_info () << eom;
652
+ log. status () << config.object_bits_info () << log. eom ;
630
653
}
631
654
632
655
catch (const char *e)
633
656
{
634
- error () << e << eom;
657
+ log. error () << e << log. eom ;
635
658
return CPROVER_EXIT_EXCEPTION;
636
659
}
637
660
638
661
catch (const std::string &e)
639
662
{
640
- error () << e << eom;
663
+ log. error () << e << log. eom ;
641
664
return CPROVER_EXIT_EXCEPTION;
642
665
}
643
666
644
667
catch (int e)
645
668
{
646
- error () << " Numeric exception : " << e << eom;
669
+ log. error () << " Numeric exception : " << e << log. eom ;
647
670
return CPROVER_EXIT_EXCEPTION;
648
671
}
649
672
650
673
catch (const std::bad_alloc &)
651
674
{
652
- error () << " Out of memory" << eom;
675
+ log. error () << " Out of memory" << log. eom ;
653
676
return CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY;
654
677
}
655
678
@@ -714,7 +737,9 @@ void cbmc_parse_optionst::preprocessing()
714
737
}
715
738
716
739
bool cbmc_parse_optionst::process_goto_program (
717
- const optionst &options)
740
+ goto_modelt &goto_model,
741
+ const optionst &options,
742
+ messaget &log)
718
743
{
719
744
try
720
745
{
@@ -723,17 +748,17 @@ bool cbmc_parse_optionst::process_goto_program(
723
748
remove_asm (goto_model);
724
749
725
750
// add the library
726
- link_to_library (goto_model, get_message_handler ());
751
+ link_to_library (goto_model, log. get_message_handler ());
727
752
728
- if (cmdline. isset (" string-abstraction" ))
729
- string_instrumentation (goto_model, get_message_handler ());
753
+ if (options. get_bool_option (" string-abstraction" ))
754
+ string_instrumentation (goto_model, log. get_message_handler ());
730
755
731
756
// remove function pointers
732
- status () << " Removal of function pointers and virtual functions" << eom;
757
+ log. status () << " Removal of function pointers and virtual functions" << eom;
733
758
remove_function_pointers (
734
- get_message_handler (),
759
+ log. get_message_handler (),
735
760
goto_model,
736
- cmdline. isset (" pointer-check" ));
761
+ options. get_bool_option (" pointer-check" ));
737
762
// remove catch and throw (introduces instanceof)
738
763
remove_exceptions (goto_model);
739
764
@@ -749,27 +774,26 @@ bool cbmc_parse_optionst::process_goto_program(
749
774
rewrite_union (goto_model);
750
775
751
776
// add generic checks
752
- status () << " Generic Property Instrumentation" << eom;
777
+ log. status () << " Generic Property Instrumentation" << eom;
753
778
goto_check (options, goto_model);
754
779
755
780
// checks don't know about adjusted float expressions
756
781
adjust_float_expressions (goto_model);
757
782
758
783
// ignore default/user-specified initialization
759
784
// of variables with static lifetime
760
- if (cmdline. isset (" nondet-static" ))
785
+ if (options. get_bool_option (" nondet-static" ))
761
786
{
762
- status () << " Adding nondeterministic initialization "
763
- " of static/global variables" << eom;
787
+ log.status () << " Adding nondeterministic initialization "
788
+ " of static/global variables"
789
+ << eom;
764
790
nondet_static (goto_model);
765
791
}
766
792
767
- if (cmdline. isset (" string-abstraction" ))
793
+ if (options. get_bool_option (" string-abstraction" ))
768
794
{
769
- status () << " String Abstraction" << eom;
770
- string_abstraction (
771
- goto_model,
772
- get_message_handler ());
795
+ log.status () << " String Abstraction" << eom;
796
+ string_abstraction (goto_model, log.get_message_handler ());
773
797
}
774
798
775
799
// add failed symbols
@@ -782,21 +806,21 @@ bool cbmc_parse_optionst::process_goto_program(
782
806
// add loop ids
783
807
goto_model.goto_functions .compute_loop_numbers ();
784
808
785
- if (cmdline. isset (" drop-unused-functions" ))
809
+ if (options. get_bool_option (" drop-unused-functions" ))
786
810
{
787
811
// 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 ());
812
+ log. status () << " Removing unused functions" << eom;
813
+ remove_unused_functions (goto_model, log. get_message_handler ());
790
814
}
791
815
792
816
// remove skips such that trivial GOTOs are deleted and not considered
793
817
// for coverage annotation:
794
818
remove_skip (goto_model);
795
819
796
820
// instrument cover goals
797
- if (cmdline. isset (" cover" ))
821
+ if (options. is_set (" cover" ))
798
822
{
799
- if (instrument_cover_goals (options, goto_model, get_message_handler ()))
823
+ if (instrument_cover_goals (options, goto_model, log. get_message_handler ()))
800
824
return true ;
801
825
}
802
826
@@ -808,37 +832,39 @@ bool cbmc_parse_optionst::process_goto_program(
808
832
label_properties (goto_model);
809
833
810
834
// reachability slice?
811
- if (cmdline. isset (" reachability-slice-fb" ))
835
+ if (options. get_bool_option (" reachability-slice-fb" ))
812
836
{
813
- if (cmdline. isset (" reachability-slice" ))
837
+ if (options. get_bool_option (" reachability-slice" ))
814
838
{
815
- error () << " --reachability-slice and --reachability-slice-fb "
816
- << " must not be given together" << eom;
839
+ log. error () << " --reachability-slice and --reachability-slice-fb "
840
+ << " must not be given together" << eom;
817
841
return true ;
818
842
}
819
843
820
- status () << " Performing a forwards-backwards reachability slice" << eom;
821
- if (cmdline.isset (" property" ))
822
- reachability_slicer (goto_model, cmdline.get_values (" property" ), true );
844
+ log.status () << " Performing a forwards-backwards reachability slice"
845
+ << eom;
846
+ if (options.is_set (" property" ))
847
+ reachability_slicer (
848
+ goto_model, options.get_list_option (" property" ), true );
823
849
else
824
850
reachability_slicer (goto_model, true );
825
851
}
826
852
827
- if (cmdline. isset (" reachability-slice" ))
853
+ if (options. get_bool_option (" reachability-slice" ))
828
854
{
829
- status () << " Performing a reachability slice" << eom;
830
- if (cmdline. isset (" property" ))
831
- reachability_slicer (goto_model, cmdline. get_values (" property" ));
855
+ log. status () << " Performing a reachability slice" << eom;
856
+ if (options. is_set (" property" ))
857
+ reachability_slicer (goto_model, options. get_list_option (" property" ));
832
858
else
833
859
reachability_slicer (goto_model);
834
860
}
835
861
836
862
// full slice?
837
- if (cmdline. isset (" full-slice" ))
863
+ if (options. get_bool_option (" full-slice" ))
838
864
{
839
- status () << " Performing a full slice" << eom;
840
- if (cmdline. isset (" property" ))
841
- property_slicer (goto_model, cmdline. get_values (" property" ));
865
+ log. status () << " Performing a full slice" << eom;
866
+ if (options. is_set (" property" ))
867
+ property_slicer (goto_model, options. get_list_option (" property" ));
842
868
else
843
869
full_slicer (goto_model);
844
870
}
@@ -849,25 +875,25 @@ bool cbmc_parse_optionst::process_goto_program(
849
875
850
876
catch (const char *e)
851
877
{
852
- error () << e << eom;
878
+ log. error () << e << eom;
853
879
return true ;
854
880
}
855
881
856
882
catch (const std::string &e)
857
883
{
858
- error () << e << eom;
884
+ log. error () << e << eom;
859
885
return true ;
860
886
}
861
887
862
888
catch (int e)
863
889
{
864
- error () << " Numeric exception : " << e << eom;
890
+ log. error () << " Numeric exception : " << e << eom;
865
891
return true ;
866
892
}
867
893
868
894
catch (const std::bad_alloc &)
869
895
{
870
- error () << " Out of memory" << eom;
896
+ log. error () << " Out of memory" << eom;
871
897
exit (CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY);
872
898
return true ;
873
899
}
0 commit comments