@@ -97,13 +97,7 @@ void cbmc_parse_optionst::set_default_options(optionst &options)
9797 options.set_option (" simplify" , true );
9898 options.set_option (" simplify-if" , true );
9999
100- // Default false
101- options.set_option (" partial-loops" , false );
102- options.set_option (" slice-formula" , false );
103- options.set_option (" stop-on-fail" , false );
104- options.set_option (" unwinding-assertions" , false );
105-
106- // Other
100+ // Other default
107101 options.set_option (" arrays-uf" , " auto" );
108102}
109103
@@ -132,6 +126,28 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
132126
133127 cbmc_parse_optionst::set_default_options (options);
134128
129+ if (cmdline.isset (" cover" ) && cmdline.isset (" unwinding-assertions" ))
130+ {
131+ error () << " --cover and --unwinding-assertions must not be given together"
132+ << eom;
133+ exit (CPROVER_EXIT_USAGE_ERROR);
134+ }
135+
136+ if (cmdline.isset (" partial-loops" ) && cmdline.isset (" unwinding-assertions" ))
137+ {
138+ error () << " --partial-loops and --unwinding-assertions must not be given "
139+ << " together" << eom;
140+ exit (CPROVER_EXIT_USAGE_ERROR);
141+ }
142+
143+ if (cmdline.isset (" reachability-slice" ) &&
144+ cmdline.isset (" reachability-slice-fb" ))
145+ {
146+ error () << " --reachability-slice and --reachability-slice-fb must not be "
147+ << " given together" << eom;
148+ exit (CPROVER_EXIT_USAGE_ERROR);
149+ }
150+
135151 if (cmdline.isset (" paths" ))
136152 options.set_option (" paths" , true );
137153
@@ -165,6 +181,24 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
165181 if (cmdline.isset (" cpp11" ))
166182 config.cpp .set_cpp11 ();
167183
184+ if (cmdline.isset (" property" ))
185+ options.set_option (" property" , cmdline.get_values (" property" ));
186+
187+ if (cmdline.isset (" drop-unused-functions" ))
188+ options.set_option (" drop-unused-functions" , true );
189+
190+ if (cmdline.isset (" string-abstraction" ))
191+ options.set_option (" string-abstraction" , true );
192+
193+ if (cmdline.isset (" reachability-slice-fb" ))
194+ options.set_option (" reachability-slice-fb" , true );
195+
196+ if (cmdline.isset (" reachability-slice" ))
197+ options.set_option (" reachability-slice" , true );
198+
199+ if (cmdline.isset (" nondet-static" ))
200+ options.set_option (" nondet-static" , true );
201+
168202 if (cmdline.isset (" no-simplify" ))
169203 options.set_option (" simplify" , false );
170204
@@ -227,21 +261,6 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
227261 if (cmdline.isset (" partial-loops" ))
228262 options.set_option (" partial-loops" , true );
229263
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-
245264 // remove unused equations
246265 if (cmdline.isset (" slice-formula" ))
247266 options.set_option (" slice-formula" , true );
@@ -532,7 +551,8 @@ int cbmc_parse_optionst::doit()
532551 return CPROVER_EXIT_SUCCESS;
533552 }
534553
535- int get_goto_program_ret=get_goto_program (options);
554+ int get_goto_program_ret =
555+ get_goto_program (goto_model, options, cmdline, *this , ui_message_handler);
536556
537557 if (get_goto_program_ret!=-1 )
538558 return get_goto_program_ret;
@@ -585,25 +605,29 @@ bool cbmc_parse_optionst::set_properties()
585605}
586606
587607int cbmc_parse_optionst::get_goto_program (
588- const optionst &options)
608+ goto_modelt &goto_model,
609+ const optionst &options,
610+ const cmdlinet &cmdline,
611+ messaget &log,
612+ ui_message_handlert &ui_message_handler)
589613{
590614 if (cmdline.args .empty ())
591615 {
592- error () << " Please provide a program to verify" << eom;
616+ log. error () << " Please provide a program to verify" << log. eom ;
593617 return CPROVER_EXIT_INCORRECT_TASK;
594618 }
595619
596620 try
597621 {
598- goto_model= initialize_goto_model (cmdline, get_message_handler () );
622+ goto_model = initialize_goto_model (cmdline, ui_message_handler );
599623
600624 if (cmdline.isset (" show-symbol-table" ))
601625 {
602626 show_symbol_table (goto_model, ui_message_handler.get_ui ());
603627 return CPROVER_EXIT_SUCCESS;
604628 }
605629
606- if (process_goto_program (options))
630+ if (cbmc_parse_optionst:: process_goto_program (goto_model, options, log ))
607631 return CPROVER_EXIT_INTERNAL_ERROR;
608632
609633 // show it?
@@ -620,36 +644,36 @@ int cbmc_parse_optionst::get_goto_program(
620644 {
621645 show_goto_functions (
622646 goto_model,
623- get_message_handler () ,
647+ ui_message_handler ,
624648 ui_message_handler.get_ui (),
625649 cmdline.isset (" list-goto-functions" ));
626650 return CPROVER_EXIT_SUCCESS;
627651 }
628652
629- status () << config.object_bits_info () << eom;
653+ log. status () << config.object_bits_info () << log. eom ;
630654 }
631655
632656 catch (const char *e)
633657 {
634- error () << e << eom;
658+ log. error () << e << log. eom ;
635659 return CPROVER_EXIT_EXCEPTION;
636660 }
637661
638662 catch (const std::string &e)
639663 {
640- error () << e << eom;
664+ log. error () << e << log. eom ;
641665 return CPROVER_EXIT_EXCEPTION;
642666 }
643667
644668 catch (int e)
645669 {
646- error () << " Numeric exception : " << e << eom;
670+ log. error () << " Numeric exception : " << e << log. eom ;
647671 return CPROVER_EXIT_EXCEPTION;
648672 }
649673
650674 catch (const std::bad_alloc &)
651675 {
652- error () << " Out of memory" << eom;
676+ log. error () << " Out of memory" << log. eom ;
653677 return CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY;
654678 }
655679
@@ -714,7 +738,9 @@ void cbmc_parse_optionst::preprocessing()
714738}
715739
716740bool cbmc_parse_optionst::process_goto_program (
717- const optionst &options)
741+ goto_modelt &goto_model,
742+ const optionst &options,
743+ messaget &log)
718744{
719745 try
720746 {
@@ -723,17 +749,17 @@ bool cbmc_parse_optionst::process_goto_program(
723749 remove_asm (goto_model);
724750
725751 // add the library
726- link_to_library (goto_model, get_message_handler ());
752+ link_to_library (goto_model, log. get_message_handler ());
727753
728- if (cmdline. isset (" string-abstraction" ))
729- string_instrumentation (goto_model, get_message_handler ());
754+ if (options. get_bool_option (" string-abstraction" ))
755+ string_instrumentation (goto_model, log. get_message_handler ());
730756
731757 // remove function pointers
732- status () << " Removal of function pointers and virtual functions" << eom;
758+ log. status () << " Removal of function pointers and virtual functions" << eom;
733759 remove_function_pointers (
734- get_message_handler (),
760+ log. get_message_handler (),
735761 goto_model,
736- cmdline. isset (" pointer-check" ));
762+ options. get_bool_option (" pointer-check" ));
737763 // remove catch and throw (introduces instanceof)
738764 remove_exceptions (goto_model);
739765
@@ -749,27 +775,26 @@ bool cbmc_parse_optionst::process_goto_program(
749775 rewrite_union (goto_model);
750776
751777 // add generic checks
752- status () << " Generic Property Instrumentation" << eom;
778+ log. status () << " Generic Property Instrumentation" << eom;
753779 goto_check (options, goto_model);
754780
755781 // checks don't know about adjusted float expressions
756782 adjust_float_expressions (goto_model);
757783
758784 // ignore default/user-specified initialization
759785 // of variables with static lifetime
760- if (cmdline. isset (" nondet-static" ))
786+ if (options. get_bool_option (" nondet-static" ))
761787 {
762- status () << " Adding nondeterministic initialization "
763- " of static/global variables" << eom;
788+ log.status () << " Adding nondeterministic initialization "
789+ " of static/global variables"
790+ << eom;
764791 nondet_static (goto_model);
765792 }
766793
767- if (cmdline. isset (" string-abstraction" ))
794+ if (options. get_bool_option (" string-abstraction" ))
768795 {
769- status () << " String Abstraction" << eom;
770- string_abstraction (
771- goto_model,
772- get_message_handler ());
796+ log.status () << " String Abstraction" << eom;
797+ string_abstraction (goto_model, log.get_message_handler ());
773798 }
774799
775800 // add failed symbols
@@ -782,21 +807,21 @@ bool cbmc_parse_optionst::process_goto_program(
782807 // add loop ids
783808 goto_model.goto_functions .compute_loop_numbers ();
784809
785- if (cmdline. isset (" drop-unused-functions" ))
810+ if (options. get_bool_option (" drop-unused-functions" ))
786811 {
787812 // 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 ());
813+ log. status () << " Removing unused functions" << eom;
814+ remove_unused_functions (goto_model, log. get_message_handler ());
790815 }
791816
792817 // remove skips such that trivial GOTOs are deleted and not considered
793818 // for coverage annotation:
794819 remove_skip (goto_model);
795820
796821 // instrument cover goals
797- if (cmdline. isset (" cover" ))
822+ if (options. is_set (" cover" ))
798823 {
799- if (instrument_cover_goals (options, goto_model, get_message_handler ()))
824+ if (instrument_cover_goals (options, goto_model, log. get_message_handler ()))
800825 return true ;
801826 }
802827
@@ -808,37 +833,32 @@ bool cbmc_parse_optionst::process_goto_program(
808833 label_properties (goto_model);
809834
810835 // reachability slice?
811- if (cmdline. isset (" reachability-slice-fb" ))
836+ if (options. get_bool_option (" reachability-slice-fb" ))
812837 {
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 );
838+ log.status () << " Performing a forwards-backwards reachability slice"
839+ << eom;
840+ if (options.is_set (" property" ))
841+ reachability_slicer (
842+ goto_model, options.get_list_option (" property" ), true );
823843 else
824844 reachability_slicer (goto_model, true );
825845 }
826846
827- if (cmdline. isset (" reachability-slice" ))
847+ if (options. get_bool_option (" reachability-slice" ))
828848 {
829- status () << " Performing a reachability slice" << eom;
830- if (cmdline. isset (" property" ))
831- reachability_slicer (goto_model, cmdline. get_values (" property" ));
849+ log. status () << " Performing a reachability slice" << eom;
850+ if (options. is_set (" property" ))
851+ reachability_slicer (goto_model, options. get_list_option (" property" ));
832852 else
833853 reachability_slicer (goto_model);
834854 }
835855
836856 // full slice?
837- if (cmdline. isset (" full-slice" ))
857+ if (options. get_bool_option (" full-slice" ))
838858 {
839- status () << " Performing a full slice" << eom;
840- if (cmdline. isset (" property" ))
841- property_slicer (goto_model, cmdline. get_values (" property" ));
859+ log. status () << " Performing a full slice" << eom;
860+ if (options. is_set (" property" ))
861+ property_slicer (goto_model, options. get_list_option (" property" ));
842862 else
843863 full_slicer (goto_model);
844864 }
@@ -849,25 +869,25 @@ bool cbmc_parse_optionst::process_goto_program(
849869
850870 catch (const char *e)
851871 {
852- error () << e << eom;
872+ log. error () << e << eom;
853873 return true ;
854874 }
855875
856876 catch (const std::string &e)
857877 {
858- error () << e << eom;
878+ log. error () << e << eom;
859879 return true ;
860880 }
861881
862882 catch (int e)
863883 {
864- error () << " Numeric exception : " << e << eom;
884+ log. error () << " Numeric exception : " << e << eom;
865885 return true ;
866886 }
867887
868888 catch (const std::bad_alloc &)
869889 {
870- error () << " Out of memory" << eom;
890+ log. error () << " Out of memory" << eom;
871891 exit (CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY);
872892 return true ;
873893 }
0 commit comments