Right now, our coding style requires that both the virtual and override
keywords to be specified for overridden virtual functions.  A few things
have changed since we decided that a number of years ago:

1. The override and final keywords are now available on all of the
compilers that we build with, and we have stopped supporting compilers that
do not support these features.
2. We have very recently gained the ability to run clang-based mass source
code transformations over our code that would let us enforce the coding
style [1].

I would like to propose a change to our coding style, and run a mass
transformation over our code in order to enforce it.  I think we should
change it to require the usage of exactly one of these keywords per
*overridden* function: virtual, override, and final.  Here are the
advantages:

* It is a more succinct, as |virtual void foo() override;| doesn't convey
more information than |void foo() override;|.
* It can be easily enforced using clang-tidy across the entire code base.
* It makes it easier to determine what kind of function you are looking at
by just looking at its declaration.  |virtual void foo();| means a virtual
function that is not overridden, |void foo() override;| means an overridden
virtual function, and |void foo() final;| means an overridden virtual
function that cannot be further overridden.
* It allows us to be in sync with the Google C++ Style on this issue [2].
* It will allow us to remove NS_IMETHODIMP, and use NS_IMETHOD instead.

Please let me know what you think!

[1] Facilitated by bug 904572.  Also see bug 1158776 for my first attempt
at this.
[2]
http://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Inheritance

Cheers,
-- 
Ehsan
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to