[LLVMdev] [RFC] C++11: 'virtual' and 'override'

Richard Smith richard at metafoo.co.uk
Tue Mar 4 23:43:33 PST 2014


On Tue, Mar 4, 2014 at 10:59 PM, Chris Lattner <clattner at apple.com> wrote:

> On Mar 4, 2014, at 10:48 PM, Duncan Exon Smith <dexonsmith at apple.com>
> wrote:
>
>
> Related, should we require use of 'override' when methods override a base
> class method?
>
>
> My vote: require override.
>
>
> +1: override is useful and prevents errors.
>
> Would it be too much to have clang emit a warning/error if override is
> missing?  I know that sounds crazy and people hate errors which fire too
> often, but there's not too much C++11 code out there yet, and so we have a
> chance to put errors/warnings in now without too much pain.  People might
> just get used to them and think its how code has to be written :)
>
>
> Might be a nightmare when including legacy headers, but warnings can
> always be disabled...
>
>
> A clang warning for this would be awesome, but it should be off by
> default.  That said, the build of LLVM itself could detect that Clang had
> this warning and turn it on.  I think it would be great to have the
> makefiles/cmake detect modern clang's and turn on additional warnings that
> we can't inflict on the world by default.
>

It might be reasonable to warn if a class has both a function marked
'override' and a function that overrides but is not marked 'override'.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140304/7d9eb912/attachment.html>


More information about the llvm-dev mailing list