Skip to content

Commit f79b73e

Browse files
author
martin
committed
Refactor doit() in goto analyzer to catch exceptions thrown during analysis.
This should only alter the behaviour in exceptional cases and then it should be a strict improvement.
1 parent 9e02d7f commit f79b73e

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/goto-analyzer/goto_analyzer_parse_options.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,40 @@ int goto_analyzer_parse_optionst::doit()
376376
return 6;
377377
}
378378

379+
try
380+
{
381+
return perform_analysis(options);
382+
}
383+
384+
catch(const char *e)
385+
{
386+
error() << e << eom;
387+
return CPROVER_EXIT_EXCEPTION;
388+
}
389+
390+
catch(const std::string &e)
391+
{
392+
error() << e << eom;
393+
return CPROVER_EXIT_EXCEPTION;
394+
}
395+
396+
catch(int e)
397+
{
398+
error() << "Numeric exception: " << e << eom;
399+
return CPROVER_EXIT_EXCEPTION;
400+
}
401+
402+
catch(const std::bad_alloc &)
403+
{
404+
error() << "Out of memory" << eom;
405+
return CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY;
406+
}
407+
}
408+
409+
410+
/// Depending on the command line mode, run one of the analysis tasks
411+
int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
412+
{
379413
if(options.get_bool_option("taint"))
380414
{
381415
std::string taint_file=cmdline.get_value("taint");

src/goto-analyzer/goto_analyzer_parse_options.h

+2
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ class goto_analyzer_parse_optionst:
166166
virtual bool process_goto_program(const optionst &options);
167167
bool set_properties();
168168

169+
virtual int perform_analysis(const optionst &options);
170+
169171
ai_baset *build_analyzer(const optionst &options);
170172

171173
void eval_verbosity();

0 commit comments

Comments
 (0)