From 70e93c1e2b36d14dbd06524b73c864e3e93a2710 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Sat, 9 Mar 2024 17:07:52 -0800 Subject: [PATCH 1/2] Make `Matcher` subclasses `final` Fixes this very long warning, which I'll only include the first line of: /nix/store/8wrjhrycpshhc3b41xmjwvgqr2m3yajq-libcxx-16.0.6-dev/include/c++/v1/__memory/construct_at.h:66:5: warning: destructor called on non-final 'RegexMatcher' that has virtual functions but non-virtual destructor [-Wdelete-non-abstract-non-virtual-dtor] __loc->~_Tp(); --- src/nix/profile.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nix/profile.cc b/src/nix/profile.cc index b5ffc7cc616..c0f80579419 100644 --- a/src/nix/profile.cc +++ b/src/nix/profile.cc @@ -485,7 +485,7 @@ struct Matcher virtual bool matches(const std::string & name, const ProfileElement & element) = 0; }; -struct RegexMatcher : public Matcher +struct RegexMatcher final : public Matcher { std::regex regex; std::string pattern; @@ -504,7 +504,7 @@ struct RegexMatcher : public Matcher } }; -struct StorePathMatcher : public Matcher +struct StorePathMatcher final : public Matcher { nix::StorePath storePath; @@ -522,7 +522,7 @@ struct StorePathMatcher : public Matcher } }; -struct NameMatcher : public Matcher +struct NameMatcher final : public Matcher { std::string name; @@ -540,7 +540,7 @@ struct NameMatcher : public Matcher } }; -struct AllMatcher : public Matcher +struct AllMatcher final : public Matcher { std::string getTitle() override { From db9bab2708d8a44067156da686dbaf7604f4bc47 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Sun, 10 Mar 2024 12:56:07 -0700 Subject: [PATCH 2/2] `Matcher`: Add virtual destructor --- src/nix/profile.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nix/profile.cc b/src/nix/profile.cc index c0f80579419..a5a40e4f66c 100644 --- a/src/nix/profile.cc +++ b/src/nix/profile.cc @@ -481,6 +481,7 @@ struct CmdProfileInstall : InstallablesCommand, MixDefaultProfile struct Matcher { + virtual ~Matcher() { } virtual std::string getTitle() = 0; virtual bool matches(const std::string & name, const ProfileElement & element) = 0; };