aboutsummaryrefslogtreecommitdiff
path: root/source/Plugins/Language/ObjC
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-05-03 10:03:28 +0000
committerRaphael Isemann <teemperor@gmail.com>2019-05-03 10:03:28 +0000
commite76cd4e36e9a9e100c69dc9c434a0d9dcb2fb03a (patch)
treea69f374b4257a0c33ef01109c69126716484c484 /source/Plugins/Language/ObjC
parentd0e71c991d888d889928d19d1cb6b1b60d6caeca (diff)
downloadlldb-e76cd4e36e9a9e100c69dc9c434a0d9dcb2fb03a.tar.gz
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@359868 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'source/Plugins/Language/ObjC')
-rw-r--r--source/Plugins/Language/ObjC/NSDictionary.h8
-rw-r--r--source/Plugins/Language/ObjC/ObjCLanguage.cpp2
2 files changed, 5 insertions, 5 deletions
diff --git a/source/Plugins/Language/ObjC/NSDictionary.h b/source/Plugins/Language/ObjC/NSDictionary.h
index e69582d6b..ecb3fccdf 100644
--- a/source/Plugins/Language/ObjC/NSDictionary.h
+++ b/source/Plugins/Language/ObjC/NSDictionary.h
@@ -51,8 +51,8 @@ public:
class Prefix : public Matcher {
public:
Prefix(ConstString p);
- virtual ~Prefix() = default;
- virtual bool Match(ConstString class_name) override;
+ ~Prefix() override = default;
+ bool Match(ConstString class_name) override;
private:
ConstString m_prefix;
@@ -60,8 +60,8 @@ public:
class Full : public Matcher {
public:
Full(ConstString n);
- virtual ~Full() = default;
- virtual bool Match(ConstString class_name) override;
+ ~Full() override = default;
+ bool Match(ConstString class_name) override;
private:
ConstString m_name;
diff --git a/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/source/Plugins/Language/ObjC/ObjCLanguage.cpp
index ad2953417..45cb4851a 100644
--- a/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ b/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -994,7 +994,7 @@ std::unique_ptr<Language::TypeScavenger> ObjCLanguage::GetTypeScavenger() {
class ObjCDebugInfoScavenger : public Language::ImageListTypeScavenger {
public:
- virtual CompilerType AdjustForInclusion(CompilerType &candidate) override {
+ CompilerType AdjustForInclusion(CompilerType &candidate) override {
LanguageType lang_type(candidate.GetMinimumLanguage());
if (!Language::LanguageIsObjC(lang_type))
return CompilerType();