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