llvm-project/lldb
Raphael Isemann 1756630dfa C.128 override, virtual keyword handling
Summary:
According to [C128] "Virtual functions should specify exactly one
of `virtual`, `override`, or `final`", I've added override where a
virtual function is overriden but the explicit `override` keyword
was missing. Whenever both `virtual` and `override` were specified,
I removed `virtual`. As C.128 puts it:

> [...] writing more than one of these three is both redundant and
> a potential source of errors.

I anticipate a discussion about whether or not to add `override` to
destructors but I went for it because of an example in [ISOCPP1000].
Let me repeat the comment for you here:

Consider this code:

```
    struct Base {
      virtual ~Base(){}
    };

    struct SubClass : Base {
      ~SubClass() {
        std::cout << "It works!\n";
      }
    };

    int main() {
      std::unique_ptr<Base> ptr = std::make_unique<SubClass>();
    }
```

If for some odd reason somebody removes the `virtual` keyword from the
`Base` struct, the code will no longer print `It works!`. So adding
`override` to destructors actively protects us from accidentally
breaking our code at runtime.

[C128]: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c128-virtual-functions-should-specify-exactly-one-of-virtual-override-or-final
[ISOCPP1000]: https://github.com/isocpp/CppCoreGuidelines/issues/1000#issuecomment-476951555

Reviewers: teemperor, JDevlieghere, davide, shafik

Reviewed By: teemperor

Subscribers: kwk, arphaman, kadircet, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D61440

llvm-svn: 359868
2019-05-03 10:03:28 +00:00
..
cmake [CMake] Fix subtle CMake bug 2019-04-29 19:44:43 +00:00
docs [CMake] Fix subtle CMake bug 2019-04-29 19:44:43 +00:00
examples [Python] Simplify the code. NFCI. 2019-04-18 23:24:54 +00:00
include/lldb C.128 override, virtual keyword handling 2019-05-03 10:03:28 +00:00
lit [lldb] [lit] Add write tests for AVX-512 registers (zmm, xmm15+, ymm15+) 2019-05-02 16:10:35 +00:00
lldb.xcodeproj Add CxxModuleHandler to Xcode project 2019-04-30 18:21:14 +00:00
lldb.xcworkspace Remove accidentally commited file in xcshareddata 2019-02-05 23:35:01 +00:00
packages/Python/lldbsuite Split TestVLA into two and XFAIL one part 2019-05-03 08:06:28 +00:00
resources [CMake] Revised LLDB.framework builds 2019-01-04 12:46:50 +00:00
scripts Kill modify-python-lldb.py 2019-04-24 13:23:19 +00:00
source C.128 override, virtual keyword handling 2019-05-03 10:03:28 +00:00
test [CMake] Fix subtle CMake bug 2019-04-29 19:44:43 +00:00
third_party/Python/module [lldb/thirdparty] Remove unneeded files, asked by Jonas. 2019-03-12 20:41:36 +00:00
tools C.128 override, virtual keyword handling 2019-05-03 10:03:28 +00:00
unittests C.128 override, virtual keyword handling 2019-05-03 10:03:28 +00:00
utils [lldb] [lit] Add tests for reading ZMM registers (AVX512) 2019-04-29 11:38:10 +00:00
www Don't abort() in lldb_assert and document why. 2019-03-29 16:12:27 +00:00
.arcconfig
.clang-format
.gitignore Add .noindex to the gitignore 2019-04-05 17:57:42 +00:00
CMakeLists.txt [CMake] Fix subtle CMake bug 2019-04-29 19:44:43 +00:00
CODE_OWNERS.txt Fix/unify the spelling of Objective-C. 2018-06-13 16:21:24 +00:00
INSTALL.txt Fix build URL in new LLDB website 2019-05-01 09:55:00 +00:00
LICENSE.TXT Fix typos throughout the license files that somehow I and my reviewers 2019-01-21 09:52:34 +00:00
use_lldb_suite_root.py