@@ -534,7 +534,8 @@ int cbmc_parse_optionst::doit()
534534 return CPROVER_EXIT_SUCCESS;
535535 }
536536
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);
538539
539540 if (get_goto_program_ret!=-1 )
540541 return get_goto_program_ret;
@@ -587,25 +588,29 @@ bool cbmc_parse_optionst::set_properties()
587588}
588589
589590int 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)
591596{
592597 if (cmdline.args .empty ())
593598 {
594- error () << " Please provide a program to verify" << eom;
599+ log. error () << " Please provide a program to verify" << log. eom ;
595600 return CPROVER_EXIT_INCORRECT_TASK;
596601 }
597602
598603 try
599604 {
600- goto_model= initialize_goto_model (cmdline, get_message_handler () );
605+ goto_model = initialize_goto_model (cmdline, ui_message_handler );
601606
602607 if (cmdline.isset (" show-symbol-table" ))
603608 {
604609 show_symbol_table (goto_model, ui_message_handler.get_ui ());
605610 return CPROVER_EXIT_SUCCESS;
606611 }
607612
608- if (process_goto_program (options))
613+ if (cbmc_parse_optionst:: process_goto_program (goto_model, options, log ))
609614 return CPROVER_EXIT_INTERNAL_ERROR;
610615
611616 // show it?
@@ -622,36 +627,36 @@ int cbmc_parse_optionst::get_goto_program(
622627 {
623628 show_goto_functions (
624629 goto_model,
625- get_message_handler () ,
630+ ui_message_handler ,
626631 ui_message_handler.get_ui (),
627632 cmdline.isset (" list-goto-functions" ));
628633 return CPROVER_EXIT_SUCCESS;
629634 }
630635
631- status () << config.object_bits_info () << eom;
636+ log. status () << config.object_bits_info () << log. eom ;
632637 }
633638
634639 catch (const char *e)
635640 {
636- error () << e << eom;
641+ log. error () << e << log. eom ;
637642 return CPROVER_EXIT_EXCEPTION;
638643 }
639644
640645 catch (const std::string &e)
641646 {
642- error () << e << eom;
647+ log. error () << e << log. eom ;
643648 return CPROVER_EXIT_EXCEPTION;
644649 }
645650
646651 catch (int e)
647652 {
648- error () << " Numeric exception : " << e << eom;
653+ log. error () << " Numeric exception : " << e << log. eom ;
649654 return CPROVER_EXIT_EXCEPTION;
650655 }
651656
652657 catch (const std::bad_alloc &)
653658 {
654- error () << " Out of memory" << eom;
659+ log. error () << " Out of memory" << log. eom ;
655660 return CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY;
656661 }
657662
@@ -716,7 +721,9 @@ void cbmc_parse_optionst::preprocessing()
716721}
717722
718723bool cbmc_parse_optionst::process_goto_program (
719- const optionst &options)
724+ goto_modelt &goto_model,
725+ const optionst &options,
726+ messaget &log)
720727{
721728 try
722729 {
@@ -725,17 +732,17 @@ bool cbmc_parse_optionst::process_goto_program(
725732 remove_asm (goto_model);
726733
727734 // add the library
728- link_to_library (goto_model, get_message_handler ());
735+ link_to_library (goto_model, log. get_message_handler ());
729736
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 ());
732739
733740 // remove function pointers
734- status () << " Removal of function pointers and virtual functions" << eom;
741+ log. status () << " Removal of function pointers and virtual functions" << eom;
735742 remove_function_pointers (
736- get_message_handler (),
743+ log. get_message_handler (),
737744 goto_model,
738- cmdline. isset (" pointer-check" ));
745+ options. get_bool_option (" pointer-check" ));
739746 // remove catch and throw (introduces instanceof)
740747 remove_exceptions (goto_model);
741748
@@ -751,27 +758,26 @@ bool cbmc_parse_optionst::process_goto_program(
751758 rewrite_union (goto_model);
752759
753760 // add generic checks
754- status () << " Generic Property Instrumentation" << eom;
761+ log. status () << " Generic Property Instrumentation" << eom;
755762 goto_check (options, goto_model);
756763
757764 // checks don't know about adjusted float expressions
758765 adjust_float_expressions (goto_model);
759766
760767 // ignore default/user-specified initialization
761768 // of variables with static lifetime
762- if (cmdline. isset (" nondet-static" ))
769+ if (options. get_bool_option (" nondet-static" ))
763770 {
764- status () << " Adding nondeterministic initialization "
765- " of static/global variables" << eom;
771+ log.status () << " Adding nondeterministic initialization "
772+ " of static/global variables"
773+ << eom;
766774 nondet_static (goto_model);
767775 }
768776
769- if (cmdline. isset (" string-abstraction" ))
777+ if (options. get_bool_option (" string-abstraction" ))
770778 {
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 ());
775781 }
776782
777783 // add failed symbols
@@ -784,21 +790,21 @@ bool cbmc_parse_optionst::process_goto_program(
784790 // add loop ids
785791 goto_model.goto_functions .compute_loop_numbers ();
786792
787- if (cmdline. isset (" drop-unused-functions" ))
793+ if (options. get_bool_option (" drop-unused-functions" ))
788794 {
789795 // 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 ());
792798 }
793799
794800 // remove skips such that trivial GOTOs are deleted and not considered
795801 // for coverage annotation:
796802 remove_skip (goto_model);
797803
798804 // instrument cover goals
799- if (cmdline. isset (" cover" ))
805+ if (options. get_bool_option (" cover" ))
800806 {
801- if (instrument_cover_goals (options, goto_model, get_message_handler ()))
807+ if (instrument_cover_goals (options, goto_model, log. get_message_handler ()))
802808 return true ;
803809 }
804810
@@ -810,37 +816,39 @@ bool cbmc_parse_optionst::process_goto_program(
810816 label_properties (goto_model);
811817
812818 // reachability slice?
813- if (cmdline. isset (" reachability-slice-fb" ))
819+ if (options. get_bool_option (" reachability-slice-fb" ))
814820 {
815- if (cmdline. isset (" reachability-slice" ))
821+ if (options. get_bool_option (" reachability-slice" ))
816822 {
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;
819825 return true ;
820826 }
821827
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.is_set (" property" ))
831+ reachability_slicer (
832+ goto_model, options.get_list_option (" property" ), true );
825833 else
826834 reachability_slicer (goto_model, true );
827835 }
828836
829- if (cmdline. isset (" reachability-slice" ))
837+ if (options. get_bool_option (" reachability-slice" ))
830838 {
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. is_set (" property" ))
841+ reachability_slicer (goto_model, options. get_list_option (" property" ));
834842 else
835843 reachability_slicer (goto_model);
836844 }
837845
838846 // full slice?
839- if (cmdline. isset (" full-slice" ))
847+ if (options. get_bool_option (" full-slice" ))
840848 {
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. is_set (" property" ))
851+ property_slicer (goto_model, options. get_list_option (" property" ));
844852 else
845853 full_slicer (goto_model);
846854 }
@@ -851,25 +859,25 @@ bool cbmc_parse_optionst::process_goto_program(
851859
852860 catch (const char *e)
853861 {
854- error () << e << eom;
862+ log. error () << e << eom;
855863 return true ;
856864 }
857865
858866 catch (const std::string &e)
859867 {
860- error () << e << eom;
868+ log. error () << e << eom;
861869 return true ;
862870 }
863871
864872 catch (int e)
865873 {
866- error () << " Numeric exception : " << e << eom;
874+ log. error () << " Numeric exception : " << e << eom;
867875 return true ;
868876 }
869877
870878 catch (const std::bad_alloc &)
871879 {
872- error () << " Out of memory" << eom;
880+ log. error () << " Out of memory" << eom;
873881 exit (CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY);
874882 return true ;
875883 }
0 commit comments