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