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
parent
7cfe226e58
commit
22675728aa
|
@ -1022,7 +1022,7 @@ public:
|
|||
Block_contain_type bc;
|
||||
read_member(bc.Variable);
|
||||
read_member(bc.Equation);
|
||||
Block_Contain_.push_back(move(bc));
|
||||
Block_Contain_.push_back(bc);
|
||||
}
|
||||
if (type == BlockSimulationType::solveTwoBoundariesSimple
|
||||
|| type == BlockSimulationType::solveTwoBoundariesComplete
|
||||
|
|
|
@ -3347,10 +3347,9 @@ ConditionalForecastStatement::writeJsonOutput(ostream& output) const
|
|||
}
|
||||
|
||||
PlotConditionalForecastStatement::PlotConditionalForecastStatement(
|
||||
optional<int> periods_arg, SymbolList symbol_list_arg, const SymbolTable& symbol_table_arg) :
|
||||
periods {move(periods_arg)},
|
||||
symbol_list {move(symbol_list_arg)},
|
||||
symbol_table {symbol_table_arg}
|
||||
const optional<int>& periods_arg, SymbolList symbol_list_arg,
|
||||
const SymbolTable& symbol_table_arg) :
|
||||
periods {periods_arg}, symbol_list {move(symbol_list_arg)}, symbol_table {symbol_table_arg}
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -929,7 +929,7 @@ private:
|
|||
const SymbolTable& symbol_table;
|
||||
|
||||
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);
|
||||
void checkPass(ModFileStructure& mod_file_struct, WarningConsolidation& warnings) override;
|
||||
void writeOutput(ostream& output, const string& basename, bool minimal_workspace) const override;
|
||||
|
|
|
@ -946,10 +946,10 @@ DataTree::strsplit(string_view str, char delim)
|
|||
}
|
||||
|
||||
filesystem::path
|
||||
DataTree::packageDir(string_view package)
|
||||
DataTree::packageDir(const string_view& package)
|
||||
{
|
||||
filesystem::path d;
|
||||
for (const auto& it : strsplit(move(package), '.'))
|
||||
for (const auto& it : strsplit(package, '.'))
|
||||
d /= "+" + it;
|
||||
return d;
|
||||
}
|
||||
|
|
|
@ -384,7 +384,7 @@ public:
|
|||
and returns the path to the corresponding filesystem directory.
|
||||
In practice the package nesting is used for the planner_objective (stored
|
||||
inside +objective subdir). */
|
||||
static filesystem::path packageDir(string_view package);
|
||||
static filesystem::path packageDir(const string_view& package);
|
||||
};
|
||||
|
||||
inline expr_t
|
||||
|
|
|
@ -1212,7 +1212,7 @@ DynamicModel::updateVarAndTrendModel() const
|
|||
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);
|
||||
}
|
||||
pac_equation_info[name] = {lhs,
|
||||
move(optim_share_index),
|
||||
optim_share_index,
|
||||
move(ar_params_and_vars),
|
||||
move(ec_params_and_vars),
|
||||
move(non_optim_vars_params_and_constants),
|
||||
|
@ -3575,14 +3575,15 @@ DynamicModel::fillEvalContext(eval_context_t& eval_context) const
|
|||
}
|
||||
|
||||
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);
|
||||
assert(beq && beq->op_code == BinaryOpcode::equal);
|
||||
|
||||
static_only_equations_equation_tags.add(static_only_equations.size(), move(eq_tags));
|
||||
static_only_equations.push_back(beq);
|
||||
static_only_equations_lineno.push_back(move(lineno));
|
||||
static_only_equations_lineno.push_back(lineno);
|
||||
}
|
||||
|
||||
size_t
|
||||
|
@ -3598,7 +3599,7 @@ DynamicModel::dynamicOnlyEquationsNbr() const
|
|||
}
|
||||
|
||||
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_relax)
|
||||
{
|
||||
|
|
|
@ -428,7 +428,7 @@ public:
|
|||
void replaceMyEquations(DynamicModel& dynamic_model) const;
|
||||
|
||||
//! 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
|
||||
size_t staticOnlyEquationsNbr() const;
|
||||
|
@ -441,7 +441,7 @@ public:
|
|||
auxiliary parameters have already been added to the symbol table.
|
||||
It also assumes that the “bind” and “relax” tags have been cleared from
|
||||
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);
|
||||
|
||||
//! Writes LaTeX file with the equations of the dynamic model
|
||||
|
|
|
@ -5697,7 +5697,7 @@ BinaryOpNode::getPacAREC(
|
|||
{
|
||||
// NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage)
|
||||
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)
|
||||
{
|
||||
|
@ -9102,7 +9102,7 @@ ExprNode::matchVariableTimesConstantTimesParam(bool variable_obligatory) const
|
|||
matchVTCTPHelper(variable_id, lag, param_id, constant, false);
|
||||
if (variable_obligatory && !variable_id)
|
||||
throw MatchFailureException {"No variable in this expression"};
|
||||
return {move(variable_id), lag, move(param_id), constant};
|
||||
return {variable_id, lag, param_id, constant};
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -9194,7 +9194,7 @@ ExprNode::matchLinearCombinationOfVariables() const
|
|||
auto [variable_id, lag, param_id, constant]
|
||||
= term->matchVariableTimesConstantTimesParam(true);
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -1394,13 +1394,13 @@ ModelTree::writeLatexModelFile(const string& mod_basename, const string& latex_b
|
|||
}
|
||||
|
||||
void
|
||||
ModelTree::addEquation(expr_t eq, optional<int> lineno)
|
||||
ModelTree::addEquation(expr_t eq, const optional<int>& lineno)
|
||||
{
|
||||
auto beq = dynamic_cast<BinaryOpNode*>(eq);
|
||||
assert(beq && beq->op_code == BinaryOpcode::equal);
|
||||
|
||||
equations.push_back(beq);
|
||||
equations_lineno.push_back(move(lineno));
|
||||
equations_lineno.push_back(lineno);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1412,10 +1412,10 @@ ModelTree::findConstantEquationsWithoutMcpTag(map<VariableNode*, NumConstNode*>&
|
|||
}
|
||||
|
||||
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));
|
||||
addEquation(eq, move(lineno));
|
||||
addEquation(eq, lineno);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -650,9 +650,9 @@ public:
|
|||
//! Absolute value under which a number is considered to be zero
|
||||
double cutoff {1e-15};
|
||||
//! 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
|
||||
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
|
||||
//! auxiliary equations
|
||||
void addAuxEquation(expr_t eq);
|
||||
|
|
|
@ -2127,7 +2127,7 @@ ParsingDriver::set_optim_weights(string name, expr_t value)
|
|||
check_symbol_is_endogenous(name);
|
||||
if (var_weights.contains(name))
|
||||
error("optim_weights: " + name + " declared twice");
|
||||
var_weights[move(name)] = move(value);
|
||||
var_weights[move(name)] = value;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2594,8 +2594,8 @@ ParsingDriver::plot_conditional_forecast(const optional<string>& periods,
|
|||
optional<int> iperiods;
|
||||
if (periods)
|
||||
iperiods = stoi(*periods);
|
||||
mod_file->addStatement(make_unique<PlotConditionalForecastStatement>(
|
||||
move(iperiods), move(symbol_list), mod_file->symbol_table));
|
||||
mod_file->addStatement(make_unique<PlotConditionalForecastStatement>(iperiods, move(symbol_list),
|
||||
mod_file->symbol_table));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -585,8 +585,8 @@ SymbolTable::addDiffLeadAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_i
|
|||
}
|
||||
|
||||
int
|
||||
SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg, optional<int> orig_symb_id,
|
||||
optional<int> orig_lag) noexcept(false)
|
||||
SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg, const optional<int>& orig_symb_id,
|
||||
const optional<int>& orig_lag) noexcept(false)
|
||||
{
|
||||
string varname {"AUX_DIFF_" + to_string(index)};
|
||||
int symb_id;
|
||||
|
@ -601,16 +601,15 @@ SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg, optional<int> orig_
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
aux_vars.emplace_back(symb_id, AuxVarType::diff, move(orig_symb_id), move(orig_lag), 0, 0,
|
||||
expr_arg, "");
|
||||
aux_vars.emplace_back(symb_id, AuxVarType::diff, orig_symb_id, orig_lag, 0, 0, expr_arg, "");
|
||||
|
||||
return symb_id;
|
||||
}
|
||||
|
||||
int
|
||||
SymbolTable::addUnaryOpAuxiliaryVar(int index, expr_t expr_arg, string unary_op,
|
||||
optional<int> orig_symb_id,
|
||||
optional<int> orig_lag) noexcept(false)
|
||||
const optional<int>& orig_symb_id,
|
||||
const optional<int>& orig_lag) noexcept(false)
|
||||
{
|
||||
string varname {"AUX_UOP_" + to_string(index)};
|
||||
int symb_id;
|
||||
|
@ -625,8 +624,8 @@ SymbolTable::addUnaryOpAuxiliaryVar(int index, expr_t expr_arg, string unary_op,
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
aux_vars.emplace_back(symb_id, AuxVarType::unaryOp, move(orig_symb_id), move(orig_lag), 0, 0,
|
||||
expr_arg, move(unary_op));
|
||||
aux_vars.emplace_back(symb_id, AuxVarType::unaryOp, orig_symb_id, orig_lag, 0, 0, expr_arg,
|
||||
move(unary_op));
|
||||
|
||||
return symb_id;
|
||||
}
|
||||
|
|
|
@ -297,8 +297,8 @@ public:
|
|||
diffLead increases it). */
|
||||
[[nodiscard]] pair<int, int> unrollDiffLeadLagChain(int symb_id, int lag) const noexcept(false);
|
||||
//! Adds an auxiliary variable when the diff operator is encountered
|
||||
int addDiffAuxiliaryVar(int index, expr_t expr_arg, optional<int> orig_symb_id = nullopt,
|
||||
optional<int> orig_lag = nullopt) noexcept(false);
|
||||
int addDiffAuxiliaryVar(int index, expr_t expr_arg, const optional<int>& orig_symb_id = nullopt,
|
||||
const optional<int>& orig_lag = nullopt) noexcept(false);
|
||||
//! Takes care of timing between diff statements
|
||||
int addDiffLagAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id,
|
||||
int orig_lag) noexcept(false);
|
||||
|
@ -307,8 +307,8 @@ public:
|
|||
int orig_lead) noexcept(false);
|
||||
//! An Auxiliary variable for a unary op
|
||||
int addUnaryOpAuxiliaryVar(int index, expr_t expr_arg, string unary_op,
|
||||
optional<int> orig_symb_id = nullopt,
|
||||
optional<int> orig_lag = nullopt) noexcept(false);
|
||||
const optional<int>& orig_symb_id = nullopt,
|
||||
const optional<int>& orig_lag = nullopt) noexcept(false);
|
||||
//! An auxiliary variable for a pac_expectation operator
|
||||
int addPacExpectationAuxiliaryVar(const string& name, expr_t expr_arg);
|
||||
//! An auxiliary variable for a pac_target_nonstationary operator
|
||||
|
|
|
@ -1135,7 +1135,7 @@ private:
|
|||
|
||||
public:
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue