From 442624912e94a10a05ccdcea1ff61c33ef52882a Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Sat, 10 Feb 2024 19:38:02 +0100 Subject: [PATCH] catch exceptions by ref --- lib/LatAnalyze/Core/MathInterpreter.cpp | 10 +++++----- lib/LatAnalyze/Io/File.hpp | 4 ++-- utils/sample-combine.cpp | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/LatAnalyze/Core/MathInterpreter.cpp b/lib/LatAnalyze/Core/MathInterpreter.cpp index 356b9b1..e42027a 100644 --- a/lib/LatAnalyze/Core/MathInterpreter.cpp +++ b/lib/LatAnalyze/Core/MathInterpreter.cpp @@ -36,7 +36,7 @@ unsigned int RunContext::addFunction(const string &name, DoubleFunction *init) return getFunctionAddress(name); } - catch (Exceptions::Definition) + catch (Exceptions::Definition &) { unsigned int address = fTable_.size(); @@ -55,7 +55,7 @@ unsigned int RunContext::addVariable(const string &name, double init) return getVariableAddress(name); } - catch (Exceptions::Definition) + catch (Exceptions::Definition &) { unsigned int address = vTable_.size(); @@ -92,7 +92,7 @@ unsigned int RunContext::getFunctionAddress(const string &name) const { return fTable_.at(name); } - catch (out_of_range) + catch (out_of_range &) { LATAN_ERROR(Definition, "undefined function '" + name + "'"); } @@ -139,7 +139,7 @@ unsigned int RunContext::getVariableAddress(const string &name) const { return vTable_.at(name); } - catch (out_of_range) + catch (out_of_range &) { LATAN_ERROR(Definition, "undefined variable '" + name + "'"); } @@ -449,7 +449,7 @@ try\ {\ address = (table).at(name);\ }\ -catch (out_of_range)\ +catch (out_of_range &)\ {\ address = (table).size();\ (table)[(name)] = address;\ diff --git a/lib/LatAnalyze/Io/File.hpp b/lib/LatAnalyze/Io/File.hpp index d375391..bf5121e 100644 --- a/lib/LatAnalyze/Io/File.hpp +++ b/lib/LatAnalyze/Io/File.hpp @@ -105,12 +105,12 @@ const IoT& File::getData(const std::string &name) const { return dynamic_cast(*(data_.at(name))); } - catch(std::out_of_range) + catch (std::out_of_range &) { LATAN_ERROR(Definition, "no data with name '" + name + "' in file " + name_); } - catch(std::bad_cast) + catch (std::bad_cast &) { LATAN_ERROR(Definition, "data with name '" + name + "' in file " + name_ + " does not have type '" + typeid(IoT).name() diff --git a/utils/sample-combine.cpp b/utils/sample-combine.cpp index e72bfac..42e2a67 100644 --- a/utils/sample-combine.cpp +++ b/utils/sample-combine.cpp @@ -75,7 +75,7 @@ void loadAndCheck(vector &sample, const vector &fileName) gotSize = true; } } - catch (Exceptions::Definition) + catch (Exceptions::Definition &) { failed.insert(i); } @@ -233,7 +233,7 @@ int main(int argc, char *argv[]) { process(outFileName, fileName, code); } - catch (Exceptions::Definition) + catch (Exceptions::Definition &) { process(outFileName, fileName, code); }