From dc3c583c9d82f0f482963391e5cf5fc78c4cff4c Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Thu, 30 May 2024 16:47:37 -0700 Subject: [PATCH 1/8] Add omitted 'override' on various exceptions' what() methods --- include/bmi/State_Exception.hpp | 2 +- include/utilities/ConfigurationException.hpp | 2 +- include/utilities/ExternalIntegrationException.hpp | 2 +- src/core/nexus/HY_PointHydroNexus.cpp | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/bmi/State_Exception.hpp b/include/bmi/State_Exception.hpp index 6154736661..965f78f639 100644 --- a/include/bmi/State_Exception.hpp +++ b/include/bmi/State_Exception.hpp @@ -29,7 +29,7 @@ namespace models { State_Exception(State_Exception &&exception) noexcept : State_Exception(std::move(exception.what_message)) {} - virtual char const *what() const noexcept { + virtual char const *what() const noexcept override { return what_message.c_str(); } diff --git a/include/utilities/ConfigurationException.hpp b/include/utilities/ConfigurationException.hpp index 027d80485d..b5daa719d9 100644 --- a/include/utilities/ConfigurationException.hpp +++ b/include/utilities/ConfigurationException.hpp @@ -23,7 +23,7 @@ namespace realization { ConfigurationException(ConfigurationException &&exception) noexcept : ConfigurationException(std::move(exception.what_message)) {} - virtual char const *what() const noexcept { + char const *what() const noexcept override { return what_message.c_str(); } diff --git a/include/utilities/ExternalIntegrationException.hpp b/include/utilities/ExternalIntegrationException.hpp index f3af5eccbd..f28b77e8be 100644 --- a/include/utilities/ExternalIntegrationException.hpp +++ b/include/utilities/ExternalIntegrationException.hpp @@ -24,7 +24,7 @@ namespace external { ExternalIntegrationException(ExternalIntegrationException &&exception) noexcept : ExternalIntegrationException(std::move(exception.what_message)) {} - virtual char const *what() const noexcept { + char const *what() const noexcept override { return what_message.c_str(); } diff --git a/src/core/nexus/HY_PointHydroNexus.cpp b/src/core/nexus/HY_PointHydroNexus.cpp index 6faab79a8d..f7b9d8645a 100644 --- a/src/core/nexus/HY_PointHydroNexus.cpp +++ b/src/core/nexus/HY_PointHydroNexus.cpp @@ -6,27 +6,27 @@ typedef boost::error_info errmsg_info; struct invalid_downstream_request : public boost::exception, public std::exception { - const char *what() const noexcept { return "All downstream catchments can not request more than 100% of flux in total"; } + const char *what() const noexcept override { return "All downstream catchments can not request more than 100% of flux in total"; } }; struct add_to_summed_nexus : public boost::exception, public std::exception { - const char *what() const noexcept { return "Can not add water to a summed point nexus"; } + const char *what() const noexcept override { return "Can not add water to a summed point nexus"; } }; struct request_from_empty_nexus : public boost::exception, public std::exception { - const char *what() const noexcept { return "Can not release water from an empty nexus"; } + const char *what() const noexcept override { return "Can not release water from an empty nexus"; } }; struct completed_time_step : public boost::exception, public std::exception { - const char *what() const noexcept { return "Can not operate on a completed time step"; } + const char *what() const noexcept override { return "Can not operate on a completed time step"; } }; struct invalid_time_step : public boost::exception, public std::exception { - const char *what() const noexcept { return "Time step before minimum time step requested"; } + const char *what() const noexcept override { return "Time step before minimum time step requested"; } }; HY_PointHydroNexus::HY_PointHydroNexus(std::string nexus_id, Catchments receiving_catchments) : HY_HydroNexus( nexus_id, receiving_catchments), upstream_flows() From 8c87b3a61946c80ab4a4ee48abe4ce1425fd88b0 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Thu, 30 May 2024 16:48:31 -0700 Subject: [PATCH 2/8] Add omitted 'override' on geojson Feature class visit() methods --- include/geojson/features/CollectionFeature.hpp | 2 +- include/geojson/features/LineStringFeature.hpp | 4 ++-- include/geojson/features/MultiLineStringFeature.hpp | 4 ++-- include/geojson/features/MultiPointFeature.hpp | 4 ++-- include/geojson/features/MultiPolygonFeature.hpp | 4 ++-- include/geojson/features/PointFeature.hpp | 4 ++-- include/geojson/features/PolygonFeature.hpp | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/geojson/features/CollectionFeature.hpp b/include/geojson/features/CollectionFeature.hpp index 610baf2b47..d17971a438 100644 --- a/include/geojson/features/CollectionFeature.hpp +++ b/include/geojson/features/CollectionFeature.hpp @@ -209,7 +209,7 @@ namespace geojson { return this->geometry_collection.cend(); } - void visit(FeatureVisitor& visitor) { + void visit(FeatureVisitor& visitor) override { visitor.visit(this); } }; diff --git a/include/geojson/features/LineStringFeature.hpp b/include/geojson/features/LineStringFeature.hpp index 422bff2b29..4c8b32e256 100644 --- a/include/geojson/features/LineStringFeature.hpp +++ b/include/geojson/features/LineStringFeature.hpp @@ -37,10 +37,10 @@ namespace geojson { return boost::get(this->geom); } - void visit(FeatureVisitor& visitor) { + void visit(FeatureVisitor& visitor) override { visitor.visit(this); } }; } -#endif // GEOJSON_LINESTRING_FEATURE_H \ No newline at end of file +#endif // GEOJSON_LINESTRING_FEATURE_H diff --git a/include/geojson/features/MultiLineStringFeature.hpp b/include/geojson/features/MultiLineStringFeature.hpp index 73e3017b66..b5412e0e1f 100644 --- a/include/geojson/features/MultiLineStringFeature.hpp +++ b/include/geojson/features/MultiLineStringFeature.hpp @@ -37,10 +37,10 @@ namespace geojson { return boost::get(this->geom); } - void visit(FeatureVisitor& visitor) { + void visit(FeatureVisitor& visitor) override { visitor.visit(this); } }; } -#endif // GEOJSON_MULTILINESTRING_FEATURE_H \ No newline at end of file +#endif // GEOJSON_MULTILINESTRING_FEATURE_H diff --git a/include/geojson/features/MultiPointFeature.hpp b/include/geojson/features/MultiPointFeature.hpp index e81cee401d..9086080c25 100644 --- a/include/geojson/features/MultiPointFeature.hpp +++ b/include/geojson/features/MultiPointFeature.hpp @@ -37,10 +37,10 @@ namespace geojson { return boost::get(this->geom); } - void visit(FeatureVisitor& visitor) { + void visit(FeatureVisitor& visitor) override { visitor.visit(this); } }; } -#endif // GEOJSON_MULTIPOINT_FEATURE_H \ No newline at end of file +#endif // GEOJSON_MULTIPOINT_FEATURE_H diff --git a/include/geojson/features/MultiPolygonFeature.hpp b/include/geojson/features/MultiPolygonFeature.hpp index 3de30b49ac..eb2b701519 100644 --- a/include/geojson/features/MultiPolygonFeature.hpp +++ b/include/geojson/features/MultiPolygonFeature.hpp @@ -37,10 +37,10 @@ namespace geojson { return boost::get(this->geom); } - void visit(FeatureVisitor& visitor) { + void visit(FeatureVisitor& visitor) override { visitor.visit(this); } }; } -#endif // GEOJSON_MULTIPOLYGON_FEATURE_H \ No newline at end of file +#endif // GEOJSON_MULTIPOLYGON_FEATURE_H diff --git a/include/geojson/features/PointFeature.hpp b/include/geojson/features/PointFeature.hpp index c8eef44dcf..c29ee9825c 100644 --- a/include/geojson/features/PointFeature.hpp +++ b/include/geojson/features/PointFeature.hpp @@ -38,10 +38,10 @@ namespace geojson { return boost::get(this->geom); } - void visit(FeatureVisitor& visitor) { + void visit(FeatureVisitor& visitor) override { visitor.visit(this); } }; } -#endif // GEOJSON_POINT_FEATURE_H \ No newline at end of file +#endif // GEOJSON_POINT_FEATURE_H diff --git a/include/geojson/features/PolygonFeature.hpp b/include/geojson/features/PolygonFeature.hpp index a45b5bee03..a9a88c3f36 100644 --- a/include/geojson/features/PolygonFeature.hpp +++ b/include/geojson/features/PolygonFeature.hpp @@ -58,10 +58,10 @@ namespace geojson { /** * Runs a visitor function on this feature */ - void visit(FeatureVisitor& visitor) { + void visit(FeatureVisitor& visitor) override { visitor.visit(this); } }; } -#endif // GEOJSON_POLYGON_FEATURE_H \ No newline at end of file +#endif // GEOJSON_POLYGON_FEATURE_H From 088ac31a59df9fd16472d49a0480f69ea3d925d2 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Thu, 30 May 2024 16:49:24 -0700 Subject: [PATCH 3/8] Add omitted 'override' on test_bmi_cpp BMI methods --- extern/test_bmi_cpp/include/test_bmi_cpp.hpp | 92 ++++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/extern/test_bmi_cpp/include/test_bmi_cpp.hpp b/extern/test_bmi_cpp/include/test_bmi_cpp.hpp index 4ad474e1eb..c15896def2 100644 --- a/extern/test_bmi_cpp/include/test_bmi_cpp.hpp +++ b/extern/test_bmi_cpp/include/test_bmi_cpp.hpp @@ -41,62 +41,62 @@ class TestBmiCpp : public bmi::Bmi { set_usage(input_array, output_array, model_params); }; - virtual void Initialize(std::string config_file); - virtual void Update(); - virtual void UpdateUntil(double time); - virtual void Finalize(); + virtual void Initialize(std::string config_file) override; + virtual void Update() override; + virtual void UpdateUntil(double time) override; + virtual void Finalize() override; // Model information functions. - virtual std::string GetComponentName(); - virtual int GetInputItemCount(); - virtual int GetOutputItemCount(); - virtual std::vector GetInputVarNames(); - virtual std::vector GetOutputVarNames(); + virtual std::string GetComponentName() override; + virtual int GetInputItemCount() override; + virtual int GetOutputItemCount() override; + virtual std::vector GetInputVarNames() override; + virtual std::vector GetOutputVarNames() override; // Variable information functions - virtual int GetVarGrid(std::string name); - virtual std::string GetVarType(std::string name); - virtual std::string GetVarUnits(std::string name); - virtual int GetVarItemsize(std::string name); - virtual int GetVarNbytes(std::string name); - virtual std::string GetVarLocation(std::string name); - - virtual double GetCurrentTime(); - virtual double GetStartTime(); - virtual double GetEndTime(); - virtual std::string GetTimeUnits(); - virtual double GetTimeStep(); + virtual int GetVarGrid(std::string name) override; + virtual std::string GetVarType(std::string name) override; + virtual std::string GetVarUnits(std::string name) override; + virtual int GetVarItemsize(std::string name) override; + virtual int GetVarNbytes(std::string name) override; + virtual std::string GetVarLocation(std::string name) override; + + virtual double GetCurrentTime() override; + virtual double GetStartTime() override; + virtual double GetEndTime() override; + virtual std::string GetTimeUnits() override; + virtual double GetTimeStep() override; // Variable getters - virtual void GetValue(std::string name, void *dest); - virtual void *GetValuePtr(std::string name); - virtual void GetValueAtIndices(std::string name, void *dest, int *inds, int count); + virtual void GetValue(std::string name, void *dest) override; + virtual void *GetValuePtr(std::string name) override; + virtual void GetValueAtIndices(std::string name, void *dest, int *inds, int count) override; // Variable setters - virtual void SetValue(std::string name, void *src); - virtual void SetValueAtIndices(std::string name, int *inds, int count, void *src); + virtual void SetValue(std::string name, void *src) override; + virtual void SetValueAtIndices(std::string name, int *inds, int count, void *src) override; // Grid information functions - virtual int GetGridRank(const int grid); - virtual int GetGridSize(const int grid); - virtual std::string GetGridType(const int grid); - - virtual void GetGridShape(const int grid, int *shape); - virtual void GetGridSpacing(const int grid, double *spacing); - virtual void GetGridOrigin(const int grid, double *origin); - - virtual void GetGridX(int grid, double *x); - virtual void GetGridY(const int grid, double *y); - virtual void GetGridZ(const int grid, double *z); - - virtual int GetGridNodeCount(const int grid); - virtual int GetGridEdgeCount(const int grid); - virtual int GetGridFaceCount(const int grid); - - virtual void GetGridEdgeNodes(const int grid, int *edge_nodes); - virtual void GetGridFaceEdges(const int grid, int *face_edges); - virtual void GetGridFaceNodes(const int grid, int *face_nodes); - virtual void GetGridNodesPerFace(const int grid, int *nodes_per_face); + virtual int GetGridRank(const int grid) override; + virtual int GetGridSize(const int grid) override; + virtual std::string GetGridType(const int grid) override; + + virtual void GetGridShape(const int grid, int *shape) override; + virtual void GetGridSpacing(const int grid, double *spacing) override; + virtual void GetGridOrigin(const int grid, double *origin) override; + + virtual void GetGridX(int grid, double *x) override; + virtual void GetGridY(const int grid, double *y) override; + virtual void GetGridZ(const int grid, double *z) override; + + virtual int GetGridNodeCount(const int grid) override; + virtual int GetGridEdgeCount(const int grid) override; + virtual int GetGridFaceCount(const int grid) override; + + virtual void GetGridEdgeNodes(const int grid, int *edge_nodes) override; + virtual void GetGridFaceEdges(const int grid, int *face_edges) override; + virtual void GetGridFaceNodes(const int grid, int *face_nodes) override; + virtual void GetGridNodesPerFace(const int grid, int *nodes_per_face) override; From 9f2993dbd7e9d860b38a277f43196ab151608fbb Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Thu, 30 May 2024 16:50:46 -0700 Subject: [PATCH 4/8] Add omitted 'override' on HY_PointHydroNexus(Remote) methods from HY_HydroNexus interface --- include/core/nexus/HY_PointHydroNexus.hpp | 10 +++++----- include/core/nexus/HY_PointHydroNexusRemote.hpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/core/nexus/HY_PointHydroNexus.hpp b/include/core/nexus/HY_PointHydroNexus.hpp index c2abeca00d..3c227e9d02 100644 --- a/include/core/nexus/HY_PointHydroNexus.hpp +++ b/include/core/nexus/HY_PointHydroNexus.hpp @@ -14,19 +14,19 @@ class HY_PointHydroNexus : public HY_HydroNexus virtual ~HY_PointHydroNexus(); /** get the request percentage of downstream flow through this nexus at timestep t. */ - double get_downstream_flow(std::string catchment_id, time_step_t t, double percent_flow); + double get_downstream_flow(std::string catchment_id, time_step_t t, double percent_flow) override; /** add flow to this nexus for timestep t. */ - void add_upstream_flow(double val, std::string catchment_id, time_step_t t); + void add_upstream_flow(double val, std::string catchment_id, time_step_t t) override; /** inspect a nexus to see what flows are recorded at a time step. */ - std::pair inspect_upstream_flows(time_step_t t); + std::pair inspect_upstream_flows(time_step_t t) override; /** inspect a nexus to see what requests are recorded at a time step. */ - virtual std::pair inspect_downstream_requests(time_step_t t); + virtual std::pair inspect_downstream_requests(time_step_t t) override; /** get the units that flows are represented in. */ - std::string get_flow_units(); + std::string get_flow_units() override; void set_mintime(time_step_t); diff --git a/include/core/nexus/HY_PointHydroNexusRemote.hpp b/include/core/nexus/HY_PointHydroNexusRemote.hpp index 7cd7cc6b46..269c242c8d 100644 --- a/include/core/nexus/HY_PointHydroNexusRemote.hpp +++ b/include/core/nexus/HY_PointHydroNexusRemote.hpp @@ -36,10 +36,10 @@ class HY_PointHydroNexusRemote : public HY_PointHydroNexus /** get the request percentage of downstream flow through this nexus at timestep t. If the indicated catchment is not local a async send will be created. Will attempt to process all async receives currently queued before processing flows*/ - double get_downstream_flow(std::string catchment_id, time_step_t t, double percent_flow); + double get_downstream_flow(std::string catchment_id, time_step_t t, double percent_flow) override; /** add flow to this nexus for timestep t. If the indicated catchment is not local an async receive will be started*/ - void add_upstream_flow(double val, std::string catchment_id, time_step_t t); + void add_upstream_flow(double val, std::string catchment_id, time_step_t t) override; /** extract a numeric id from the catchment id for use as a mpi tag */ static long extract(std::string s) { return std::stoi( s.substr( s.find(hy_features::identifiers::seperator)+1 ) ); } From 2f0b8f5c2564a144c0fbd3dedefd865a1e3da877 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Thu, 30 May 2024 16:51:36 -0700 Subject: [PATCH 5/8] Add omitted 'override' on geojson test visit() methods --- test/geojson/FeatureCollection_Test.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/geojson/FeatureCollection_Test.cpp b/test/geojson/FeatureCollection_Test.cpp index 492340b29a..18684ac21c 100644 --- a/test/geojson/FeatureCollection_Test.cpp +++ b/test/geojson/FeatureCollection_Test.cpp @@ -27,31 +27,31 @@ class FeatureCollection_Test : public ::testing::Test { class Visitor : public geojson::FeatureVisitor { public: - void visit(geojson::PointFeature *feature) { + void visit(geojson::PointFeature *feature) override { this->types.push_back("PointFeature"); } - void visit(geojson::LineStringFeature *feature) { + void visit(geojson::LineStringFeature *feature) override { this->types.push_back("LineStringFeature"); } - void visit(geojson::PolygonFeature *feature) { + void visit(geojson::PolygonFeature *feature) override { this->types.push_back("PolygonFeature"); } - void visit(geojson::MultiPointFeature *feature) { + void visit(geojson::MultiPointFeature *feature) override { this->types.push_back("MultiPointFeature"); } - void visit(geojson::MultiLineStringFeature *feature) { + void visit(geojson::MultiLineStringFeature *feature) override { this->types.push_back("MultiLineStringFeature"); } - void visit(geojson::MultiPolygonFeature *feature) { + void visit(geojson::MultiPolygonFeature *feature) override { this->types.push_back("MultiPolygonFeature"); } - void visit(geojson::CollectionFeature *feature) { + void visit(geojson::CollectionFeature *feature) override { this->types.push_back("CollectionFeature"); } From 45ebc4dce194e608c29fd0d619be0c728f857953 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Thu, 30 May 2024 16:52:06 -0700 Subject: [PATCH 6/8] Add omitted 'override' on Network_Test2::SetUp() test fixture method --- test/core/NetworkTests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/NetworkTests.cpp b/test/core/NetworkTests.cpp index 2c6448ae9c..84f4d81976 100644 --- a/test/core/NetworkTests.cpp +++ b/test/core/NetworkTests.cpp @@ -133,7 +133,7 @@ class Network_Test1 : public Network_Test, public ::testing::TestWithParamadd_catchment("cat-0", "nex-0"); this->add_catchment("cat-1", "nex-0"); this->add_nexus("nex-0", "cat-2"); From b8d5d617870197c99ed64e70a75b054dcc95ca05 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Thu, 30 May 2024 17:29:44 -0700 Subject: [PATCH 7/8] Update SLoTH to add override to BMI methods --- extern/sloth | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/sloth b/extern/sloth index 006932f386..27350d8959 160000 --- a/extern/sloth +++ b/extern/sloth @@ -1 +1 @@ -Subproject commit 006932f386afc6c09cf4bd5c55f57ca3571080c6 +Subproject commit 27350d8959f9f51b5b0c5e5a8ef72a4e02529b97 From e44477a99f482380daca95e7399ecd076dbe9878 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Thu, 30 May 2024 17:32:57 -0700 Subject: [PATCH 8/8] Add -Wsuggest-override to CI compiler flags --- .github/actions/ngen-build/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/ngen-build/action.yaml b/.github/actions/ngen-build/action.yaml index 9920c64342..ae9a96383d 100644 --- a/.github/actions/ngen-build/action.yaml +++ b/.github/actions/ngen-build/action.yaml @@ -182,7 +182,7 @@ runs: run: | export BOOST_ROOT="$(pwd)/boost_1_79_0" export CFLAGS="-fsanitize=address -O1 -g -fno-omit-frame-pointer -Werror" - export CXXFLAGS="-fsanitize=address -O1 -g -fno-omit-frame-pointer -pedantic-errors -Werror -Wpessimizing-move -Wparentheses -Wrange-loop-construct" + export CXXFLAGS="-fsanitize=address -O1 -g -fno-omit-frame-pointer -pedantic-errors -Werror -Wpessimizing-move -Wparentheses -Wrange-loop-construct -Wsuggest-override" . .venv/bin/activate [ ! -d "$BOOST_ROOT" ] && echo "Error: no Boost root found at $BOOST_ROOT" && exit 1 cmake -B ${{ inputs.build-dir }} \