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

Side by Side 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 and rebase 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef HEAP_STUBS_H_ 5 #ifndef HEAP_STUBS_H_
6 #define HEAP_STUBS_H_ 6 #define HEAP_STUBS_H_
7 7
8 #include "stddef.h" 8 #include "stddef.h"
9 9
10 namespace WTF { 10 namespace WTF {
11 11
12 template<typename T> class RefCounted { }; 12 template<typename T> class RefCounted { };
13 13
14 template<typename T> class RawPtr { 14 template<typename T> class RawPtr {
15 public: 15 public:
16 operator T*() const { return 0; } 16 operator T*() const { return 0; }
17 }; 17 };
18 18
19 template<typename T> class RefPtr { 19 template<typename T> class RefPtr {
20 public: 20 public:
21 operator T*() const { return 0; } 21 operator T*() const { return 0; }
22 }; 22 };
23 23
24 template<typename T> class OwnPtr { 24 template<typename T> class OwnPtr {
25 public: 25 public:
26 operator T*() const { return 0; } 26 operator T*() const { return 0; }
27 }; 27 };
28 28
29 class DefaultAllocator { }; 29 class DefaultAllocator {
30 public:
31 static const bool isGarbageCollected = false;
32 };
33
34 template<typename T>
35 struct VectorTraits {
36 static const bool needsDestruction = true;
37 };
38
39 template<size_t inlineCapacity, bool isGarbageCollected, bool tNeedsDestruction>
40 class VectorDestructorBase {
41 public:
42 ~VectorDestructorBase() {}
43 };
44
45 template<size_t inlineCapacity>
46 class VectorDestructorBase<inlineCapacity, true, false> {};
47
48 template<>
49 class VectorDestructorBase<0, true, true> {};
30 50
31 template<typename T, 51 template<typename T,
32 size_t inlineCapacity = 0, 52 size_t inlineCapacity = 0,
33 typename Allocator = DefaultAllocator> 53 typename Allocator = DefaultAllocator>
34 class Vector { }; 54 class Vector : public VectorDestructorBase<inlineCapacity,
55 Allocator::isGarbageCollected,
56 VectorTraits<T>::needsDestruction> {
57 };
35 58
36 } 59 }
37 60
38 namespace WebCore { 61 namespace WebCore {
39 62
40 using namespace WTF; 63 using namespace WTF;
41 64
42 #define DISALLOW_ALLOCATION() \ 65 #define DISALLOW_ALLOCATION() \
43 private: \ 66 private: \
44 void* operator new(size_t) = delete; 67 void* operator new(size_t) = delete;
(...skipping 19 matching lines...) Expand all
64 template<typename T> class Member { 87 template<typename T> class Member {
65 public: 88 public:
66 operator T*() const { return 0; } 89 operator T*() const { return 0; }
67 }; 90 };
68 91
69 template<typename T> class Persistent { 92 template<typename T> class Persistent {
70 public: 93 public:
71 operator T*() const { return 0; } 94 operator T*() const { return 0; }
72 }; 95 };
73 96
74 class HeapAllocator { }; 97 class HeapAllocator {
98 public:
99 static const bool isGarbageCollected = true;
100 };
75 101
76 template<typename T> 102 template<typename T, size_t inlineCapacity = 0>
77 class HeapVector : public Vector<T, 0, HeapAllocator> { }; 103 class HeapVector : public Vector<T, inlineCapacity, HeapAllocator> { };
78 104
79 template<typename T> 105 template<typename T>
80 class PersistentHeapVector : public Vector<T, 0, HeapAllocator> { }; 106 class PersistentHeapVector : public Vector<T, 0, HeapAllocator> { };
81 107
82 class Visitor { 108 class Visitor {
83 public: 109 public:
84 template<typename T> void trace(const T&); 110 template<typename T> void trace(const T&);
85 }; 111 };
86 112
87 class GarbageCollectedMixin { 113 class GarbageCollectedMixin {
88 virtual void adjustAndMark(Visitor*) const = 0; 114 virtual void adjustAndMark(Visitor*) const = 0;
89 virtual bool isAlive(Visitor*) const = 0; 115 virtual bool isAlive(Visitor*) const = 0;
90 }; 116 };
91 117
92 } 118 }
93 119
120 namespace WTF {
121
122 template<typename T>
123 struct VectorTraits<WebCore::Member<T> > {
124 static const bool needsDestruction = false;
125 };
126
127 }
128
94 #endif 129 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698