Skip to content

catch by const ref instead of by value or non-const ref #1560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/cbmc/bmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ safety_checkert::resultt bmct::run(
return safety_checkert::resultt::ERROR;
}

catch(std::bad_alloc)
catch(const std::bad_alloc &)
{
error() << "Out of memory" << eom;
return safety_checkert::resultt::ERROR;
Expand Down Expand Up @@ -471,7 +471,7 @@ safety_checkert::resultt bmct::run(
return decide(goto_functions, prop_conv);
}

catch(std::string &error_str)
catch(const std::string &error_str)
{
error() << error_str << eom;
return safety_checkert::resultt::ERROR;
Expand All @@ -483,7 +483,7 @@ safety_checkert::resultt bmct::run(
return safety_checkert::resultt::ERROR;
}

catch(std::bad_alloc)
catch(const std::bad_alloc &)
{
error() << "Out of memory" << eom;
return safety_checkert::resultt::ERROR;
Expand Down
16 changes: 8 additions & 8 deletions src/cbmc/cbmc_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ int cbmc_parse_optionst::doit()
return CPROVER_EXIT_EXCEPTION;
}

catch(const std::string error_msg)
catch(const std::string &error_msg)
{
error() << error_msg << eom;
return CPROVER_EXIT_EXCEPTION;
Expand Down Expand Up @@ -589,7 +589,7 @@ bool cbmc_parse_optionst::set_properties()
return true;
}

catch(const std::string e)
catch(const std::string &e)
{
error() << e << eom;
return true;
Expand Down Expand Up @@ -649,7 +649,7 @@ int cbmc_parse_optionst::get_goto_program(
return CPROVER_EXIT_EXCEPTION;
}

catch(const std::string e)
catch(const std::string &e)
{
error() << e << eom;
return CPROVER_EXIT_EXCEPTION;
Expand All @@ -661,7 +661,7 @@ int cbmc_parse_optionst::get_goto_program(
return CPROVER_EXIT_EXCEPTION;
}

catch(std::bad_alloc)
catch(const std::bad_alloc &)
{
error() << "Out of memory" << eom;
return CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY;
Expand Down Expand Up @@ -710,7 +710,7 @@ void cbmc_parse_optionst::preprocessing()
error() << e << eom;
}

catch(const std::string e)
catch(const std::string &e)
{
error() << e << eom;
}
Expand All @@ -720,7 +720,7 @@ void cbmc_parse_optionst::preprocessing()
error() << "Numeric exception : " << e << eom;
}

catch(std::bad_alloc)
catch(const std::bad_alloc &)
{
error() << "Out of memory" << eom;
exit(CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY);
Expand Down Expand Up @@ -844,7 +844,7 @@ bool cbmc_parse_optionst::process_goto_program(
return true;
}

catch(const std::string e)
catch(const std::string &e)
{
error() << e << eom;
return true;
Expand All @@ -856,7 +856,7 @@ bool cbmc_parse_optionst::process_goto_program(
return true;
}

catch(std::bad_alloc)
catch(const std::bad_alloc &)
{
error() << "Out of memory" << eom;
exit(CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY);
Expand Down
4 changes: 2 additions & 2 deletions src/clobber/clobber_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ int clobber_parse_optionst::doit()
return 0;
}

catch(const std::string error_msg)
catch(const std::string &error_msg)
{
error() << error_msg << messaget::eom;
return 8;
Expand All @@ -165,7 +165,7 @@ int clobber_parse_optionst::doit()
return 8;
}

catch(std::bad_alloc)
catch(const std::bad_alloc &)
{
error() << "Out of memory" << messaget::eom;
return 8;
Expand Down
8 changes: 4 additions & 4 deletions src/goto-analyzer/goto_analyzer_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ int goto_analyzer_parse_optionst::doit()
return true;
}

catch(const std::string e)
catch(const std::string &e)
{
error() << e << eom;
return true;
Expand Down Expand Up @@ -340,7 +340,7 @@ bool goto_analyzer_parse_optionst::set_properties()
return true;
}

catch(const std::string e)
catch(const std::string &e)
{
error() << e << eom;
return true;
Expand Down Expand Up @@ -422,7 +422,7 @@ bool goto_analyzer_parse_optionst::process_goto_program(
return true;
}

catch(const std::string e)
catch(const std::string &e)
{
error() << e << eom;
return true;
Expand All @@ -433,7 +433,7 @@ bool goto_analyzer_parse_optionst::process_goto_program(
return true;
}

catch(std::bad_alloc)
catch(const std::bad_alloc &)
{
error() << "Out of memory" << eom;
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/goto-cc/goto_cc_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int goto_cc_modet::main(int argc, const char **argv)
return EX_SOFTWARE;
}

catch(const std::string e)
catch(const std::string &e)
{
error() << e << eom;
return EX_SOFTWARE;
Expand All @@ -99,7 +99,7 @@ int goto_cc_modet::main(int argc, const char **argv)
return EX_SOFTWARE;
}

catch(std::bad_alloc)
catch(const std::bad_alloc &)
{
error() << "Out of memory" << eom;
return EX_SOFTWARE;
Expand Down
4 changes: 2 additions & 2 deletions src/goto-diff/goto_diff_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ bool goto_diff_parse_optionst::process_goto_program(
return true;
}

catch(const std::string e)
catch(const std::string &e)
{
error() << e << eom;
return true;
Expand All @@ -460,7 +460,7 @@ bool goto_diff_parse_optionst::process_goto_program(
return true;
}

catch(std::bad_alloc)
catch(const std::bad_alloc &)
{
error() << "Out of memory" << eom;
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/goto-instrument/accelerate/acceleration_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ bool acceleration_utilst::check_inductive(
return true;
}
}
catch(std::string s)
catch(const std::string &s)
{
std::cout << "Error in inductiveness SAT check: " << s << '\n';
return false;
Expand Down Expand Up @@ -458,7 +458,7 @@ bool acceleration_utilst::do_assumptions(
return false;
}
}
catch(std::string s)
catch(const std::string &s)
{
std::cout << "Error in monotonicity SAT check: " << s << '\n';
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ bool disjunctive_polynomial_accelerationt::accelerate(
{
path_is_monotone=utils.do_assumptions(polynomials, path, guard);
}
catch(std::string s)
catch(const std::string &s)
{
// Couldn't do WP.
std::cout << "Assumptions error: " << s << '\n';
Expand Down Expand Up @@ -389,7 +389,7 @@ bool disjunctive_polynomial_accelerationt::find_path(patht &path)
return true;
}
}
catch(std::string s)
catch(const std::string &s)
{
std::cout << "Error in fitting polynomial SAT check: " << s << '\n';
}
Expand Down Expand Up @@ -637,7 +637,7 @@ bool disjunctive_polynomial_accelerationt::fit_polynomial(
return true;
}
}
catch(std::string s)
catch(const std::string &s)
{
std::cout << "Error in fitting polynomial SAT check: " << s << '\n';
}
Expand Down
8 changes: 4 additions & 4 deletions src/goto-instrument/accelerate/polynomial_accelerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ bool polynomial_acceleratort::accelerate(
{
path_is_monotone=utils.do_assumptions(polynomials, loop, guard);
}
catch (std::string s)
catch(const std::string &s)
{
// Couldn't do WP.
std::cout << "Assumptions error: " << s << '\n';
Expand Down Expand Up @@ -424,7 +424,7 @@ bool polynomial_acceleratort::fit_polynomial_sliced(
return true;
}
}
catch(std::string s)
catch(const std::string &s)
{
std::cout << "Error in fitting polynomial SAT check: " << s << '\n';
}
Expand Down Expand Up @@ -485,7 +485,7 @@ bool polynomial_acceleratort::fit_const(
return true;
}
}
catch(std::string s)
catch(const std::string &s)
{
std::cout << "Error in fitting polynomial SAT check: " << s << '\n';
}
Expand Down Expand Up @@ -719,7 +719,7 @@ bool polynomial_acceleratort::check_inductive(
return true;
}
}
catch(std::string s)
catch(const std::string &s)
{
std::cout << "Error in inductiveness SAT check: " << s << '\n';
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/goto-instrument/accelerate/sat_path_enumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ bool sat_path_enumeratort::next(patht &path)
return true;
}
}
catch(std::string s)
catch(const std::string &s)
{
std::cout << "Error in fitting polynomial SAT check: " << s << '\n';
}
Expand Down
4 changes: 2 additions & 2 deletions src/goto-instrument/goto_instrument_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ int goto_instrument_parse_optionst::doit()
return CPROVER_EXIT_EXCEPTION_GOTO_INSTRUMENT;
}

catch(const std::string e)
catch(const std::string &e)
{
error() << e << eom;
return CPROVER_EXIT_EXCEPTION_GOTO_INSTRUMENT;
Expand All @@ -775,7 +775,7 @@ int goto_instrument_parse_optionst::doit()
return CPROVER_EXIT_EXCEPTION_GOTO_INSTRUMENT;
}

catch(std::bad_alloc)
catch(const std::bad_alloc &)
{
error() << "Out of memory" << eom;
return CPROVER_EXIT_EXCEPTION_GOTO_INSTRUMENT;
Expand Down
4 changes: 2 additions & 2 deletions src/goto-instrument/wmm/goto2graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bool inline instrumentert::local(const irep_idt &id)

return false;
}
catch(std::string exception)
catch(const std::string &exception)
{
message.debug()<<"Exception: "<<exception << messaget::eom;
return false;
Expand Down Expand Up @@ -714,7 +714,7 @@ void instrumentert::cfg_visitort::visit_cfg_function_call(
cur_fun=stack_fun.pop();
#endif
}
catch(std::string s)
catch(const std::string &s)
{
instrumenter.message.warning() << "sorry, doesn't handle recursion "
<< "(function " << fun_id << "; .cpp) "
Expand Down
2 changes: 1 addition & 1 deletion src/goto-instrument/wmm/goto2graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class instrumentert
function, empty_in, end_out);
leave_function(function);
}
catch(std::string s)
catch(const std::string &s)
{
instrumenter.message.warning() << s << messaget::eom;
}
Expand Down
2 changes: 1 addition & 1 deletion src/goto-instrument/wmm/pair_collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void event_grapht::graph_pensieve_explorert::collect_pairs(namespacet &ns)
first_event.source_location.get_line(), first_event.variable,
static_cast<int>(first_event.operation));
}
catch(std::string s)
catch(const std::string &s)
{
egraph.message.warning() << "failed to find" << s << messaget::eom;
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/goto-instrument/wmm/shared_buffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void shared_bufferst::assignment(

t++;
}
catch(std::string s)
catch(const std::string &s)
{
message.warning() << s << messaget::eom;
}
Expand Down Expand Up @@ -929,7 +929,7 @@ void shared_bufferst::nondet_flush(
buff1_thd_3_expr))))));
}
}
catch (std::string s)
catch(const std::string &s)
{
message.warning() << s << messaget::eom;
}
Expand Down
Loading