mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
clang-tidy: bugprone-virtual-near-miss
A few virtual functions are called by constructors or destructors, which is dangerous in C++ (as an overridden virtual impl won't be called, only the one in the current class). Fix by either marking the function final or not calling at all (if possible).
This commit is contained in:
@@ -51,7 +51,7 @@ class ADXL345_I2C : public ErrorBase,
|
||||
ADXL345_I2C& operator=(ADXL345_I2C&&) = default;
|
||||
|
||||
// Accelerometer interface
|
||||
void SetRange(Range range) override;
|
||||
void SetRange(Range range) final;
|
||||
double GetX() override;
|
||||
double GetY() override;
|
||||
double GetZ() override;
|
||||
|
||||
@@ -47,7 +47,7 @@ class ADXL345_SPI : public ErrorBase,
|
||||
ADXL345_SPI& operator=(ADXL345_SPI&&) = default;
|
||||
|
||||
// Accelerometer interface
|
||||
void SetRange(Range range) override;
|
||||
void SetRange(Range range) final;
|
||||
double GetX() override;
|
||||
double GetY() override;
|
||||
double GetZ() override;
|
||||
|
||||
@@ -55,7 +55,7 @@ class ADXL362 : public ErrorBase,
|
||||
ADXL362& operator=(ADXL362&&) = default;
|
||||
|
||||
// Accelerometer interface
|
||||
void SetRange(Range range) override;
|
||||
void SetRange(Range range) final;
|
||||
double GetX() override;
|
||||
double GetY() override;
|
||||
double GetZ() override;
|
||||
|
||||
@@ -87,7 +87,7 @@ class ADXRS450_Gyro : public GyroBase {
|
||||
* robot is first turned on while it's sitting at rest before the competition
|
||||
* starts.
|
||||
*/
|
||||
void Calibrate() override;
|
||||
void Calibrate() final;
|
||||
|
||||
/**
|
||||
* Get the SPI port number.
|
||||
|
||||
@@ -172,16 +172,16 @@ class AnalogGyro : public GyroBase {
|
||||
* significant drift in the gyro and it needs to be recalibrated after it has
|
||||
* been running.
|
||||
*/
|
||||
void Reset() override;
|
||||
void Reset() final;
|
||||
|
||||
/**
|
||||
* Initialize the gyro.
|
||||
*
|
||||
* Calibration is handled by Calibrate().
|
||||
*/
|
||||
virtual void InitGyro();
|
||||
void InitGyro();
|
||||
|
||||
void Calibrate() override;
|
||||
void Calibrate() final;
|
||||
|
||||
/**
|
||||
* Gets the analog input for the gyro.
|
||||
|
||||
@@ -45,7 +45,7 @@ class SimDeviceSim {
|
||||
});
|
||||
}
|
||||
|
||||
operator HAL_SimDeviceHandle() const { return m_handle; }
|
||||
operator HAL_SimDeviceHandle() const { return m_handle; } // NOLINT
|
||||
|
||||
template <typename F>
|
||||
static void EnumerateDevices(const char* prefix, F callback) {
|
||||
|
||||
Reference in New Issue
Block a user