Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Unified Diff: tools/clang/blink_gc_plugin/tests/heap/stubs.h

Issue 192933002: Check that classes with non-trivial destructors have finalization support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/clang/blink_gc_plugin/tests/heap/stubs.h
diff --git a/tools/clang/blink_gc_plugin/tests/heap/stubs.h b/tools/clang/blink_gc_plugin/tests/heap/stubs.h
index 10b777ca2f349fbb9a45834e1fe072fd14feda7a..f6994f4b2098761aebd640692eb3aa5dd8bde18a 100644
--- a/tools/clang/blink_gc_plugin/tests/heap/stubs.h
+++ b/tools/clang/blink_gc_plugin/tests/heap/stubs.h
@@ -18,20 +18,45 @@ public:
template<typename T> class RefPtr {
public:
+ ~RefPtr() { }
operator T*() const { return 0; }
};
template<typename T> class OwnPtr {
public:
+ ~OwnPtr() { }
operator T*() const { return 0; }
};
-class DefaultAllocator { };
+class DefaultAllocator {
+public:
+ static const bool isGarbageCollected = false;
+};
+
+template<typename T>
+struct VectorTraits {
+ static const bool needsDestruction = true;
+};
+
+template<size_t inlineCapacity, bool isGarbageCollected, bool tNeedsDestruction>
+class VectorDestructorBase {
+public:
+ ~VectorDestructorBase() {}
+};
+
+template<size_t inlineCapacity>
+class VectorDestructorBase<inlineCapacity, true, false> {};
+
+template<>
+class VectorDestructorBase<0, true, true> {};
template<typename T,
size_t inlineCapacity = 0,
typename Allocator = DefaultAllocator>
-class Vector { };
+class Vector : public VectorDestructorBase<inlineCapacity,
+ Allocator::isGarbageCollected,
+ VectorTraits<T>::needsDestruction> {
+};
}
@@ -71,10 +96,13 @@ public:
operator T*() const { return 0; }
};
-class HeapAllocator { };
+class HeapAllocator {
+public:
+ static const bool isGarbageCollected = true;
+};
-template<typename T>
-class HeapVector : public Vector<T, 0, HeapAllocator> { };
+template<typename T, size_t inlineCapacity = 0>
+class HeapVector : public Vector<T, inlineCapacity, HeapAllocator> { };
template<typename T>
class PersistentHeapVector : public Vector<T, 0, HeapAllocator> { };
@@ -91,4 +119,13 @@ class GarbageCollectedMixin {
}
+namespace WTF {
+
+template<typename T>
+struct VectorTraits<WebCore::Member<T> > {
+ static const bool needsDestruction = false;
+};
+
+}
+
#endif

Powered by Google App Engine
This is Rietveld 408576698