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 #include "Config.h" | 5 #include "Config.h" |
6 #include "RecordInfo.h" | 6 #include "RecordInfo.h" |
7 | 7 |
8 using namespace clang; | 8 using namespace clang; |
9 using std::string; | 9 using std::string; |
10 | 10 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 CXXMethodDecl* RecordInfo::DeclaresNewOperator() { | 233 CXXMethodDecl* RecordInfo::DeclaresNewOperator() { |
234 for (CXXRecordDecl::method_iterator it = record_->method_begin(); | 234 for (CXXRecordDecl::method_iterator it = record_->method_begin(); |
235 it != record_->method_end(); | 235 it != record_->method_end(); |
236 ++it) { | 236 ++it) { |
237 if (it->getNameAsString() == kNewOperatorName && it->getNumParams() == 1) | 237 if (it->getNameAsString() == kNewOperatorName && it->getNumParams() == 1) |
238 return *it; | 238 return *it; |
239 } | 239 } |
240 return 0; | 240 return 0; |
241 } | 241 } |
242 | 242 |
243 // An object requires a tracing method if it has any fields that need tracing. | 243 // An object requires a tracing method if it has any fields that need tracing |
| 244 // or if it inherits from multiple bases that need tracing. |
244 bool RecordInfo::RequiresTraceMethod() { | 245 bool RecordInfo::RequiresTraceMethod() { |
245 if (IsStackAllocated()) | 246 if (IsStackAllocated()) |
246 return false; | 247 return false; |
| 248 unsigned bases_with_trace = 0; |
| 249 for (Bases::iterator it = GetBases().begin(); it != GetBases().end(); ++it) { |
| 250 if (it->second.NeedsTracing().IsNeeded()) |
| 251 ++bases_with_trace; |
| 252 } |
| 253 if (bases_with_trace > 1) |
| 254 return true; |
247 GetFields(); | 255 GetFields(); |
248 return fields_need_tracing_.IsNeeded(); | 256 return fields_need_tracing_.IsNeeded(); |
249 } | 257 } |
250 | 258 |
251 // Get the actual tracing method (ie, can be traceAfterDispatch if there is a | 259 // Get the actual tracing method (ie, can be traceAfterDispatch if there is a |
252 // dispatch method). | 260 // dispatch method). |
253 CXXMethodDecl* RecordInfo::GetTraceMethod() { | 261 CXXMethodDecl* RecordInfo::GetTraceMethod() { |
254 DetermineTracingMethods(); | 262 DetermineTracingMethods(); |
255 return trace_method_; | 263 return trace_method_; |
256 } | 264 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 edge->members().push_back(member); | 524 edge->members().push_back(member); |
517 } | 525 } |
518 // TODO: Handle the case where we fail to create an edge (eg, if the | 526 // TODO: Handle the case where we fail to create an edge (eg, if the |
519 // argument is a primitive type or just not fully known yet). | 527 // argument is a primitive type or just not fully known yet). |
520 } | 528 } |
521 return edge; | 529 return edge; |
522 } | 530 } |
523 | 531 |
524 return new Value(info); | 532 return new Value(info); |
525 } | 533 } |
OLD | NEW |