Fix clang-tidy cppcoreguidelines-virtual-class-destructor warnings in headers

This commit is contained in:
Tim Wojtulewicz 2025-06-10 14:27:54 -07:00
parent e84c99fb14
commit 311a744a20
8 changed files with 24 additions and 14 deletions

View file

@ -99,6 +99,8 @@ extern Registry registry;
*/ */
class Modifiable { class Modifiable {
public: public:
virtual ~Modifiable();
/** /**
* Calling this method signals to all registered receivers that the * Calling this method signals to all registered receivers that the
* object has been modified. * object has been modified.
@ -111,8 +113,6 @@ public:
protected: protected:
friend class Registry; friend class Registry;
virtual ~Modifiable();
// Number of currently registered receivers. // Number of currently registered receivers.
uint64_t num_receivers = 0; uint64_t num_receivers = 0;
}; };

View file

@ -21,6 +21,8 @@ class ZAMCompiler; // for "friend" declarations
class ExprListStmt : public Stmt { class ExprListStmt : public Stmt {
public: public:
~ExprListStmt() override;
const ListExpr* ExprList() const { return l.get(); } const ListExpr* ExprList() const { return l.get(); }
const ListExprPtr& ExprListPtr() const { return l; } const ListExprPtr& ExprListPtr() const { return l; }
@ -35,8 +37,6 @@ public:
protected: protected:
ExprListStmt(StmtTag t, ListExprPtr arg_l); ExprListStmt(StmtTag t, ListExprPtr arg_l);
~ExprListStmt() override;
ValPtr Exec(Frame* f, StmtFlowType& flow) override; ValPtr Exec(Frame* f, StmtFlowType& flow) override;
virtual ValPtr DoExec(std::vector<ValPtr> vals, StmtFlowType& flow) = 0; virtual ValPtr DoExec(std::vector<ValPtr> vals, StmtFlowType& flow) = 0;

View file

@ -356,6 +356,8 @@ protected:
class IndexType : public Type { class IndexType : public Type {
public: public:
~IndexType() override = default;
int MatchesIndex(detail::ListExpr* index) const override; int MatchesIndex(detail::ListExpr* index) const override;
const TypeListPtr& GetIndices() const { return indices; } const TypeListPtr& GetIndices() const { return indices; }
@ -391,8 +393,6 @@ protected:
is_pattern_index = types.size() == 1 && types[0]->Tag() == TYPE_PATTERN; is_pattern_index = types.size() == 1 && types[0]->Tag() == TYPE_PATTERN;
} }
~IndexType() override = default;
void DoDescribe(ODesc* d) const override; void DoDescribe(ODesc* d) const override;
TypeListPtr indices; TypeListPtr indices;

View file

@ -327,6 +327,8 @@ public:
inits_vec.resize(inits.size()); inits_vec.resize(inits.size());
} }
virtual ~CPP_AbstractBasicConsts() = default;
void InitializeCohort(InitsManager* im, int cohort) { void InitializeCohort(InitsManager* im, int cohort) {
ASSERT(cohort == 0); ASSERT(cohort == 0);
auto& offsets_vec = im->Indices(offsets_set); auto& offsets_vec = im->Indices(offsets_set);

View file

@ -25,6 +25,8 @@ public:
*/ */
FileState(Cookie cookie) : ParsingState(::spicy::rt::driver::ParsingType::Stream), _cookie(std::move(cookie)) {} FileState(Cookie cookie) : ParsingState(::spicy::rt::driver::ParsingType::Stream), _cookie(std::move(cookie)) {}
virtual ~FileState() = default;
/** Returns the cookie pointer to use with the runtime library during analysis. */ /** Returns the cookie pointer to use with the runtime library during analysis. */
auto* cookie() { return &_cookie; } auto* cookie() { return &_cookie; }

View file

@ -26,6 +26,8 @@ public:
*/ */
PacketState(Cookie cookie) : ParsingState(::spicy::rt::driver::ParsingType::Block), _cookie(std::move(cookie)) {} PacketState(Cookie cookie) : ParsingState(::spicy::rt::driver::ParsingType::Block), _cookie(std::move(cookie)) {}
virtual ~PacketState() = default;
/** Returns the cookie pointer to use with the runtime library during analysis. */ /** Returns the cookie pointer to use with the runtime library during analysis. */
auto* cookie() { return &_cookie; } auto* cookie() { return &_cookie; }

View file

@ -17,6 +17,11 @@
namespace zeek::spicy::rt { namespace zeek::spicy::rt {
/** Parsing state for one endpoint of the connection. */ /** Parsing state for one endpoint of the connection. */
// FIXME: It's strange that the parent class of this does not have a virtual destructor,
// but fixing it requires also implementing copy constructor/operators, and it turns into
// a rabbit hole.
//
// NOLINTNEXTLINE(cppcoreguidelines-virtual-class-destructor)
class EndpointState : public ::spicy::rt::driver::ParsingState { class EndpointState : public ::spicy::rt::driver::ParsingState {
public: public:
/** /**

View file

@ -37,6 +37,13 @@ public:
BasicThread(BasicThread const&) = delete; BasicThread(BasicThread const&) = delete;
BasicThread& operator=(BasicThread const&) = delete; BasicThread& operator=(BasicThread const&) = delete;
/**
* Destructor. This will be called by the manager.
*
* Only Zeek's main thread may delete thread instances.
*/
virtual ~BasicThread();
/** /**
* Returns a descriptive name for the thread. If not set via * Returns a descriptive name for the thread. If not set via
* SetName(), a default name is chosen automatically. * SetName(), a default name is chosen automatically.
@ -168,14 +175,6 @@ protected:
*/ */
virtual void OnKill() {} virtual void OnKill() {}
/**
* Destructor. This will be called by the manager.
*
* Only Zeek's main thread may delete thread instances.
*
*/
virtual ~BasicThread();
/** /**
* Waits until the thread's Run() method has finished and then joins * Waits until the thread's Run() method has finished and then joins
* it. This is called from the threading::Manager. * it. This is called from the threading::Manager.