Commit 33b13599 authored by Sébastien Villemot's avatar Sébastien Villemot

Port to C++11 emplace_back() method on containers

Performed using modernize-use-emplace from clang-tidy.

Manual intervention was needed to transform a NULL into nullptr in SymbolTable.cc.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-emplace.html
parent a185ecf7
...@@ -3377,7 +3377,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de ...@@ -3377,7 +3377,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
if ((i < n_obs) || (i >= nb_diag + n_obs) || (j1 >= nb_diag)) if ((i < n_obs) || (i >= nb_diag + n_obs) || (j1 >= nb_diag))
for (int k = n_obs; k < i_nz_state_var[i]; k++) for (int k = n_obs; k < i_nz_state_var[i]; k++)
{ {
v_index_KF.push_back(make_pair(i + j1 * n, make_pair(i + k * n, k + j1_n_state))); v_index_KF.emplace_back(i + j1 * n, make_pair(i + k * n, k + j1_n_state));
} }
} }
int size_v_index_KF = v_index_KF.size(); int size_v_index_KF = v_index_KF.size();
...@@ -3396,7 +3396,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de ...@@ -3396,7 +3396,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
for (int k = n_obs; k < i_nz_state_var[j]; k++) for (int k = n_obs; k < i_nz_state_var[j]; k++)
{ {
int k_n = k * n; int k_n = k * n;
v_index_KF_2.push_back(make_pair(i * n + j, make_pair(i + k_n - n_n_obs, j + k_n))); v_index_KF_2.emplace_back(i * n + j, make_pair(i + k_n - n_n_obs, j + k_n));
} }
} }
int size_v_index_KF_2 = v_index_KF_2.size(); int size_v_index_KF_2 = v_index_KF_2.size();
...@@ -4351,7 +4351,7 @@ DynamicModel::collectBlockVariables() ...@@ -4351,7 +4351,7 @@ DynamicModel::collectBlockVariables()
} }
} }
} }
block_var_exo.push_back(make_pair(tmp_var_exo, count_col_exo)); block_var_exo.emplace_back(tmp_var_exo, count_col_exo);
} }
} }
......
This diff is collapsed.
...@@ -918,21 +918,21 @@ ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_j ...@@ -918,21 +918,21 @@ ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_j
{ {
block_type_size_mfs.push_back(make_pair(make_pair(Simulation_Type, eq), make_pair(Blck_Size, MFS_Size))); block_type_size_mfs.push_back(make_pair(make_pair(Simulation_Type, eq), make_pair(Blck_Size, MFS_Size)));
block_lag_lead.push_back(make_pair(Lag, Lead)); block_lag_lead.push_back(make_pair(Lag, Lead));
block_col_type.push_back(make_pair(make_pair(l_n_static, l_n_forward), make_pair(l_n_backward, l_n_mixed))); block_col_type.emplace_back(make_pair(l_n_static, l_n_forward), make_pair(l_n_backward, l_n_mixed));
} }
} }
else else
{ {
block_type_size_mfs.push_back(make_pair(make_pair(Simulation_Type, eq), make_pair(Blck_Size, MFS_Size))); block_type_size_mfs.push_back(make_pair(make_pair(Simulation_Type, eq), make_pair(Blck_Size, MFS_Size)));
block_lag_lead.push_back(make_pair(Lag, Lead)); block_lag_lead.push_back(make_pair(Lag, Lead));
block_col_type.push_back(make_pair(make_pair(l_n_static, l_n_forward), make_pair(l_n_backward, l_n_mixed))); block_col_type.emplace_back(make_pair(l_n_static, l_n_forward), make_pair(l_n_backward, l_n_mixed));
} }
} }
else else
{ {
block_type_size_mfs.push_back(make_pair(make_pair(Simulation_Type, eq), make_pair(Blck_Size, MFS_Size))); block_type_size_mfs.push_back(make_pair(make_pair(Simulation_Type, eq), make_pair(Blck_Size, MFS_Size)));
block_lag_lead.push_back(make_pair(Lag, Lead)); block_lag_lead.push_back(make_pair(Lag, Lead));
block_col_type.push_back(make_pair(make_pair(l_n_static, l_n_forward), make_pair(l_n_backward, l_n_mixed))); block_col_type.emplace_back(make_pair(l_n_static, l_n_forward), make_pair(l_n_backward, l_n_mixed));
} }
prev_Type = Simulation_Type; prev_Type = Simulation_Type;
eq += Blck_Size; eq += Blck_Size;
...@@ -1745,7 +1745,7 @@ ModelTree::addEquation(expr_t eq, int lineno, const vector<pair<string, string> ...@@ -1745,7 +1745,7 @@ ModelTree::addEquation(expr_t eq, int lineno, const vector<pair<string, string>
{ {
int n = equations.size(); int n = equations.size();
for (const auto & eq_tag : eq_tags) for (const auto & eq_tag : eq_tags)
equation_tags.push_back(make_pair(n, eq_tag)); equation_tags.emplace_back(n, eq_tag);
addEquation(eq, lineno); addEquation(eq, lineno);
} }
......
...@@ -144,7 +144,7 @@ ParsingDriver::create_error_string(const Dynare::parser::location_type &l, const ...@@ -144,7 +144,7 @@ ParsingDriver::create_error_string(const Dynare::parser::location_type &l, const
{ {
ostringstream stream; ostringstream stream;
create_error_string(l, m, stream); create_error_string(l, m, stream);
model_errors.push_back(make_pair(var, stream.str())); model_errors.emplace_back(var, stream.str());
} }
void void
...@@ -173,7 +173,7 @@ ParsingDriver::undeclared_model_variable_error(const string &m, const string &va ...@@ -173,7 +173,7 @@ ParsingDriver::undeclared_model_variable_error(const string &m, const string &va
stream << m; stream << m;
if (nostrict) if (nostrict)
stream << " automatically declared exogenous."; stream << " automatically declared exogenous.";
undeclared_model_variable_errors.push_back(make_pair(var, stream.str())); undeclared_model_variable_errors.emplace_back(var, stream.str());
} }
void void
...@@ -370,7 +370,7 @@ ParsingDriver::add_predetermined_variable(string *name) ...@@ -370,7 +370,7 @@ ParsingDriver::add_predetermined_variable(string *name)
void void
ParsingDriver::add_equation_tags(string *key, string *value) ParsingDriver::add_equation_tags(string *key, string *value)
{ {
eq_tags.push_back(make_pair(*key, *value)); eq_tags.emplace_back(*key, *value);
delete key; delete key;
delete value; delete value;
} }
...@@ -623,7 +623,7 @@ ParsingDriver::add_VAR_restriction_coeff(string *name1, string *name2, string *l ...@@ -623,7 +623,7 @@ ParsingDriver::add_VAR_restriction_coeff(string *name1, string *name2, string *l
void void
ParsingDriver::add_VAR_restriction_eq_or_crosseq(expr_t expr) ParsingDriver::add_VAR_restriction_eq_or_crosseq(expr_t expr)
{ {
var_restriction_eq_or_crosseq.push_back(make_pair(var_restriction_coeff, expr)); var_restriction_eq_or_crosseq.emplace_back(var_restriction_coeff, expr);
} }
void void
...@@ -1182,7 +1182,7 @@ ParsingDriver::add_period(string *p1, string *p2) ...@@ -1182,7 +1182,7 @@ ParsingDriver::add_period(string *p1, string *p2)
int p2_val = atoi(p2->c_str()); int p2_val = atoi(p2->c_str());
if (p1_val > p2_val) if (p1_val > p2_val)
error("shocks/conditional_forecast_paths: can't have first period index greater than second index in range specification"); error("shocks/conditional_forecast_paths: can't have first period index greater than second index in range specification");
det_shocks_periods.push_back(make_pair(p1_val, p2_val)); det_shocks_periods.emplace_back(p1_val, p2_val);
delete p1; delete p1;
delete p2; delete p2;
} }
...@@ -1191,7 +1191,7 @@ void ...@@ -1191,7 +1191,7 @@ void
ParsingDriver::add_period(string *p1) ParsingDriver::add_period(string *p1)
{ {
int p1_val = atoi(p1->c_str()); int p1_val = atoi(p1->c_str());
det_shocks_periods.push_back(make_pair(p1_val, p1_val)); det_shocks_periods.emplace_back(p1_val, p1_val);
delete p1; delete p1;
} }
......
...@@ -39,7 +39,7 @@ SteadyStateModel::addDefinition(int symb_id, expr_t expr) ...@@ -39,7 +39,7 @@ SteadyStateModel::addDefinition(int symb_id, expr_t expr)
// Add the variable // Add the variable
vector<int> v; vector<int> v;
v.push_back(symb_id); v.push_back(symb_id);
def_table.push_back(make_pair(v, expr)); def_table.emplace_back(v, expr);
} }
void void
...@@ -52,7 +52,7 @@ SteadyStateModel::addMultipleDefinitions(const vector<int> &symb_ids, expr_t exp ...@@ -52,7 +52,7 @@ SteadyStateModel::addMultipleDefinitions(const vector<int> &symb_ids, expr_t exp
|| symbol_table.getType(symb_id) == eModFileLocalVariable || symbol_table.getType(symb_id) == eModFileLocalVariable
|| symbol_table.getType(symb_id) == eParameter); || symbol_table.getType(symb_id) == eParameter);
} }
def_table.push_back(make_pair(symb_ids, expr)); def_table.emplace_back(symb_ids, expr);
} }
void void
......
...@@ -624,7 +624,7 @@ SymbolTable::addLeadAuxiliaryVarInternal(bool endo, int index, expr_t expr_arg) ...@@ -624,7 +624,7 @@ SymbolTable::addLeadAuxiliaryVarInternal(bool endo, int index, expr_t expr_arg)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
aux_vars.push_back(AuxVarInfo(symb_id, (endo ? avEndoLead : avExoLead), 0, 0, 0, 0, expr_arg)); aux_vars.emplace_back(symb_id, (endo ? avEndoLead : avExoLead), 0, 0, 0, 0, expr_arg);
return symb_id; return symb_id;
} }
...@@ -650,7 +650,7 @@ SymbolTable::addLagAuxiliaryVarInternal(bool endo, int orig_symb_id, int orig_le ...@@ -650,7 +650,7 @@ SymbolTable::addLagAuxiliaryVarInternal(bool endo, int orig_symb_id, int orig_le
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
aux_vars.push_back(AuxVarInfo(symb_id, (endo ? avEndoLag : avExoLag), orig_symb_id, orig_lead_lag, 0, 0, expr_arg)); aux_vars.emplace_back(symb_id, (endo ? avEndoLag : avExoLag), orig_symb_id, orig_lead_lag, 0, 0, expr_arg);
return symb_id; return symb_id;
} }
...@@ -698,7 +698,7 @@ SymbolTable::addExpectationAuxiliaryVar(int information_set, int index, expr_t e ...@@ -698,7 +698,7 @@ SymbolTable::addExpectationAuxiliaryVar(int information_set, int index, expr_t e
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
aux_vars.push_back(AuxVarInfo(symb_id, avExpectation, 0, 0, 0, information_set, expr_arg)); aux_vars.emplace_back(symb_id, avExpectation, 0, 0, 0, information_set, expr_arg);
return symb_id; return symb_id;
} }
...@@ -721,7 +721,7 @@ SymbolTable::addDiffLagAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id ...@@ -721,7 +721,7 @@ SymbolTable::addDiffLagAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
aux_vars.push_back(AuxVarInfo(symb_id, avDiffLag, orig_symb_id, orig_lag, 0, 0, expr_arg)); aux_vars.emplace_back(symb_id, avDiffLag, orig_symb_id, orig_lag, 0, 0, expr_arg);
return symb_id; return symb_id;
} }
...@@ -744,7 +744,7 @@ SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, i ...@@ -744,7 +744,7 @@ SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, i
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
aux_vars.push_back(AuxVarInfo(symb_id, avDiff, orig_symb_id, orig_lag, 0, 0, expr_arg)); aux_vars.emplace_back(symb_id, avDiff, orig_symb_id, orig_lag, 0, 0, expr_arg);
return symb_id; return symb_id;
} }
...@@ -772,7 +772,7 @@ SymbolTable::addUnaryOpAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id ...@@ -772,7 +772,7 @@ SymbolTable::addUnaryOpAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
aux_vars.push_back(AuxVarInfo(symb_id, avUnaryOp, orig_symb_id, orig_lag, 0, 0, expr_arg)); aux_vars.emplace_back(symb_id, avUnaryOp, orig_symb_id, orig_lag, 0, 0, expr_arg);
return symb_id; return symb_id;
} }
...@@ -794,7 +794,7 @@ SymbolTable::addVarModelEndoLagAuxiliaryVar(int orig_symb_id, int orig_lead_lag, ...@@ -794,7 +794,7 @@ SymbolTable::addVarModelEndoLagAuxiliaryVar(int orig_symb_id, int orig_lead_lag,
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
aux_vars.push_back(AuxVarInfo(symb_id, avVarModel, orig_symb_id, orig_lead_lag, 0, 0, expr_arg)); aux_vars.emplace_back(symb_id, avVarModel, orig_symb_id, orig_lead_lag, 0, 0, expr_arg);
return symb_id; return symb_id;
} }
...@@ -816,7 +816,7 @@ SymbolTable::addMultiplierAuxiliaryVar(int index) throw (FrozenException) ...@@ -816,7 +816,7 @@ SymbolTable::addMultiplierAuxiliaryVar(int index) throw (FrozenException)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
aux_vars.push_back(AuxVarInfo(symb_id, avMultiplier, 0, 0, index, 0, NULL)); aux_vars.emplace_back(symb_id, avMultiplier, 0, 0, index, 0, nullptr);
return symb_id; return symb_id;
} }
...@@ -837,7 +837,7 @@ SymbolTable::addDiffForwardAuxiliaryVar(int orig_symb_id, expr_t expr_arg) throw ...@@ -837,7 +837,7 @@ SymbolTable::addDiffForwardAuxiliaryVar(int orig_symb_id, expr_t expr_arg) throw
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
aux_vars.push_back(AuxVarInfo(symb_id, avDiffForward, orig_symb_id, 0, 0, 0, expr_arg)); aux_vars.emplace_back(symb_id, avDiffForward, orig_symb_id, 0, 0, 0, expr_arg);
return symb_id; return symb_id;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment