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:
// \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.