From afe039864bd3cc34948344cd141544cad5e85e4e Mon Sep 17 00:00:00 2001 From: Christina Tempelaar-Lietz Date: Mon, 7 Oct 2019 17:06:16 -0700 Subject: [PATCH] Explicitly define destructors. Suppress SonarCloud bug reports for array index operators. Signed-off-by: Christina Tempelaar-Lietz --- IlmBase/Imath/ImathEuler.h | 10 ++++++++-- IlmBase/Imath/ImathMatrix.h | 11 +++++++++++ IlmBase/Imath/ImathQuat.h | 19 ++++++++++++++++++- IlmBase/Imath/ImathShear.h | 9 +++++++-- IlmBase/Imath/ImathVec.h | 27 +++++++++++++++++++++------ 5 files changed, 65 insertions(+), 11 deletions(-) diff --git a/IlmBase/Imath/ImathEuler.h b/IlmBase/Imath/ImathEuler.h index 6b2b39e6..9a5d0dd4 100644 --- a/IlmBase/Imath/ImathEuler.h +++ b/IlmBase/Imath/ImathEuler.h @@ -226,6 +226,12 @@ class Euler : public Vec3 Euler(const Matrix33 &, Order o = Default); Euler(const Matrix44 &, Order o = Default); + //------------- + // Destructor + //------------- + + ~Euler() = default; + //--------------------------------- // Algebraic functions/ Operators //--------------------------------- @@ -746,14 +752,14 @@ Quat Euler::toQuat() const if ( _initialRepeated ) { a[i] = cj*(cs + sc); - a[j] = sj*(cc + ss) * parity, + a[j] = sj*(cc + ss) * parity, // NOSONAR - suppress SonarCloud bug report. a[k] = sj*(cs - sc); q.r = cj*(cc - ss); } else { a[i] = cj*sc - sj*cs, - a[j] = (cj*ss + sj*cc) * parity, + a[j] = (cj*ss + sj*cc) * parity, // NOSONAR - suppress SonarCloud bug report. a[k] = cj*cs - sj*sc; q.r = cj*cc + sj*ss; } diff --git a/IlmBase/Imath/ImathMatrix.h b/IlmBase/Imath/ImathMatrix.h index 5729c734..85dd12d6 100644 --- a/IlmBase/Imath/ImathMatrix.h +++ b/IlmBase/Imath/ImathMatrix.h @@ -119,6 +119,12 @@ template class Matrix33 const Matrix33 & operator = (T a); + //------------ + // Destructor + //------------ + + ~Matrix33 () = default; + //---------------------- // Compatibility with Sb //---------------------- @@ -474,6 +480,11 @@ template class Matrix44 // r r r 0 // t t t 1 + //------------ + // Destructor + //------------ + + ~Matrix44 () = default; //-------------------------------- // Copy constructor and assignment diff --git a/IlmBase/Imath/ImathQuat.h b/IlmBase/Imath/ImathQuat.h index e95e356d..d2fe0c20 100644 --- a/IlmBase/Imath/ImathQuat.h +++ b/IlmBase/Imath/ImathQuat.h @@ -78,7 +78,7 @@ class Quat //----------------------------------------------------- - // Constructors - default constructor is identity quat + // Constructors - default constructor is identity quat //----------------------------------------------------- Quat (); @@ -92,6 +92,17 @@ class Quat static Quat identity (); + //------------------- + // Copy constructor + //------------------- + + Quat (const Quat &q); + + //------------- + // Destructor + //------------- + + ~Quat () = default; //------------------------------------------------- // Basic Algebra - Operators and Methods @@ -258,6 +269,12 @@ Quat::Quat (T s, Vec3 d): r (s), v (d) // empty } +template +inline +Quat::Quat(const Quat &q) +{ + operator=(q); +} template inline Quat diff --git a/IlmBase/Imath/ImathShear.h b/IlmBase/Imath/ImathShear.h index b6f7b9a9..c6d8e85a 100644 --- a/IlmBase/Imath/ImathShear.h +++ b/IlmBase/Imath/ImathShear.h @@ -91,6 +91,11 @@ template class Shear6 template const Shear6 & operator = (const Vec3 &v); + //------------ + // Destructor + //------------ + + ~Shear6() = default; //---------------------- // Compatibility with Sb @@ -251,14 +256,14 @@ template inline T & Shear6::operator [] (int i) { - return (&xy)[i]; + return (&xy)[i]; // NOSONAR - suppress SonarCloud bug report. } template inline const T & Shear6::operator [] (int i) const { - return (&xy)[i]; + return (&xy)[i]; // NOSONAR - suppress SonarCloud bug report. } template diff --git a/IlmBase/Imath/ImathVec.h b/IlmBase/Imath/ImathVec.h index 6f4e82a3..1576a365 100644 --- a/IlmBase/Imath/ImathVec.h +++ b/IlmBase/Imath/ImathVec.h @@ -98,6 +98,11 @@ template class Vec2 const Vec2 & operator = (const Vec2 &v); + //------------ + // Destructor + //------------ + + ~Vec2 () = default; //---------------------- // Compatibility with Sb @@ -296,6 +301,11 @@ template class Vec3 const Vec3 & operator = (const Vec3 &v); + //----------- + // Destructor + //----------- + + ~Vec3 () = default; //--------------------------------------------------------- // Vec4 to Vec3 conversion, divides x, y and z by w: @@ -509,6 +519,11 @@ template class Vec4 const Vec4 & operator = (const Vec4 &v); + //----------- + // Destructor + //----------- + + ~Vec4 () = default; //------------------------------------- // Vec3 to Vec4 conversion, sets w to 1 @@ -853,14 +868,14 @@ template inline T & Vec2::operator [] (int i) { - return (&x)[i]; + return (&x)[i]; // NOSONAR - suppress SonarCloud bug report. } template inline const T & Vec2::operator [] (int i) const { - return (&x)[i]; + return (&x)[i]; // NOSONAR - suppress SonarCloud bug report. } template @@ -1274,14 +1289,14 @@ template inline T & Vec3::operator [] (int i) { - return (&x)[i]; + return (&x)[i]; // NOSONAR - suppress SonarCloud bug report. } template inline const T & Vec3::operator [] (int i) const { - return (&x)[i]; + return (&x)[i]; // NOSONAR - suppress SonarCloud bug report. } template @@ -1768,14 +1783,14 @@ template inline T & Vec4::operator [] (int i) { - return (&x)[i]; + return (&x)[i]; // NOSONAR - suppress SonarCloud bug report. } template inline const T & Vec4::operator [] (int i) const { - return (&x)[i]; + return (&x)[i]; // NOSONAR - suppress SonarCloud bug report. } template