Add [[nodiscard]] attribute to various functions

Automatically detected using clang-tidy with modernize-use-nodiscard check.
master
Sébastien Villemot 2023-12-01 14:02:38 +01:00
parent 5332c12ab7
commit 7e6abc97c4
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
18 changed files with 482 additions and 442 deletions

View File

@ -528,7 +528,7 @@ protected:
const SymbolTable& symbol_table; const SymbolTable& symbol_table;
AbstractEstimatedParamsStatement(vector<EstimationParams> estim_params_list_arg, AbstractEstimatedParamsStatement(vector<EstimationParams> estim_params_list_arg,
const SymbolTable& symbol_table_arg); const SymbolTable& symbol_table_arg);
virtual string blockName() const = 0; [[nodiscard]] virtual string blockName() const = 0;
// Part of the check pass that is common to the three estimated_params{,_init,bounds} blocks // Part of the check pass that is common to the three estimated_params{,_init,bounds} blocks
void commonCheckPass() const; void commonCheckPass() const;
}; };
@ -541,7 +541,7 @@ private:
public: public:
EstimatedParamsStatement(vector<EstimationParams> estim_params_list_arg, EstimatedParamsStatement(vector<EstimationParams> estim_params_list_arg,
const SymbolTable& symbol_table_arg, bool overwrite_arg); const SymbolTable& symbol_table_arg, bool overwrite_arg);
string [[nodiscard]] string
blockName() const override blockName() const override
{ {
return "estimated_params"; return "estimated_params";
@ -559,7 +559,7 @@ private:
public: public:
EstimatedParamsInitStatement(vector<EstimationParams> estim_params_list_arg, EstimatedParamsInitStatement(vector<EstimationParams> estim_params_list_arg,
const SymbolTable& symbol_table_arg, const bool use_calibration_arg); const SymbolTable& symbol_table_arg, const bool use_calibration_arg);
string [[nodiscard]] string
blockName() const override blockName() const override
{ {
return "estimated_params_init"; return "estimated_params_init";
@ -574,7 +574,7 @@ class EstimatedParamsBoundsStatement : public AbstractEstimatedParamsStatement
public: public:
EstimatedParamsBoundsStatement(vector<EstimationParams> estim_params_list_arg, EstimatedParamsBoundsStatement(vector<EstimationParams> estim_params_list_arg,
const SymbolTable& symbol_table_arg); const SymbolTable& symbol_table_arg);
string [[nodiscard]] string
blockName() const override blockName() const override
{ {
return "estimated_params_bounds"; return "estimated_params_bounds";
@ -981,7 +981,7 @@ private:
const svar_identification_restrictions_t restrictions; const svar_identification_restrictions_t restrictions;
const bool upper_cholesky_present, lower_cholesky_present, constants_exclusion_present; const bool upper_cholesky_present, lower_cholesky_present, constants_exclusion_present;
const SymbolTable& symbol_table; const SymbolTable& symbol_table;
int getMaxLag() const; [[nodiscard]] int getMaxLag() const;
public: public:
SvarIdentificationStatement(svar_identification_restrictions_t restrictions_arg, SvarIdentificationStatement(svar_identification_restrictions_t restrictions_arg,
@ -1111,7 +1111,7 @@ protected:
void writeCommonOutput(ostream& output, const string& lhs_field) const; void writeCommonOutput(ostream& output, const string& lhs_field) const;
void writeCommonOutputHelper(ostream& output, const string& field, const string& lhs_field) const; void writeCommonOutputHelper(ostream& output, const string& field, const string& lhs_field) const;
void writePriorOutput(ostream& output, string& lhs_field, const string& name2) const; void writePriorOutput(ostream& output, string& lhs_field, const string& name2) const;
bool is_structural_innovation(const SymbolType symb_type) const; [[nodiscard]] bool is_structural_innovation(const SymbolType symb_type) const;
void writePriorIndex(ostream& output, const string& lhs_field) const; void writePriorIndex(ostream& output, const string& lhs_field) const;
void writeVarianceOption(ostream& output, const string& lhs_field) const; void writeVarianceOption(ostream& output, const string& lhs_field) const;
void writeOutputHelper(ostream& output, const string& field, const string& lhs_field) const; void writeOutputHelper(ostream& output, const string& field, const string& lhs_field) const;
@ -1185,7 +1185,7 @@ protected:
void writeOptionsOutput(ostream& output, string& lhs_field, const string& name2) const; void writeOptionsOutput(ostream& output, string& lhs_field, const string& name2) const;
void writeCommonOutput(ostream& output, const string& lhs_field) const; void writeCommonOutput(ostream& output, const string& lhs_field) const;
void writeCommonOutputHelper(ostream& output, const string& field, const string& lhs_field) const; void writeCommonOutputHelper(ostream& output, const string& field, const string& lhs_field) const;
bool is_structural_innovation(const SymbolType symb_type) const; [[nodiscard]] bool is_structural_innovation(const SymbolType symb_type) const;
void writeOptionsIndex(ostream& output, const string& lhs_field) const; void writeOptionsIndex(ostream& output, const string& lhs_field) const;
void writeOutputHelper(ostream& output, const string& field, const string& lhs_field) const; void writeOutputHelper(ostream& output, const string& field, const string& lhs_field) const;
void writeJsonOptionsOutput(ostream& output) const; void writeJsonOptionsOutput(ostream& output) const;

View File

@ -39,7 +39,7 @@ private:
map<string, string> hooks; map<string, string> hooks;
public: public:
map<string, string> [[nodiscard]] map<string, string>
get_hooks() const get_hooks() const
{ {
return hooks; return hooks;
@ -55,7 +55,7 @@ private:
map<string, vector<string>> paths; map<string, vector<string>> paths;
public: public:
map<string, vector<string>> [[nodiscard]] map<string, vector<string>>
get_paths() const get_paths() const
{ {
return paths; return paths;
@ -136,7 +136,7 @@ public:
//! Check Pass //! Check Pass
void transformPass(); void transformPass();
//! Get Path Info //! Get Path Info
vector<filesystem::path> getIncludePaths() const; [[nodiscard]] vector<filesystem::path> getIncludePaths() const;
//! Write any hooks //! Write any hooks
void writeHooks(ostream& output) const; void writeHooks(ostream& output) const;
//! Create options_.parallel structure, write options //! Create options_.parallel structure, write options

View File

@ -111,7 +111,7 @@ protected:
vector<int> local_variables_vector; vector<int> local_variables_vector;
//! Internal implementation of ParamUsedWithLeadLag() //! Internal implementation of ParamUsedWithLeadLag()
bool ParamUsedWithLeadLagInternal() const; [[nodiscard]] bool ParamUsedWithLeadLagInternal() const;
/* Writes the contents of “new_contents” to the file “filename”. However, if /* Writes the contents of “new_contents” to the file “filename”. However, if
the file already exists and would not be modified by this operation, then do the file already exists and would not be modified by this operation, then do
@ -166,7 +166,7 @@ public:
//! Gets a variable //! Gets a variable
/*! Same as AddVariable, except that it fails if the variable node has not /*! Same as AddVariable, except that it fails if the variable node has not
already been created */ already been created */
VariableNode* getVariable(int symb_id, int lag = 0) const; [[nodiscard]] VariableNode* getVariable(int symb_id, int lag = 0) const;
//! Adds "arg1+arg2" to model tree //! Adds "arg1+arg2" to model tree
expr_t AddPlus(expr_t iArg1, expr_t iArg2); expr_t AddPlus(expr_t iArg1, expr_t iArg2);
//! Adds "arg1-arg2" to model tree //! Adds "arg1-arg2" to model tree
@ -274,19 +274,19 @@ public:
expr_t AddSecondDerivExternalFunction(int top_level_symb_id, const vector<expr_t>& arguments, expr_t AddSecondDerivExternalFunction(int top_level_symb_id, const vector<expr_t>& arguments,
int input_index1, int input_index2); int input_index1, int input_index2);
//! Checks if a given symbol is used somewhere in the data tree //! Checks if a given symbol is used somewhere in the data tree
bool isSymbolUsed(int symb_id) const; [[nodiscard]] bool isSymbolUsed(int symb_id) const;
//! Checks if a given unary op is used somewhere in the data tree //! Checks if a given unary op is used somewhere in the data tree
bool isUnaryOpUsed(UnaryOpcode opcode) const; [[nodiscard]] bool isUnaryOpUsed(UnaryOpcode opcode) const;
//! Checks if a given unary op is used somewhere in the data tree on an endogenous variable //! Checks if a given unary op is used somewhere in the data tree on an endogenous variable
bool isUnaryOpUsedOnType(SymbolType type, UnaryOpcode opcode) const; [[nodiscard]] bool isUnaryOpUsedOnType(SymbolType type, UnaryOpcode opcode) const;
//! Checks if a given binary op is used somewhere in the data tree //! Checks if a given binary op is used somewhere in the data tree
bool isBinaryOpUsed(BinaryOpcode opcode) const; [[nodiscard]] bool isBinaryOpUsed(BinaryOpcode opcode) const;
//! Checks if a given binary op is used somewhere in the data tree on an endogenous variable //! Checks if a given binary op is used somewhere in the data tree on an endogenous variable
bool isBinaryOpUsedOnType(SymbolType type, BinaryOpcode opcode) const; [[nodiscard]] bool isBinaryOpUsedOnType(SymbolType type, BinaryOpcode opcode) const;
//! Returns the minimum lag (as a negative number) of the given symbol in the whole data tree (and //! Returns the minimum lag (as a negative number) of the given symbol in the whole data tree (and
//! not only in the equations !!) //! not only in the equations !!)
/*! Returns 0 if the symbol is not used */ /*! Returns 0 if the symbol is not used */
int minLagForSymbol(int symb_id) const; [[nodiscard]] int minLagForSymbol(int symb_id) const;
/* Writes definitions of C function helpers (getPowerDeriv(), sign()) as /* Writes definitions of C function helpers (getPowerDeriv(), sign()) as
inline functions */ inline functions */
void writeCHelpersDefinition(ostream& output) const; void writeCHelpersDefinition(ostream& output) const;
@ -308,17 +308,17 @@ public:
}; };
// Returns the derivation ID, or throws an exception if the derivation ID does not exist // Returns the derivation ID, or throws an exception if the derivation ID does not exist
virtual int getDerivID(int symb_id, int lag) const noexcept(false); [[nodiscard]] virtual int getDerivID(int symb_id, int lag) const noexcept(false);
// Get the type corresponding to a derivation ID // Get the type corresponding to a derivation ID
virtual SymbolType getTypeByDerivID(int deriv_id) const noexcept(false); [[nodiscard]] virtual SymbolType getTypeByDerivID(int deriv_id) const noexcept(false);
// Get the lag corresponding to a derivation ID // Get the lag corresponding to a derivation ID
virtual int getLagByDerivID(int deriv_id) const noexcept(false); [[nodiscard]] virtual int getLagByDerivID(int deriv_id) const noexcept(false);
// Get the symbol ID corresponding to a derivation ID // Get the symbol ID corresponding to a derivation ID
virtual int getSymbIDByDerivID(int deriv_id) const noexcept(false); [[nodiscard]] virtual int getSymbIDByDerivID(int deriv_id) const noexcept(false);
// Get the type-specific ID corresponding to a derivation ID // Get the type-specific ID corresponding to a derivation ID
virtual int getTypeSpecificIDByDerivID(int deriv_id) const; [[nodiscard]] virtual int getTypeSpecificIDByDerivID(int deriv_id) const;
// Get the symbol name corresponding to a derivation ID // Get the symbol name corresponding to a derivation ID
string [[nodiscard]] string
getNameByDerivID(int deriv_id) const getNameByDerivID(int deriv_id) const
{ {
return symbol_table.getName(getSymbIDByDerivID(deriv_id)); return symbol_table.getName(getSymbIDByDerivID(deriv_id));
@ -327,7 +327,7 @@ public:
/* Returns the column of the Jacobian associated to a derivation ID. /* Returns the column of the Jacobian associated to a derivation ID.
The sparse argument selects between the legacy representation and the The sparse argument selects between the legacy representation and the
sparse representation. */ sparse representation. */
virtual int [[nodiscard]] virtual int
getJacobianCol([[maybe_unused]] int deriv_id, [[maybe_unused]] bool sparse) const getJacobianCol([[maybe_unused]] int deriv_id, [[maybe_unused]] bool sparse) const
{ {
throw UnknownDerivIDException(); throw UnknownDerivIDException();
@ -336,7 +336,7 @@ public:
/* Returns the number of columns of the Jacobian /* Returns the number of columns of the Jacobian
The sparse argument selects between the legacy representation and the The sparse argument selects between the legacy representation and the
sparse representation. */ sparse representation. */
virtual int [[nodiscard]] virtual int
getJacobianColsNbr([[maybe_unused]] bool sparse) const getJacobianColsNbr([[maybe_unused]] bool sparse) const
{ {
throw UnknownDerivIDException(); throw UnknownDerivIDException();
@ -347,7 +347,7 @@ public:
//! Returns bool indicating whether DataTree represents a Dynamic Model (returns true in //! Returns bool indicating whether DataTree represents a Dynamic Model (returns true in
//! DynamicModel.hh) //! DynamicModel.hh)
virtual bool [[nodiscard]] virtual bool
isDynamic() const isDynamic() const
{ {
return false; return false;
@ -359,7 +359,7 @@ public:
int id; int id;
}; };
expr_t [[nodiscard]] expr_t
getLocalVariable(int symb_id) const getLocalVariable(int symb_id) const
{ {
auto it = local_variables_table.find(symb_id); auto it = local_variables_table.find(symb_id);

View File

@ -63,7 +63,7 @@ public:
//! Various functions to get info from equation tags //! Various functions to get info from equation tags
//! Get equation tags for a given equation //! Get equation tags for a given equation
map<string, string> [[nodiscard]] map<string, string>
getTagsByEqn(int eqn) const getTagsByEqn(int eqn) const
{ {
if (auto it = eqn_tags.find(eqn); it != eqn_tags.end()) if (auto it = eqn_tags.find(eqn); it != eqn_tags.end())
@ -72,19 +72,19 @@ public:
} }
//! Get equations that have the given key //! Get equations that have the given key
set<int> getEqnsByKey(const string& key) const; [[nodiscard]] set<int> getEqnsByKey(const string& key) const;
//! Get equations that have the given key and value //! Get equations that have the given key and value
set<int> getEqnsByTag(const string& key, const string& value) const; [[nodiscard]] set<int> getEqnsByTag(const string& key, const string& value) const;
//! Get the first equation that has the given key and value //! Get the first equation that has the given key and value
optional<int> getEqnByTag(const string& key, const string& value) const; [[nodiscard]] optional<int> getEqnByTag(const string& key, const string& value) const;
// Get equations that have all the given keys and values (seen as a conjunction) // Get equations that have all the given keys and values (seen as a conjunction)
set<int> getEqnsByTags(const map<string, string>& tags_selected) const; [[nodiscard]] set<int> getEqnsByTags(const map<string, string>& tags_selected) const;
//! Get the tag value given the equation number and key //! Get the tag value given the equation number and key
optional<string> [[nodiscard]] optional<string>
getTagValueByEqnAndKey(int eqn, const string& key) const getTagValueByEqnAndKey(int eqn, const string& key) const
{ {
if (auto it = eqn_tags.find(eqn); it != eqn_tags.end()) if (auto it = eqn_tags.find(eqn); it != eqn_tags.end())
@ -94,21 +94,21 @@ public:
} }
//! Get the equations marked dynamic //! Get the equations marked dynamic
set<int> [[nodiscard]] set<int>
getDynamicEqns() const getDynamicEqns() const
{ {
return getEqnsByTag("dynamic", ""); return getEqnsByTag("dynamic", "");
} }
//! Returns true if equation tag with key and value exists //! Returns true if equation tag with key and value exists
bool [[nodiscard]] bool
exists(const string& key, const string& value) const exists(const string& key, const string& value) const
{ {
return getEqnByTag(key, value).has_value(); return getEqnByTag(key, value).has_value();
} }
//! Returns true if equation tag with key exists for a given equation //! Returns true if equation tag with key exists for a given equation
bool [[nodiscard]] bool
exists(int eqn, const string& key) const exists(int eqn, const string& key) const
{ {
auto it = eqn_tags.find(eqn); auto it = eqn_tags.find(eqn);

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* /*
* Copyright © 2010-2022 Dynare Team * Copyright © 2010-2023 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -66,13 +66,13 @@ public:
const external_function_options& external_function_options_arg, const external_function_options& external_function_options_arg,
bool track_nargs); bool track_nargs);
//! See if the function exists in the External Functions Table //! See if the function exists in the External Functions Table
inline bool exists(int symb_id) const; [[nodiscard]] inline bool exists(int symb_id) const;
//! Get the number of arguments for a given external function //! Get the number of arguments for a given external function
inline int getNargs(int symb_id) const noexcept(false); [[nodiscard]] inline int getNargs(int symb_id) const noexcept(false);
//! Get the symbol_id of the first derivative function //! Get the symbol_id of the first derivative function
inline int getFirstDerivSymbID(int symb_id) const noexcept(false); [[nodiscard]] inline int getFirstDerivSymbID(int symb_id) const noexcept(false);
//! Get the symbol_id of the second derivative function //! Get the symbol_id of the second derivative function
inline int getSecondDerivSymbID(int symb_id) const noexcept(false); [[nodiscard]] inline int getSecondDerivSymbID(int symb_id) const noexcept(false);
}; };
inline bool inline bool

View File

@ -204,7 +204,7 @@ protected:
max_endo_lead { max_endo_lead {
0}; // Maximum lag/lead on endos that appear in and *that belong to* the block 0}; // Maximum lag/lead on endos that appear in and *that belong to* the block
int [[nodiscard]] int
getRecursiveSize() const getRecursiveSize() const
{ {
return size - mfs_size; return size - mfs_size;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright © 2003-2022 Dynare Team * Copyright © 2003-2023 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -41,9 +41,9 @@ public:
//! Adds a non-negative constant (possibly Inf or NaN) and returns its ID //! Adds a non-negative constant (possibly Inf or NaN) and returns its ID
int AddNonNegativeConstant(const string& iConst); int AddNonNegativeConstant(const string& iConst);
//! Get a constant in string form //! Get a constant in string form
string get(int ID) const; [[nodiscard]] string get(int ID) const;
//! Get a constant in double form //! Get a constant in double form
double getDouble(int ID) const; [[nodiscard]] double getDouble(int ID) const;
}; };
#endif #endif

View File

@ -856,7 +856,7 @@ public:
//! Adds an external function argument //! Adds an external function argument
void add_external_function_arg(expr_t arg); void add_external_function_arg(expr_t arg);
//! Test to see if model/external function has exactly one integer argument //! Test to see if model/external function has exactly one integer argument
optional<int> is_there_one_integer_argument() const; [[nodiscard]] optional<int> is_there_one_integer_argument() const;
//! Adds an external function call node //! Adds an external function call node
expr_t add_model_var_or_external_function(const string& function_name, bool in_model_block); expr_t add_model_var_or_external_function(const string& function_name, bool in_model_block);
//! Adds a native statement //! Adds a native statement

View File

@ -72,7 +72,7 @@ private:
void writeCovarOrCorrShock(ostream& output, const pair<pair<int, int>, expr_t>& it, void writeCovarOrCorrShock(ostream& output, const pair<pair<int, int>, expr_t>& it,
bool corr) const; bool corr) const;
void writeCovarAndCorrShocks(ostream& output) const; void writeCovarAndCorrShocks(ostream& output) const;
bool has_calibrated_measurement_errors() const; [[nodiscard]] bool has_calibrated_measurement_errors() const;
public: public:
ShocksStatement(bool overwrite_arg, det_shocks_t det_shocks_arg, ShocksStatement(bool overwrite_arg, det_shocks_t det_shocks_arg,

View File

@ -254,10 +254,10 @@ public:
{ {
}; };
bool empty() const; [[nodiscard]] bool empty() const;
void clear(); void clear();
// Whether there is an option with that name that has been given a value // Whether there is an option with that name that has been given a value
bool contains(const string& name) const; [[nodiscard]] bool contains(const string& name) const;
// Erase the option with that name // Erase the option with that name
void erase(const string& name); void erase(const string& name);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright © 2018-2022 Dynare Team * Copyright © 2018-2023 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -64,25 +64,25 @@ public:
void addTrendComponentModel(string name_arg, vector<string> eqtags_arg, void addTrendComponentModel(string name_arg, vector<string> eqtags_arg,
vector<string> target_eqtags_arg); vector<string> target_eqtags_arg);
inline bool isExistingTrendComponentModelName(const string& name_arg) const; [[nodiscard]] inline bool isExistingTrendComponentModelName(const string& name_arg) const;
inline bool empty() const; [[nodiscard]] inline bool empty() const;
const map<string, vector<string>>& getEqTags() const; [[nodiscard]] const map<string, vector<string>>& getEqTags() const;
const vector<string>& getEqTags(const string& name_arg) const; [[nodiscard]] const vector<string>& getEqTags(const string& name_arg) const;
const map<string, vector<string>>& getTargetEqTags() const; [[nodiscard]] const map<string, vector<string>>& getTargetEqTags() const;
const map<string, vector<int>>& getEqNums() const; [[nodiscard]] const map<string, vector<int>>& getEqNums() const;
const map<string, vector<int>>& getTargetEqNums() const; [[nodiscard]] const map<string, vector<int>>& getTargetEqNums() const;
const vector<int>& getTargetEqNums(const string& name_arg) const; [[nodiscard]] const vector<int>& getTargetEqNums(const string& name_arg) const;
const vector<int>& getEqNums(const string& name_arg) const; [[nodiscard]] const vector<int>& getEqNums(const string& name_arg) const;
const vector<int>& getMaxLags(const string& name_arg) const; [[nodiscard]] const vector<int>& getMaxLags(const string& name_arg) const;
int getMaxLag(const string& name_arg) const; [[nodiscard]] int getMaxLag(const string& name_arg) const;
const vector<int>& getLhs(const string& name_arg) const; [[nodiscard]] const vector<int>& getLhs(const string& name_arg) const;
const vector<expr_t>& getLhsExprT(const string& name_arg) const; [[nodiscard]] const vector<expr_t>& getLhsExprT(const string& name_arg) const;
const vector<bool>& getDiff(const string& name_arg) const; [[nodiscard]] const vector<bool>& getDiff(const string& name_arg) const;
const map<string, vector<int>>& getNonTargetEqNums() const; [[nodiscard]] const map<string, vector<int>>& getNonTargetEqNums() const;
const vector<int>& getNonTargetEqNums(const string& name_arg) const; [[nodiscard]] const vector<int>& getNonTargetEqNums(const string& name_arg) const;
const vector<int>& getNonTargetLhs(const string& name_arg) const; [[nodiscard]] const vector<int>& getNonTargetLhs(const string& name_arg) const;
const vector<int>& getTargetLhs(const string& name_arg) const; [[nodiscard]] const vector<int>& getTargetLhs(const string& name_arg) const;
void setVals(map<string, vector<int>> eqnums_arg, map<string, vector<int>> target_eqnums_arg, void setVals(map<string, vector<int>> eqnums_arg, map<string, vector<int>> target_eqnums_arg,
map<string, vector<int>> lhs_arg, map<string, vector<expr_t>> lhs_expr_t_arg); map<string, vector<int>> lhs_arg, map<string, vector<expr_t>> lhs_expr_t_arg);
@ -145,21 +145,21 @@ public:
//! Add a VAR model //! Add a VAR model
void addVarModel(string name, bool structural_arg, vector<string> eqtags); void addVarModel(string name, bool structural_arg, vector<string> eqtags);
inline bool isExistingVarModelName(const string& name_arg) const; [[nodiscard]] inline bool isExistingVarModelName(const string& name_arg) const;
inline bool empty() const; [[nodiscard]] inline bool empty() const;
const map<string, bool>& getStructural() const; [[nodiscard]] const map<string, bool>& getStructural() const;
const map<string, vector<string>>& getEqTags() const; [[nodiscard]] const map<string, vector<string>>& getEqTags() const;
const vector<string>& getEqTags(const string& name_arg) const; [[nodiscard]] const vector<string>& getEqTags(const string& name_arg) const;
const map<string, vector<int>>& getEqNums() const; [[nodiscard]] const map<string, vector<int>>& getEqNums() const;
const vector<bool>& getDiff(const string& name_arg) const; [[nodiscard]] const vector<bool>& getDiff(const string& name_arg) const;
const vector<int>& getEqNums(const string& name_arg) const; [[nodiscard]] const vector<int>& getEqNums(const string& name_arg) const;
const vector<int>& getMaxLags(const string& name_arg) const; [[nodiscard]] const vector<int>& getMaxLags(const string& name_arg) const;
int getMaxLag(const string& name_arg) const; [[nodiscard]] int getMaxLag(const string& name_arg) const;
const vector<int>& getLhs(const string& name_arg) const; [[nodiscard]] const vector<int>& getLhs(const string& name_arg) const;
const vector<int>& getLhsOrigIds(const string& name_arg) const; [[nodiscard]] const vector<int>& getLhsOrigIds(const string& name_arg) const;
const vector<set<pair<int, int>>>& getRhs(const string& name_arg) const; [[nodiscard]] const vector<set<pair<int, int>>>& getRhs(const string& name_arg) const;
const vector<expr_t>& getLhsExprT(const string& name_arg) const; [[nodiscard]] const vector<expr_t>& getLhsExprT(const string& name_arg) const;
void setEqNums(map<string, vector<int>> eqnums_arg); void setEqNums(map<string, vector<int>> eqnums_arg);
void setLhs(map<string, vector<int>> lhs_arg); void setLhs(map<string, vector<int>> lhs_arg);
@ -213,8 +213,8 @@ public:
explicit VarExpectationModelTable(SymbolTable& symbol_table_arg); explicit VarExpectationModelTable(SymbolTable& symbol_table_arg);
void addVarExpectationModel(string name_arg, expr_t expression_arg, string aux_model_name_arg, void addVarExpectationModel(string name_arg, expr_t expression_arg, string aux_model_name_arg,
string horizon_arg, expr_t discount_arg, int time_shift_arg); string horizon_arg, expr_t discount_arg, int time_shift_arg);
bool isExistingVarExpectationModelName(const string& name_arg) const; [[nodiscard]] bool isExistingVarExpectationModelName(const string& name_arg) const;
bool empty() const; [[nodiscard]] bool empty() const;
void substituteUnaryOpsInExpression(const lag_equivalence_table_t& nodes, void substituteUnaryOpsInExpression(const lag_equivalence_table_t& nodes,
ExprNode::subst_table_t& subst_table, ExprNode::subst_table_t& subst_table,
vector<BinaryOpNode*>& neweqs); vector<BinaryOpNode*>& neweqs);
@ -313,7 +313,7 @@ private:
// pac_model_name → (target variable/expr, auxname_target_nonstationary, target components) // pac_model_name → (target variable/expr, auxname_target_nonstationary, target components)
map<string, tuple<expr_t, string, vector<target_component_t>>> target_info; map<string, tuple<expr_t, string, vector<target_component_t>>> target_info;
int pacEquationMaxLag(const string& name_arg) const; [[nodiscard]] int pacEquationMaxLag(const string& name_arg) const;
// Return a text representation of a kind (but fails on “unspecified” kind value) // Return a text representation of a kind (but fails on “unspecified” kind value)
static string kindToString(PacTargetKind kind); static string kindToString(PacTargetKind kind);
@ -322,8 +322,8 @@ public:
explicit PacModelTable(SymbolTable& symbol_table_arg); explicit PacModelTable(SymbolTable& symbol_table_arg);
void addPacModel(string name_arg, string aux_model_name_arg, string discount_arg, void addPacModel(string name_arg, string aux_model_name_arg, string discount_arg,
expr_t growth_arg, string auxname_arg, PacTargetKind kind_arg); expr_t growth_arg, string auxname_arg, PacTargetKind kind_arg);
bool isExistingPacModelName(const string& name_arg) const; [[nodiscard]] bool isExistingPacModelName(const string& name_arg) const;
bool empty() const; [[nodiscard]] bool empty() const;
void checkPass(ModFileStructure& mod_file_struct); void checkPass(ModFileStructure& mod_file_struct);
// Called by DynamicModel::substituteUnaryOps() // Called by DynamicModel::substituteUnaryOps()
void substituteUnaryOpsInGrowth(const lag_equivalence_table_t& nodes, void substituteUnaryOpsInGrowth(const lag_equivalence_table_t& nodes,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright © 2003-2022 Dynare Team * Copyright © 2003-2023 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -59,13 +59,13 @@ public:
//! Write JSON output //! Write JSON output
void writeJsonOutput(ostream& output) const; void writeJsonOutput(ostream& output) const;
//! Is Empty //! Is Empty
bool [[nodiscard]] bool
empty() const empty() const
{ {
return symbols.empty(); return symbols.empty();
}; };
//! Return the list of symbols //! Return the list of symbols
vector<string> getSymbols() const; [[nodiscard]] vector<string> getSymbols() const;
}; };
#endif #endif

View File

@ -84,7 +84,7 @@ struct AuxVarInfo
const expr_t expr_node; // Auxiliary variable definition const expr_t expr_node; // Auxiliary variable definition
const string unary_op; // Used with AuxUnaryOp const string unary_op; // Used with AuxUnaryOp
int [[nodiscard]] int
get_type_id() const get_type_id() const
{ {
return static_cast<int>(type); return static_cast<int>(type);
@ -278,14 +278,14 @@ public:
\return the symbol ID of the auxiliary variable \return the symbol ID of the auxiliary variable
Throws an exception if match not found. Throws an exception if match not found.
*/ */
int searchAuxiliaryVars(int orig_symb_id, int orig_lead_lag) const noexcept(false); [[nodiscard]] int searchAuxiliaryVars(int orig_symb_id, int orig_lead_lag) const noexcept(false);
/* Searches aux_vars for the aux var represented by aux_var_symb_id and /* Searches aux_vars for the aux var represented by aux_var_symb_id and
returns its associated orig_symb_id. returns its associated orig_symb_id.
Throws an UnknownSymbolIDException if there is no orig_symb_id associated to Throws an UnknownSymbolIDException if there is no orig_symb_id associated to
this auxvar (either because its of the wrong type, or because there is this auxvar (either because its of the wrong type, or because there is
no such orig var for this specific auxvar, in case of complex expressions no such orig var for this specific auxvar, in case of complex expressions
in diff or unaryOp). */ in diff or unaryOp). */
int getOrigSymbIdForAuxVar(int aux_var_symb_id_arg) const noexcept(false); [[nodiscard]] int getOrigSymbIdForAuxVar(int aux_var_symb_id_arg) const noexcept(false);
/* Unrolls a chain of diffLag or diffLead aux vars until it founds a (regular) diff aux /* Unrolls a chain of diffLag or diffLead aux vars until it founds a (regular) diff aux
var. In other words: var. In other words:
- if the arg is a (regu) diff aux var, returns the arg - if the arg is a (regu) diff aux var, returns the arg
@ -297,7 +297,7 @@ public:
output argument is equal to the 2nd input argument, shifted by as many output argument is equal to the 2nd input argument, shifted by as many
lead/lags were encountered in the chain (a diffLag decreases it, a lead/lags were encountered in the chain (a diffLag decreases it, a
diffLead increases it). */ diffLead increases it). */
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, optional<int> orig_symb_id = nullopt,
optional<int> orig_lag = nullopt) noexcept(false); optional<int> orig_lag = nullopt) noexcept(false);
@ -316,32 +316,33 @@ public:
//! An auxiliary variable for a pac_target_nonstationary operator //! An auxiliary variable for a pac_target_nonstationary operator
int addPacTargetNonstationaryAuxiliaryVar(const string& name, expr_t expr_arg); int addPacTargetNonstationaryAuxiliaryVar(const string& name, expr_t expr_arg);
//! Returns the number of auxiliary variables //! Returns the number of auxiliary variables
int [[nodiscard]] int
AuxVarsSize() const AuxVarsSize() const
{ {
return aux_vars.size(); return aux_vars.size();
}; };
//! Tests if symbol already exists //! Tests if symbol already exists
inline bool exists(const string& name) const; [[nodiscard]] inline bool exists(const string& name) const;
//! Get symbol name (by ID) //! Get symbol name (by ID)
inline string getName(int id) const noexcept(false); [[nodiscard]] inline string getName(int id) const noexcept(false);
//! Get TeX name //! Get TeX name
inline string getTeXName(int id) const noexcept(false); [[nodiscard]] inline string getTeXName(int id) const noexcept(false);
//! Get long name //! Get long name
inline string getLongName(int id) const noexcept(false); [[nodiscard]] inline string getLongName(int id) const noexcept(false);
//! Returns true if the partition name is the first encountered for the type of variable //! Returns true if the partition name is the first encountered for the type of variable
//! represented by id //! represented by id
bool isFirstOfPartitionForType(int id) const noexcept(false); [[nodiscard]] bool isFirstOfPartitionForType(int id) const noexcept(false);
//! Returns a list of partitions and symbols that belong to that partition //! Returns a list of partitions and symbols that belong to that partition
map<string, map<int, string>> getPartitionsForType(SymbolType st) const noexcept(false); [[nodiscard]] map<string, map<int, string>> getPartitionsForType(SymbolType st) const
noexcept(false);
//! Get type (by ID) //! Get type (by ID)
inline SymbolType getType(int id) const noexcept(false); [[nodiscard]] inline SymbolType getType(int id) const noexcept(false);
//! Get type (by name) //! Get type (by name)
inline SymbolType getType(const string& name) const noexcept(false); [[nodiscard]] inline SymbolType getType(const string& name) const noexcept(false);
//! Get ID (by name) //! Get ID (by name)
inline int getID(const string& name) const noexcept(false); [[nodiscard]] inline int getID(const string& name) const noexcept(false);
//! Get ID (by type specific ID) //! Get ID (by type specific ID)
int getID(SymbolType type, int tsid) const noexcept(false); [[nodiscard]] int getID(SymbolType type, int tsid) const noexcept(false);
//! Freeze symbol table //! Freeze symbol table
void freeze() noexcept(false); void freeze() noexcept(false);
//! unreeze symbol table //! unreeze symbol table
@ -350,21 +351,21 @@ public:
//! Change the type of a symbol //! Change the type of a symbol
void changeType(int id, SymbolType newtype) noexcept(false); void changeType(int id, SymbolType newtype) noexcept(false);
//! Get type specific ID (by symbol ID) //! Get type specific ID (by symbol ID)
inline int getTypeSpecificID(int id) const noexcept(false); [[nodiscard]] inline int getTypeSpecificID(int id) const noexcept(false);
//! Get type specific ID (by symbol name) //! Get type specific ID (by symbol name)
inline int getTypeSpecificID(const string& name) const noexcept(false); [[nodiscard]] inline int getTypeSpecificID(const string& name) const noexcept(false);
//! Get number of endogenous variables //! Get number of endogenous variables
inline int endo_nbr() const noexcept(false); [[nodiscard]] inline int endo_nbr() const noexcept(false);
//! Get number of exogenous variables //! Get number of exogenous variables
inline int exo_nbr() const noexcept(false); [[nodiscard]] inline int exo_nbr() const noexcept(false);
//! Get number of exogenous deterministic variables //! Get number of exogenous deterministic variables
inline int exo_det_nbr() const noexcept(false); [[nodiscard]] inline int exo_det_nbr() const noexcept(false);
//! Get number of parameters //! Get number of parameters
inline int param_nbr() const noexcept(false); [[nodiscard]] inline int param_nbr() const noexcept(false);
//! Returns the greatest symbol ID (the smallest is zero) //! Returns the greatest symbol ID (the smallest is zero)
inline int maxID(); inline int maxID();
//! Get number of user-declared endogenous variables (without the auxiliary variables) //! Get number of user-declared endogenous variables (without the auxiliary variables)
inline int orig_endo_nbr() const noexcept(false); [[nodiscard]] inline int orig_endo_nbr() const noexcept(false);
//! Write output of this class //! Write output of this class
void writeOutput(ostream& output) const noexcept(false); void writeOutput(ostream& output) const noexcept(false);
//! Write JSON Output //! Write JSON Output
@ -374,56 +375,56 @@ public:
//! Mark an endogenous as having been declared with “var(log)” //! Mark an endogenous as having been declared with “var(log)”
void markWithLogTransform(int symb_id) noexcept(false); void markWithLogTransform(int symb_id) noexcept(false);
//! Test if a given symbol is a predetermined variable //! Test if a given symbol is a predetermined variable
bool isPredetermined(int symb_id) const noexcept(false); [[nodiscard]] bool isPredetermined(int symb_id) const noexcept(false);
//! Return the number of predetermined variables //! Return the number of predetermined variables
int predeterminedNbr() const; [[nodiscard]] int predeterminedNbr() const;
//! Add an observed variable //! Add an observed variable
void addObservedVariable(int symb_id) noexcept(false); void addObservedVariable(int symb_id) noexcept(false);
//! Return the number of observed variables //! Return the number of observed variables
int observedVariablesNbr() const; [[nodiscard]] int observedVariablesNbr() const;
//! Is a given symbol in the set of observed variables //! Is a given symbol in the set of observed variables
bool isObservedVariable(int symb_id) const; [[nodiscard]] bool isObservedVariable(int symb_id) const;
//! Return the index of a given observed variable in the vector of all observed variables //! Return the index of a given observed variable in the vector of all observed variables
int getObservedVariableIndex(int symb_id) const; [[nodiscard]] int getObservedVariableIndex(int symb_id) const;
//! Add an observed exogenous variable //! Add an observed exogenous variable
void addObservedExogenousVariable(int symb_id) noexcept(false); void addObservedExogenousVariable(int symb_id) noexcept(false);
//! Return the number of observed exogenous variables //! Return the number of observed exogenous variables
int observedExogenousVariablesNbr() const; [[nodiscard]] int observedExogenousVariablesNbr() const;
//! Is a given symbol in the set of observed exogenous variables //! Is a given symbol in the set of observed exogenous variables
bool isObservedExogenousVariable(int symb_id) const; [[nodiscard]] bool isObservedExogenousVariable(int symb_id) const;
//! Return the index of a given observed exogenous variable in the vector of all observed //! Return the index of a given observed exogenous variable in the vector of all observed
//! variables //! variables
int getObservedExogenousVariableIndex(int symb_id) const; [[nodiscard]] int getObservedExogenousVariableIndex(int symb_id) const;
vector<int> getTrendVarIds() const; [[nodiscard]] vector<int> getTrendVarIds() const;
//! Get list of exogenous variables //! Get list of exogenous variables
set<int> getExogenous() const; [[nodiscard]] set<int> getExogenous() const;
//! Get list of exogenous variables //! Get list of exogenous variables
set<int> getObservedExogenous() const; [[nodiscard]] set<int> getObservedExogenous() const;
//! Get list of endogenous variables //! Get list of endogenous variables
set<int> getEndogenous() const; [[nodiscard]] set<int> getEndogenous() const;
//! Is a given symbol an auxiliary variable //! Is a given symbol an auxiliary variable
bool isAuxiliaryVariable(int symb_id) const; [[nodiscard]] bool isAuxiliaryVariable(int symb_id) const;
//! Is a given symbol a diff, diff lead, or diff lag auxiliary variable //! Is a given symbol a diff, diff lead, or diff lag auxiliary variable
bool isDiffAuxiliaryVariable(int symb_id) const; [[nodiscard]] bool isDiffAuxiliaryVariable(int symb_id) const;
//! Get list of endogenous variables without aux vars //! Get list of endogenous variables without aux vars
set<int> getOrigEndogenous() const; [[nodiscard]] set<int> getOrigEndogenous() const;
//! Returns the original symbol corresponding to this variable //! Returns the original symbol corresponding to this variable
/* If symb_id has no original variable, returns symb_id. Otherwise, /* If symb_id has no original variable, returns symb_id. Otherwise,
repeatedly call getOrigSymbIDForAuxVar() until an original variable is repeatedly call getOrigSymbIDForAuxVar() until an original variable is
found. Note that the result may be an auxiliary variable if the latter has found. Note that the result may be an auxiliary variable if the latter has
no original variable (e.g. aux var for lead, Lagrange Multiplier or diff no original variable (e.g. aux var for lead, Lagrange Multiplier or diff
associated to a complex expression). */ associated to a complex expression). */
int getUltimateOrigSymbID(int symb_id) const; [[nodiscard]] int getUltimateOrigSymbID(int symb_id) const;
//! If this is a Lagrange multiplier, return its associated equation number; otherwise return //! If this is a Lagrange multiplier, return its associated equation number; otherwise return
//! nullopt //! nullopt
optional<int> getEquationNumberForMultiplier(int symb_id) const; [[nodiscard]] optional<int> getEquationNumberForMultiplier(int symb_id) const;
/* Return all the information about a given auxiliary variable. Throws /* Return all the information about a given auxiliary variable. Throws
UnknownSymbolIDException if it is not an aux var */ UnknownSymbolIDException if it is not an aux var */
const AuxVarInfo& getAuxVarInfo(int symb_id) const; [[nodiscard]] const AuxVarInfo& getAuxVarInfo(int symb_id) const;
// Returns the set of all endogenous declared with “var(log)” // Returns the set of all endogenous declared with “var(log)”
const set<int>& getVariablesWithLogTransform() const; [[nodiscard]] const set<int>& getVariablesWithLogTransform() const;
// Returns all Lagrange multipliers // Returns all Lagrange multipliers
set<int> getLagrangeMultipliers() const; [[nodiscard]] set<int> getLagrangeMultipliers() const;
}; };
inline void inline void

View File

@ -1,5 +1,5 @@
/* /*
* Copyright © 2009-2020 Dynare Team * Copyright © 2009-2023 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -59,18 +59,18 @@ public:
The property vertex_index1 of the subgraph contains indices of the original The property vertex_index1 of the subgraph contains indices of the original
graph. graph.
*/ */
VariableDependencyGraph extractSubgraph(const vector<int>& select_index) const; [[nodiscard]] VariableDependencyGraph extractSubgraph(const vector<int>& select_index) const;
//! Return the feedback set //! Return the feedback set
set<int> minimalSetOfFeedbackVertices() const; [[nodiscard]] set<int> minimalSetOfFeedbackVertices() const;
//! Reorder the recursive variables //! Reorder the recursive variables
/*! They appear first in a quasi triangular form and they are followed by the feedback variables /*! They appear first in a quasi triangular form and they are followed by the feedback variables
*/ */
vector<int> reorderRecursiveVariables(const set<int>& feedback_vertices) const; [[nodiscard]] vector<int> reorderRecursiveVariables(const set<int>& feedback_vertices) const;
/* Computes the strongly connected components (SCCs) of the graph, and sort them /* Computes the strongly connected components (SCCs) of the graph, and sort them
topologically. topologically.
Returns the number of SCCs, and a mapping of vertex indices to sorted SCC Returns the number of SCCs, and a mapping of vertex indices to sorted SCC
indices. */ indices. */
pair<int, vector<int>> sortedStronglyConnectedComponents() const; [[nodiscard]] pair<int, vector<int>> sortedStronglyConnectedComponents() const;
// Print on stdout a description of the graph // Print on stdout a description of the graph
void print() const; void print() const;
@ -86,7 +86,7 @@ private:
// Internal helper for hasCycle() // Internal helper for hasCycle()
bool hasCycleDFS(vertex_descriptor u, color_t& color, vector<int>& circuit_stack) const; bool hasCycleDFS(vertex_descriptor u, color_t& color, vector<int>& circuit_stack) const;
// Determine whether the graph has a cycle // Determine whether the graph has a cycle
bool hasCycle() const; [[nodiscard]] bool hasCycle() const;
bool vertexBelongsToAClique(vertex_descriptor vertex) const; bool vertexBelongsToAClique(vertex_descriptor vertex) const;
bool eliminationOfVerticesWithOneOrLessIndegreeOrOutdegree(); bool eliminationOfVerticesWithOneOrLessIndegreeOrOutdegree();
bool eliminationOfVerticesBelongingToAClique(); bool eliminationOfVerticesBelongingToAClique();

View File

@ -92,7 +92,7 @@ public:
//! Error handler //! Error handler
void error(const Tokenizer::parser::location_type& location, const string& message) const; void error(const Tokenizer::parser::location_type& location, const string& message) const;
bool [[nodiscard]] bool
inContext() const inContext() const
{ {
return !directive_stack.empty(); return !directive_stack.empty();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright © 2019-2022 Dynare Team * Copyright © 2019-2023 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -42,12 +42,15 @@ public:
} }
void define(VariablePtr var, ExpressionPtr value); void define(VariablePtr var, ExpressionPtr value);
void define(FunctionPtr func, ExpressionPtr value); void define(FunctionPtr func, ExpressionPtr value);
ExpressionPtr getVariable(const string& name) const; /* The following two functions are not marked [[nodiscard]], because they are used without output
tuple<FunctionPtr, ExpressionPtr> getFunction(const string& name) const; to check whether they return an exception or not. */
codes::BaseType getType(const string& name) const; ExpressionPtr getVariable(const string& name) const; // NOLINT(modernize-use-nodiscard)
bool isVariableDefined(const string& name) const noexcept; tuple<FunctionPtr, ExpressionPtr> // NOLINT(modernize-use-nodiscard)
bool isFunctionDefined(const string& name) const noexcept; getFunction(const string& name) const;
bool [[nodiscard]] codes::BaseType getType(const string& name) const;
[[nodiscard]] bool isVariableDefined(const string& name) const noexcept;
[[nodiscard]] bool isFunctionDefined(const string& name) const noexcept;
[[nodiscard]] bool
isSymbolDefined(const string& name) const noexcept isSymbolDefined(const string& name) const noexcept
{ {
return isVariableDefined(name) || isFunctionDefined(name); return isVariableDefined(name) || isFunctionDefined(name);
@ -58,12 +61,12 @@ public:
bool save) const; bool save) const;
void printFunction(ostream& output, const tuple<FunctionPtr, ExpressionPtr>& function, void printFunction(ostream& output, const tuple<FunctionPtr, ExpressionPtr>& function,
const optional<int>& line, bool save) const; const optional<int>& line, bool save) const;
size_t [[nodiscard]] size_t
size() const noexcept size() const noexcept
{ {
return variables.size() + functions.size(); return variables.size() + functions.size();
} }
const Environment* [[nodiscard]] const Environment*
getGlobalEnv() const noexcept getGlobalEnv() const noexcept
{ {
return parent == nullptr ? this : parent->getGlobalEnv(); return parent == nullptr ? this : parent->getGlobalEnv();

View File

@ -72,7 +72,7 @@ public:
ss << "-" << end_col; ss << "-" << end_col;
message.emplace_back(ss.str()); message.emplace_back(ss.str());
} }
string [[nodiscard]] string
trace() const trace() const
{ {
stringstream ss; stringstream ss;
@ -94,7 +94,7 @@ public:
virtual ~Node() = default; virtual ~Node() = default;
public: public:
Tokenizer::location [[nodiscard]] Tokenizer::location
getLocation() const noexcept getLocation() const noexcept
{ {
return location; return location;
@ -131,7 +131,7 @@ public:
explicit Expression(Tokenizer::location location_arg) : Node(move(location_arg)) explicit Expression(Tokenizer::location location_arg) : Node(move(location_arg))
{ {
} }
virtual string to_string() const noexcept = 0; [[nodiscard]] virtual string to_string() const noexcept = 0;
virtual void print(ostream& output, bool matlab_output = false) const noexcept = 0; virtual void print(ostream& output, bool matlab_output = false) const noexcept = 0;
virtual BaseTypePtr eval(Environment& env) const = 0; virtual BaseTypePtr eval(Environment& env) const = 0;
}; };
@ -1063,7 +1063,7 @@ public:
Expression(move(location_arg)), name {move(name_arg)}, indices {move(indices_arg)} Expression(move(location_arg)), name {move(name_arg)}, indices {move(indices_arg)}
{ {
} }
string [[nodiscard]] string
to_string() const noexcept override to_string() const noexcept override
{ {
return name; return name;
@ -1076,12 +1076,12 @@ public:
BaseTypePtr eval(Environment& env) const override; BaseTypePtr eval(Environment& env) const override;
public: public:
const string& [[nodiscard]] const string&
getName() const noexcept getName() const noexcept
{ {
return name; return name;
} }
codes::BaseType [[nodiscard]] codes::BaseType
getType(const Environment& env) const getType(const Environment& env) const
{ {
return env.getType(name); return env.getType(name);
@ -1099,7 +1099,7 @@ public:
Expression(move(location_arg)), name {move(name_arg)}, args {move(args_arg)} Expression(move(location_arg)), name {move(name_arg)}, args {move(args_arg)}
{ {
} }
string to_string() const noexcept override; [[nodiscard]] string to_string() const noexcept override;
void void
print(ostream& output, [[maybe_unused]] bool matlab_output = false) const noexcept override print(ostream& output, [[maybe_unused]] bool matlab_output = false) const noexcept override
{ {
@ -1115,12 +1115,12 @@ public:
output << name; output << name;
} }
void printArgs(ostream& output) const noexcept; void printArgs(ostream& output) const noexcept;
const string& [[nodiscard]] const string&
getName() const getName() const
{ {
return name; return name;
} }
const vector<ExpressionPtr>& [[nodiscard]] const vector<ExpressionPtr>&
getArgs() const getArgs() const
{ {
return args; return args;
@ -1138,7 +1138,7 @@ public:
Expression(move(location_arg)), op_code {move(op_code_arg)}, arg {move(arg_arg)} Expression(move(location_arg)), op_code {move(op_code_arg)}, arg {move(arg_arg)}
{ {
} }
string to_string() const noexcept override; [[nodiscard]] string to_string() const noexcept override;
void print(ostream& output, bool matlab_output = false) const noexcept override; void print(ostream& output, bool matlab_output = false) const noexcept override;
BaseTypePtr eval(Environment& env) const override; BaseTypePtr eval(Environment& env) const override;
}; };
@ -1160,7 +1160,7 @@ public:
} }
public: public:
string to_string() const noexcept override; [[nodiscard]] string to_string() const noexcept override;
void print(ostream& output, bool matlab_output = false) const noexcept override; void print(ostream& output, bool matlab_output = false) const noexcept override;
BaseTypePtr eval(Environment& env) const override; BaseTypePtr eval(Environment& env) const override;
}; };
@ -1181,7 +1181,7 @@ public:
arg3 {move(arg3_arg)} arg3 {move(arg3_arg)}
{ {
} }
string to_string() const noexcept override; [[nodiscard]] string to_string() const noexcept override;
void print(ostream& output, bool matlab_output = false) const noexcept override; void print(ostream& output, bool matlab_output = false) const noexcept override;
BaseTypePtr eval(Environment& env) const override; BaseTypePtr eval(Environment& env) const override;
}; };
@ -1223,7 +1223,7 @@ public:
c_when {move(c_when_arg)} c_when {move(c_when_arg)}
{ {
} }
string to_string() const noexcept override; [[nodiscard]] string to_string() const noexcept override;
void print(ostream& output, bool matlab_output = false) const noexcept override; void print(ostream& output, bool matlab_output = false) const noexcept override;
BaseTypePtr eval(Environment& env) const override; BaseTypePtr eval(Environment& env) const override;
}; };