Skip to content

Commit 326f958

Browse files
jbmc_parse_options is not a messaget
This already inherits from a class with a log field for handling messages.
1 parent eed359b commit 326f958

File tree

2 files changed

+69
-68
lines changed

2 files changed

+69
-68
lines changed

jbmc/src/jbmc/jbmc_parse_options.cpp

Lines changed: 68 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,20 @@ 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 "
549+
"use '--java-load-class somepackage.SomeClass' or "
550+
"'--lazy-methods-extra-entry-point "
551+
"somepackage.SomeClass.method' along "
552+
"with '--classpath'"
553+
<< messaget::eom;
551554
return 6;
552555
}
553556

@@ -563,7 +566,7 @@ int jbmc_parse_optionst::doit()
563566
if(cmdline.isset("show-properties"))
564567
{
565568
show_properties(
566-
goto_model, get_message_handler(), ui_message_handler.get_ui());
569+
goto_model, log.get_message_handler(), ui_message_handler.get_ui());
567570
return 0; // should contemplate EX_OK from sysexits.h
568571
}
569572

@@ -681,8 +684,8 @@ int jbmc_parse_optionst::doit()
681684
else
682685
{
683686
// Use symex-driven lazy loading:
684-
lazy_goto_modelt lazy_goto_model=lazy_goto_modelt::from_handler_object(
685-
*this, options, get_message_handler());
687+
lazy_goto_modelt lazy_goto_model =
688+
lazy_goto_modelt::from_handler_object(*this, options, ui_message_handler);
686689
lazy_goto_model.initialize(cmdline.args, options);
687690

688691
class_hierarchy =
@@ -693,7 +696,7 @@ int jbmc_parse_optionst::doit()
693696
// trip an invariant when it tries to load it)
694697
if(!lazy_goto_model.symbol_table.has_symbol(goto_functionst::entry_point()))
695698
{
696-
error() << "the program has no entry point";
699+
log.error() << "the program has no entry point";
697700
return 6;
698701
}
699702

@@ -738,8 +741,8 @@ int jbmc_parse_optionst::get_goto_program(
738741
const optionst &options)
739742
{
740743
{
741-
lazy_goto_modelt lazy_goto_model=lazy_goto_modelt::from_handler_object(
742-
*this, options, get_message_handler());
744+
lazy_goto_modelt lazy_goto_model =
745+
lazy_goto_modelt::from_handler_object(*this, options, ui_message_handler);
743746
lazy_goto_model.initialize(cmdline.args, options);
744747

745748
class_hierarchy =
@@ -756,7 +759,7 @@ int jbmc_parse_optionst::get_goto_program(
756759
// particular function:
757760
add_failed_symbols(lazy_goto_model.symbol_table);
758761

759-
status() << "Generating GOTO Program" << messaget::eom;
762+
log.status() << "Generating GOTO Program" << messaget::eom;
760763
lazy_goto_model.load_all_functions();
761764

762765
// Show the symbol table before process_goto_functions mangles return
@@ -798,13 +801,13 @@ int jbmc_parse_optionst::get_goto_program(
798801
{
799802
show_goto_functions(
800803
*goto_model,
801-
get_message_handler(),
804+
log.get_message_handler(),
802805
ui_message_handler.get_ui(),
803806
cmdline.isset("list-goto-functions"));
804807
return 0;
805808
}
806809

807-
status() << config.object_bits_info() << eom;
810+
log.status() << config.object_bits_info() << messaget::eom;
808811
}
809812

810813
return -1; // no error, continue
@@ -829,7 +832,7 @@ void jbmc_parse_optionst::process_goto_function(
829832
goto_function,
830833
symbol_table,
831834
*class_hierarchy,
832-
get_message_handler());
835+
log.get_message_handler());
833836
// Java virtual functions -> explicit dispatch tables:
834837
remove_virtual_functions(function);
835838

@@ -844,10 +847,7 @@ void jbmc_parse_optionst::process_goto_function(
844847

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

852852
if(using_symex_driven_loading)
853853
{
@@ -861,7 +861,7 @@ void jbmc_parse_optionst::process_goto_function(
861861
goto_function.body,
862862
symbol_table,
863863
*class_hierarchy.get(),
864-
get_message_handler());
864+
ui_message_handler);
865865
}
866866

867867
// add generic checks
@@ -873,7 +873,7 @@ void jbmc_parse_optionst::process_goto_function(
873873
function.get_function_id(),
874874
goto_function,
875875
symbol_table,
876-
get_message_handler());
876+
ui_message_handler);
877877

878878
// checks don't know about adjusted float expressions
879879
adjust_float_expressions(goto_function, ns);
@@ -932,7 +932,7 @@ bool jbmc_parse_optionst::show_loaded_functions(
932932
namespacet ns(goto_model.get_symbol_table());
933933
show_goto_functions(
934934
ns,
935-
get_message_handler(),
935+
ui_message_handler,
936936
ui_message_handler.get_ui(),
937937
goto_model.get_goto_functions(),
938938
cmdline.isset("list-goto-functions"));
@@ -944,7 +944,7 @@ bool jbmc_parse_optionst::show_loaded_functions(
944944
namespacet ns(goto_model.get_symbol_table());
945945
show_properties(
946946
ns,
947-
get_message_handler(),
947+
log.get_message_handler(),
948948
ui_message_handler.get_ui(),
949949
goto_model.get_goto_functions());
950950
return true;
@@ -958,7 +958,8 @@ bool jbmc_parse_optionst::process_goto_functions(
958958
const optionst &options)
959959
{
960960
{
961-
status() << "Running GOTO functions transformation passes" << eom;
961+
log.status() << "Running GOTO functions transformation passes"
962+
<< messaget::eom;
962963

963964
bool using_symex_driven_loading =
964965
options.get_bool_option("symex-driven-lazy-loading");
@@ -970,7 +971,7 @@ bool jbmc_parse_optionst::process_goto_functions(
970971

971972
// remove catch and throw
972973
remove_exceptions(
973-
goto_model, *class_hierarchy.get(), get_message_handler());
974+
goto_model, *class_hierarchy.get(), log.get_message_handler());
974975

975976
// instrument library preconditions
976977
instrument_preconditions(goto_model);
@@ -979,8 +980,9 @@ bool jbmc_parse_optionst::process_goto_functions(
979980
// of variables with static lifetime
980981
if(cmdline.isset("nondet-static"))
981982
{
982-
status() << "Adding nondeterministic initialization "
983-
"of static/global variables" << eom;
983+
log.status() << "Adding nondeterministic initialization "
984+
"of static/global variables"
985+
<< messaget::eom;
984986
nondet_static(goto_model);
985987
}
986988

@@ -990,8 +992,8 @@ bool jbmc_parse_optionst::process_goto_functions(
990992
if(cmdline.isset("drop-unused-functions"))
991993
{
992994
// 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());
995+
log.status() << "Removing unused functions" << messaget::eom;
996+
remove_unused_functions(goto_model, log.get_message_handler());
995997
}
996998

997999
// remove skips such that trivial GOTOs are deleted
@@ -1009,12 +1011,13 @@ bool jbmc_parse_optionst::process_goto_functions(
10091011
{
10101012
if(cmdline.isset("reachability-slice"))
10111013
{
1012-
error() << "--reachability-slice and --reachability-slice-fb "
1013-
<< "must not be given together" << eom;
1014+
log.error() << "--reachability-slice and --reachability-slice-fb "
1015+
<< "must not be given together" << messaget::eom;
10141016
return true;
10151017
}
10161018

1017-
status() << "Performing a forwards-backwards reachability slice" << eom;
1019+
log.status() << "Performing a forwards-backwards reachability slice"
1020+
<< messaget::eom;
10181021
if(cmdline.isset("property"))
10191022
reachability_slicer(goto_model, cmdline.get_values("property"), true);
10201023
else
@@ -1023,7 +1026,7 @@ bool jbmc_parse_optionst::process_goto_functions(
10231026

10241027
if(cmdline.isset("reachability-slice"))
10251028
{
1026-
status() << "Performing a reachability slice" << eom;
1029+
log.status() << "Performing a reachability slice" << messaget::eom;
10271030
if(cmdline.isset("property"))
10281031
reachability_slicer(goto_model, cmdline.get_values("property"));
10291032
else
@@ -1033,7 +1036,7 @@ bool jbmc_parse_optionst::process_goto_functions(
10331036
// full slice?
10341037
if(cmdline.isset("full-slice"))
10351038
{
1036-
status() << "Performing a full slice" << eom;
1039+
log.status() << "Performing a full slice" << messaget::eom;
10371040
if(cmdline.isset("property"))
10381041
property_slicer(goto_model, cmdline.get_values("property"));
10391042
else
@@ -1076,9 +1079,9 @@ bool jbmc_parse_optionst::generate_function_body(
10761079
symbol_table,
10771080
stub_objects_are_not_null,
10781081
object_factory_params,
1079-
get_message_handler());
1082+
ui_message_handler);
10801083

1081-
goto_convert_functionst converter(symbol_table, get_message_handler());
1084+
goto_convert_functionst converter(symbol_table, ui_message_handler);
10821085
converter.convert_function(function_name, function);
10831086

10841087
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)