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

+3-3
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

+8-8
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

+2-2
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

+4-4
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

+2-2
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

+2-2
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

+2-2
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

+3-3
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

+4-4
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

+1-1
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
}

src/goto-instrument/goto_instrument_parse_options.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ int goto_instrument_parse_optionst::doit()
763763
return CPROVER_EXIT_EXCEPTION_GOTO_INSTRUMENT;
764764
}
765765

766-
catch(const std::string e)
766+
catch(const std::string &e)
767767
{
768768
error() << e << eom;
769769
return CPROVER_EXIT_EXCEPTION_GOTO_INSTRUMENT;
@@ -775,7 +775,7 @@ int goto_instrument_parse_optionst::doit()
775775
return CPROVER_EXIT_EXCEPTION_GOTO_INSTRUMENT;
776776
}
777777

778-
catch(std::bad_alloc)
778+
catch(const std::bad_alloc &)
779779
{
780780
error() << "Out of memory" << eom;
781781
return CPROVER_EXIT_EXCEPTION_GOTO_INSTRUMENT;

src/goto-instrument/wmm/goto2graph.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ bool inline instrumentert::local(const irep_idt &id)
7676

7777
return false;
7878
}
79-
catch(std::string exception)
79+
catch(const std::string &exception)
8080
{
8181
message.debug()<<"Exception: "<<exception << messaget::eom;
8282
return false;
@@ -714,7 +714,7 @@ void instrumentert::cfg_visitort::visit_cfg_function_call(
714714
cur_fun=stack_fun.pop();
715715
#endif
716716
}
717-
catch(std::string s)
717+
catch(const std::string &s)
718718
{
719719
instrumenter.message.warning() << "sorry, doesn't handle recursion "
720720
<< "(function " << fun_id << "; .cpp) "

src/goto-instrument/wmm/goto2graph.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ class instrumentert
251251
function, empty_in, end_out);
252252
leave_function(function);
253253
}
254-
catch(std::string s)
254+
catch(const std::string &s)
255255
{
256256
instrumenter.message.warning() << s << messaget::eom;
257257
}

src/goto-instrument/wmm/pair_collection.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void event_grapht::graph_pensieve_explorert::collect_pairs(namespacet &ns)
5353
first_event.source_location.get_line(), first_event.variable,
5454
static_cast<int>(first_event.operation));
5555
}
56-
catch(std::string s)
56+
catch(const std::string &s)
5757
{
5858
egraph.message.warning() << "failed to find" << s << messaget::eom;
5959
continue;

src/goto-instrument/wmm/shared_buffers.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ void shared_bufferst::assignment(
177177

178178
t++;
179179
}
180-
catch(std::string s)
180+
catch(const std::string &s)
181181
{
182182
message.warning() << s << messaget::eom;
183183
}
@@ -929,7 +929,7 @@ void shared_bufferst::nondet_flush(
929929
buff1_thd_3_expr))))));
930930
}
931931
}
932-
catch (std::string s)
932+
catch(const std::string &s)
933933
{
934934
message.warning() << s << messaget::eom;
935935
}

0 commit comments

Comments
 (0)