Skip to content

Commit a959df9

Browse files
author
martin
committed
Remove the patchy exception handling in Java tools and use default
This is a copy of an earlier patch to the CBMC tools which replaced patchy and inconsistent exception handling in each tool with the comprehensive set of catch handlers in parse_options_baset.
1 parent 185e5b7 commit a959df9

File tree

4 files changed

+8
-213
lines changed

4 files changed

+8
-213
lines changed

jbmc/src/janalyzer/janalyzer_parse_options.cpp

Lines changed: 5 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -355,29 +355,8 @@ int janalyzer_parse_optionst::doit()
355355

356356
register_languages();
357357

358-
try
359-
{
360-
goto_model =
361-
initialize_goto_model(cmdline.args, get_message_handler(), options);
362-
}
363-
364-
catch(const char *e)
365-
{
366-
error() << e << eom;
367-
return CPROVER_EXIT_EXCEPTION;
368-
}
369-
370-
catch(const std::string &e)
371-
{
372-
error() << e << eom;
373-
return CPROVER_EXIT_EXCEPTION;
374-
}
375-
376-
catch(int e)
377-
{
378-
error() << "Numeric exception: " << e << eom;
379-
return CPROVER_EXIT_EXCEPTION;
380-
}
358+
goto_model =
359+
initialize_goto_model(cmdline.args, get_message_handler(), options);
381360

382361
if(process_goto_program(options))
383362
return CPROVER_EXIT_INTERNAL_ERROR;
@@ -402,34 +381,7 @@ int janalyzer_parse_optionst::doit()
402381
return CPROVER_EXIT_SUCCESS;
403382
}
404383

405-
try
406-
{
407-
return perform_analysis(options);
408-
}
409-
410-
catch(const char *e)
411-
{
412-
error() << e << eom;
413-
return CPROVER_EXIT_EXCEPTION;
414-
}
415-
416-
catch(const std::string &e)
417-
{
418-
error() << e << eom;
419-
return CPROVER_EXIT_EXCEPTION;
420-
}
421-
422-
catch(int e)
423-
{
424-
error() << "Numeric exception: " << e << eom;
425-
return CPROVER_EXIT_EXCEPTION;
426-
}
427-
428-
catch(const std::bad_alloc &)
429-
{
430-
error() << "Out of memory" << eom;
431-
return CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY;
432-
}
384+
return perform_analysis(options);
433385
}
434386

435387
/// Depending on the command line mode, run one of the analysis tasks
@@ -554,8 +506,8 @@ int janalyzer_parse_optionst::perform_analysis(const optionst &options)
554506
return CPROVER_EXIT_SUCCESS;
555507
}
556508

557-
if(set_properties())
558-
return CPROVER_EXIT_SET_PROPERTIES_FAILED;
509+
if(cmdline.isset("property"))
510+
::set_properties(goto_model, cmdline.get_values("property"));
559511

560512
if(options.get_bool_option("general-analysis"))
561513
{
@@ -637,34 +589,6 @@ int janalyzer_parse_optionst::perform_analysis(const optionst &options)
637589
return CPROVER_EXIT_USAGE_ERROR;
638590
}
639591

640-
bool janalyzer_parse_optionst::set_properties()
641-
{
642-
try
643-
{
644-
if(cmdline.isset("property"))
645-
::set_properties(goto_model, cmdline.get_values("property"));
646-
}
647-
648-
catch(const char *e)
649-
{
650-
error() << e << eom;
651-
return true;
652-
}
653-
654-
catch(const std::string &e)
655-
{
656-
error() << e << eom;
657-
return true;
658-
}
659-
660-
catch(int)
661-
{
662-
return true;
663-
}
664-
665-
return false;
666-
}
667-
668592
bool janalyzer_parse_optionst::process_goto_program(const optionst &options)
669593
{
670594
try

jbmc/src/janalyzer/janalyzer_parse_options.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ class janalyzer_parse_optionst : public parse_options_baset, public messaget
167167
virtual void get_command_line_options(optionst &options);
168168

169169
virtual bool process_goto_program(const optionst &options);
170-
bool set_properties();
171170

172171
virtual int perform_analysis(const optionst &options);
173172

jbmc/src/jbmc/jbmc_parse_options.cpp

Lines changed: 3 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -429,22 +429,7 @@ int jbmc_parse_optionst::doit()
429429
//
430430

431431
optionst options;
432-
try
433-
{
434-
get_command_line_options(options);
435-
}
436-
437-
catch(const char *error_msg)
438-
{
439-
error() << error_msg << eom;
440-
return 6; // should contemplate EX_SOFTWARE from sysexits.h
441-
}
442-
443-
catch(const std::string &error_msg)
444-
{
445-
error() << error_msg << eom;
446-
return 6; // should contemplate EX_SOFTWARE from sysexits.h
447-
}
432+
get_command_line_options(options);
448433

449434
//
450435
// Print a banner
@@ -640,28 +625,8 @@ int jbmc_parse_optionst::doit()
640625

641626
bool jbmc_parse_optionst::set_properties(goto_modelt &goto_model)
642627
{
643-
try
644-
{
645-
if(cmdline.isset("property"))
646-
::set_properties(goto_model, cmdline.get_values("property"));
647-
}
648-
649-
catch(const char *e)
650-
{
651-
error() << e << eom;
652-
return true;
653-
}
654-
655-
catch(const std::string &e)
656-
{
657-
error() << e << eom;
658-
return true;
659-
}
660-
661-
catch(int)
662-
{
663-
return true;
664-
}
628+
if(cmdline.isset("property"))
629+
::set_properties(goto_model, cmdline.get_values("property"));
665630

666631
return false;
667632
}
@@ -676,7 +641,6 @@ int jbmc_parse_optionst::get_goto_program(
676641
return 6;
677642
}
678643

679-
try
680644
{
681645
lazy_goto_modelt lazy_goto_model=lazy_goto_modelt::from_handler_object(
682646
*this, options, get_message_handler());
@@ -742,29 +706,6 @@ int jbmc_parse_optionst::get_goto_program(
742706
status() << config.object_bits_info() << eom;
743707
}
744708

745-
catch(const char *e)
746-
{
747-
error() << e << eom;
748-
return 6;
749-
}
750-
751-
catch(const std::string &e)
752-
{
753-
error() << e << eom;
754-
return 6;
755-
}
756-
757-
catch(int)
758-
{
759-
return 6;
760-
}
761-
762-
catch(const std::bad_alloc &)
763-
{
764-
error() << "Out of memory" << eom;
765-
return 6;
766-
}
767-
768709
return -1; // no error, continue
769710
}
770711

@@ -780,7 +721,6 @@ void jbmc_parse_optionst::process_goto_function(
780721
bool using_symex_driven_loading =
781722
options.get_bool_option("symex-driven-lazy-loading");
782723

783-
try
784724
{
785725
// Removal of RTTI inspection:
786726
remove_instanceof(
@@ -865,24 +805,6 @@ void jbmc_parse_optionst::process_goto_function(
865805
// update the function member in each instruction
866806
function.update_instructions_function();
867807
}
868-
869-
catch(const char *e)
870-
{
871-
error() << e << eom;
872-
throw;
873-
}
874-
875-
catch(const std::string &e)
876-
{
877-
error() << e << eom;
878-
throw;
879-
}
880-
881-
catch(const std::bad_alloc &)
882-
{
883-
error() << "Out of memory" << eom;
884-
throw;
885-
}
886808
}
887809

888810
bool jbmc_parse_optionst::show_loaded_functions(
@@ -937,7 +859,6 @@ bool jbmc_parse_optionst::process_goto_functions(
937859
goto_modelt &goto_model,
938860
const optionst &options)
939861
{
940-
try
941862
{
942863
status() << "Running GOTO functions transformation passes" << eom;
943864

@@ -1025,29 +946,6 @@ bool jbmc_parse_optionst::process_goto_functions(
1025946
remove_skip(goto_model);
1026947
}
1027948

1028-
catch(const char *e)
1029-
{
1030-
error() << e << eom;
1031-
return true;
1032-
}
1033-
1034-
catch(const std::string &e)
1035-
{
1036-
error() << e << eom;
1037-
return true;
1038-
}
1039-
1040-
catch(int)
1041-
{
1042-
return true;
1043-
}
1044-
1045-
catch(const std::bad_alloc &)
1046-
{
1047-
error() << "Out of memory" << eom;
1048-
return true;
1049-
}
1050-
1051949
return false;
1052950
}
1053951

jbmc/src/jdiff/jdiff_parse_options.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ bool jdiff_parse_optionst::process_goto_program(
346346
const optionst &options,
347347
goto_modelt &goto_model)
348348
{
349-
try
350349
{
351350
// remove function pointers
352351
status() << "Removing function pointers and virtual functions" << eom;
@@ -411,31 +410,6 @@ bool jdiff_parse_optionst::process_goto_program(
411410
goto_model.goto_functions.update();
412411
}
413412

414-
catch(const char *e)
415-
{
416-
error() << e << eom;
417-
return true;
418-
}
419-
420-
catch(const std::string &e)
421-
{
422-
error() << e << eom;
423-
return true;
424-
}
425-
426-
catch(int e)
427-
{
428-
error() << "Numeric exception: " << e << eom;
429-
return true;
430-
}
431-
432-
catch(const std::bad_alloc &)
433-
{
434-
error() << "Out of memory" << eom;
435-
exit(CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY);
436-
return true;
437-
}
438-
439413
return false;
440414
}
441415

0 commit comments

Comments
 (0)