Skip to content

Commit 0f928f8

Browse files
Merge pull request #4520 from romainbrenguier/clean-up/jbmc-parse-options-messaget
jbmc_parse_options is not a messaget
2 parents 05769c0 + d585426 commit 0f928f8

File tree

2 files changed

+67
-68
lines changed

2 files changed

+67
-68
lines changed

jbmc/src/jbmc/jbmc_parse_options.cpp

Lines changed: 66 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ Author: Daniel Kroening, [email protected]
7878

7979
jbmc_parse_optionst::jbmc_parse_optionst(int argc, const char **argv)
8080
: parse_options_baset(JBMC_OPTIONS, argc, argv, ui_message_handler),
81-
messaget(ui_message_handler),
8281
ui_message_handler(cmdline, std::string("JBMC ") + CBMC_VERSION)
8382
{
8483
}
@@ -92,7 +91,6 @@ ::jbmc_parse_optionst::jbmc_parse_optionst(
9291
argc,
9392
argv,
9493
ui_message_handler),
95-
messaget(ui_message_handler),
9694
ui_message_handler(cmdline, std::string("JBMC ") + CBMC_VERSION)
9795
{
9896
}
@@ -134,11 +132,11 @@ void jbmc_parse_optionst::get_command_line_options(optionst &options)
134132

135133
if(cmdline.isset("show-symex-strategies"))
136134
{
137-
status() << show_path_strategies() << eom;
135+
log.status() << show_path_strategies() << messaget::eom;
138136
exit(CPROVER_EXIT_SUCCESS);
139137
}
140138

141-
parse_path_strategy_options(cmdline, options, ui_message_handler);
139+
parse_path_strategy_options(cmdline, options, log.get_message_handler());
142140

143141
if(cmdline.isset("program-only"))
144142
options.set_option("program-only", true);
@@ -217,8 +215,8 @@ void jbmc_parse_optionst::get_command_line_options(optionst &options)
217215
if(options.get_bool_option("partial-loops") &&
218216
options.get_bool_option("unwinding-assertions"))
219217
{
220-
error() << "--partial-loops and --unwinding-assertions "
221-
<< "must not be given together" << eom;
218+
log.error() << "--partial-loops and --unwinding-assertions "
219+
<< "must not be given together" << messaget::eom;
222220
exit(1); // should contemplate EX_USAGE from sysexits.h
223221
}
224222

@@ -293,7 +291,7 @@ void jbmc_parse_optionst::get_command_line_options(optionst &options)
293291

294292
if(cmdline.isset("smt1"))
295293
{
296-
error() << "--smt1 is no longer supported" << eom;
294+
log.error() << "--smt1 is no longer supported" << messaget::eom;
297295
exit(CPROVER_EXIT_USAGE_ERROR);
298296
}
299297

@@ -424,8 +422,10 @@ int jbmc_parse_optionst::doit()
424422
return 0; // should contemplate EX_OK from sysexits.h
425423
}
426424

427-
eval_verbosity(
428-
cmdline.get_value("verbosity"), messaget::M_STATISTICS, ui_message_handler);
425+
messaget::eval_verbosity(
426+
cmdline.get_value("verbosity"),
427+
messaget::M_STATISTICS,
428+
log.get_message_handler());
429429

430430
//
431431
// command line options
@@ -437,28 +437,29 @@ int jbmc_parse_optionst::doit()
437437
//
438438
// Print a banner
439439
//
440-
status() << "JBMC version " << CBMC_VERSION << " " << sizeof(void *) * 8
441-
<< "-bit " << config.this_architecture() << " "
442-
<< config.this_operating_system() << eom;
440+
log.status() << "JBMC version " << CBMC_VERSION << " " << sizeof(void *) * 8
441+
<< "-bit " << config.this_architecture() << " "
442+
<< config.this_operating_system() << messaget::eom;
443443

444444
// output the options
445445
switch(ui_message_handler.get_ui())
446446
{
447447
case ui_message_handlert::uit::PLAIN:
448-
conditional_output(debug(), [&options](messaget::mstreamt &debug_stream) {
449-
debug_stream << "\nOptions: \n";
450-
options.output(debug_stream);
451-
debug_stream << messaget::eom;
452-
});
448+
log.conditional_output(
449+
log.debug(), [&options](messaget::mstreamt &debug_stream) {
450+
debug_stream << "\nOptions: \n";
451+
options.output(debug_stream);
452+
debug_stream << messaget::eom;
453+
});
453454
break;
454455
case ui_message_handlert::uit::JSON_UI:
455456
{
456457
json_objectt json_options{{"options", options.to_json()}};
457-
debug() << json_options;
458+
log.debug() << json_options;
458459
break;
459460
}
460461
case ui_message_handlert::uit::XML_UI:
461-
debug() << options.to_xml();
462+
log.debug() << options.to_xml();
462463
break;
463464
}
464465

@@ -469,7 +470,7 @@ int jbmc_parse_optionst::doit()
469470
{
470471
if(cmdline.args.size()!=1)
471472
{
472-
error() << "Please give exactly one source file" << eom;
473+
log.error() << "Please give exactly one source file" << messaget::eom;
473474
return 6;
474475
}
475476

@@ -483,8 +484,8 @@ int jbmc_parse_optionst::doit()
483484

484485
if(!infile)
485486
{
486-
error() << "failed to open input file `"
487-
<< filename << "'" << eom;
487+
log.error() << "failed to open input file `" << filename << "'"
488+
<< messaget::eom;
488489
return 6;
489490
}
490491

@@ -493,19 +494,19 @@ int jbmc_parse_optionst::doit()
493494

494495
if(language==nullptr)
495496
{
496-
error() << "failed to figure out type of file `"
497-
<< filename << "'" << eom;
497+
log.error() << "failed to figure out type of file `" << filename << "'"
498+
<< messaget::eom;
498499
return 6;
499500
}
500501

501502
language->set_language_options(options);
502-
language->set_message_handler(get_message_handler());
503+
language->set_message_handler(log.get_message_handler());
503504

504-
status() << "Parsing " << filename << eom;
505+
log.status() << "Parsing " << filename << messaget::eom;
505506

506507
if(language->parse(infile, filename))
507508
{
508-
error() << "PARSING ERROR" << eom;
509+
log.error() << "PARSING ERROR" << messaget::eom;
509510
return 6;
510511
}
511512

@@ -536,18 +537,18 @@ int jbmc_parse_optionst::doit()
536537

537538
if(cmdline.args.empty())
538539
{
539-
error() << "Please provide a program to verify" << eom;
540+
log.error() << "Please provide a program to verify" << messaget::eom;
540541
return 6;
541542
}
542543

543544
if(cmdline.args.size() != 1)
544545
{
545-
error() << "Only one .class, .jar or .gbf file should be directly "
546-
"specified on the command-line. To force loading another another class "
547-
"use '--java-load-class somepackage.SomeClass' or "
548-
"'--lazy-methods-extra-entry-point somepackage.SomeClass.method' along "
549-
"with '--classpath'"
550-
<< messaget::eom;
546+
log.error() << "Only one .class, .jar or .gbf file should be directly "
547+
"specified on the command-line. To force loading another "
548+
"another class use '--java-load-class somepackage.SomeClass'"
549+
" or '--lazy-methods-extra-entry-point "
550+
"somepackage.SomeClass.method' along with '--classpath'"
551+
<< messaget::eom;
551552
return 6;
552553
}
553554

@@ -563,7 +564,7 @@ int jbmc_parse_optionst::doit()
563564
if(cmdline.isset("show-properties"))
564565
{
565566
show_properties(
566-
goto_model, get_message_handler(), ui_message_handler.get_ui());
567+
goto_model, log.get_message_handler(), ui_message_handler.get_ui());
567568
return 0; // should contemplate EX_OK from sysexits.h
568569
}
569570

@@ -681,8 +682,8 @@ int jbmc_parse_optionst::doit()
681682
else
682683
{
683684
// Use symex-driven lazy loading:
684-
lazy_goto_modelt lazy_goto_model=lazy_goto_modelt::from_handler_object(
685-
*this, options, get_message_handler());
685+
lazy_goto_modelt lazy_goto_model =
686+
lazy_goto_modelt::from_handler_object(*this, options, ui_message_handler);
686687
lazy_goto_model.initialize(cmdline.args, options);
687688

688689
class_hierarchy =
@@ -693,7 +694,7 @@ int jbmc_parse_optionst::doit()
693694
// trip an invariant when it tries to load it)
694695
if(!lazy_goto_model.symbol_table.has_symbol(goto_functionst::entry_point()))
695696
{
696-
error() << "the program has no entry point";
697+
log.error() << "the program has no entry point";
697698
return 6;
698699
}
699700

@@ -738,8 +739,8 @@ int jbmc_parse_optionst::get_goto_program(
738739
const optionst &options)
739740
{
740741
{
741-
lazy_goto_modelt lazy_goto_model=lazy_goto_modelt::from_handler_object(
742-
*this, options, get_message_handler());
742+
lazy_goto_modelt lazy_goto_model =
743+
lazy_goto_modelt::from_handler_object(*this, options, ui_message_handler);
743744
lazy_goto_model.initialize(cmdline.args, options);
744745

745746
class_hierarchy =
@@ -756,7 +757,7 @@ int jbmc_parse_optionst::get_goto_program(
756757
// particular function:
757758
add_failed_symbols(lazy_goto_model.symbol_table);
758759

759-
status() << "Generating GOTO Program" << messaget::eom;
760+
log.status() << "Generating GOTO Program" << messaget::eom;
760761
lazy_goto_model.load_all_functions();
761762

762763
// Show the symbol table before process_goto_functions mangles return
@@ -798,13 +799,13 @@ int jbmc_parse_optionst::get_goto_program(
798799
{
799800
show_goto_functions(
800801
*goto_model,
801-
get_message_handler(),
802+
log.get_message_handler(),
802803
ui_message_handler.get_ui(),
803804
cmdline.isset("list-goto-functions"));
804805
return 0;
805806
}
806807

807-
status() << config.object_bits_info() << eom;
808+
log.status() << config.object_bits_info() << messaget::eom;
808809
}
809810

810811
return -1; // no error, continue
@@ -829,7 +830,7 @@ void jbmc_parse_optionst::process_goto_function(
829830
goto_function,
830831
symbol_table,
831832
*class_hierarchy,
832-
get_message_handler());
833+
log.get_message_handler());
833834
// Java virtual functions -> explicit dispatch tables:
834835
remove_virtual_functions(function);
835836

@@ -844,10 +845,7 @@ void jbmc_parse_optionst::process_goto_function(
844845

845846
// Similar removal of java nondet statements:
846847
convert_nondet(
847-
function,
848-
get_message_handler(),
849-
object_factory_params,
850-
ID_java);
848+
function, ui_message_handler, object_factory_params, ID_java);
851849

852850
if(using_symex_driven_loading)
853851
{
@@ -861,7 +859,7 @@ void jbmc_parse_optionst::process_goto_function(
861859
goto_function.body,
862860
symbol_table,
863861
*class_hierarchy.get(),
864-
get_message_handler());
862+
ui_message_handler);
865863
}
866864

867865
// add generic checks
@@ -873,7 +871,7 @@ void jbmc_parse_optionst::process_goto_function(
873871
function.get_function_id(),
874872
goto_function,
875873
symbol_table,
876-
get_message_handler());
874+
ui_message_handler);
877875

878876
// checks don't know about adjusted float expressions
879877
adjust_float_expressions(goto_function, ns);
@@ -932,7 +930,7 @@ bool jbmc_parse_optionst::show_loaded_functions(
932930
namespacet ns(goto_model.get_symbol_table());
933931
show_goto_functions(
934932
ns,
935-
get_message_handler(),
933+
ui_message_handler,
936934
ui_message_handler.get_ui(),
937935
goto_model.get_goto_functions(),
938936
cmdline.isset("list-goto-functions"));
@@ -944,7 +942,7 @@ bool jbmc_parse_optionst::show_loaded_functions(
944942
namespacet ns(goto_model.get_symbol_table());
945943
show_properties(
946944
ns,
947-
get_message_handler(),
945+
log.get_message_handler(),
948946
ui_message_handler.get_ui(),
949947
goto_model.get_goto_functions());
950948
return true;
@@ -958,7 +956,8 @@ bool jbmc_parse_optionst::process_goto_functions(
958956
const optionst &options)
959957
{
960958
{
961-
status() << "Running GOTO functions transformation passes" << eom;
959+
log.status() << "Running GOTO functions transformation passes"
960+
<< messaget::eom;
962961

963962
bool using_symex_driven_loading =
964963
options.get_bool_option("symex-driven-lazy-loading");
@@ -970,7 +969,7 @@ bool jbmc_parse_optionst::process_goto_functions(
970969

971970
// remove catch and throw
972971
remove_exceptions(
973-
goto_model, *class_hierarchy.get(), get_message_handler());
972+
goto_model, *class_hierarchy.get(), log.get_message_handler());
974973

975974
// instrument library preconditions
976975
instrument_preconditions(goto_model);
@@ -979,8 +978,9 @@ bool jbmc_parse_optionst::process_goto_functions(
979978
// of variables with static lifetime
980979
if(cmdline.isset("nondet-static"))
981980
{
982-
status() << "Adding nondeterministic initialization "
983-
"of static/global variables" << eom;
981+
log.status() << "Adding nondeterministic initialization "
982+
"of static/global variables"
983+
<< messaget::eom;
984984
nondet_static(goto_model);
985985
}
986986

@@ -990,8 +990,8 @@ bool jbmc_parse_optionst::process_goto_functions(
990990
if(cmdline.isset("drop-unused-functions"))
991991
{
992992
// Entry point will have been set before and function pointers removed
993-
status() << "Removing unused functions" << eom;
994-
remove_unused_functions(goto_model, get_message_handler());
993+
log.status() << "Removing unused functions" << messaget::eom;
994+
remove_unused_functions(goto_model, log.get_message_handler());
995995
}
996996

997997
// remove skips such that trivial GOTOs are deleted
@@ -1009,12 +1009,13 @@ bool jbmc_parse_optionst::process_goto_functions(
10091009
{
10101010
if(cmdline.isset("reachability-slice"))
10111011
{
1012-
error() << "--reachability-slice and --reachability-slice-fb "
1013-
<< "must not be given together" << eom;
1012+
log.error() << "--reachability-slice and --reachability-slice-fb "
1013+
<< "must not be given together" << messaget::eom;
10141014
return true;
10151015
}
10161016

1017-
status() << "Performing a forwards-backwards reachability slice" << eom;
1017+
log.status() << "Performing a forwards-backwards reachability slice"
1018+
<< messaget::eom;
10181019
if(cmdline.isset("property"))
10191020
reachability_slicer(goto_model, cmdline.get_values("property"), true);
10201021
else
@@ -1023,7 +1024,7 @@ bool jbmc_parse_optionst::process_goto_functions(
10231024

10241025
if(cmdline.isset("reachability-slice"))
10251026
{
1026-
status() << "Performing a reachability slice" << eom;
1027+
log.status() << "Performing a reachability slice" << messaget::eom;
10271028
if(cmdline.isset("property"))
10281029
reachability_slicer(goto_model, cmdline.get_values("property"));
10291030
else
@@ -1033,7 +1034,7 @@ bool jbmc_parse_optionst::process_goto_functions(
10331034
// full slice?
10341035
if(cmdline.isset("full-slice"))
10351036
{
1036-
status() << "Performing a full slice" << eom;
1037+
log.status() << "Performing a full slice" << messaget::eom;
10371038
if(cmdline.isset("property"))
10381039
property_slicer(goto_model, cmdline.get_values("property"));
10391040
else
@@ -1076,9 +1077,9 @@ bool jbmc_parse_optionst::generate_function_body(
10761077
symbol_table,
10771078
stub_objects_are_not_null,
10781079
object_factory_params,
1079-
get_message_handler());
1080+
ui_message_handler);
10801081

1081-
goto_convert_functionst converter(symbol_table, get_message_handler());
1082+
goto_convert_functionst converter(symbol_table, ui_message_handler);
10821083
converter.convert_function(function_name, function);
10831084

10841085
return true;

jbmc/src/jbmc/jbmc_parse_options.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ class optionst;
8484
"(symex-driven-lazy-loading)"
8585
// clang-format on
8686

87-
class jbmc_parse_optionst:
88-
public parse_options_baset,
89-
public messaget
87+
class jbmc_parse_optionst : public parse_options_baset
9088
{
9189
public:
9290
virtual int doit() override;

0 commit comments

Comments
 (0)