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

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

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