Skip to content

ENH: Modernize: add override in virtual functions of derived classes

phcerdan requested to merge github/fork/phcerdan/clang_tidy_override into master

After ITK_OVERRIDE and VTK_OVERRIDE have been replaced for override we run clang-tidy to add overrides on virtual functions of derived classes.

Example:

-virtual void ShowProgress()
+void ShowProgress() override

This allows compiler warnings and errors if the method does not override the base class after a change in the base class.

Check the Slicer Wiki for an updated version of the documentation on how to run clang-tidy. https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/MigrationGuide#C.2B.2B11:_Update_source_code_to_use_override

run-clang-tidy.py -checks=-*,modernize-use-override  -header-filter=.* -fix

Multiple override are added to the same method.

void PrintSelf(ostream& os, vtkIndent indent) override override override;

Clean them with (15 here is just a high enough number):

for n in `seq 1 15`;
do
    ack "override override" -l --print0 | xargs -0 -n 1 sed -i \
    's/override override/override/g'
done

When all of them are fixed, you should see in the terminal:

sed: no input files

This branch includes #1109 and #1107 (VTK_OVERRIDE and ITK_OVERRIDE)

Merge request reports

Loading