No longer call std::move on trivially-copyable types

Automatically detected by clang-tidy with performance-move-const-arg check.

Do not make the modification for Tokenizer::location type, since we have no
guarantee that the type will remain trivially-copyable in the future.
master
Sébastien Villemot 2023-12-13 15:37:07 +01:00
parent 7cfe226e58
commit 22675728aa
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
14 changed files with 40 additions and 41 deletions

View File

@ -1022,7 +1022,7 @@ public:
Block_contain_type bc; Block_contain_type bc;
read_member(bc.Variable); read_member(bc.Variable);
read_member(bc.Equation); read_member(bc.Equation);
Block_Contain_.push_back(move(bc)); Block_Contain_.push_back(bc);
} }
if (type == BlockSimulationType::solveTwoBoundariesSimple if (type == BlockSimulationType::solveTwoBoundariesSimple
|| type == BlockSimulationType::solveTwoBoundariesComplete || type == BlockSimulationType::solveTwoBoundariesComplete

View File

@ -3347,10 +3347,9 @@ ConditionalForecastStatement::writeJsonOutput(ostream& output) const
} }
PlotConditionalForecastStatement::PlotConditionalForecastStatement( PlotConditionalForecastStatement::PlotConditionalForecastStatement(
optional<int> periods_arg, SymbolList symbol_list_arg, const SymbolTable& symbol_table_arg) : const optional<int>& periods_arg, SymbolList symbol_list_arg,
periods {move(periods_arg)}, const SymbolTable& symbol_table_arg) :
symbol_list {move(symbol_list_arg)}, periods {periods_arg}, symbol_list {move(symbol_list_arg)}, symbol_table {symbol_table_arg}
symbol_table {symbol_table_arg}
{ {
} }

View File

@ -929,7 +929,7 @@ private:
const SymbolTable& symbol_table; const SymbolTable& symbol_table;
public: public:
PlotConditionalForecastStatement(optional<int> periods_arg, SymbolList symbol_list_arg, PlotConditionalForecastStatement(const optional<int>& periods_arg, SymbolList symbol_list_arg,
const SymbolTable& symbol_table_arg); const SymbolTable& symbol_table_arg);
void checkPass(ModFileStructure& mod_file_struct, WarningConsolidation& warnings) override; void checkPass(ModFileStructure& mod_file_struct, WarningConsolidation& warnings) override;
void writeOutput(ostream& output, const string& basename, bool minimal_workspace) const override; void writeOutput(ostream& output, const string& basename, bool minimal_workspace) const override;

View File

@ -946,10 +946,10 @@ DataTree::strsplit(string_view str, char delim)
} }
filesystem::path filesystem::path
DataTree::packageDir(string_view package) DataTree::packageDir(const string_view& package)
{ {
filesystem::path d; filesystem::path d;
for (const auto& it : strsplit(move(package), '.')) for (const auto& it : strsplit(package, '.'))
d /= "+" + it; d /= "+" + it;
return d; return d;
} }

View File

@ -384,7 +384,7 @@ public:
and returns the path to the corresponding filesystem directory. and returns the path to the corresponding filesystem directory.
In practice the package nesting is used for the planner_objective (stored In practice the package nesting is used for the planner_objective (stored
inside +objective subdir). */ inside +objective subdir). */
static filesystem::path packageDir(string_view package); static filesystem::path packageDir(const string_view& package);
}; };
inline expr_t inline expr_t

View File

@ -1212,7 +1212,7 @@ DynamicModel::updateVarAndTrendModel() const
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
trend_var.push_back(move(trend_var_symb_id)); trend_var.push_back(trend_var_symb_id);
} }
} }
@ -1906,7 +1906,7 @@ DynamicModel::analyzePacEquationStructure(const string& name, map<string, string
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
pac_equation_info[name] = {lhs, pac_equation_info[name] = {lhs,
move(optim_share_index), optim_share_index,
move(ar_params_and_vars), move(ar_params_and_vars),
move(ec_params_and_vars), move(ec_params_and_vars),
move(non_optim_vars_params_and_constants), move(non_optim_vars_params_and_constants),
@ -3575,14 +3575,15 @@ DynamicModel::fillEvalContext(eval_context_t& eval_context) const
} }
void void
DynamicModel::addStaticOnlyEquation(expr_t eq, optional<int> lineno, map<string, string> eq_tags) DynamicModel::addStaticOnlyEquation(expr_t eq, const optional<int>& lineno,
map<string, string> eq_tags)
{ {
auto beq = dynamic_cast<BinaryOpNode*>(eq); auto beq = dynamic_cast<BinaryOpNode*>(eq);
assert(beq && beq->op_code == BinaryOpcode::equal); assert(beq && beq->op_code == BinaryOpcode::equal);
static_only_equations_equation_tags.add(static_only_equations.size(), move(eq_tags)); static_only_equations_equation_tags.add(static_only_equations.size(), move(eq_tags));
static_only_equations.push_back(beq); static_only_equations.push_back(beq);
static_only_equations_lineno.push_back(move(lineno)); static_only_equations_lineno.push_back(lineno);
} }
size_t size_t
@ -3598,7 +3599,7 @@ DynamicModel::dynamicOnlyEquationsNbr() const
} }
void void
DynamicModel::addOccbinEquation(expr_t eq, optional<int> lineno, map<string, string> eq_tags, DynamicModel::addOccbinEquation(expr_t eq, const optional<int>& lineno, map<string, string> eq_tags,
const vector<string>& regimes_bind, const vector<string>& regimes_bind,
const vector<string>& regimes_relax) const vector<string>& regimes_relax)
{ {

View File

@ -428,7 +428,7 @@ public:
void replaceMyEquations(DynamicModel& dynamic_model) const; void replaceMyEquations(DynamicModel& dynamic_model) const;
//! Adds an equation marked as [static] //! Adds an equation marked as [static]
void addStaticOnlyEquation(expr_t eq, optional<int> lineno, map<string, string> eq_tags); void addStaticOnlyEquation(expr_t eq, const optional<int>& lineno, map<string, string> eq_tags);
//! Returns number of static only equations //! Returns number of static only equations
size_t staticOnlyEquationsNbr() const; size_t staticOnlyEquationsNbr() const;
@ -441,7 +441,7 @@ public:
auxiliary parameters have already been added to the symbol table. auxiliary parameters have already been added to the symbol table.
It also assumes that the bind and relax tags have been cleared from It also assumes that the bind and relax tags have been cleared from
eq_tags. */ eq_tags. */
void addOccbinEquation(expr_t eq, optional<int> lineno, map<string, string> eq_tags, void addOccbinEquation(expr_t eq, const optional<int>& lineno, map<string, string> eq_tags,
const vector<string>& regimes_bind, const vector<string>& regimes_relax); const vector<string>& regimes_bind, const vector<string>& regimes_relax);
//! Writes LaTeX file with the equations of the dynamic model //! Writes LaTeX file with the equations of the dynamic model

View File

@ -5697,7 +5697,7 @@ BinaryOpNode::getPacAREC(
{ {
// NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) // NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage)
auto [vid, lag, pid, constant] = term->matchVariableTimesConstantTimesParam(true); auto [vid, lag, pid, constant] = term->matchVariableTimesConstantTimesParam(true);
linear_combination.emplace_back(vid.value(), lag, move(pid), constant); linear_combination.emplace_back(vid.value(), lag, pid, constant);
} }
catch (MatchFailureException& e) catch (MatchFailureException& e)
{ {
@ -9102,7 +9102,7 @@ ExprNode::matchVariableTimesConstantTimesParam(bool variable_obligatory) const
matchVTCTPHelper(variable_id, lag, param_id, constant, false); matchVTCTPHelper(variable_id, lag, param_id, constant, false);
if (variable_obligatory && !variable_id) if (variable_obligatory && !variable_id)
throw MatchFailureException {"No variable in this expression"}; throw MatchFailureException {"No variable in this expression"};
return {move(variable_id), lag, move(param_id), constant}; return {variable_id, lag, param_id, constant};
} }
void void
@ -9194,7 +9194,7 @@ ExprNode::matchLinearCombinationOfVariables() const
auto [variable_id, lag, param_id, constant] auto [variable_id, lag, param_id, constant]
= term->matchVariableTimesConstantTimesParam(true); = term->matchVariableTimesConstantTimesParam(true);
constant *= sign; constant *= sign;
result.emplace_back(variable_id.value(), lag, move(param_id), constant); result.emplace_back(variable_id.value(), lag, param_id, constant);
} }
return result; return result;
} }

View File

@ -1394,13 +1394,13 @@ ModelTree::writeLatexModelFile(const string& mod_basename, const string& latex_b
} }
void void
ModelTree::addEquation(expr_t eq, optional<int> lineno) ModelTree::addEquation(expr_t eq, const optional<int>& lineno)
{ {
auto beq = dynamic_cast<BinaryOpNode*>(eq); auto beq = dynamic_cast<BinaryOpNode*>(eq);
assert(beq && beq->op_code == BinaryOpcode::equal); assert(beq && beq->op_code == BinaryOpcode::equal);
equations.push_back(beq); equations.push_back(beq);
equations_lineno.push_back(move(lineno)); equations_lineno.push_back(lineno);
} }
void void
@ -1412,10 +1412,10 @@ ModelTree::findConstantEquationsWithoutMcpTag(map<VariableNode*, NumConstNode*>&
} }
void void
ModelTree::addEquation(expr_t eq, optional<int> lineno, map<string, string> eq_tags) ModelTree::addEquation(expr_t eq, const optional<int>& lineno, map<string, string> eq_tags)
{ {
equation_tags.add(equations.size(), move(eq_tags)); equation_tags.add(equations.size(), move(eq_tags));
addEquation(eq, move(lineno)); addEquation(eq, lineno);
} }
void void

View File

@ -650,9 +650,9 @@ public:
//! Absolute value under which a number is considered to be zero //! Absolute value under which a number is considered to be zero
double cutoff {1e-15}; double cutoff {1e-15};
//! Declare a node as an equation of the model; also give its line number //! Declare a node as an equation of the model; also give its line number
void addEquation(expr_t eq, optional<int> lineno); void addEquation(expr_t eq, const optional<int>& lineno);
//! Declare a node as an equation of the model, also giving its tags //! Declare a node as an equation of the model, also giving its tags
void addEquation(expr_t eq, optional<int> lineno, map<string, string> eq_tags); void addEquation(expr_t eq, const optional<int>& lineno, map<string, string> eq_tags);
//! Declare a node as an auxiliary equation of the model, adding it at the end of the list of //! Declare a node as an auxiliary equation of the model, adding it at the end of the list of
//! auxiliary equations //! auxiliary equations
void addAuxEquation(expr_t eq); void addAuxEquation(expr_t eq);

View File

@ -2127,7 +2127,7 @@ ParsingDriver::set_optim_weights(string name, expr_t value)
check_symbol_is_endogenous(name); check_symbol_is_endogenous(name);
if (var_weights.contains(name)) if (var_weights.contains(name))
error("optim_weights: " + name + " declared twice"); error("optim_weights: " + name + " declared twice");
var_weights[move(name)] = move(value); var_weights[move(name)] = value;
} }
void void
@ -2594,8 +2594,8 @@ ParsingDriver::plot_conditional_forecast(const optional<string>& periods,
optional<int> iperiods; optional<int> iperiods;
if (periods) if (periods)
iperiods = stoi(*periods); iperiods = stoi(*periods);
mod_file->addStatement(make_unique<PlotConditionalForecastStatement>( mod_file->addStatement(make_unique<PlotConditionalForecastStatement>(iperiods, move(symbol_list),
move(iperiods), move(symbol_list), mod_file->symbol_table)); mod_file->symbol_table));
} }
void void

View File

@ -585,8 +585,8 @@ SymbolTable::addDiffLeadAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_i
} }
int int
SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg, optional<int> orig_symb_id, SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg, const optional<int>& orig_symb_id,
optional<int> orig_lag) noexcept(false) const optional<int>& orig_lag) noexcept(false)
{ {
string varname {"AUX_DIFF_" + to_string(index)}; string varname {"AUX_DIFF_" + to_string(index)};
int symb_id; int symb_id;
@ -601,16 +601,15 @@ SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg, optional<int> orig_
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
aux_vars.emplace_back(symb_id, AuxVarType::diff, move(orig_symb_id), move(orig_lag), 0, 0, aux_vars.emplace_back(symb_id, AuxVarType::diff, orig_symb_id, orig_lag, 0, 0, expr_arg, "");
expr_arg, "");
return symb_id; return symb_id;
} }
int int
SymbolTable::addUnaryOpAuxiliaryVar(int index, expr_t expr_arg, string unary_op, SymbolTable::addUnaryOpAuxiliaryVar(int index, expr_t expr_arg, string unary_op,
optional<int> orig_symb_id, const optional<int>& orig_symb_id,
optional<int> orig_lag) noexcept(false) const optional<int>& orig_lag) noexcept(false)
{ {
string varname {"AUX_UOP_" + to_string(index)}; string varname {"AUX_UOP_" + to_string(index)};
int symb_id; int symb_id;
@ -625,8 +624,8 @@ SymbolTable::addUnaryOpAuxiliaryVar(int index, expr_t expr_arg, string unary_op,
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
aux_vars.emplace_back(symb_id, AuxVarType::unaryOp, move(orig_symb_id), move(orig_lag), 0, 0, aux_vars.emplace_back(symb_id, AuxVarType::unaryOp, orig_symb_id, orig_lag, 0, 0, expr_arg,
expr_arg, move(unary_op)); move(unary_op));
return symb_id; return symb_id;
} }

View File

@ -297,8 +297,8 @@ public:
diffLead increases it). */ diffLead increases it). */
[[nodiscard]] pair<int, int> unrollDiffLeadLagChain(int symb_id, int lag) const noexcept(false); [[nodiscard]] pair<int, int> unrollDiffLeadLagChain(int symb_id, int lag) const noexcept(false);
//! Adds an auxiliary variable when the diff operator is encountered //! Adds an auxiliary variable when the diff operator is encountered
int addDiffAuxiliaryVar(int index, expr_t expr_arg, optional<int> orig_symb_id = nullopt, int addDiffAuxiliaryVar(int index, expr_t expr_arg, const optional<int>& orig_symb_id = nullopt,
optional<int> orig_lag = nullopt) noexcept(false); const optional<int>& orig_lag = nullopt) noexcept(false);
//! Takes care of timing between diff statements //! Takes care of timing between diff statements
int addDiffLagAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, int addDiffLagAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id,
int orig_lag) noexcept(false); int orig_lag) noexcept(false);
@ -307,8 +307,8 @@ public:
int orig_lead) noexcept(false); int orig_lead) noexcept(false);
//! An Auxiliary variable for a unary op //! An Auxiliary variable for a unary op
int addUnaryOpAuxiliaryVar(int index, expr_t expr_arg, string unary_op, int addUnaryOpAuxiliaryVar(int index, expr_t expr_arg, string unary_op,
optional<int> orig_symb_id = nullopt, const optional<int>& orig_symb_id = nullopt,
optional<int> orig_lag = nullopt) noexcept(false); const optional<int>& orig_lag = nullopt) noexcept(false);
//! An auxiliary variable for a pac_expectation operator //! An auxiliary variable for a pac_expectation operator
int addPacExpectationAuxiliaryVar(const string& name, expr_t expr_arg); int addPacExpectationAuxiliaryVar(const string& name, expr_t expr_arg);
//! An auxiliary variable for a pac_target_nonstationary operator //! An auxiliary variable for a pac_target_nonstationary operator

View File

@ -1135,7 +1135,7 @@ private:
public: public:
UnaryOp(codes::UnaryOp op_code_arg, ExpressionPtr arg_arg, Tokenizer::location location_arg) : UnaryOp(codes::UnaryOp op_code_arg, ExpressionPtr arg_arg, Tokenizer::location location_arg) :
Expression(move(location_arg)), op_code {move(op_code_arg)}, arg {move(arg_arg)} Expression(move(location_arg)), op_code {op_code_arg}, arg {move(arg_arg)}
{ {
} }
[[nodiscard]] string to_string() const noexcept override; [[nodiscard]] string to_string() const noexcept override;