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

Side by Side Diff: tools/clang/blink_gc_plugin/RecordInfo.h

Issue 2068983003: Revert of GC plugin: improve error reporting when tracing illegal fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« 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_
11 11
12 #include <map> 12 #include <map>
13 #include <vector> 13 #include <vector>
14 14
15 #include "Edge.h" 15 #include "Edge.h"
16 16
17 #include "clang/AST/AST.h" 17 #include "clang/AST/AST.h"
18 #include "clang/AST/CXXInheritance.h" 18 #include "clang/AST/CXXInheritance.h"
19 #include "clang/Frontend/CompilerInstance.h"
20 19
21 class RecordCache; 20 class RecordCache;
22 21
23 // A potentially tracable and/or lifetime affecting point in the object graph. 22 // A potentially tracable and/or lifetime affecting point in the object graph.
24 class GraphPoint { 23 class GraphPoint {
25 public: 24 public:
26 GraphPoint() : traced_(false) {} 25 GraphPoint() : traced_(false) {}
27 virtual ~GraphPoint() {} 26 virtual ~GraphPoint() {}
28 void MarkTraced() { traced_ = true; } 27 void MarkTraced() { traced_ = true; }
29 bool IsProperlyTraced() { return traced_ || !NeedsTracing().IsNeeded(); } 28 bool IsProperlyTraced() { return traced_ || !NeedsTracing().IsNeeded(); }
30 bool IsInproperlyTraced() { return traced_ && NeedsTracing().IsIllegal(); }
31 virtual const TracingStatus NeedsTracing() = 0; 29 virtual const TracingStatus NeedsTracing() = 0;
32 30
33 private: 31 private:
34 bool traced_; 32 bool traced_;
35 }; 33 };
36 34
37 class BasePoint : public GraphPoint { 35 class BasePoint : public GraphPoint {
38 public: 36 public:
39 BasePoint(const clang::CXXBaseSpecifier& spec, 37 BasePoint(const clang::CXXBaseSpecifier& spec,
40 RecordInfo* info, 38 RecordInfo* info,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 151
154 bool is_gc_derived_; 152 bool is_gc_derived_;
155 153
156 std::vector<std::string> gc_base_names_; 154 std::vector<std::string> gc_base_names_;
157 155
158 friend class RecordCache; 156 friend class RecordCache;
159 }; 157 };
160 158
161 class RecordCache { 159 class RecordCache {
162 public: 160 public:
163 RecordCache(clang::CompilerInstance& instance)
164 : instance_(instance)
165 {
166 }
167
168 RecordInfo* Lookup(clang::CXXRecordDecl* record); 161 RecordInfo* Lookup(clang::CXXRecordDecl* record);
169 162
170 RecordInfo* Lookup(const clang::CXXRecordDecl* record) { 163 RecordInfo* Lookup(const clang::CXXRecordDecl* record) {
171 return Lookup(const_cast<clang::CXXRecordDecl*>(record)); 164 return Lookup(const_cast<clang::CXXRecordDecl*>(record));
172 } 165 }
173 166
174 RecordInfo* Lookup(clang::DeclContext* decl) { 167 RecordInfo* Lookup(clang::DeclContext* decl) {
175 return Lookup(clang::dyn_cast<clang::CXXRecordDecl>(decl)); 168 return Lookup(clang::dyn_cast<clang::CXXRecordDecl>(decl));
176 } 169 }
177 170
(...skipping 10 matching lines...) Expand all
188 if (!it->second.fields_) 181 if (!it->second.fields_)
189 continue; 182 continue;
190 for (RecordInfo::Fields::iterator fit = it->second.fields_->begin(); 183 for (RecordInfo::Fields::iterator fit = it->second.fields_->begin();
191 fit != it->second.fields_->end(); 184 fit != it->second.fields_->end();
192 ++fit) { 185 ++fit) {
193 fit->second.deleteEdge(); 186 fit->second.deleteEdge();
194 } 187 }
195 } 188 }
196 } 189 }
197 190
198 clang::CompilerInstance& instance() const { return instance_; }
199
200 private: 191 private:
201 clang::CompilerInstance& instance_;
202
203 typedef std::map<clang::CXXRecordDecl*, RecordInfo> Cache; 192 typedef std::map<clang::CXXRecordDecl*, RecordInfo> Cache;
204 Cache cache_; 193 Cache cache_;
205 }; 194 };
206 195
207 #endif // TOOLS_BLINK_GC_PLUGIN_RECORD_INFO_H_ 196 #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