Warning on hiding base functions

924 Views Asked by At

I have a C++ code base where some non-virtual methods in a base class or overriden/hidden by virtual or non-virtual methods in derived classes. Mostly this is an error in the code.

Is there anything I can do to automaticly check for such cases like a compiler warning or a tool?

This is similar to Prevent derived classes from hiding non virtual functions from base or No warning for hiding non-virtual methods with similar prototype (G++ 4.4) but I'm looking for an actual solution to detect these issues in an existing codebase. Maybe just a warning for hidden functions is enough (I think that list will be small enough to go through one by one)

Changing the code base by hand to add "override" or "final" or so is not an option as this check should only be done once. A global solution like a define to "final" all non-virtual functions preventing them from beeing hidden would be ok.

I'm using Visual Studio 2012 but also have access to ubuntu and gcc.

0

There are 0 best solutions below