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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 fields_need_tracing_ = fields_status; | 419 fields_need_tracing_ = fields_status; |
420 return fields; | 420 return fields; |
421 } | 421 } |
422 | 422 |
423 void RecordInfo::DetermineTracingMethods() { | 423 void RecordInfo::DetermineTracingMethods() { |
424 if (determined_trace_methods_) | 424 if (determined_trace_methods_) |
425 return; | 425 return; |
426 determined_trace_methods_ = true; | 426 determined_trace_methods_ = true; |
427 if (Config::IsGCBase(name_)) | 427 if (Config::IsGCBase(name_)) |
428 return; | 428 return; |
429 CXXMethodDecl* trace = 0; | 429 CXXMethodDecl* trace = nullptr; |
430 CXXMethodDecl* traceAfterDispatch = 0; | 430 CXXMethodDecl* trace_after_dispatch = nullptr; |
431 bool isTraceAfterDispatch; | 431 bool has_adjust_and_mark = false; |
432 bool hasAdjustAndMark = false; | 432 bool has_is_heap_object_alive = false; |
433 bool hasIsHeapObjectAlive = false; | |
434 for (CXXRecordDecl::method_iterator it = record_->method_begin(); | 433 for (CXXRecordDecl::method_iterator it = record_->method_begin(); |
435 it != record_->method_end(); | 434 it != record_->method_end(); |
436 ++it) { | 435 ++it) { |
437 if (Config::IsTraceMethod(*it, &isTraceAfterDispatch)) { | 436 switch (Config::GetTraceMethodType(*it)) { |
438 if (isTraceAfterDispatch) { | 437 case Config::TRACE_METHOD: |
439 traceAfterDispatch = *it; | |
440 } else { | |
441 trace = *it; | 438 trace = *it; |
442 } | 439 break; |
443 } else if (it->getNameAsString() == kFinalizeName) { | 440 case Config::TRACE_AFTER_DISPATCH_METHOD: |
444 finalize_dispatch_method_ = *it; | 441 trace_after_dispatch = *it; |
445 } else if (it->getNameAsString() == kAdjustAndMarkName) { | 442 break; |
446 hasAdjustAndMark = true; | 443 case Config::TRACE_IMPL_METHOD: |
447 } else if (it->getNameAsString() == kIsHeapObjectAliveName) { | 444 case Config::TRACE_AFTER_DISPATCH_IMPL_METHOD: |
448 hasIsHeapObjectAlive = true; | 445 break; |
| 446 case Config::NOT_TRACE_METHOD: |
| 447 if (it->getNameAsString() == kFinalizeName) { |
| 448 finalize_dispatch_method_ = *it; |
| 449 } else if (it->getNameAsString() == kAdjustAndMarkName) { |
| 450 has_adjust_and_mark = true; |
| 451 } else if (it->getNameAsString() == kIsHeapObjectAliveName) { |
| 452 has_is_heap_object_alive = true; |
| 453 } |
| 454 break; |
449 } | 455 } |
450 } | 456 } |
451 // Record if class defines the two GCMixin methods. | 457 // Record if class defines the two GCMixin methods. |
452 has_gc_mixin_methods_ = | 458 has_gc_mixin_methods_ = |
453 hasAdjustAndMark && hasIsHeapObjectAlive ? kTrue : kFalse; | 459 has_adjust_and_mark && has_is_heap_object_alive ? kTrue : kFalse; |
454 if (traceAfterDispatch) { | 460 if (trace_after_dispatch) { |
455 trace_method_ = traceAfterDispatch; | 461 trace_method_ = trace_after_dispatch; |
456 trace_dispatch_method_ = trace; | 462 trace_dispatch_method_ = trace; |
457 } else { | 463 } else { |
458 // TODO: Can we never have a dispatch method called trace without the same | 464 // TODO: Can we never have a dispatch method called trace without the same |
459 // class defining a traceAfterDispatch method? | 465 // class defining a traceAfterDispatch method? |
460 trace_method_ = trace; | 466 trace_method_ = trace; |
461 trace_dispatch_method_ = 0; | 467 trace_dispatch_method_ = nullptr; |
462 } | 468 } |
463 if (trace_dispatch_method_ && finalize_dispatch_method_) | 469 if (trace_dispatch_method_ && finalize_dispatch_method_) |
464 return; | 470 return; |
465 // If this class does not define dispatching methods inherit them. | 471 // If this class does not define dispatching methods inherit them. |
466 for (Bases::iterator it = GetBases().begin(); it != GetBases().end(); ++it) { | 472 for (Bases::iterator it = GetBases().begin(); it != GetBases().end(); ++it) { |
467 // TODO: Does it make sense to inherit multiple dispatch methods? | 473 // TODO: Does it make sense to inherit multiple dispatch methods? |
468 if (CXXMethodDecl* dispatch = it->second.info()->GetTraceDispatchMethod()) { | 474 if (CXXMethodDecl* dispatch = it->second.info()->GetTraceDispatchMethod()) { |
469 assert(!trace_dispatch_method_ && "Multiple trace dispatching methods"); | 475 assert(!trace_dispatch_method_ && "Multiple trace dispatching methods"); |
470 trace_dispatch_method_ = dispatch; | 476 trace_dispatch_method_ = dispatch; |
471 } | 477 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 edge->members().push_back(member); | 631 edge->members().push_back(member); |
626 } | 632 } |
627 // TODO: Handle the case where we fail to create an edge (eg, if the | 633 // TODO: Handle the case where we fail to create an edge (eg, if the |
628 // argument is a primitive type or just not fully known yet). | 634 // argument is a primitive type or just not fully known yet). |
629 } | 635 } |
630 return edge; | 636 return edge; |
631 } | 637 } |
632 | 638 |
633 return new Value(info); | 639 return new Value(info); |
634 } | 640 } |
OLD | NEW |