llvm-project/lldb/unittests
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
..
Breakpoint Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Core [LLDB] - Update the test cases after yaml2obj change. 2019-04-03 15:28:35 +00:00
Disassembler When disassembling Aarch64 target and vendor Apple, set the cpu to 2019-03-07 03:16:45 +00:00
Editline C.128 override, virtual keyword handling 2019-05-03 10:03:28 +00:00
Expression DWARFExpression: Fix implementation of DW_OP_pick 2019-04-29 10:55:22 +00:00
Host Clear the output string passed to GetHostName() 2019-04-17 03:13:06 +00:00
Interpreter [CMake] Only the Python scirpt interpreter should link against Python. 2019-04-01 22:03:04 +00:00
Language [NFC] Remove ASCII lines from comments 2019-04-10 20:48:55 +00:00
ObjectFile Breakpad: Match the new UUID algorithm in minidumps 2019-04-16 14:51:47 +00:00
Platform Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Process C.128 override, virtual keyword handling 2019-05-03 10:03:28 +00:00
ScriptInterpreter [CMake] Only the Python scirpt interpreter should link against Python. 2019-04-01 22:03:04 +00:00
Signals Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Symbol C.128 override, virtual keyword handling 2019-05-03 10:03:28 +00:00
SymbolFile Remove obsoleted NativePDB tests 2019-04-29 14:00:58 +00:00
Target C.128 override, virtual keyword handling 2019-05-03 10:03:28 +00:00
TestingSupport Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
UnwindAssembly Use std::make_shared in LLDB (NFC) 2019-02-11 23:13:08 +00:00
Utility Allow direct comparison of ConstString against StringRef 2019-04-26 07:21:36 +00:00
debugserver [NFC] Remove ASCII lines from comments 2019-04-10 20:48:55 +00:00
tools [lldb-mi] Check raw pointers before passing them to std::string ctor/assignment 2019-02-25 16:40:11 +00:00
CMakeLists.txt [CMake] Only test debugserver if platform can use debugserver 2019-01-18 00:05:25 +00:00
gtest_common.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00