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

Unified Diff: tools/clang/blink_gc_plugin/tests/class_requires_finalization_field.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: mixin support 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/class_requires_finalization_field.h
diff --git a/tools/clang/blink_gc_plugin/tests/class_requires_finalization_field.h b/tools/clang/blink_gc_plugin/tests/class_requires_finalization_field.h
new file mode 100644
index 0000000000000000000000000000000000000000..869fceae1ee742e1047cecc85b68f73d78fd6f44
--- /dev/null
+++ b/tools/clang/blink_gc_plugin/tests/class_requires_finalization_field.h
@@ -0,0 +1,58 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CLASS_REQUIRES_FINALIZATION_H_
+#define CLASS_REQUIRES_FINALIZATION_H_
+
+#include "heap/stubs.h"
+
+namespace WebCore {
+
+class A : public GarbageCollected<A> {
+public:
+ virtual void trace(Visitor*) {}
+};
+
+class B {
+public:
+ ~B() { /* user-declared, thus, non-trivial */ }
+};
+
+// Off-heap vectors always need to be finalized.
+class NeedsFinalizer : public A {
+public:
+ void trace(Visitor*);
+private:
+ Vector<Member<A> > m_as;
+};
+
+// On-heap vectors with inlined objects that need destruction
+// need to be finalized.
+class AlsoNeedsFinalizer : public A {
+public:
+ void trace(Visitor*);
+private:
+ HeapVector<B, 10> m_bs;
+};
+
+// On-heap vectors with no inlined objects never need to be finalized.
+class DoesNotNeedFinalizer : public A {
+public:
+ void trace(Visitor*);
+private:
+ HeapVector<B> m_bs;
+};
+
+// On-heap vectors with inlined objects that don't need destruction
+// don't need to be finalized.
+class AlsoDoesNotNeedFinalizer : public A {
+public:
+ void trace(Visitor*);
+private:
+ HeapVector<Member<A>, 10> m_as;
Vyacheslav Egorov (Chromium) 2014/03/12 18:24:24 What about class C { public: void trace(Visito
zerny-chromium 2014/03/13 09:32:22 Done.
+};
+
+}
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698