OLD | NEW |
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 clang::FieldDecl* field_; | 62 clang::FieldDecl* field_; |
63 Edge* edge_; | 63 Edge* edge_; |
64 | 64 |
65 friend class RecordCache; | 65 friend class RecordCache; |
66 void deleteEdge() { delete edge_; } | 66 void deleteEdge() { delete edge_; } |
67 }; | 67 }; |
68 | 68 |
69 // Wrapper class to lazily collect information about a C++ record. | 69 // Wrapper class to lazily collect information about a C++ record. |
70 class RecordInfo { | 70 class RecordInfo { |
71 public: | 71 public: |
72 typedef std::map<clang::CXXRecordDecl*, BasePoint> Bases; | 72 typedef std::vector<std::pair<clang::CXXRecordDecl*, BasePoint>> Bases; |
73 typedef std::map<clang::FieldDecl*, FieldPoint> Fields; | 73 |
| 74 struct FieldDeclCmp { |
| 75 bool operator()(clang::FieldDecl* a, clang::FieldDecl *b) const { |
| 76 return a->getLocStart() < b->getLocStart(); |
| 77 } |
| 78 }; |
| 79 typedef std::map<clang::FieldDecl*, FieldPoint, FieldDeclCmp> Fields; |
| 80 |
74 typedef std::vector<const clang::Type*> TemplateArgs; | 81 typedef std::vector<const clang::Type*> TemplateArgs; |
75 | 82 |
76 ~RecordInfo(); | 83 ~RecordInfo(); |
77 | 84 |
78 clang::CXXRecordDecl* record() const { return record_; } | 85 clang::CXXRecordDecl* record() const { return record_; } |
79 const std::string& name() const { return name_; } | 86 const std::string& name() const { return name_; } |
80 Fields& GetFields(); | 87 Fields& GetFields(); |
81 Bases& GetBases(); | 88 Bases& GetBases(); |
82 clang::CXXMethodDecl* GetTraceMethod(); | 89 clang::CXXMethodDecl* GetTraceMethod(); |
83 clang::CXXMethodDecl* GetTraceDispatchMethod(); | 90 clang::CXXMethodDecl* GetTraceDispatchMethod(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 188 } |
182 } | 189 } |
183 } | 190 } |
184 | 191 |
185 private: | 192 private: |
186 typedef std::map<clang::CXXRecordDecl*, RecordInfo> Cache; | 193 typedef std::map<clang::CXXRecordDecl*, RecordInfo> Cache; |
187 Cache cache_; | 194 Cache cache_; |
188 }; | 195 }; |
189 | 196 |
190 #endif // TOOLS_BLINK_GC_PLUGIN_RECORD_INFO_H_ | 197 #endif // TOOLS_BLINK_GC_PLUGIN_RECORD_INFO_H_ |
OLD | NEW |