File tree Expand file tree Collapse file tree 3 files changed +31
-26
lines changed Expand file tree Collapse file tree 3 files changed +31
-26
lines changed Original file line number Diff line number Diff line change @@ -41,11 +41,9 @@ int wmain(int argc, const wchar_t **argv_wide)
4141int main (int argc, const char **argv)
4242{
4343#endif
44- try
45- {
46- cbmc_parse_optionst parse_options (argc, argv);
44+ cbmc_parse_optionst parse_options (argc, argv);
4745
48- int res = parse_options.main ();
46+ int res = parse_options.main ();
4947
5048 #ifdef IREP_HASH_STATS
5149 std::cout << " IREP_HASH_CNT=" << irep_hash_cnt << ' \n ' ;
@@ -54,9 +52,4 @@ int main(int argc, const char **argv)
5452 #endif
5553
5654 return res;
57- }
58- catch (invalid_user_input_exceptiont &e)
59- {
60- std::cerr << e.what () << std::endl;
61- }
6255}
Original file line number Diff line number Diff line change @@ -76,10 +76,9 @@ class optionst;
7676 " (claim):(show-claims)(floatbv)(all-claims)(all-properties)" // legacy, and will eventually disappear // NOLINT(whitespace/line_length)
7777// clang-format on
7878
79- class cbmc_parse_optionst :
80- public parse_options_baset,
81- public xml_interfacet,
82- public messaget
79+ class cbmc_parse_optionst : public parse_options_baset ,
80+ public xml_interfacet,
81+ public messaget
8382{
8483public:
8584 virtual int doit () override ;
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ Author: Daniel Kroening, kroening@kroening.com
1818#endif
1919
2020#include " cmdline.h"
21+ #include " exception_utils.h"
22+ #include " exit_codes.h"
2123#include " signal_catcher.h"
2224
2325parse_options_baset::parse_options_baset (
@@ -47,23 +49,34 @@ void parse_options_baset::unknown_option_msg()
4749
4850int parse_options_baset::main ()
4951{
50- if (parse_result)
52+ // catch all exceptions here so that this code is not duplicated
53+ // for each tool
54+ try
5155 {
52- usage_error ();
53- unknown_option_msg ();
54- return EX_USAGE;
56+ if (parse_result)
57+ {
58+ usage_error ();
59+ unknown_option_msg ();
60+ return EX_USAGE;
61+ }
62+
63+ if (cmdline.isset (' ?' ) || cmdline.isset (' h' ) || cmdline.isset (" help" ))
64+ {
65+ help ();
66+ return EX_OK;
67+ }
68+
69+ // install signal catcher
70+ install_signal_catcher ();
71+
72+ return doit ();
5573 }
56-
57- if (cmdline.isset (' ?' ) || cmdline.isset (' h' ) || cmdline.isset (" help" ))
74+ catch (invalid_user_input_exceptiont &e)
5875 {
59- help () ;
60- return EX_OK ;
76+ std::cerr << e. what () << " \n " ;
77+ return CPROVER_EXIT_USAGE_ERROR ;
6178 }
62-
63- // install signal catcher
64- install_signal_catcher ();
65-
66- return doit ();
79+ return CPROVER_EXIT_SUCCESS;
6780}
6881
6982std::string
You can’t perform that action at this time.
0 commit comments