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

Side by Side Diff: tools/clang/blink_gc_plugin/RecordInfo.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/clang/blink_gc_plugin/Edge.cpp ('k') | tools/clang/blink_gc_plugin/RecordInfo.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This file provides a wrapper for CXXRecordDecl that accumulates GC related 5 // This file provides a wrapper for CXXRecordDecl that accumulates GC related
6 // information about a class. Accumulated information is memoized and the info 6 // information about a class. Accumulated information is memoized and the info
7 // objects are stored in a RecordCache. 7 // objects are stored in a RecordCache.
8 8
9 #ifndef TOOLS_BLINK_GC_PLUGIN_RECORD_INFO_H_ 9 #ifndef TOOLS_BLINK_GC_PLUGIN_RECORD_INFO_H_
10 #define TOOLS_BLINK_GC_PLUGIN_RECORD_INFO_H_ 10 #define TOOLS_BLINK_GC_PLUGIN_RECORD_INFO_H_
(...skipping 14 matching lines...) Expand all
25 GraphPoint() : traced_(false) {} 25 GraphPoint() : traced_(false) {}
26 void MarkTraced() { traced_ = true; } 26 void MarkTraced() { traced_ = true; }
27 bool IsProperlyTraced() { return traced_ || !NeedsTracing().IsNeeded(); } 27 bool IsProperlyTraced() { return traced_ || !NeedsTracing().IsNeeded(); }
28 virtual const TracingStatus NeedsTracing() = 0; 28 virtual const TracingStatus NeedsTracing() = 0;
29 private: 29 private:
30 bool traced_; 30 bool traced_;
31 }; 31 };
32 32
33 class BasePoint : public GraphPoint { 33 class BasePoint : public GraphPoint {
34 public: 34 public:
35 BasePoint(RecordInfo* info, const TracingStatus& status) 35 BasePoint(const clang::CXXBaseSpecifier& spec,
36 : info_(info), status_(status) {} 36 RecordInfo* info,
37 RecordInfo* info() { return info_; } 37 const TracingStatus& status)
38 : spec_(spec), info_(info), status_(status) {}
38 const TracingStatus NeedsTracing() { return status_; } 39 const TracingStatus NeedsTracing() { return status_; }
39 // Needed to change the status of bases with a pure-virtual trace. 40 // Needed to change the status of bases with a pure-virtual trace.
40 void MarkUnneeded() { status_ = TracingStatus::Unneeded(); } 41 void MarkUnneeded() { status_ = TracingStatus::Unneeded(); }
42 const clang::CXXBaseSpecifier& spec() { return spec_; }
43 RecordInfo* info() { return info_; }
41 private: 44 private:
45 const clang::CXXBaseSpecifier& spec_;
42 RecordInfo* info_; 46 RecordInfo* info_;
43 TracingStatus status_; 47 TracingStatus status_;
44 }; 48 };
45 49
46 class FieldPoint : public GraphPoint { 50 class FieldPoint : public GraphPoint {
47 public: 51 public:
48 FieldPoint(clang::FieldDecl* field, Edge* edge) : field_(field), edge_(edge) { 52 FieldPoint(clang::FieldDecl* field, Edge* edge) : field_(field), edge_(edge) {
49 assert(edge && "FieldPoint edge must be non-null"); 53 assert(edge && "FieldPoint edge must be non-null");
50 } 54 }
51 const TracingStatus NeedsTracing() { 55 const TracingStatus NeedsTracing() {
(...skipping 23 matching lines...) Expand all
75 Bases& GetBases(); 79 Bases& GetBases();
76 clang::CXXMethodDecl* GetTraceMethod(); 80 clang::CXXMethodDecl* GetTraceMethod();
77 clang::CXXMethodDecl* GetTraceDispatchMethod(); 81 clang::CXXMethodDecl* GetTraceDispatchMethod();
78 82
79 bool GetTemplateArgs(size_t count, TemplateArgs* output_args); 83 bool GetTemplateArgs(size_t count, TemplateArgs* output_args);
80 84
81 bool IsHeapAllocatedCollection(); 85 bool IsHeapAllocatedCollection();
82 bool IsGCDerived(); 86 bool IsGCDerived();
83 bool IsGCAllocated(); 87 bool IsGCAllocated();
84 bool IsGCFinalized(); 88 bool IsGCFinalized();
89 bool IsUnmixedGCMixin();
85 90
86 bool IsStackAllocated(); 91 bool IsStackAllocated();
87 bool RequiresTraceMethod(); 92 bool RequiresTraceMethod();
93 bool NeedsFinalization();
88 TracingStatus NeedsTracing(Edge::NeedsTracingOption); 94 TracingStatus NeedsTracing(Edge::NeedsTracingOption);
89 95
90 private: 96 private:
91 RecordInfo(clang::CXXRecordDecl* record, RecordCache* cache); 97 RecordInfo(clang::CXXRecordDecl* record, RecordCache* cache);
92 98
93 Fields* CollectFields(); 99 Fields* CollectFields();
94 Bases* CollectBases(); 100 Bases* CollectBases();
95 void DetermineTracingMethods(); 101 void DetermineTracingMethods();
96 bool InheritsNonPureTrace(); 102 bool InheritsNonPureTrace();
97 103
(...skipping 29 matching lines...) Expand all
127 } 133 }
128 134
129 RecordInfo* Lookup(const clang::CXXRecordDecl* record) { 135 RecordInfo* Lookup(const clang::CXXRecordDecl* record) {
130 return Lookup(const_cast<clang::CXXRecordDecl*>(record)); 136 return Lookup(const_cast<clang::CXXRecordDecl*>(record));
131 } 137 }
132 138
133 RecordInfo* Lookup(clang::Decl* decl) { 139 RecordInfo* Lookup(clang::Decl* decl) {
134 return Lookup(clang::dyn_cast<clang::CXXRecordDecl>(decl)); 140 return Lookup(clang::dyn_cast<clang::CXXRecordDecl>(decl));
135 } 141 }
136 142
143 RecordInfo* Lookup(const clang::Type* type) {
144 return Lookup(type->getAsCXXRecordDecl());
145 }
146
147 RecordInfo* Lookup(const clang::QualType& type) {
148 return Lookup(type.getTypePtr());
149 }
150
137 ~RecordCache() { 151 ~RecordCache() {
138 for (Cache::iterator it = cache_.begin(); it != cache_.end(); ++it) { 152 for (Cache::iterator it = cache_.begin(); it != cache_.end(); ++it) {
139 if (!it->second.fields_) 153 if (!it->second.fields_)
140 continue; 154 continue;
141 for (RecordInfo::Fields::iterator fit = it->second.fields_->begin(); 155 for (RecordInfo::Fields::iterator fit = it->second.fields_->begin();
142 fit != it->second.fields_->end(); 156 fit != it->second.fields_->end();
143 ++fit) { 157 ++fit) {
144 fit->second.deleteEdge(); 158 fit->second.deleteEdge();
145 } 159 }
146 } 160 }
147 } 161 }
148 162
149 private: 163 private:
150 typedef std::map<clang::CXXRecordDecl*, RecordInfo> Cache; 164 typedef std::map<clang::CXXRecordDecl*, RecordInfo> Cache;
151 Cache cache_; 165 Cache cache_;
152 }; 166 };
153 167
154 #endif // TOOLS_BLINK_GC_PLUGIN_RECORD_INFO_H_ 168 #endif // TOOLS_BLINK_GC_PLUGIN_RECORD_INFO_H_
OLDNEW
« no previous file with comments | « tools/clang/blink_gc_plugin/Edge.cpp ('k') | tools/clang/blink_gc_plugin/RecordInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698