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

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: ...@@ -97,7 +97,7 @@ private:
// \code{DoInit()} method contains class information and description, parameter set up, and example values. // \code{DoInit()} method contains class information and description, parameter set up, and example values.
// Software Guide : EndLatex // Software Guide : EndLatex
void DoInit() void DoInit() override
{ {
// Software Guide : BeginLatex // Software Guide : BeginLatex
...@@ -228,7 +228,7 @@ private: ...@@ -228,7 +228,7 @@ private:
// gives a complete description of this method. // gives a complete description of this method.
// Software Guide : EndLatex // Software Guide : EndLatex
// Software Guide :BeginCodeSnippet // Software Guide :BeginCodeSnippet
void DoUpdateParameters() void DoUpdateParameters() override
{ {
} }
// Software Guide : EndCodeSnippet // Software Guide : EndCodeSnippet
...@@ -238,7 +238,7 @@ private: ...@@ -238,7 +238,7 @@ private:
// gives a complete description of this method. // gives a complete description of this method.
// Software Guide : EndLatex // Software Guide : EndLatex
// Software Guide :BeginCodeSnippet // Software Guide :BeginCodeSnippet
void DoExecute() void DoExecute() override
{ {
FloatVectorImageType::Pointer inImage = GetParameterImage("in"); FloatVectorImageType::Pointer inImage = GetParameterImage("in");
......
...@@ -138,7 +138,7 @@ public: ...@@ -138,7 +138,7 @@ public:
protected: protected:
MyChangeDetectorImageFilter() {} MyChangeDetectorImageFilter() {}
virtual ~MyChangeDetectorImageFilter() {} ~MyChangeDetectorImageFilter() override {}
private: private:
MyChangeDetectorImageFilter(const Self &); //purposely not implemented MyChangeDetectorImageFilter(const Self &); //purposely not implemented
......
...@@ -93,7 +93,7 @@ public: ...@@ -93,7 +93,7 @@ public:
itkTypeMacro(CompositeExampleImageFilter, itk::ImageToImageFilter); itkTypeMacro(CompositeExampleImageFilter, itk::ImageToImageFilter);
/** Display */ /** Display */
void PrintSelf(std::ostream& os, itk::Indent indent) const; void PrintSelf(std::ostream& os, itk::Indent indent) const override;
// Software Guide : BeginLatex // Software Guide : BeginLatex
// //
...@@ -132,7 +132,7 @@ protected: ...@@ -132,7 +132,7 @@ protected:
RescalerType; RescalerType;
// Software Guide : EndCodeSnippet // Software Guide : EndCodeSnippet
void GenerateData(); void GenerateData() override;
private: private:
......
...@@ -99,11 +99,11 @@ protected: ...@@ -99,11 +99,11 @@ protected:
/** Default constructor. */ /** Default constructor. */
MyReprojectionFilter(){ } MyReprojectionFilter(){ }
/** Destructor. */ /** Destructor. */
virtual ~MyReprojectionFilter(){ } ~MyReprojectionFilter() override{ }
private: 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(); return m_osr.get();
} }
......
...@@ -78,12 +78,12 @@ public: ...@@ -78,12 +78,12 @@ public:
typedef itk::RegularStepGradientDescentOptimizer OptimizerType; typedef itk::RegularStepGradientDescentOptimizer OptimizerType;
typedef const OptimizerType * OptimizerPointer; 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); 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 = OptimizerPointer optimizer =
dynamic_cast<OptimizerPointer>(object); dynamic_cast<OptimizerPointer>(object);
......
...@@ -97,12 +97,12 @@ public: ...@@ -97,12 +97,12 @@ public:
typedef itk::GradientDescentOptimizer OptimizerType; typedef itk::GradientDescentOptimizer OptimizerType;
typedef const OptimizerType * OptimizerPointer; 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); 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 = OptimizerPointer optimizer =
dynamic_cast<OptimizerPointer>(object); dynamic_cast<OptimizerPointer>(object);
......
...@@ -92,12 +92,12 @@ public: ...@@ -92,12 +92,12 @@ public:
typedef itk::RegularStepGradientDescentOptimizer OptimizerType; typedef itk::RegularStepGradientDescentOptimizer OptimizerType;
typedef const OptimizerType * OptimizerPointer; 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); 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 = OptimizerPointer optimizer =
dynamic_cast<OptimizerPointer>(object); dynamic_cast<OptimizerPointer>(object);
......
...@@ -87,12 +87,12 @@ public: ...@@ -87,12 +87,12 @@ public:
typedef itk::RegularStepGradientDescentOptimizer OptimizerType; typedef itk::RegularStepGradientDescentOptimizer OptimizerType;
typedef const OptimizerType * OptimizerPointer; 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); 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 = OptimizerPointer optimizer =
dynamic_cast<OptimizerPointer>(object); dynamic_cast<OptimizerPointer>(object);
......
...@@ -132,10 +132,10 @@ protected: ...@@ -132,10 +132,10 @@ protected:
{ {
m_Image = NULL; 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); Superclass::PrintSelf(os, indent);
os << indent << "Image: " << m_Image.GetPointer() << std::endl; os << indent << "Image: " << m_Image.GetPointer() << std::endl;
...@@ -449,9 +449,9 @@ public: ...@@ -449,9 +449,9 @@ public:
protected: protected:
TernaryFunctorImageFilterWithNBands() {} TernaryFunctorImageFilterWithNBands() {}
virtual ~TernaryFunctorImageFilterWithNBands() {} ~TernaryFunctorImageFilterWithNBands() override {}
void GenerateOutputInformation() void GenerateOutputInformation() override
{ {
Superclass::GenerateOutputInformation(); Superclass::GenerateOutputInformation();
this->GetOutput()->SetNumberOfComponentsPerPixel( m_NumberOfOutputBands ); this->GetOutput()->SetNumberOfComponentsPerPixel( m_NumberOfOutputBands );
......
...@@ -45,19 +45,19 @@ public: ...@@ -45,19 +45,19 @@ public:
itkTypeMacro(CurlHelper, CurlHelperInterface); itkTypeMacro(CurlHelper, CurlHelperInterface);
itkNewMacro(Self); 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; 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, int RetrieveFileMulti(const std::vector<std::string>& listURLs,
const std::vector<std::string>& listFiles,