mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Everything: Add -Wnon-virtual-dtor
flag
This flag warns on classes which have `virtual` functions but do not have a `virtual` destructor. This patch adds both the flag and missing destructors. The access level of the destructors was determined by a two rules of thumb: 1. A destructor should have a similar or lower access level to that of a constructor. 2. Having a `private` destructor implicitly deletes the default constructor, which is probably undesirable for "interface" types (classes with only virtual functions and no data). In short, most of the added destructors are `protected`, unless the compiler complained about access.
This commit is contained in:
parent
b75d2d36e1
commit
c4ede38542
Notes:
sideshowbarker
2024-07-18 20:17:38 +09:00
Author: https://github.com/Nicholas-Baron Commit: https://github.com/SerenityOS/serenity/commit/c4ede385423 Pull-request: https://github.com/SerenityOS/serenity/pull/6351
21 changed files with 57 additions and 0 deletions
|
@ -174,6 +174,7 @@ add_compile_options(-Wlogical-op)
|
|||
add_compile_options(-Wmisleading-indentation)
|
||||
add_compile_options(-Wmissing-declarations)
|
||||
add_compile_options(-Wno-nonnull-compare)
|
||||
add_compile_options(-Wnon-virtual-dtor)
|
||||
add_compile_options(-Wno-unknown-warning-option)
|
||||
add_compile_options(-Wundef)
|
||||
add_compile_options(-Wunused)
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
|
||||
protected:
|
||||
explicit Parser(PhysicalAddress rsdp);
|
||||
virtual ~Parser() = default;
|
||||
|
||||
private:
|
||||
static void set_the(Parser&);
|
||||
|
|
|
@ -83,6 +83,9 @@ public:
|
|||
void enumerate_interrupt_handlers(Function<void(GenericInterruptHandler&)>);
|
||||
IRQController& get_interrupt_controller(int index);
|
||||
|
||||
protected:
|
||||
virtual ~InterruptManagement() = default;
|
||||
|
||||
private:
|
||||
InterruptManagement();
|
||||
PhysicalAddress search_for_madt();
|
||||
|
|
|
@ -66,6 +66,8 @@ protected:
|
|||
u16 early_read_type(Address address);
|
||||
|
||||
Access();
|
||||
virtual ~Access() = default;
|
||||
|
||||
Vector<PhysicalID> m_physical_ids;
|
||||
};
|
||||
|
||||
|
|
|
@ -49,6 +49,9 @@ public:
|
|||
virtual void image_did_modify_layer_stack() { }
|
||||
virtual void image_did_change() { }
|
||||
virtual void image_select_layer(Layer*) { }
|
||||
|
||||
protected:
|
||||
virtual ~ImageClient() = default;
|
||||
};
|
||||
|
||||
class Image : public RefCounted<Image> {
|
||||
|
|
|
@ -84,6 +84,8 @@ public:
|
|||
PlaybackManager& manager() { return m_player_state.manager; }
|
||||
|
||||
protected:
|
||||
virtual ~Player() = default;
|
||||
|
||||
PlayerState m_player_state;
|
||||
RefPtr<PlaylistModel> m_playlist_model;
|
||||
};
|
||||
|
|
|
@ -32,4 +32,7 @@ class Visualization {
|
|||
public:
|
||||
virtual void set_buffer(RefPtr<Audio::Buffer> buffer) = 0;
|
||||
virtual void set_samplerate(int) { }
|
||||
|
||||
protected:
|
||||
virtual ~Visualization() = default;
|
||||
};
|
||||
|
|
|
@ -37,6 +37,9 @@ struct TreeMapNode {
|
|||
virtual size_t num_children() const = 0;
|
||||
virtual const TreeMapNode& child_at(size_t i) const = 0;
|
||||
virtual void sort_children_by_area() const = 0;
|
||||
|
||||
protected:
|
||||
virtual ~TreeMapNode() = default;
|
||||
};
|
||||
|
||||
struct TreeMap : public RefCounted<TreeMap> {
|
||||
|
|
|
@ -35,6 +35,9 @@ class ChecksumFunction {
|
|||
public:
|
||||
virtual void update(ReadonlyBytes data) = 0;
|
||||
virtual ChecksumType digest() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~ChecksumFunction() = default;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -92,6 +92,9 @@ public:
|
|||
ptr[index] = (u8)value;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~CipherBlock() = default;
|
||||
|
||||
private:
|
||||
virtual Bytes bytes() = 0;
|
||||
PaddingMode m_padding_mode;
|
||||
|
@ -132,6 +135,9 @@ public:
|
|||
|
||||
virtual String class_name() const = 0;
|
||||
|
||||
protected:
|
||||
virtual ~Cipher() = default;
|
||||
|
||||
private:
|
||||
PaddingMode m_padding_mode;
|
||||
};
|
||||
|
|
|
@ -57,6 +57,9 @@ public:
|
|||
virtual void reset() = 0;
|
||||
|
||||
virtual String class_name() const = 0;
|
||||
|
||||
protected:
|
||||
virtual ~HashFunction() = default;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ public:
|
|||
HashFunction& hasher() { return m_hasher; }
|
||||
|
||||
protected:
|
||||
virtual ~Code() = default;
|
||||
|
||||
HashFunction m_hasher;
|
||||
};
|
||||
|
||||
|
|
|
@ -60,6 +60,8 @@ public:
|
|||
virtual size_t output_size() const = 0;
|
||||
|
||||
protected:
|
||||
virtual ~PKSystem() = default;
|
||||
|
||||
PublicKeyType m_public_key;
|
||||
PrivateKeyType m_private_key;
|
||||
};
|
||||
|
|
|
@ -93,6 +93,8 @@ public:
|
|||
virtual Value count_reset() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~ConsoleClient() = default;
|
||||
|
||||
VM& vm();
|
||||
|
||||
GlobalObject& global_object() { return m_console.global_object(); }
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void visit_impl(Cell*) = 0;
|
||||
virtual ~Visitor() = default;
|
||||
};
|
||||
|
||||
virtual void visit_edges(Visitor&) { }
|
||||
|
|
|
@ -33,6 +33,9 @@ namespace TextCodec {
|
|||
class Decoder {
|
||||
public:
|
||||
virtual String to_utf8(const StringView&) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~Decoder() = default;
|
||||
};
|
||||
|
||||
class UTF8Decoder final : public Decoder {
|
||||
|
|
|
@ -113,6 +113,9 @@ public:
|
|||
virtual String page_did_request_prompt(const String&, const String&) { return {}; }
|
||||
virtual String page_did_request_cookie(const URL&, Cookie::Source) { return {}; }
|
||||
virtual void page_did_set_cookie(const URL&, const String&, Cookie::Source) { }
|
||||
|
||||
protected:
|
||||
virtual ~PageClient() = default;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,9 @@ typedef void (Interpreter::*InstructionHandler)(const Instruction&);
|
|||
class SymbolProvider {
|
||||
public:
|
||||
virtual String symbolicate(FlatPtr, u32* offset = nullptr) const = 0;
|
||||
|
||||
protected:
|
||||
virtual ~SymbolProvider() = default;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
@ -316,6 +319,9 @@ public:
|
|||
virtual u16 read16() = 0;
|
||||
virtual u32 read32() = 0;
|
||||
virtual u64 read64() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~InstructionStream() = default;
|
||||
};
|
||||
|
||||
class SimpleInstructionStream final : public InstructionStream {
|
||||
|
|
|
@ -622,6 +622,9 @@ public:
|
|||
virtual void wrap_0xD2(const Instruction&) = 0;
|
||||
virtual void wrap_0xD3_16(const Instruction&) = 0;
|
||||
virtual void wrap_0xD3_32(const Instruction&) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~Interpreter() = default;
|
||||
};
|
||||
|
||||
typedef void (Interpreter::*InstructionHandler)(const Instruction&);
|
||||
|
|
|
@ -75,6 +75,9 @@ public:
|
|||
virtual void visit(const AST::VariableDeclarations*);
|
||||
virtual void visit(const AST::WriteAppendRedirection*);
|
||||
virtual void visit(const AST::WriteRedirection*);
|
||||
|
||||
protected:
|
||||
virtual ~NodeVisitor() = default;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -99,6 +99,8 @@ public:
|
|||
s_the = this;
|
||||
}
|
||||
|
||||
virtual ~TestRunner() = default;
|
||||
|
||||
void run();
|
||||
|
||||
const Test::Counts& counts() const { return m_counts; }
|
||||
|
|
Loading…
Reference in a new issue