Skip to content

Commit af2d3dd

Browse files
authored
Merge pull request diffblue#1560 from NathanJPhillips/bugfix/catch-by-const-ref
catch by const ref instead of by value or non-const ref
2 parents b7cc0ae + 7de4858 commit af2d3dd

18 files changed

+49
-47
lines changed

src/cbmc/bmc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ safety_checkert::resultt bmct::run(
371371
return safety_checkert::resultt::ERROR;
372372
}
373373

374-
catch(std::bad_alloc)
374+
catch(const std::bad_alloc &)
375375
{
376376
error() << "Out of memory" << eom;
377377
return safety_checkert::resultt::ERROR;
@@ -471,7 +471,7 @@ safety_checkert::resultt bmct::run(
471471
return decide(goto_functions, prop_conv);
472472
}
473473

474-
catch(std::string &error_str)
474+
catch(const std::string &error_str)
475475
{
476476
error() << error_str << eom;
477477
return safety_checkert::resultt::ERROR;
@@ -483,7 +483,7 @@ safety_checkert::resultt bmct::run(
483483
return safety_checkert::resultt::ERROR;
484484
}
485485

486-
catch(std::bad_alloc)
486+
catch(const std::bad_alloc &)
487487
{
488488
error() << "Out of memory" << eom;
489489
return safety_checkert::resultt::ERROR;

src/cbmc/cbmc_parse_options.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ int cbmc_parse_optionst::doit()
435435
return CPROVER_EXIT_EXCEPTION;
436436
}
437437

438-
catch(const std::string error_msg)
438+
catch(const std::string &error_msg)
439439
{
440440
error() << error_msg << eom;
441441
return CPROVER_EXIT_EXCEPTION;
@@ -589,7 +589,7 @@ bool cbmc_parse_optionst::set_properties()
589589
return true;
590590
}
591591

592-
catch(const std::string e)
592+
catch(const std::string &e)
593593
{
594594
error() << e << eom;
595595
return true;
@@ -649,7 +649,7 @@ int cbmc_parse_optionst::get_goto_program(
649649
return CPROVER_EXIT_EXCEPTION;
650650
}
651651

652-
catch(const std::string e)
652+
catch(const std::string &e)
653653
{
654654
error() << e << eom;
655655
return CPROVER_EXIT_EXCEPTION;
@@ -661,7 +661,7 @@ int cbmc_parse_optionst::get_goto_program(
661661
return CPROVER_EXIT_EXCEPTION;
662662
}
663663

664-
catch(std::bad_alloc)
664+
catch(const std::bad_alloc &)
665665
{
666666
error() << "Out of memory" << eom;
667667
return CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY;
@@ -710,7 +710,7 @@ void cbmc_parse_optionst::preprocessing()
710710
error() << e << eom;
711711
}
712712

713-
catch(const std::string e)
713+
catch(const std::string &e)
714714
{
715715
error() << e << eom;
716716
}
@@ -720,7 +720,7 @@ void cbmc_parse_optionst::preprocessing()
720720
error() << "Numeric exception : " << e << eom;
721721
}
722722

723-
catch(std::bad_alloc)
723+
catch(const std::bad_alloc &)
724724
{
725725
error() << "Out of memory" << eom;
726726
exit(CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY);
@@ -844,7 +844,7 @@ bool cbmc_parse_optionst::process_goto_program(
844844
return true;
845845
}
846846

847-
catch(const std::string e)
847+
catch(const std::string &e)
848848
{
849849
error() << e << eom;
850850
return true;
@@ -856,7 +856,7 @@ bool cbmc_parse_optionst::process_goto_program(
856856
return true;
857857
}
858858

859-
catch(std::bad_alloc)
859+
catch(const std::bad_alloc &)
860860
{
861861
error() << "Out of memory" << eom;
862862
exit(CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY);

src/clobber/clobber_parse_options.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ int clobber_parse_optionst::doit()
153153
return 0;
154154
}
155155

156-
catch(const std::string error_msg)
156+
catch(const std::string &error_msg)
157157
{
158158
error() << error_msg << messaget::eom;
159159
return 8;
@@ -165,7 +165,7 @@ int clobber_parse_optionst::doit()
165165
return 8;
166166
}
167167

168-
catch(std::bad_alloc)
168+
catch(const std::bad_alloc &)
169169
{
170170
error() << "Out of memory" << messaget::eom;
171171
return 8;

src/goto-analyzer/goto_analyzer_parse_options.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ int goto_analyzer_parse_optionst::doit()
171171
return true;
172172
}
173173

174-
catch(const std::string e)
174+
catch(const std::string &e)
175175
{
176176
error() << e << eom;
177177
return true;
@@ -340,7 +340,7 @@ bool goto_analyzer_parse_optionst::set_properties()
340340
return true;
341341
}
342342

343-
catch(const std::string e)
343+
catch(const std::string &e)
344344
{
345345
error() << e << eom;
346346
return true;
@@ -422,7 +422,7 @@ bool goto_analyzer_parse_optionst::process_goto_program(
422422
return true;
423423
}
424424

425-
catch(const std::string e)
425+
catch(const std::string &e)
426426
{
427427
error() << e << eom;
428428
return true;
@@ -433,7 +433,7 @@ bool goto_analyzer_parse_optionst::process_goto_program(
433433
return true;
434434
}
435435

436-
catch(std::bad_alloc)
436+
catch(const std::bad_alloc &)
437437
{
438438
error() << "Out of memory" << eom;
439439
return true;

src/goto-cc/goto_cc_mode.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ int goto_cc_modet::main(int argc, const char **argv)
8888
return EX_SOFTWARE;
8989
}
9090

91-
catch(const std::string e)
91+
catch(const std::string &e)
9292
{
9393
error() << e << eom;
9494
return EX_SOFTWARE;
@@ -99,7 +99,7 @@ int goto_cc_modet::main(int argc, const char **argv)
9999
return EX_SOFTWARE;
100100
}
101101

102-
catch(std::bad_alloc)
102+
catch(const std::bad_alloc &)
103103
{
104104
error() << "Out of memory" << eom;
105105
return EX_SOFTWARE;

src/goto-diff/goto_diff_parse_options.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ bool goto_diff_parse_optionst::process_goto_program(
449449
return true;
450450
}
451451

452-
catch(const std::string e)
452+
catch(const std::string &e)
453453
{
454454
error() << e << eom;
455455
return true;
@@ -460,7 +460,7 @@ bool goto_diff_parse_optionst::process_goto_program(
460460
return true;
461461
}
462462

463-
catch(std::bad_alloc)
463+
catch(const std::bad_alloc &)
464464
{
465465
error() << "Out of memory" << eom;
466466
return true;

src/goto-instrument/accelerate/acceleration_utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ bool acceleration_utilst::check_inductive(
181181
return true;
182182
}
183183
}
184-
catch(std::string s)
184+
catch(const std::string &s)
185185
{
186186
std::cout << "Error in inductiveness SAT check: " << s << '\n';
187187
return false;
@@ -458,7 +458,7 @@ bool acceleration_utilst::do_assumptions(
458458
return false;
459459
}
460460
}
461-
catch(std::string s)
461+
catch(const std::string &s)
462462
{
463463
std::cout << "Error in monotonicity SAT check: " << s << '\n';
464464
return false;

src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ bool disjunctive_polynomial_accelerationt::accelerate(
248248
{
249249
path_is_monotone=utils.do_assumptions(polynomials, path, guard);
250250
}
251-
catch(std::string s)
251+
catch(const std::string &s)
252252
{
253253
// Couldn't do WP.
254254
std::cout << "Assumptions error: " << s << '\n';
@@ -389,7 +389,7 @@ bool disjunctive_polynomial_accelerationt::find_path(patht &path)
389389
return true;
390390
}
391391
}
392-
catch(std::string s)
392+
catch(const std::string &s)
393393
{
394394
std::cout << "Error in fitting polynomial SAT check: " << s << '\n';
395395
}
@@ -637,7 +637,7 @@ bool disjunctive_polynomial_accelerationt::fit_polynomial(
637637
return true;
638638
}
639639
}
640-
catch(std::string s)
640+
catch(const std::string &s)
641641
{
642642
std::cout << "Error in fitting polynomial SAT check: " << s << '\n';
643643
}

src/goto-instrument/accelerate/polynomial_accelerator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ bool polynomial_acceleratort::accelerate(
181181
{
182182
path_is_monotone=utils.do_assumptions(polynomials, loop, guard);
183183
}
184-
catch (std::string s)
184+
catch(const std::string &s)
185185
{
186186
// Couldn't do WP.
187187
std::cout << "Assumptions error: " << s << '\n';
@@ -424,7 +424,7 @@ bool polynomial_acceleratort::fit_polynomial_sliced(
424424
return true;
425425
}
426426
}
427-
catch(std::string s)
427+
catch(const std::string &s)
428428
{
429429
std::cout << "Error in fitting polynomial SAT check: " << s << '\n';
430430
}
@@ -485,7 +485,7 @@ bool polynomial_acceleratort::fit_const(
485485
return true;
486486
}
487487
}
488-
catch(std::string s)
488+
catch(const std::string &s)
489489
{
490490
std::cout << "Error in fitting polynomial SAT check: " << s << '\n';
491491
}
@@ -719,7 +719,7 @@ bool polynomial_acceleratort::check_inductive(
719719
return true;
720720
}
721721
}
722-
catch(std::string s)
722+
catch(const std::string &s)
723723
{
724724
std::cout << "Error in inductiveness SAT check: " << s << '\n';
725725
return false;

src/goto-instrument/accelerate/sat_path_enumerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ bool sat_path_enumeratort::next(patht &path)
9595
return true;
9696
}
9797
}
98-
catch(std::string s)
98+
catch(const std::string &s)
9999
{
100100
std::cout << "Error in fitting polynomial SAT check: " << s << '\n';
101101
}

0 commit comments

Comments
 (0)