Skip to content

Commit 461e8c7

Browse files
author
martin
committed
Remove some exception handling in CBMC
This changes the return value in a few exceptional cases but is more consistent and simpler.
1 parent 5c23e11 commit 461e8c7

File tree

1 file changed

+4
-73
lines changed

1 file changed

+4
-73
lines changed

src/cbmc/cbmc_parse_options.cpp

+4-73
Original file line numberDiff line numberDiff line change
@@ -560,32 +560,11 @@ int cbmc_parse_optionst::doit()
560560

561561
bool cbmc_parse_optionst::set_properties()
562562
{
563-
try
564-
{
565-
if(cmdline.isset("claim")) // will go away
566-
::set_properties(goto_model, cmdline.get_values("claim"));
567-
568-
if(cmdline.isset("property")) // use this one
569-
::set_properties(goto_model, cmdline.get_values("property"));
570-
}
571-
572-
catch(const char *e)
573-
{
574-
error() << e << eom;
575-
return true;
576-
}
577-
578-
catch(const std::string &e)
579-
{
580-
error() << e << eom;
581-
return true;
582-
}
563+
if(cmdline.isset("claim")) // will go away
564+
::set_properties(goto_model, cmdline.get_values("claim"));
583565

584-
catch(int e)
585-
{
586-
error() << "Numeric exception : " << e << eom;
587-
return true;
588-
}
566+
if(cmdline.isset("property")) // use this one
567+
::set_properties(goto_model, cmdline.get_values("property"));
589568

590569
return false;
591570
}
@@ -644,7 +623,6 @@ int cbmc_parse_optionst::get_goto_program(
644623

645624
void cbmc_parse_optionst::preprocessing(const optionst &options)
646625
{
647-
try
648626
{
649627
if(cmdline.args.size()!=1)
650628
{
@@ -676,35 +654,13 @@ void cbmc_parse_optionst::preprocessing(const optionst &options)
676654
if(language->preprocess(infile, filename, std::cout))
677655
error() << "PREPROCESSING ERROR" << eom;
678656
}
679-
680-
catch(const char *e)
681-
{
682-
error() << e << eom;
683-
}
684-
685-
catch(const std::string &e)
686-
{
687-
error() << e << eom;
688-
}
689-
690-
catch(int e)
691-
{
692-
error() << "Numeric exception : " << e << eom;
693-
}
694-
695-
catch(const std::bad_alloc &)
696-
{
697-
error() << "Out of memory" << eom;
698-
exit(CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY);
699-
}
700657
}
701658

702659
bool cbmc_parse_optionst::process_goto_program(
703660
goto_modelt &goto_model,
704661
const optionst &options,
705662
messaget &log)
706663
{
707-
try
708664
{
709665
// Remove inline assembler; this needs to happen before
710666
// adding the library.
@@ -832,31 +788,6 @@ bool cbmc_parse_optionst::process_goto_program(
832788
remove_skip(goto_model);
833789
}
834790

835-
catch(const char *e)
836-
{
837-
log.error() << e << eom;
838-
return true;
839-
}
840-
841-
catch(const std::string &e)
842-
{
843-
log.error() << e << eom;
844-
return true;
845-
}
846-
847-
catch(int e)
848-
{
849-
log.error() << "Numeric exception : " << e << eom;
850-
return true;
851-
}
852-
853-
catch(const std::bad_alloc &)
854-
{
855-
log.error() << "Out of memory" << eom;
856-
exit(CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY);
857-
return true;
858-
}
859-
860791
return false;
861792
}
862793

0 commit comments

Comments
 (0)