@@ -132,6 +132,28 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
132132
133133 cbmc_parse_optionst::set_default_options (options);
134134
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+
135157 if (cmdline.isset (" paths" ))
136158 options.set_option (" paths" , true );
137159
@@ -165,6 +187,24 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
165187 if (cmdline.isset (" cpp11" ))
166188 config.cpp .set_cpp11 ();
167189
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+
168208 if (cmdline.isset (" no-simplify" ))
169209 options.set_option (" simplify" , false );
170210
@@ -227,21 +267,6 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
227267 if (cmdline.isset (" partial-loops" ))
228268 options.set_option (" partial-loops" , true );
229269
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-
245270 // remove unused equations
246271 if (cmdline.isset (" slice-formula" ))
247272 options.set_option (" slice-formula" , true );
@@ -532,7 +557,8 @@ int cbmc_parse_optionst::doit()
532557 return CPROVER_EXIT_SUCCESS;
533558 }
534559
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);
536562
537563 if (get_goto_program_ret!=-1 )
538564 return get_goto_program_ret;
@@ -585,25 +611,29 @@ bool cbmc_parse_optionst::set_properties()
585611}
586612
587613int 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)
589619{
590620 if (cmdline.args .empty ())
591621 {
592- error () << " Please provide a program to verify" << eom;
622+ log. error () << " Please provide a program to verify" << log. eom ;
593623 return CPROVER_EXIT_INCORRECT_TASK;
594624 }
595625
596626 try
597627 {
598- goto_model= initialize_goto_model (cmdline, get_message_handler () );
628+ goto_model = initialize_goto_model (cmdline, ui_message_handler );
599629
600630 if (cmdline.isset (" show-symbol-table" ))
601631 {
602632 show_symbol_table (goto_model, ui_message_handler.get_ui ());
603633 return CPROVER_EXIT_SUCCESS;
604634 }
605635
606- if (process_goto_program (options))
636+ if (cbmc_parse_optionst:: process_goto_program (goto_model, options, log ))
607637 return CPROVER_EXIT_INTERNAL_ERROR;
608638
609639 // show it?
@@ -620,36 +650,36 @@ int cbmc_parse_optionst::get_goto_program(
620650 {
621651 show_goto_functions (
622652 goto_model,
623- get_message_handler () ,
653+ ui_message_handler ,
624654 ui_message_handler.get_ui (),
625655 cmdline.isset (" list-goto-functions" ));
626656 return CPROVER_EXIT_SUCCESS;
627657 }
628658
629- status () << config.object_bits_info () << eom;
659+ log. status () << config.object_bits_info () << log. eom ;
630660 }
631661
632662 catch (const char *e)
633663 {
634- error () << e << eom;
664+ log. error () << e << log. eom ;
635665 return CPROVER_EXIT_EXCEPTION;
636666 }
637667
638668 catch (const std::string &e)
639669 {
640- error () << e << eom;
670+ log. error () << e << log. eom ;
641671 return CPROVER_EXIT_EXCEPTION;
642672 }
643673
644674 catch (int e)
645675 {
646- error () << " Numeric exception : " << e << eom;
676+ log. error () << " Numeric exception : " << e << log. eom ;
647677 return CPROVER_EXIT_EXCEPTION;
648678 }
649679
650680 catch (const std::bad_alloc &)
651681 {
652- error () << " Out of memory" << eom;
682+ log. error () << " Out of memory" << log. eom ;
653683 return CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY;
654684 }
655685
@@ -714,7 +744,9 @@ void cbmc_parse_optionst::preprocessing()
714744}
715745
716746bool cbmc_parse_optionst::process_goto_program (
717- const optionst &options)
747+ goto_modelt &goto_model,
748+ const optionst &options,
749+ messaget &log)
718750{
719751 try
720752 {
@@ -723,17 +755,17 @@ bool cbmc_parse_optionst::process_goto_program(
723755 remove_asm (goto_model);
724756
725757 // add the library
726- link_to_library (goto_model, get_message_handler ());
758+ link_to_library (goto_model, log. get_message_handler ());
727759
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 ());
730762
731763 // remove function pointers
732- status () << " Removal of function pointers and virtual functions" << eom;
764+ log. status () << " Removal of function pointers and virtual functions" << eom;
733765 remove_function_pointers (
734- get_message_handler (),
766+ log. get_message_handler (),
735767 goto_model,
736- cmdline. isset (" pointer-check" ));
768+ options. get_bool_option (" pointer-check" ));
737769 // remove catch and throw (introduces instanceof)
738770 remove_exceptions (goto_model);
739771
@@ -749,27 +781,26 @@ bool cbmc_parse_optionst::process_goto_program(
749781 rewrite_union (goto_model);
750782
751783 // add generic checks
752- status () << " Generic Property Instrumentation" << eom;
784+ log. status () << " Generic Property Instrumentation" << eom;
753785 goto_check (options, goto_model);
754786
755787 // checks don't know about adjusted float expressions
756788 adjust_float_expressions (goto_model);
757789
758790 // ignore default/user-specified initialization
759791 // of variables with static lifetime
760- if (cmdline. isset (" nondet-static" ))
792+ if (options. get_bool_option (" nondet-static" ))
761793 {
762- status () << " Adding nondeterministic initialization "
763- " of static/global variables" << eom;
794+ log.status () << " Adding nondeterministic initialization "
795+ " of static/global variables"
796+ << eom;
764797 nondet_static (goto_model);
765798 }
766799
767- if (cmdline. isset (" string-abstraction" ))
800+ if (options. get_bool_option (" string-abstraction" ))
768801 {
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 ());
773804 }
774805
775806 // add failed symbols
@@ -782,21 +813,21 @@ bool cbmc_parse_optionst::process_goto_program(
782813 // add loop ids
783814 goto_model.goto_functions .compute_loop_numbers ();
784815
785- if (cmdline. isset (" drop-unused-functions" ))
816+ if (options. get_bool_option (" drop-unused-functions" ))
786817 {
787818 // 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 ());
790821 }
791822
792823 // remove skips such that trivial GOTOs are deleted and not considered
793824 // for coverage annotation:
794825 remove_skip (goto_model);
795826
796827 // instrument cover goals
797- if (cmdline. isset (" cover" ))
828+ if (options. is_set (" cover" ))
798829 {
799- if (instrument_cover_goals (options, goto_model, get_message_handler ()))
830+ if (instrument_cover_goals (options, goto_model, log. get_message_handler ()))
800831 return true ;
801832 }
802833
@@ -808,37 +839,32 @@ bool cbmc_parse_optionst::process_goto_program(
808839 label_properties (goto_model);
809840
810841 // reachability slice?
811- if (cmdline. isset (" reachability-slice-fb" ))
842+ if (options. get_bool_option (" reachability-slice-fb" ))
812843 {
813- if (cmdline.isset (" reachability-slice" ))
814- {
815- error () << " --reachability-slice and --reachability-slice-fb "
816- << " must not be given together" << eom;
817- return true ;
818- }
819-
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 );
823849 else
824850 reachability_slicer (goto_model, true );
825851 }
826852
827- if (cmdline. isset (" reachability-slice" ))
853+ if (options. get_bool_option (" reachability-slice" ))
828854 {
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" ));
832858 else
833859 reachability_slicer (goto_model);
834860 }
835861
836862 // full slice?
837- if (cmdline. isset (" full-slice" ))
863+ if (options. get_bool_option (" full-slice" ))
838864 {
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" ));
842868 else
843869 full_slicer (goto_model);
844870 }
@@ -849,25 +875,25 @@ bool cbmc_parse_optionst::process_goto_program(
849875
850876 catch (const char *e)
851877 {
852- error () << e << eom;
878+ log. error () << e << eom;
853879 return true ;
854880 }
855881
856882 catch (const std::string &e)
857883 {
858- error () << e << eom;
884+ log. error () << e << eom;
859885 return true ;
860886 }
861887
862888 catch (int e)
863889 {
864- error () << " Numeric exception : " << e << eom;
890+ log. error () << " Numeric exception : " << e << eom;
865891 return true ;
866892 }
867893
868894 catch (const std::bad_alloc &)
869895 {
870- error () << " Out of memory" << eom;
896+ log. error () << " Out of memory" << eom;
871897 exit (CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY);
872898 return true ;
873899 }
0 commit comments