Prevent overriding virtual methods that are called in a destructor

Virtual methods are no longer valid once the derived destructor has
run. This means the compiler is free to optimize them to be
non-virtual.

Found using clang-tidy
This commit is contained in:
Yorick 2023-08-11 11:58:33 +02:00
parent a1fdc68c65
commit b9b51f9579
No known key found for this signature in database
GPG key ID: D8D3CC6D951384DE
3 changed files with 7 additions and 3 deletions

View file

@ -108,7 +108,8 @@ public:
stop(); stop();
} }
void stop() override /* Called by destructor, can't be overridden */
void stop() override final
{ {
{ {
auto state(state_.lock()); auto state(state_.lock());

View file

@ -272,8 +272,10 @@ struct LocalDerivationGoal : public DerivationGoal
/** /**
* Forcibly kill the child process, if any. * Forcibly kill the child process, if any.
*
* Called by destructor, can't be overridden
*/ */
void killChild() override; void killChild() override final;
/** /**
* Kill any processes running under the build user UID or in the * Kill any processes running under the build user UID or in the

View file

@ -114,7 +114,8 @@ public:
void handleChildOutput(int fd, std::string_view data) override; void handleChildOutput(int fd, std::string_view data) override;
void handleEOF(int fd) override; void handleEOF(int fd) override;
void cleanup() override; /* Called by destructor, can't be overridden */
void cleanup() override final;
JobCategory jobCategory() override { return JobCategory::Substitution; }; JobCategory jobCategory() override { return JobCategory::Substitution; };
}; };