Commit 0d6df47e authored by Michael Lippautz's avatar Michael Lippautz Committed by Chromium LUCI CQ

heap: Forbid inheriting from more containers

Inheriting from Heap* containers is dangerous because of missing
virtual destructors and trace methods.

This only leaves HeapHashSet as container that can be inherited from,
which has one actual use in production code.

Bug: 1056170
Change-Id: I66a301754adb4d970ccc631f1113edcb915c3abc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2589855Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836765}
parent 1bc83f66
......@@ -183,12 +183,12 @@ template <typename KeyArg,
typename HashArg = typename DefaultHash<KeyArg>::Hash,
typename KeyTraitsArg = HashTraits<KeyArg>,
typename MappedTraitsArg = HashTraits<MappedArg>>
class HeapHashMap : public HashMap<KeyArg,
MappedArg,
HashArg,
KeyTraitsArg,
MappedTraitsArg,
HeapAllocator> {
class HeapHashMap final : public HashMap<KeyArg,
MappedArg,
HashArg,
KeyTraitsArg,
MappedTraitsArg,
HeapAllocator> {
IS_GARBAGE_COLLECTED_CONTAINER_TYPE();
DISALLOW_NEW();
......@@ -262,7 +262,7 @@ struct GCInfoTrait<HeapHashSet<T, U, V>>
template <typename Value,
typename HashFunctions = typename DefaultHash<Value>::Hash,
typename Traits = HashTraits<Value>>
class HeapHashCountedSet
class HeapHashCountedSet final
: public HashCountedSet<Value, HashFunctions, Traits, HeapAllocator> {
IS_GARBAGE_COLLECTED_CONTAINER_TYPE();
DISALLOW_NEW();
......@@ -292,7 +292,7 @@ struct GCInfoTrait<HeapHashCountedSet<T, U, V>>
: public GCInfoTrait<HashCountedSet<T, U, V, HeapAllocator>> {};
template <typename T, wtf_size_t inlineCapacity = 0>
class HeapVector : public Vector<T, inlineCapacity, HeapAllocator> {
class HeapVector final : public Vector<T, inlineCapacity, HeapAllocator> {
IS_GARBAGE_COLLECTED_CONTAINER_TYPE();
DISALLOW_NEW();
......@@ -369,7 +369,7 @@ struct GCInfoTrait<HeapVector<T, inlineCapacity>>
: public GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator>> {};
template <typename T>
class HeapDeque : public Deque<T, 0, HeapAllocator> {
class HeapDeque final : public Deque<T, 0, HeapAllocator> {
IS_GARBAGE_COLLECTED_CONTAINER_TYPE();
DISALLOW_NEW();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment