[Development] Branch for adding Q_DECL_OVERRIDEs
Thiago Macieira
thiago.macieira at intel.com
Thu Oct 27 20:13:43 CEST 2016
On quinta-feira, 27 de outubro de 2016 16:43:59 PDT Александр Волков wrote:
> Hi all,
>
> Many methods are still missing 'override' specifier.
> You can find them by compiling with gcc's -Wsuggest-override.
> It improves code readability and helps to find unused code
> (e.g. https://codereview.qt-project.org/#/c/174370/ )
> Are there plans about adding 'override' or 'Q_DECL_OVERRIDE'
> and which branch is preferred for such changes?
I would prefer we did not add Q_DECL_OVERRIDE at all to current code. We may
add "override" if that keyword is allowed by all compilers, otherwise leave it
as it is.
GCC and Clang support a warning for "inconsistent override", which is caused
by having some overridden methods marked but not others. So the recommendation
is:
1) for new classes, always mark with Q_DECL_OVERRIDE
2) for existing classes, if possible use Q_DECL_OVERRIDE, but be careful to be
consistent (be careful with #ifdef'ed functions too!). It's ok to add a
handful of other Q_DECL_OVERRIDE to other functions in the same class, but
don't do it if it uglifies your patch. Instead, leave it out.
3) if you get an inconsistent override use warning, fix it
Note that only #3 applies to the 5.6 branch. You can't add new public classes
or public methods in 5.6 or 5.7. And you should not be adding even new,
private, polymorphic classes in those branch. And there's only a short window
while that is permitted in 5.8 too.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list