Skip to content

Commit

Permalink
chore: Fix warnings from -Wsuggest-override (#827)
Browse files Browse the repository at this point in the history
* Add omitted 'override' on  various exceptions' what() methods

* Add omitted 'override' on geojson Feature class visit() methods

* Add omitted 'override' on test_bmi_cpp BMI methods

* Add omitted 'override' on HY_PointHydroNexus(Remote) methods from HY_HydroNexus interface

* Add omitted 'override' on geojson test visit() methods

* Add omitted 'override' on Network_Test2::SetUp() test fixture method

* Update SLoTH to add override to BMI methods

* Add -Wsuggest-override to CI compiler flags
  • Loading branch information
PhilMiller authored Jun 3, 2024
1 parent 94ce654 commit 9abd2d3
Show file tree
Hide file tree
Showing 18 changed files with 84 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/actions/ngen-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }} \
Expand Down
2 changes: 1 addition & 1 deletion extern/sloth
Submodule sloth updated 1 files
+46 −48 include/sloth.hpp
92 changes: 46 additions & 46 deletions extern/test_bmi_cpp/include/test_bmi_cpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> GetInputVarNames();
virtual std::vector<std::string> GetOutputVarNames();
virtual std::string GetComponentName() override;
virtual int GetInputItemCount() override;
virtual int GetOutputItemCount() override;
virtual std::vector<std::string> GetInputVarNames() override;
virtual std::vector<std::string> 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;



Expand Down
2 changes: 1 addition & 1 deletion include/bmi/State_Exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
10 changes: 5 additions & 5 deletions include/core/nexus/HY_PointHydroNexus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double, int> inspect_upstream_flows(time_step_t t);
std::pair<double, int> inspect_upstream_flows(time_step_t t) override;

/** inspect a nexus to see what requests are recorded at a time step. */
virtual std::pair<double, int> inspect_downstream_requests(time_step_t t);
virtual std::pair<double, int> 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);

Expand Down
4 changes: 2 additions & 2 deletions include/core/nexus/HY_PointHydroNexusRemote.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ); }
Expand Down
2 changes: 1 addition & 1 deletion include/geojson/features/CollectionFeature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ namespace geojson {
return this->geometry_collection.cend();
}

void visit(FeatureVisitor& visitor) {
void visit(FeatureVisitor& visitor) override {
visitor.visit(this);
}
};
Expand Down
4 changes: 2 additions & 2 deletions include/geojson/features/LineStringFeature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ namespace geojson {
return boost::get<linestring_t>(this->geom);
}

void visit(FeatureVisitor& visitor) {
void visit(FeatureVisitor& visitor) override {
visitor.visit(this);
}
};
}

#endif // GEOJSON_LINESTRING_FEATURE_H
#endif // GEOJSON_LINESTRING_FEATURE_H
4 changes: 2 additions & 2 deletions include/geojson/features/MultiLineStringFeature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ namespace geojson {
return boost::get<multilinestring_t>(this->geom);
}

void visit(FeatureVisitor& visitor) {
void visit(FeatureVisitor& visitor) override {
visitor.visit(this);
}
};
}

#endif // GEOJSON_MULTILINESTRING_FEATURE_H
#endif // GEOJSON_MULTILINESTRING_FEATURE_H
4 changes: 2 additions & 2 deletions include/geojson/features/MultiPointFeature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ namespace geojson {
return boost::get<multipoint_t>(this->geom);
}

void visit(FeatureVisitor& visitor) {
void visit(FeatureVisitor& visitor) override {
visitor.visit(this);
}
};
}

#endif // GEOJSON_MULTIPOINT_FEATURE_H
#endif // GEOJSON_MULTIPOINT_FEATURE_H
4 changes: 2 additions & 2 deletions include/geojson/features/MultiPolygonFeature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ namespace geojson {
return boost::get<multipolygon_t>(this->geom);
}

void visit(FeatureVisitor& visitor) {
void visit(FeatureVisitor& visitor) override {
visitor.visit(this);
}
};
}

#endif // GEOJSON_MULTIPOLYGON_FEATURE_H
#endif // GEOJSON_MULTIPOLYGON_FEATURE_H
4 changes: 2 additions & 2 deletions include/geojson/features/PointFeature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ namespace geojson {
return boost::get<coordinate_t>(this->geom);
}

void visit(FeatureVisitor& visitor) {
void visit(FeatureVisitor& visitor) override {
visitor.visit(this);
}
};
}

#endif // GEOJSON_POINT_FEATURE_H
#endif // GEOJSON_POINT_FEATURE_H
4 changes: 2 additions & 2 deletions include/geojson/features/PolygonFeature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
#endif // GEOJSON_POLYGON_FEATURE_H
2 changes: 1 addition & 1 deletion include/utilities/ConfigurationException.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion include/utilities/ExternalIntegrationException.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
10 changes: 5 additions & 5 deletions src/core/nexus/HY_PointHydroNexus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ typedef boost::error_info<struct tag_errmsg, std::string> 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()
Expand Down
2 changes: 1 addition & 1 deletion test/core/NetworkTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Network_Test1 : public Network_Test, public ::testing::TestWithParam<Test
class Network_Test2 : public Network_Test, public ::testing::Test{
public:
Network_Test2(){}
void SetUp(){
void SetUp() override {
this->add_catchment("cat-0", "nex-0");
this->add_catchment("cat-1", "nex-0");
this->add_nexus("nex-0", "cat-2");
Expand Down
14 changes: 7 additions & 7 deletions test/geojson/FeatureCollection_Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down

0 comments on commit 9abd2d3

Please sign in to comment.