From 4a81b33c07cbb440c7fefcc073e94e113feeac52 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Sat, 4 Dec 2021 10:09:09 +0100 Subject: [PATCH] Everywhere: Fix -Winconsistent-missing-override warnings from Clang This option is already enabled when building Lagom, so let's enable it for the main build too. We will no longer be surprised by Lagom Clang CI builds failing while everything compiles locally. Furthermore, the stronger `-Wsuggest-override` warning is enabled in this commit, which enforces the use of the `override` keyword in all classes, not just those which already have some methods marked as `override`. This works with both GCC and Clang. --- CMakeLists.txt | 2 +- Kernel/FileSystem/AnonymousFile.h | 2 +- Kernel/FileSystem/ProcFS.h | 4 ++-- Kernel/FileSystem/SysFS.h | 2 +- Kernel/Firmware/PowerStateSwitch.h | 2 +- Kernel/Graphics/GenericFramebufferDevice.h | 2 +- Kernel/Graphics/VirtIOGPU/FramebufferDevice.h | 4 ++-- Kernel/Net/NE2000NetworkAdapter.h | 4 ++-- .../Tools/CodeGenerators/IPCCompiler/main.cpp | 2 +- Userland/Applications/SpaceAnalyzer/main.cpp | 10 ++++---- Userland/Applications/Terminal/main.cpp | 4 ++-- .../DevTools/HackStudio/Git/GitFilesView.h | 2 +- Userland/Libraries/LibChess/UCICommand.h | 24 +++++++++---------- .../Libraries/LibCrypto/Checksum/Adler32.h | 4 ++-- Userland/Libraries/LibCrypto/Checksum/CRC32.h | 4 ++-- Userland/Libraries/LibJS/Heap/Heap.cpp | 2 +- Userland/Libraries/LibSQL/AST/AST.h | 2 +- Userland/Libraries/LibWeb/CSS/CSSImportRule.h | 4 ++-- Userland/Libraries/LibWeb/CSS/StyleValue.h | 2 +- Userland/Libraries/LibWeb/DOM/Document.h | 2 +- Userland/Libraries/LibWeb/Layout/Box.h | 4 ++-- Userland/Shell/Shell.cpp | 2 +- 22 files changed, 45 insertions(+), 45 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 653c1fd7578..d9de81ae463 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,6 +157,7 @@ add_compile_options(-Wlogical-op) add_compile_options(-Wmisleading-indentation) add_compile_options(-Wmissing-declarations) add_compile_options(-Wnon-virtual-dtor) +add_compile_options(-Wsuggest-override) add_compile_options(-Wno-unknown-warning-option) add_compile_options(-Wundef) add_compile_options(-Wunused) @@ -186,7 +187,6 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang$") add_compile_options(-Wno-atomic-alignment) add_compile_options(-Wno-c99-designator) add_compile_options(-Wno-implicit-const-int-float-conversion) - add_compile_options(-Wno-inconsistent-missing-override) add_compile_options(-Wno-null-pointer-subtraction) add_compile_options(-Wno-tautological-constant-out-of-range-compare) add_compile_options(-Wno-unneeded-internal-declaration) diff --git a/Kernel/FileSystem/AnonymousFile.h b/Kernel/FileSystem/AnonymousFile.h index a6e85810c83..a1346aef28a 100644 --- a/Kernel/FileSystem/AnonymousFile.h +++ b/Kernel/FileSystem/AnonymousFile.h @@ -24,7 +24,7 @@ public: private: virtual StringView class_name() const override { return "AnonymousFile"sv; } - virtual ErrorOr> pseudo_path(const OpenFileDescription&) const; + virtual ErrorOr> pseudo_path(const OpenFileDescription&) const override; virtual bool can_read(const OpenFileDescription&, size_t) const override { return false; } virtual bool can_write(const OpenFileDescription&, size_t) const override { return false; } virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return ENOTSUP; } diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h index de4ca65c7a0..cc83c98cf0f 100644 --- a/Kernel/FileSystem/ProcFS.h +++ b/Kernel/FileSystem/ProcFS.h @@ -54,8 +54,8 @@ protected: ProcFS const& procfs() const { return static_cast(Inode::fs()); } // ^Inode - virtual ErrorOr attach(OpenFileDescription& description) = 0; - virtual void did_seek(OpenFileDescription&, off_t) = 0; + virtual ErrorOr attach(OpenFileDescription& description) override = 0; + virtual void did_seek(OpenFileDescription&, off_t) override = 0; virtual ErrorOr flush_metadata() override final; virtual ErrorOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override final; virtual ErrorOr add_child(Inode&, StringView name, mode_t) override final; diff --git a/Kernel/FileSystem/SysFS.h b/Kernel/FileSystem/SysFS.h index eef4e4c88c0..00daf60e051 100644 --- a/Kernel/FileSystem/SysFS.h +++ b/Kernel/FileSystem/SysFS.h @@ -146,7 +146,7 @@ protected: virtual ErrorOr chmod(mode_t) override; virtual ErrorOr chown(UserID, GroupID) override; virtual ErrorOr truncate(u64) override; - virtual ErrorOr set_mtime(time_t); + virtual ErrorOr set_mtime(time_t) override; virtual ErrorOr attach(OpenFileDescription& description) override final; virtual void did_seek(OpenFileDescription&, off_t) override final; diff --git a/Kernel/Firmware/PowerStateSwitch.h b/Kernel/Firmware/PowerStateSwitch.h index e02db5138fd..7e167539fa1 100644 --- a/Kernel/Firmware/PowerStateSwitch.h +++ b/Kernel/Firmware/PowerStateSwitch.h @@ -26,7 +26,7 @@ public: virtual mode_t permissions() const override; virtual ErrorOr write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) override; virtual ErrorOr truncate(u64) override; - virtual ErrorOr set_mtime(time_t) { return {}; } + virtual ErrorOr set_mtime(time_t) override { return {}; } private: PowerStateSwitchNode(FirmwareSysFSDirectory&); diff --git a/Kernel/Graphics/GenericFramebufferDevice.h b/Kernel/Graphics/GenericFramebufferDevice.h index c3a59c10fe5..7f9eb0c9d9e 100644 --- a/Kernel/Graphics/GenericFramebufferDevice.h +++ b/Kernel/Graphics/GenericFramebufferDevice.h @@ -29,7 +29,7 @@ public: virtual ~GenericFramebufferDevice() = default; // ^File - virtual ErrorOr mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared) = 0; + virtual ErrorOr mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared) override = 0; virtual ErrorOr ioctl(OpenFileDescription&, unsigned request, Userspace arg) override final; virtual StringView class_name() const override final { return "FramebufferDevice"sv; } diff --git a/Kernel/Graphics/VirtIOGPU/FramebufferDevice.h b/Kernel/Graphics/VirtIOGPU/FramebufferDevice.h index dcec88e689a..e8aa88683d8 100644 --- a/Kernel/Graphics/VirtIOGPU/FramebufferDevice.h +++ b/Kernel/Graphics/VirtIOGPU/FramebufferDevice.h @@ -30,8 +30,8 @@ public: virtual ErrorOr try_to_initialize() override { return {}; } - virtual void deactivate_writes(); - virtual void activate_writes(); + virtual void deactivate_writes() override; + virtual void activate_writes() override; size_t width() const { return display_info().rect.width; } size_t height() const { return display_info().rect.height; } diff --git a/Kernel/Net/NE2000NetworkAdapter.h b/Kernel/Net/NE2000NetworkAdapter.h index b29d3b514ac..f901a934ea1 100644 --- a/Kernel/Net/NE2000NetworkAdapter.h +++ b/Kernel/Net/NE2000NetworkAdapter.h @@ -31,12 +31,12 @@ public: // just assume that it's up. return true; } - virtual i32 link_speed() + virtual i32 link_speed() override { // Can only do 10mbit.. return 10; } - virtual bool link_full_duplex() { return true; } + virtual bool link_full_duplex() override { return true; } virtual StringView purpose() const override { return class_name(); } diff --git a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp index 0abc3bc693d..b3d47c1f8d4 100644 --- a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp @@ -416,7 +416,7 @@ public: )~~~"); message_generator.append(R"~~~( - virtual bool valid() const { return m_ipc_message_valid; } + virtual bool valid() const override { return m_ipc_message_valid; } virtual IPC::MessageBuffer encode() const override { diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index ec41f9d4a53..d1b7297698d 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -35,17 +35,17 @@ struct TreeNode : public SpaceAnalyzer::TreeMapNode { TreeNode(String name) : m_name(move(name)) {}; - virtual String name() const { return m_name; } - virtual i64 area() const { return m_area; } - virtual size_t num_children() const + virtual String name() const override { return m_name; } + virtual i64 area() const override { return m_area; } + virtual size_t num_children() const override { if (m_children) { return m_children->size(); } return 0; } - virtual const TreeNode& child_at(size_t i) const { return m_children->at(i); } - virtual void sort_children_by_area() const + virtual const TreeNode& child_at(size_t i) const override { return m_children->at(i); } + virtual void sort_children_by_area() const override { if (m_children) { Vector* children = const_cast*>(m_children.ptr()); diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index 12e9c154a10..786258d5ddb 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -51,7 +51,7 @@ public: { } - virtual void config_string_did_change(String const& domain, String const& group, String const& key, String const& value) + virtual void config_string_did_change(String const& domain, String const& group, String const& key, String const& value) override { VERIFY(domain == "Terminal"); @@ -77,7 +77,7 @@ public: } } - virtual void config_i32_did_change(String const& domain, String const& group, String const& key, i32 value) + virtual void config_i32_did_change(String const& domain, String const& group, String const& key, i32 value) override { VERIFY(domain == "Terminal"); diff --git a/Userland/DevTools/HackStudio/Git/GitFilesView.h b/Userland/DevTools/HackStudio/Git/GitFilesView.h index 0901e4787e9..648cbfcb776 100644 --- a/Userland/DevTools/HackStudio/Git/GitFilesView.h +++ b/Userland/DevTools/HackStudio/Git/GitFilesView.h @@ -24,7 +24,7 @@ protected: GitFilesView(GitFileActionCallback, NonnullRefPtr action_icon); private: - virtual void paint_list_item(GUI::Painter& painter, int row_index, int painted_item_index); + virtual void paint_list_item(GUI::Painter& painter, int row_index, int painted_item_index) override; virtual void mousedown_event(GUI::MouseEvent&) override; virtual Gfx::IntRect action_icon_rect(size_t painted_item_index); diff --git a/Userland/Libraries/LibChess/UCICommand.h b/Userland/Libraries/LibChess/UCICommand.h index e591906e5cd..a72b78025ca 100644 --- a/Userland/Libraries/LibChess/UCICommand.h +++ b/Userland/Libraries/LibChess/UCICommand.h @@ -58,7 +58,7 @@ public: static UCICommand from_string(StringView command); - virtual String to_string() const; + virtual String to_string() const override; }; class DebugCommand : public Command { @@ -76,7 +76,7 @@ public: static DebugCommand from_string(StringView command); - virtual String to_string() const; + virtual String to_string() const override; Flag flag() const { return m_flag; } @@ -93,7 +93,7 @@ public: static IsReadyCommand from_string(StringView command); - virtual String to_string() const; + virtual String to_string() const override; }; class SetOptionCommand : public Command { @@ -107,7 +107,7 @@ public: static SetOptionCommand from_string(StringView command); - virtual String to_string() const; + virtual String to_string() const override; const String& name() const { return m_name; } const Optional& value() const { return m_value; } @@ -128,7 +128,7 @@ public: static PositionCommand from_string(StringView command); - virtual String to_string() const; + virtual String to_string() const override; const Optional& fen() const { return m_fen; } const Vector& moves() const { return m_moves; } @@ -147,7 +147,7 @@ public: static GoCommand from_string(StringView command); - virtual String to_string() const; + virtual String to_string() const override; Optional> searchmoves; bool ponder { false }; @@ -172,7 +172,7 @@ public: static StopCommand from_string(StringView command); - virtual String to_string() const; + virtual String to_string() const override; }; class IdCommand : public Command { @@ -191,7 +191,7 @@ public: static IdCommand from_string(StringView command); - virtual String to_string() const; + virtual String to_string() const override; Type field_type() const { return m_field_type; } const String& value() const { return m_value; } @@ -210,7 +210,7 @@ public: static UCIOkCommand from_string(StringView command); - virtual String to_string() const; + virtual String to_string() const override; }; class ReadyOkCommand : public Command { @@ -222,7 +222,7 @@ public: static ReadyOkCommand from_string(StringView command); - virtual String to_string() const; + virtual String to_string() const override; }; class BestMoveCommand : public Command { @@ -235,7 +235,7 @@ public: static BestMoveCommand from_string(StringView command); - virtual String to_string() const; + virtual String to_string() const override; Chess::Move move() const { return m_move; } @@ -252,7 +252,7 @@ public: static InfoCommand from_string(StringView command); - virtual String to_string() const; + virtual String to_string() const override; Optional depth; Optional seldepth; diff --git a/Userland/Libraries/LibCrypto/Checksum/Adler32.h b/Userland/Libraries/LibCrypto/Checksum/Adler32.h index 97117766ab7..3c4595465be 100644 --- a/Userland/Libraries/LibCrypto/Checksum/Adler32.h +++ b/Userland/Libraries/LibCrypto/Checksum/Adler32.h @@ -27,8 +27,8 @@ public: update(data); } - void update(ReadonlyBytes data); - u32 digest(); + virtual void update(ReadonlyBytes data) override; + virtual u32 digest() override; private: u32 m_state_a { 1 }; diff --git a/Userland/Libraries/LibCrypto/Checksum/CRC32.h b/Userland/Libraries/LibCrypto/Checksum/CRC32.h index 885cf5bde5f..e2913527fde 100644 --- a/Userland/Libraries/LibCrypto/Checksum/CRC32.h +++ b/Userland/Libraries/LibCrypto/Checksum/CRC32.h @@ -55,8 +55,8 @@ public: update(data); } - void update(ReadonlyBytes data); - u32 digest(); + virtual void update(ReadonlyBytes data) override; + virtual u32 digest() override; private: u32 m_state { ~0u }; diff --git a/Userland/Libraries/LibJS/Heap/Heap.cpp b/Userland/Libraries/LibJS/Heap/Heap.cpp index 023f0aaf7ed..e616ecbb986 100644 --- a/Userland/Libraries/LibJS/Heap/Heap.cpp +++ b/Userland/Libraries/LibJS/Heap/Heap.cpp @@ -178,7 +178,7 @@ class MarkingVisitor final : public Cell::Visitor { public: MarkingVisitor() { } - virtual void visit_impl(Cell& cell) + virtual void visit_impl(Cell& cell) override { if (cell.is_marked()) return; diff --git a/Userland/Libraries/LibSQL/AST/AST.h b/Userland/Libraries/LibSQL/AST/AST.h index b0ee4c72622..7dbcb7c3897 100644 --- a/Userland/Libraries/LibSQL/AST/AST.h +++ b/Userland/Libraries/LibSQL/AST/AST.h @@ -943,7 +943,7 @@ public: bool has_selection() const { return !m_select_statement.is_null(); } const RefPtr