[clang-tidy] Add several references

Found with performance-unnecessary-value-param

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2019-12-26 21:54:21 -08:00
parent 5501953c07
commit 06cb0bbe9a
No known key found for this signature in database
GPG key ID: 36D31CFA845F0E3B
15 changed files with 35 additions and 33 deletions

View file

@ -1643,16 +1643,16 @@ void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> *out_c
/// Print the short switch \c opt, and the argument \c arg to the specified
/// wcstring, but only if \c argument isn't an empty string.
static void append_switch(wcstring &out, wchar_t opt, const wcstring arg) {
static void append_switch(wcstring &out, wchar_t opt, const wcstring &arg) {
if (arg.empty()) return;
append_format(out, L" -%lc %ls", opt, escape_string(arg, ESCAPE_ALL).c_str());
}
static void append_switch(wcstring &out, const wcstring opt, const wcstring arg) {
static void append_switch(wcstring &out, const wcstring &opt, const wcstring &arg) {
if (arg.empty()) return;
append_format(out, L" --%ls %ls", opt.c_str(), escape_string(arg, ESCAPE_ALL).c_str());
}
static void append_switch(wcstring &out, wchar_t opt) { append_format(out, L" -%lc", opt); }
static void append_switch(wcstring &out, const wcstring opt) {
static void append_switch(wcstring &out, const wcstring &opt) {
append_format(out, L" --%ls", opt.c_str());
}

View file

@ -878,7 +878,7 @@ class env_stack_impl_t final : public env_scoped_impl_t {
/// Remove a variable from the chain \p node.
/// \return true if the variable was found and removed.
bool remove_from_chain(env_node_ref_t node, const wcstring &key) const {
bool remove_from_chain(const env_node_ref_t &node, const wcstring &key) const {
for (auto cursor = node; cursor; cursor = cursor->next) {
auto iter = cursor->env.find(key);
if (iter != cursor->env.end()) {
@ -901,7 +901,7 @@ class env_stack_impl_t final : public env_scoped_impl_t {
void set_universal(const wcstring &key, wcstring_list_t val, const query_t &query);
/// Set a variable in a given node \p node.
void set_in_node(env_node_ref_t node, const wcstring &key, wcstring_list_t &&val,
void set_in_node(const env_node_ref_t &node, const wcstring &key, wcstring_list_t &&val,
const var_flags_t &flags);
// Implement the default behavior of 'set' by finding the node for an unspecified scope.
@ -970,8 +970,8 @@ static wcstring_list_t colon_split(const wcstring_list_t &val) {
return split_val;
}
void env_stack_impl_t::set_in_node(env_node_ref_t node, const wcstring &key, wcstring_list_t &&val,
const var_flags_t &flags) {
void env_stack_impl_t::set_in_node(const env_node_ref_t &node, const wcstring &key,
wcstring_list_t &&val, const var_flags_t &flags) {
env_var_t &var = node->env[key];
// Use an explicit exports, or inherit from the existing variable.

View file

@ -277,7 +277,7 @@ void env_universal_t::set_internal(const wcstring &key, const env_var_t &var) {
}
}
void env_universal_t::set(const wcstring &key, env_var_t var) {
void env_universal_t::set(const wcstring &key, const env_var_t &var) {
scoped_lock locker(lock);
this->set_internal(key, var);
}

View file

@ -103,7 +103,7 @@ class env_universal_t {
maybe_t<env_var_t::env_var_flags_t> get_flags(const wcstring &name) const;
// Sets a variable.
void set(const wcstring &key, env_var_t var);
void set(const wcstring &key, const env_var_t &var);
// Removes a variable. Returns true if it was found, false if not.
bool remove(const wcstring &key);

View file

@ -241,7 +241,7 @@ static void on_process_created(const std::shared_ptr<job_t> &j, pid_t child_pid)
/// (stdout), and there is a dup2 3->1, then we need to write to fd 3. Then exit the internal
/// process.
static bool run_internal_process(process_t *p, std::string outdata, std::string errdata,
io_chain_t ios) {
const io_chain_t &ios) {
p->check_generations_before_launch();
// We want both the dup2s and the io_chain_ts to be kept alive by the background thread, because
@ -780,8 +780,8 @@ static proc_performer_t get_performer_for_process(process_t *p, const job_t *job
/// \p conflicts contains the list of fds which pipes should avoid.
/// \p allow_buffering if true, permit buffering the output.
/// \return true on success, false on error.
static bool exec_block_or_func_process(parser_t &parser, std::shared_ptr<job_t> j, process_t *p,
const fd_set_t &conflicts, io_chain_t io_chain,
static bool exec_block_or_func_process(parser_t &parser, const std::shared_ptr<job_t> &j,
process_t *p, const fd_set_t &conflicts, io_chain_t io_chain,
bool allow_buffering) {
// Create an output buffer if we're piping to another process.
shared_ptr<io_bufferfill_t> block_output_bufferfill{};
@ -839,7 +839,7 @@ static bool exec_block_or_func_process(parser_t &parser, std::shared_ptr<job_t>
/// \p deferred_pipes represents the pipes from our deferred process; if set ensure they get closed
/// in any child. If \p is_deferred_run is true, then this is a deferred run; this affects how
/// certain buffering works. \returns true on success, false on exec error.
static bool exec_process_in_job(parser_t &parser, process_t *p, std::shared_ptr<job_t> j,
static bool exec_process_in_job(parser_t &parser, process_t *p, const std::shared_ptr<job_t> &j,
const io_chain_t &block_io, autoclose_pipes_t pipes,
const fd_set_t &conflicts, const autoclose_pipes_t &deferred_pipes,
size_t stdout_read_limit, bool is_deferred_run = false) {
@ -1027,7 +1027,7 @@ static bool should_claim_process_group_for_job(const shared_ptr<job_t> &j) {
DIE("unreachable");
}
bool exec_job(parser_t &parser, shared_ptr<job_t> j, const job_lineage_t &lineage) {
bool exec_job(parser_t &parser, const shared_ptr<job_t> &j, const job_lineage_t &lineage) {
assert(j && "null job_t passed to exec_job!");
// Set to true if something goes wrong while executing the job, in which case the cleanup

View file

@ -15,7 +15,7 @@
class job_t;
struct job_lineage_t;
class parser_t;
bool exec_job(parser_t &parser, std::shared_ptr<job_t> j, const job_lineage_t &lineage);
bool exec_job(parser_t &parser, const std::shared_ptr<job_t> &j, const job_lineage_t &lineage);
/// Evaluate the expression cmd in a subshell, add the outputs into the list l. On return, the
/// status flag as returned bu \c proc_gfet_last_status will not be changed.

View file

@ -166,7 +166,8 @@ void function_add(wcstring name, wcstring description, function_properties_ref_t
// Create and store a new function.
auto ins = funcset->funcs.emplace(
std::move(name), function_info_t(props, std::move(description), filename, is_autoload));
std::move(name),
function_info_t(std::move(props), std::move(description), filename, is_autoload));
assert(ins.second && "Function should not already be present in the table");
(void)ins;
}

View file

@ -17,6 +17,7 @@
#include <atomic>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "common.h"
@ -427,9 +428,9 @@ bool inputter_t::mapping_is_match(const input_mapping_t &m) {
return true;
}
void inputter_t::queue_ch(char_event_t ch) { event_queue_.push_back(ch); }
void inputter_t::queue_ch(const char_event_t &ch) { event_queue_.push_back(std::move(ch)); }
void inputter_t::push_front(char_event_t ch) { event_queue_.push_front(ch); }
void inputter_t::push_front(const char_event_t &ch) { event_queue_.push_front(std::move(ch)); }
/// \return the first mapping that matches, walking first over the user's mapping list, then the
/// preset list. \return null if nothing matches.

View file

@ -57,10 +57,10 @@ class inputter_t {
/// Enqueue a char event to the queue of unread characters that input_readch will return before
/// actually reading from fd 0.
void queue_ch(char_event_t ch);
void queue_ch(const char_event_t &ch);
/// Enqueue a char event to the front of the queue; this will be the next event returned.
void push_front(char_event_t ch);
void push_front(const char_event_t &ch);
/// Sets the return status of the most recently executed input function.
void function_set_status(bool status) { function_status_ = status; }

View file

@ -225,6 +225,6 @@ char_event_t input_event_queue_t::readch_timed(bool dequeue_timeouts) {
return result;
}
void input_event_queue_t::push_back(char_event_t ch) { queue_.push_back(ch); }
void input_event_queue_t::push_back(const char_event_t& ch) { queue_.push_back(ch); }
void input_event_queue_t::push_front(char_event_t ch) { queue_.push_front(ch); }
void input_event_queue_t::push_front(const char_event_t& ch) { queue_.push_front(ch); }

View file

@ -186,11 +186,11 @@ class input_event_queue_t {
/// Enqueue a character or a readline function to the queue of unread characters that
/// readch will return before actually reading from fd 0.
void push_back(char_event_t ch);
void push_back(const char_event_t& ch);
/// Add a character or a readline function to the front of the queue of unread characters. This
/// will be the next character returned by readch.
void push_front(char_event_t ch);
void push_front(const char_event_t& ch);
};
#endif

View file

@ -626,7 +626,7 @@ eval_result_t parser_t::eval(const wcstring &cmd, const io_chain_t &io,
}
}
eval_result_t parser_t::eval(parsed_source_ref_t ps, const io_chain_t &io,
eval_result_t parser_t::eval(const parsed_source_ref_t &ps, const io_chain_t &io,
enum block_type_t block_type) {
assert(block_type == block_type_t::top || block_type == block_type_t::subst);
if (!ps->tree.empty()) {
@ -640,8 +640,8 @@ eval_result_t parser_t::eval(parsed_source_ref_t ps, const io_chain_t &io,
}
template <typename T>
eval_result_t parser_t::eval_node(parsed_source_ref_t ps, tnode_t<T> node, job_lineage_t lineage,
block_type_t block_type) {
eval_result_t parser_t::eval_node(const parsed_source_ref_t &ps, tnode_t<T> node,
job_lineage_t lineage, block_type_t block_type) {
static_assert(
std::is_same<T, grammar::statement>::value || std::is_same<T, grammar::job_list>::value,
"Unexpected node type");
@ -683,9 +683,9 @@ eval_result_t parser_t::eval_node(parsed_source_ref_t ps, tnode_t<T> node, job_l
}
// Explicit instantiations. TODO: use overloads instead?
template eval_result_t parser_t::eval_node(parsed_source_ref_t, tnode_t<grammar::statement>,
template eval_result_t parser_t::eval_node(const parsed_source_ref_t &, tnode_t<grammar::statement>,
job_lineage_t, block_type_t);
template eval_result_t parser_t::eval_node(parsed_source_ref_t, tnode_t<grammar::job_list>,
template eval_result_t parser_t::eval_node(const parsed_source_ref_t &, tnode_t<grammar::job_list>,
job_lineage_t, block_type_t);
void parser_t::get_backtrace(const wcstring &src, const parse_error_list_t &errors,

View file

@ -268,13 +268,13 @@ class parser_t : public std::enable_shared_from_this<parser_t> {
/// Evaluate the parsed source ps.
/// Because the source has been parsed, a syntax error is impossible.
eval_result_t eval(parsed_source_ref_t ps, const io_chain_t &io,
eval_result_t eval(const parsed_source_ref_t &ps, const io_chain_t &io,
block_type_t block_type = block_type_t::top);
/// Evaluates a node.
/// The node type must be grammar::statement or grammar::job_list.
template <typename T>
eval_result_t eval_node(parsed_source_ref_t ps, tnode_t<T> node, job_lineage_t lineage,
eval_result_t eval_node(const parsed_source_ref_t &ps, tnode_t<T> node, job_lineage_t lineage,
block_type_t block_type = block_type_t::top);
/// Evaluate line as a list of parameters, i.e. tokenize it and perform parameter expansion and

View file

@ -269,7 +269,7 @@ void process_t::check_generations_before_launch() {
gens_ = topic_monitor_t::principal().current_generations();
}
job_t::job_t(job_id_t job_id, const properties_t &props, job_lineage_t lineage)
job_t::job_t(job_id_t job_id, const properties_t &props, const job_lineage_t &lineage)
: properties(props),
job_id(job_id),
root_constructed(lineage.root_constructed ? lineage.root_constructed : this->constructed) {}

View file

@ -320,7 +320,7 @@ class job_t {
void operator=(const job_t &) = delete;
public:
job_t(job_id_t job_id, const properties_t &props, job_lineage_t lineage);
job_t(job_id_t job_id, const properties_t &props, const job_lineage_t &lineage);
~job_t();
/// Returns the command as a wchar_t *. */