From 6b08a52c8b8bc5dacfe0745bdae0b7e15f30bbc2 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Mon, 12 May 2025 15:18:18 +0200 Subject: [PATCH] LibGC: Make destructors non-virtual where possible `ConservativeVector`, `RootVector` and `RootHashMap` are final types, and their base classes have a protected destructor, so when their destructor is called, the static and dynamic types will be the same (can't destruct them through a pointer to a base or derived class). Therefore, there is no need for a virtual destructor. This fixes the newly introduced `-Wunnecessary-virtual-specifier` Clang warning (llvm/llvm-project#131188). --- Libraries/LibGC/ConservativeVector.h | 2 +- Libraries/LibGC/RootHashMap.h | 2 +- Libraries/LibGC/RootVector.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Libraries/LibGC/ConservativeVector.h b/Libraries/LibGC/ConservativeVector.h index 8277e6bcbcd..64051357dea 100644 --- a/Libraries/LibGC/ConservativeVector.h +++ b/Libraries/LibGC/ConservativeVector.h @@ -42,7 +42,7 @@ public: { } - virtual ~ConservativeVector() = default; + ~ConservativeVector() = default; ConservativeVector(ConservativeVector const& other) : ConservativeVectorBase(*other.m_heap) diff --git a/Libraries/LibGC/RootHashMap.h b/Libraries/LibGC/RootHashMap.h index fec2d48ae34..371611f71c2 100644 --- a/Libraries/LibGC/RootHashMap.h +++ b/Libraries/LibGC/RootHashMap.h @@ -45,7 +45,7 @@ public: { } - virtual ~RootHashMap() = default; + ~RootHashMap() = default; virtual void gather_roots(HashMap& roots) const override { diff --git a/Libraries/LibGC/RootVector.h b/Libraries/LibGC/RootVector.h index a448ea54e6b..eaf698038b2 100644 --- a/Libraries/LibGC/RootVector.h +++ b/Libraries/LibGC/RootVector.h @@ -46,7 +46,7 @@ public: { } - virtual ~RootVector() = default; + ~RootVector() = default; RootVector(Heap& heap, ReadonlySpan other) : RootVectorBase(heap)