1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0025622: CAST analysis: Avoid invocation of virtual Methods of the declared Class in a Constructor or Destructor

The Delete() methods have been deleted from the following classes:
- Adaptor2d_Curve2d
- Adaptor3d_Curve
- Adaptor3d_Surface
- AppBlend_Approx
- AppCont_Function
- AppParCurves_MultiCurve
- AppParCurves_MultiPoint
- ApproxInt_SvSurfaces
- BRepPrim_OneAxis
- BRepSweep_NumLinearRegularSweep
- BRepSweep_Translation
- BRepSweep_Trsf
- DBC_BaseArray
- GeomFill_Profiler
- HatchGen_PointOnHatching
- math_BFGS
- math_FunctionSet
- math_FunctionSetRoot
- math_FunctionWithDerivative
- math_MultipleVarFunction
- math_MultipleVarFunctionWithHessian
- math_MultipleVarFunctionWithGradient
- math_Powell
- math_NewtonMinimum
- math_NewtonFunctionSetRoot
- math_BissecNewton (just add virtual destructor)
- math_FRPR
- math_BrentMinimum (just add virtual destructor)
- OSD_Chronometer
- ProjLib_Projector

Virtual methods Delete() or Destroy() of the transient inheritors is not changed (-> separate issue).
Classes Graphic3d_DataStructureManager and PrsMgr_Presentation without changes.
This commit is contained in:
azn
2014-12-18 10:27:01 +03:00
committed by bugmaster
parent e2b55410ff
commit 6da30ff153
63 changed files with 226 additions and 239 deletions

View File

@@ -43,9 +43,7 @@ is
-- function F.
returns BFGS;
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~math_BFGS(){Delete() ; }"
---C++: alias "Standard_EXPORT virtual ~math_BFGS();"
Perform(me: in out; F: in out MultipleVarFunctionWithGradient;
StartingPoint: Vector)

View File

@@ -281,8 +281,9 @@ void math_BFGS::Perform(math_MultipleVarFunctionWithGradient& F,
}
void math_BFGS::Delete()
{}
math_BFGS::~math_BFGS()
{
}
void math_BFGS::Dump(Standard_OStream& o) const {

View File

@@ -51,8 +51,9 @@ is
-- The maximum number of iterations allowed is given by NbIterations.
returns BissecNewton;
---C++: alias " Standard_EXPORT virtual ~math_BissecNewton();"
IsSolutionReached(me: in out; F: out FunctionWithDerivative)
---Purpose:
-- This method is called at the end of each iteration to check if the

View File

@@ -15,6 +15,9 @@
#include <math_BissecNewton.ixx>
#include <math_FunctionWithDerivative.hxx>
math_BissecNewton::~math_BissecNewton()
{
}
void math_BissecNewton::Perform(math_FunctionWithDerivative& F,
const Standard_Real Bound1,

View File

@@ -64,8 +64,9 @@ is
-- The maximum number of iterations allowed is given by NbIterations.
returns BrentMinimum;
---C++: alias " Standard_EXPORT virtual ~math_BrentMinimum();"
Perform(me: in out; F: in out Function;
Ax, Bx, Cx: Real)
---Purpose:
@@ -85,11 +86,11 @@ is
-- solution is found.
-- It can be redefined in a sub-class to implement a specific test to
-- stop the iterations.
returns Boolean
is virtual;
IsDone(me)
---Purpose: Returns true if the computations are successful, otherwise returns false.
---C++: inline

View File

@@ -23,6 +23,10 @@
#define SIGN(a,b) ((b) > 0.0 ? fabs(a) : -fabs(a))
#define SHFT(a,b,c,d) (a)=(b);(b)=(c);(c)=(d)
math_BrentMinimum::~math_BrentMinimum()
{
}
void math_BrentMinimum::Perform(math_Function& F,
const Standard_Real ax,
const Standard_Real bx,

View File

@@ -52,10 +52,8 @@ is
-- initialization to compute the minimum of the function.
returns FRPR;
---C++: alias " Standard_EXPORT virtual ~math_FRPR();"
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~math_FRPR(){Delete();}"
Perform(me: in out; F: in out MultipleVarFunctionWithGradient;
StartingPoint: Vector)
---Purpose: Use this method after a call to the initialization constructor

View File

@@ -216,8 +216,9 @@ void math_FRPR::Perform(math_MultipleVarFunctionWithGradient& F,
}
void math_FRPR::Delete()
{}
math_FRPR::~math_FRPR()
{
}
void math_FRPR::Dump(Standard_OStream& o) const {

View File

@@ -22,10 +22,6 @@ deferred class FunctionSet from math
uses Vector from math
is
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~math_FunctionSet(){Delete();}"
NbVariables(me)
---Purpose: Returns the number of variables of the function.
@@ -46,8 +42,7 @@ is
-- returns True if the computation was done successfully,
-- False otherwise.
returns Boolean
is deferred;
returns Boolean is deferred;
GetStateNumber(me: in out)
@@ -66,8 +61,9 @@ is
-- to save the current state of the function and to return
-- an Integer that allows retrieval of the state.
returns Integer
is virtual;
returns Integer is virtual;
---C++: alias " Standard_EXPORT virtual ~math_FunctionSet();"
end FunctionSet;

View File

@@ -15,7 +15,19 @@
#include <Standard_Integer.hxx>
#include <math_FunctionSet.ixx>
Standard_Integer math_FunctionSet::GetStateNumber() { return 0; }
//=======================================================================
//function : ~math_FunctionSet
//purpose : Destructor
//=======================================================================
math_FunctionSet::~math_FunctionSet()
{
}
void math_FunctionSet::Delete()
{}
//=======================================================================
//function : GetStateNumber
//purpose :
//=======================================================================
Standard_Integer math_FunctionSet::GetStateNumber()
{
return 0;
}

View File

@@ -85,11 +85,8 @@ is
returns FunctionSetRoot from math;
---C++: alias " Standard_EXPORT virtual ~math_FunctionSetRoot();"
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~math_FunctionSetRoot(){Delete();}"
SetTolerance(me: in out; Tolerance: Vector)
---Purpose: Initializes the tolerance values.
@@ -107,7 +104,7 @@ is
-- not performed by the constructors.
is static;
IsSolutionReached(me: in out; F: in out FunctionSetWithDerivatives)
---Purpose: This routine is called at the end of each iteration

View File

@@ -689,8 +689,9 @@ DF(1, F.NbEquations(),
Perform(F, StartingPoint, InfBound, SupBound);
}
void math_FunctionSetRoot::Delete()
{}
math_FunctionSetRoot::~math_FunctionSetRoot()
{
}
void math_FunctionSetRoot::SetTolerance(const math_Vector& Tolerance)
{

View File

@@ -23,17 +23,12 @@ deferred class FunctionWithDerivative from math
inherits Function
is
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~math_FunctionWithDerivative(){Delete();}"
Value(me: in out; X: Real; F: out Real)
---Purpose: Computes the value <F>of the function for the variable <X>.
-- Returns True if the calculation were successfully done,
-- False otherwise.
returns Boolean
is deferred;
returns Boolean is deferred;
Derivative(me: in out; X: Real; D: out Real)
---Purpose: Computes the derivative <D> of the function
@@ -41,8 +36,7 @@ is
-- Returns True if the calculation were successfully done,
-- False otherwise.
returns Boolean
is deferred;
returns Boolean is deferred;
Values(me: in out; X: Real; F, D: out Real)
---Purpose: Computes the value <F> and the derivative <D> of the
@@ -50,7 +44,8 @@ is
-- Returns True if the calculation were successfully done,
-- False otherwise.
returns Boolean
is deferred;
returns Boolean is deferred;
---C++: alias " Standard_EXPORT virtual ~math_FunctionWithDerivative();"
end FunctionWithDerivative;

View File

@@ -14,5 +14,10 @@
#include <math_FunctionWithDerivative.ixx>
void math_FunctionWithDerivative::Delete()
{}
//=======================================================================
//function : ~math_FunctionWithDerivative
//purpose : Destructor
//=======================================================================
math_FunctionWithDerivative::~math_FunctionWithDerivative()
{
}

View File

@@ -20,9 +20,6 @@ deferred class MultipleVarFunction from math
uses Vector from math
is
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~math_MultipleVarFunction(){Delete();}"
NbVariables(me)
---Purpose:
-- Returns the number of variables of the function
@@ -60,4 +57,6 @@ is
returns Integer
is virtual;
---C++: alias " Standard_EXPORT virtual ~math_MultipleVarFunction();"
end MultipleVarFunction;

View File

@@ -15,7 +15,19 @@
#include <Standard_Integer.hxx>
#include <math_MultipleVarFunction.ixx>
Standard_Integer math_MultipleVarFunction::GetStateNumber() { return 0; }
//=======================================================================
//function : ~math_MultipleVarFunction
//purpose : Destructor
//=======================================================================
math_MultipleVarFunction::~math_MultipleVarFunction()
{
}
void math_MultipleVarFunction::Delete()
{}
//=======================================================================
//function : GetStateNumber
//purpose :
//=======================================================================
Standard_Integer math_MultipleVarFunction::GetStateNumber()
{
return 0;
}

View File

@@ -23,15 +23,10 @@ inherits MultipleVarFunction
uses Vector from math
is
Delete(me:out) is redefined virtual;
---C++: alias "Standard_EXPORT virtual ~math_MultipleVarFunctionWithGradient(){Delete();}"
NbVariables(me)
---Purpose: Returns the number of variables of the function.
returns Integer
is deferred;
returns Integer is deferred;
Value(me: in out; X: Vector; F: out Real)
@@ -39,8 +34,7 @@ is
-- Returns True if the computation was done successfully,
-- False otherwise.
returns Boolean
is deferred;
returns Boolean is deferred;
Gradient(me: in out; X: Vector; G: out Vector)
@@ -48,8 +42,7 @@ is
-- Returns True if the computation was done successfully,
-- False otherwise.
returns Boolean
is deferred;
returns Boolean is deferred;
Values(me: in out; X: Vector; F: out Real; G: out Vector)
@@ -58,7 +51,6 @@ is
-- Returns True if the computation was done successfully,
-- False otherwise.
returns Boolean
is deferred;
returns Boolean is deferred;
end MultipleVarFunctionWithGradient;

View File

@@ -1,18 +0,0 @@
// Copyright (c) 1997-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <math_MultipleVarFunctionWithGradient.ixx>
void math_MultipleVarFunctionWithGradient::Delete()
{}

View File

@@ -23,15 +23,10 @@ uses Matrix from math,
Vector from math
is
Delete(me:out) is redefined virtual;
---C++: alias "Standard_EXPORT virtual ~math_MultipleVarFunctionWithHessian(){Delete();}"
NbVariables(me)
---Purpose: returns the number of variables of the function.
returns Integer
is deferred;
returns Integer is deferred;
Value(me: in out; X: Vector; F: out Real)
@@ -40,8 +35,7 @@ is
-- Returns True if the computation was done successfully,
-- False otherwise.
returns Boolean
is deferred;
returns Boolean is deferred;
Gradient(me: in out; X: Vector; G: out Vector)
@@ -50,8 +44,7 @@ is
-- Returns True if the computation was done successfully,
-- False otherwise.
returns Boolean
is deferred;
returns Boolean is deferred;
Values(me: in out; X: Vector; F: out Real; G: out Vector)
@@ -60,8 +53,7 @@ is
-- Returns True if the computation was done successfully,
-- False otherwise.
returns Boolean
is deferred;
returns Boolean is deferred;
Values(me: in out; X: Vector; F: out Real; G: out Vector; H: out Matrix)
---Purpose: computes the value <F>, the gradient <G> and the
@@ -69,8 +61,6 @@ is
-- Returns True if the computation was done
-- successfully, False otherwise.
returns Boolean
is deferred;
returns Boolean is deferred;
end MultipleVarFunctionWithHessian;

View File

@@ -1,20 +0,0 @@
// Created on: 1996-05-03
// Created by: Philippe MANGIN
// Copyright (c) 1996-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <math_MultipleVarFunctionWithHessian.ixx>
void math_MultipleVarFunctionWithHessian::Delete()
{}

View File

@@ -88,8 +88,7 @@ is
returns NewtonFunctionSetRoot;
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~math_NewtonFunctionSetRoot(){Delete();}"
---C++: alias " Standard_EXPORT virtual ~math_NewtonFunctionSetRoot();"
SetTolerance(me: in out; XTol: Vector)
---Purpose: Initializes the tolerance values for the unknowns.

View File

@@ -130,8 +130,9 @@ math_NewtonFunctionSetRoot::math_NewtonFunctionSetRoot
Perform(F, StartingPoint, InfBound, SupBound);
}
void math_NewtonFunctionSetRoot::Delete()
{}
math_NewtonFunctionSetRoot::~math_NewtonFunctionSetRoot()
{
}
void math_NewtonFunctionSetRoot::SetTolerance
(const math_Vector& XTol)

View File

@@ -60,8 +60,7 @@ is
-- Warning: This constructor do not computation
returns NewtonMinimum;
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~math_NewtonMinimum(){Delete();}"
---C++: alias " Standard_EXPORT virtual ~math_NewtonMinimum();"
Perform(me: in out; F: in out MultipleVarFunctionWithHessian;
StartingPoint: Vector)

View File

@@ -69,8 +69,10 @@ math_NewtonMinimum::math_NewtonMinimum(math_MultipleVarFunctionWithHessian& F,
TheStatus = math_NotBracketed;
}
//============================================================================
void math_NewtonMinimum::Delete()
{}
math_NewtonMinimum::~math_NewtonMinimum()
{
}
//============================================================================
void math_NewtonMinimum::Perform(math_MultipleVarFunctionWithHessian& F,
const math_Vector& StartingPoint)

View File

@@ -48,10 +48,8 @@ is
-- of this class.
returns Powell;
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~math_Powell(){Delete();}"
---C++: alias " Standard_EXPORT virtual ~math_Powell();"
Perform(me: in out;F: in out MultipleVarFunction;
StartingPoint: Vector;

View File

@@ -104,7 +104,9 @@ static Standard_Boolean MinimizeDirection(math_Vector& P,
return Standard_False;
}
math_Powell::~math_Powell()
{
}
void math_Powell::Perform(math_MultipleVarFunction& F,
const math_Vector& StartingPoint,
@@ -231,10 +233,7 @@ math_Powell::math_Powell(math_MultipleVarFunction& F,
XTol = Tolerance;
EPSZ = ZEPS;
Itermax = NbIterations;
}
void math_Powell::Delete()
{}
}
void math_Powell::Dump(Standard_OStream& o) const {