Commit 3de2b346 authored by Manuel Grizonnet's avatar Manuel Grizonnet
Browse files

ENH: Explicitly recognize virtual functions

    clang-tidy tool can insert missing override keyword as a macro so that missing [optional] virtual identifiers can be easily added.

    build otb with clang 3.8 and use cmake option CMAKE_EXPORT_COMPILE_COMMANDS=ON. Most modules and third parties have been activated.

    #Save override occurences in otb code
    cd src/Modules ; grep -nR "override" * > ~/temporary/override_otb.txt

    #Run clang modernize check using utility script which allow to process the code in parallel
    python run-clang-tidy.py -clang-tidy-binary ~/software/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/bin/clang-tidy -checks=-*,modernize-use-override -header-filter=/home/grizonnetm/projets/otb/src/OTB/Modules/.*/.*/include/.* -j8 -fix -p ~/projets/otb/bin/release/OTB-clang3.8/ ~/projets/otb/src/OTB/Modules/*/*/src/*.cxx ~/projets/otb/src/OTB/Examples/*/*.cxx ~/projets/otb/src/OTB/Modules/*/*/test/*.cxx > ~/temporary/run-clang-tidy-log.txt

    #Replace override by ITK macro (to maintain compat with c++98)
    find . -type f -print -name "*.h" -o -name "*.txx" |xargs perl -pi -e 's/\ override/\ ITK_OVERRIDE/g'
parent a0f2bdc1
......@@ -97,7 +97,7 @@ private:
// \code{DoInit()} method contains class information and description, parameter set up, and example values.
// Software Guide : EndLatex
void DoInit()
void DoInit() override
{
// Software Guide : BeginLatex
......@@ -228,7 +228,7 @@ private:
// gives a complete description of this method.
// Software Guide : EndLatex
// Software Guide :BeginCodeSnippet
void DoUpdateParameters()
void DoUpdateParameters() override
{
}
// Software Guide : EndCodeSnippet
......@@ -238,7 +238,7 @@ private:
// gives a complete description of this method.
// Software Guide : EndLatex
// Software Guide :BeginCodeSnippet
void DoExecute()
void DoExecute() override
{
FloatVectorImageType::Pointer inImage = GetParameterImage("in");
......
......@@ -138,7 +138,7 @@ public:
protected:
MyChangeDetectorImageFilter() {}
virtual ~MyChangeDetectorImageFilter() {}
~MyChangeDetectorImageFilter() override {}
private:
MyChangeDetectorImageFilter(const Self &); //purposely not implemented
......
......@@ -93,7 +93,7 @@ public:
itkTypeMacro(CompositeExampleImageFilter, itk::ImageToImageFilter);
/** Display */
void PrintSelf(std::ostream& os, itk::Indent indent) const;
void PrintSelf(std::ostream& os, itk::Indent indent) const override;
// Software Guide : BeginLatex
//
......@@ -132,7 +132,7 @@ protected:
RescalerType;
// Software Guide : EndCodeSnippet
void GenerateData();
void GenerateData() override;
private:
......
......@@ -99,11 +99,11 @@ protected:
/** Default constructor. */
MyReprojectionFilter(){ }
/** Destructor. */
virtual ~MyReprojectionFilter(){ }
~MyReprojectionFilter() override{ }
private:
virtual OGRSpatialReference* DoDefineNewLayerSpatialReference(otb::ogr::Layer const& itkNotUsed(source)) const
OGRSpatialReference* DoDefineNewLayerSpatialReference(otb::ogr::Layer const& itkNotUsed(source)) const override
{
return m_osr.get();
}
......
......@@ -78,12 +78,12 @@ public:
typedef itk::RegularStepGradientDescentOptimizer OptimizerType;
typedef const OptimizerType * OptimizerPointer;
void Execute(itk::Object *caller, const itk::EventObject& event)
void Execute(itk::Object *caller, const itk::EventObject& event) override
{
Execute((const itk::Object *) caller, event);
}
void Execute(const itk::Object * object, const itk::EventObject& event)
void Execute(const itk::Object * object, const itk::EventObject& event) override
{
OptimizerPointer optimizer =
dynamic_cast<OptimizerPointer>(object);
......
......@@ -97,12 +97,12 @@ public:
typedef itk::GradientDescentOptimizer OptimizerType;
typedef const OptimizerType * OptimizerPointer;
void Execute(itk::Object *caller, const itk::EventObject& event)
void Execute(itk::Object *caller, const itk::EventObject& event) override
{
Execute((const itk::Object *) caller, event);
}
void Execute(const itk::Object * object, const itk::EventObject& event)
void Execute(const itk::Object * object, const itk::EventObject& event) override
{
OptimizerPointer optimizer =
dynamic_cast<OptimizerPointer>(object);
......
......@@ -92,12 +92,12 @@ public:
typedef itk::RegularStepGradientDescentOptimizer OptimizerType;
typedef const OptimizerType * OptimizerPointer;
void Execute(itk::Object *caller, const itk::EventObject& event)
void Execute(itk::Object *caller, const itk::EventObject& event) override
{
Execute((const itk::Object *) caller, event);
}
void Execute(const itk::Object * object, const itk::EventObject& event)
void Execute(const itk::Object * object, const itk::EventObject& event) override
{
OptimizerPointer optimizer =
dynamic_cast<OptimizerPointer>(object);
......
......@@ -87,12 +87,12 @@ public:
typedef itk::RegularStepGradientDescentOptimizer OptimizerType;
typedef const OptimizerType * OptimizerPointer;
void Execute(itk::Object *caller, const itk::EventObject& event)
void Execute(itk::Object *caller, const itk::EventObject& event) override
{
Execute((const itk::Object *) caller, event);
}
void Execute(const itk::Object * object, const itk::EventObject& event)
void Execute(const itk::Object * object, const itk::EventObject& event) override
{
OptimizerPointer optimizer =
dynamic_cast<OptimizerPointer>(object);
......
......@@ -132,10 +132,10 @@ protected:
{
m_Image = NULL;
}
virtual ~ImageUniqueValuesCalculator()
~ImageUniqueValuesCalculator() override
{
}
void PrintSelf(std::ostream& os, itk::Indent indent) const
void PrintSelf(std::ostream& os, itk::Indent indent) const override
{
Superclass::PrintSelf(os, indent);
os << indent << "Image: " << m_Image.GetPointer() << std::endl;
......@@ -449,9 +449,9 @@ public:
protected:
TernaryFunctorImageFilterWithNBands() {}
virtual ~TernaryFunctorImageFilterWithNBands() {}
~TernaryFunctorImageFilterWithNBands() override {}
void GenerateOutputInformation()
void GenerateOutputInformation() override
{
Superclass::GenerateOutputInformation();
this->GetOutput()->SetNumberOfComponentsPerPixel( m_NumberOfOutputBands );
......
......@@ -45,19 +45,19 @@ public:
itkTypeMacro(CurlHelper, CurlHelperInterface);
itkNewMacro(Self);
bool TestUrlAvailability(const std::string& url) const;
bool TestUrlAvailability(const std::string& url) const ITK_OVERRIDE;
bool IsCurlReturnHttpError(const std::string& url) const;
int RetrieveFile(const std::ostringstream& urlStream, std::string filename) const;
int RetrieveFile(const std::ostringstream& urlStream, std::string filename) const ITK_OVERRIDE;
int RetrieveFile(const std::string& urlString, std::string filename) const;
int RetrieveFile(const std::string& urlString, std::string filename) const ITK_OVERRIDE;
int RetrieveUrlInMemory(const std::string& urlString, std::string& output) const;
int RetrieveUrlInMemory(const std::string& urlString, std::string& output) const ITK_OVERRIDE;
int RetrieveFileMulti(const std::vector<std::string>& listURLs,
const std::vector<std::string>& listFiles,
int maxConnect) const;
int maxConnect) const ITK_OVERRIDE;
itkGetMacro(Timeout,long int);
......@@ -68,7 +68,7 @@ protected:
m_Browser("Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.8.1.11) "
"Gecko/20071127 Firefox/2.0.0.11"),
m_Timeout(10) {}
virtual ~CurlHelper() {}
~CurlHelper() ITK_OVERRIDE {}
private:
CurlHelper(const Self &); //purposely not implemented
......
......@@ -62,7 +62,7 @@ public:
protected:
CurlHelperInterface() {}
virtual ~CurlHelperInterface() {}
~CurlHelperInterface() ITK_OVERRIDE {}
private:
CurlHelperInterface(const Self &); //purposely not implemented
......
......@@ -44,20 +44,20 @@ public:
itkNewMacro(Self);
bool TestUrlAvailability(const std::string& url) const;
bool TestUrlAvailability(const std::string& url) const ITK_OVERRIDE;
int RetrieveUrlInMemory(const std::string& urlString, std::string& output) const;
int RetrieveUrlInMemory(const std::string& urlString, std::string& output) const ITK_OVERRIDE;
int RetrieveFile(const std::ostringstream& urlStream, std::string filename) const;
int RetrieveFile(const std::ostringstream& urlStream, std::string filename) const ITK_OVERRIDE;
int RetrieveFile(const std::string& urlString, std::string filename) const;
int RetrieveFile(const std::string& urlString, std::string filename) const ITK_OVERRIDE;
int RetrieveFileMulti(const std::vector<std::string>& listURLs,
const std::vector<std::string>& listFiles,
int maxConnect) const;
int maxConnect) const ITK_OVERRIDE;
protected:
CurlHelperStub() {}
virtual ~CurlHelperStub() {}
~CurlHelperStub() ITK_OVERRIDE {}
private:
CurlHelperStub(const Self &); //purposely not implemented
......
......@@ -91,7 +91,7 @@ protected:
}
}
virtual ~CurlResource()
~CurlResource() ITK_OVERRIDE
{
curl_easy_cleanup(m_Curl);
}
......@@ -137,7 +137,7 @@ protected:
}
}
virtual ~CurlMultiResource()
~CurlMultiResource() ITK_OVERRIDE
{
curl_multi_cleanup(m_Curl);
}
......@@ -184,7 +184,7 @@ public:
protected:
CurlFileDescriptorResource(){}
virtual ~CurlFileDescriptorResource()
~CurlFileDescriptorResource() ITK_OVERRIDE
{
fclose(m_File);
}
......
......@@ -156,10 +156,10 @@ protected:
GeometriesSet(ogr::Layer layer);
/** Destructor. */
virtual ~GeometriesSet();
~GeometriesSet() ITK_OVERRIDE;
/** Prints self to stream. */
void PrintSelf(std::ostream& os, itk::Indent indent) const;
void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
private:
typedef boost::variant<ogr::DataSource::Pointer, ogr::Layer> AnyGeometriesSetType;
AnyGeometriesSetType m_GeometriesSet;
......
......@@ -114,7 +114,7 @@ public:
* initializing them.
* \post <tt>GetOutput() != NULL</tt>
*/
virtual void PrepareOutputs();
void PrepareOutputs() ITK_OVERRIDE;
protected:
/** Default constructor.
......@@ -124,7 +124,7 @@ protected:
/** Destructor.
* Does nothing.
*/
virtual ~GeometriesSource();
~GeometriesSource() ITK_OVERRIDE;
/** Ensures that the output geometries are allocated before processing.
* If the output hasn't been set, at this point, the default output geometries
......
......@@ -86,13 +86,13 @@ protected:
/** Destructor.
* Does nothing.
*/
virtual ~GeometriesToGeometriesFilter();
~GeometriesToGeometriesFilter() ITK_OVERRIDE;
/** Processes the input to fill the output.
* This is the main processing function. It either works \em in-place or by
* \em copying the transformed input \c Feature s into the output.
*/
virtual void GenerateData(void);
void GenerateData(void) ITK_OVERRIDE;
private:
/** \e In-place processing function.
......@@ -358,7 +358,7 @@ protected:
/** Default constructor. */
DefaultGeometriesToGeometriesFilter();
/** Destructor. */
virtual ~DefaultGeometriesToGeometriesFilter();
~DefaultGeometriesToGeometriesFilter() ITK_OVERRIDE;
/**
* Hook that actually filters an OGR \c Layer.
......@@ -370,7 +370,7 @@ protected:
* \note When <tt>source == destination</tt>, it means this is an \em in-place
* filter.
*/
virtual void DoProcessLayer(ogr::Layer const& source, ogr::Layer & destination) const;
void DoProcessLayer(ogr::Layer const& source, ogr::Layer & destination) const ITK_OVERRIDE;
/**
* Hook used to define the fields of the new layer.
* \param[in] source source \c Layer -- for reference
......@@ -379,7 +379,7 @@ protected:
* Just forwards the fields definition to the \c FieldTransformationPolicy
* inherited from the \c TransformationFunctorDispatcherType.
*/
virtual void DoDefineNewLayerFields(ogr::Layer const& source, ogr::Layer & dest) const
void DoDefineNewLayerFields(ogr::Layer const& source, ogr::Layer & dest) const ITK_OVERRIDE
{
this->DefineFields(source, dest);
}
......
......@@ -286,7 +286,7 @@ public:
* meta information of another data source and use the same underlying \c
* GDALDataset.
*/
virtual void Graft(const itk::DataObject *data);
void Graft(const itk::DataObject *data) ITK_OVERRIDE;
/**
* Resets current data source with the one in parameter.
......@@ -510,12 +510,12 @@ protected:
/** Destructor.
* \post The \c GDALDataset owned is released (if not null).
*/
virtual ~DataSource();
~DataSource() ITK_OVERRIDE;
static Pointer OpenDataSource(std::string const& datasourceName, Modes::type mode);
/** Prints self into stream. */
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
private:
/**
......
......@@ -128,7 +128,7 @@ template
* <tt> = T</tt>)
*
* \internal
* This override is required because of the particular nature of the
* This ITK_OVERRIDE is required because of the particular nature of the
* <tt>char**</tt> type chosen by OGR API, plus the fact this is the only
* const-correct getter...
* \since OTB v 3.14.0
......@@ -258,7 +258,7 @@ template
* <tt> = T</tt>)
*
* \internal
* This override is required because of the particular nature of the
* This ITK_OVERRIDE is required because of the particular nature of the
* <tt>char**</tt> type chosen by OGR API.
* \since OTB v 3.14.0
*/
......
......@@ -44,7 +44,7 @@ public:
protected:
DEMConvertAdapter();
virtual ~DEMConvertAdapter();
~DEMConvertAdapter() ITK_OVERRIDE;
private:
DEMConvertAdapter(const Self &); //purposely not implemented
......
......@@ -165,9 +165,9 @@ public:
protected:
DEMHandler();
virtual ~DEMHandler() {}
~DEMHandler() ITK_OVERRIDE {}
void PrintSelf(std::ostream& os, itk::Indent indent) const;
void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
// Ossim does not allow retrieving the geoid file path
// We therefore must keep it on our side
......
......@@ -81,7 +81,7 @@ public:
protected:
DateTimeAdapter();
virtual ~DateTimeAdapter();
~DateTimeAdapter() ITK_OVERRIDE;
private:
DateTimeAdapter(const Self &); //purposely not implemented
......
......@@ -62,7 +62,7 @@ public:
protected:
EllipsoidAdapter();
virtual ~EllipsoidAdapter();
~EllipsoidAdapter() ITK_OVERRIDE;
private:
EllipsoidAdapter(const Self &); //purposely not implemented
......
......@@ -98,10 +98,10 @@ protected:
/** Constructor */
FilterFunctionValues();
/** Destructor */
~FilterFunctionValues() {}
~FilterFunctionValues() ITK_OVERRIDE {}
/** PrintSelf method */
void PrintSelf(std::ostream& os, itk::Indent indent) const;
void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
private:
FilterFunctionValues(const Self &); //purposely not implemented
......
......@@ -73,7 +73,7 @@ public:
protected:
GeometricSarSensorModelAdapter();
virtual ~GeometricSarSensorModelAdapter();
~GeometricSarSensorModelAdapter() ITK_OVERRIDE;
private:
GeometricSarSensorModelAdapter(const Self &); //purposely not implemented
......
......@@ -82,7 +82,7 @@ public:
protected:
MapProjectionAdapter();
virtual ~MapProjectionAdapter();
~MapProjectionAdapter() ITK_OVERRIDE;
private:
MapProjectionAdapter(const Self &); //purposely not implemented
......
......@@ -73,7 +73,7 @@ public:
protected:
PlatformPositionAdapter();
virtual ~PlatformPositionAdapter();
~PlatformPositionAdapter() ITK_OVERRIDE;
private:
PlatformPositionAdapter(const Self &); //purposely not implemented
......
......@@ -108,7 +108,7 @@ public:
protected:
SensorModelAdapter();
virtual ~SensorModelAdapter();
~SensorModelAdapter() ITK_OVERRIDE;
private:
SensorModelAdapter(const Self &); //purposely not implemented
......
......@@ -137,7 +137,7 @@ public:
// const char *GetOptionParameter(const char *option, unsigned int number = 0);
int GetNumberOfParameters(const std::string& option);
void PrintSelf(std::ostream& os, itk::Indent indent) const;
void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
#define otbGetParameterMacro(name, type) \
virtual type GetParameter ## name (const std::string& option, unsigned int number = 0) const \
......@@ -167,7 +167,7 @@ public:
protected:
CommandLineArgumentParseResult();
virtual ~CommandLineArgumentParseResult();
~CommandLineArgumentParseResult() ITK_OVERRIDE;
private:
template<typename TypeValeur>
......@@ -251,7 +251,7 @@ public:
protected:
CommandLineArgumentParser();
virtual ~CommandLineArgumentParser();
~CommandLineArgumentParser() ITK_OVERRIDE;
private:
......
......@@ -245,7 +245,7 @@ protected:
}
/** Destructor */
virtual ~ChannelSelectorFunctor() {}
~ChannelSelectorFunctor() ITK_OVERRIDE {}
private:
......
......@@ -45,9 +45,9 @@ protected:
public:
typedef const TFilter * FilterPointer;
void Execute(itk::Object *caller, const itk::EventObject& event);
void Execute(itk::Object *caller, const itk::EventObject& event) ITK_OVERRIDE;
void Execute(const itk::Object * object, const itk::EventObject& event);
void Execute(const itk::Object * object, const itk::EventObject& event) ITK_OVERRIDE;
};
} // end namespace otb
......
......@@ -96,7 +96,7 @@ public:
protected:
ComplexToIntensityImageFilter() {}
virtual ~ComplexToIntensityImageFilter() {}
~ComplexToIntensityImageFilter() ITK_OVERRIDE {}
private:
ComplexToIntensityImageFilter(const Self&); //purposely not implemented
......
......@@ -137,7 +137,7 @@ public:
protected:
ComplexToVectorImageCastFilter() {}
virtual ~ComplexToVectorImageCastFilter() {}
~ComplexToVectorImageCastFilter() ITK_OVERRIDE {}
template<class T>
bool PixelIsSingle(const T& /*dummy*/)
......@@ -151,7 +151,7 @@ protected:
return false;
}
void GenerateOutputInformation()
void GenerateOutputInformation() ITK_OVERRIDE
{
Superclass::GenerateOutputInformation();
InputPixelType dummy;
......
......@@ -137,9 +137,9 @@ public:
protected:
DotProductImageFilter();
virtual ~DotProductImageFilter() {}
~DotProductImageFilter() ITK_OVERRIDE {}
void PrintSelf(std::ostream& os, itk::Indent indent) const;
void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
private:
DotProductImageFilter(const Self &); //purpos