OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "BlinkGCPluginConsumer.h" | 5 #include "BlinkGCPluginConsumer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "CheckDispatchVisitor.h" | 10 #include "CheckDispatchVisitor.h" |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 } | 521 } |
522 | 522 |
523 CheckTraceOrDispatchMethod(parent, method); | 523 CheckTraceOrDispatchMethod(parent, method); |
524 } | 524 } |
525 | 525 |
526 void BlinkGCPluginConsumer::CheckTraceOrDispatchMethod( | 526 void BlinkGCPluginConsumer::CheckTraceOrDispatchMethod( |
527 RecordInfo* parent, | 527 RecordInfo* parent, |
528 CXXMethodDecl* method) { | 528 CXXMethodDecl* method) { |
529 Config::TraceMethodType trace_type = Config::GetTraceMethodType(method); | 529 Config::TraceMethodType trace_type = Config::GetTraceMethodType(method); |
530 if (trace_type == Config::TRACE_AFTER_DISPATCH_METHOD || | 530 if (trace_type == Config::TRACE_AFTER_DISPATCH_METHOD || |
531 trace_type == Config::TRACE_AFTER_DISPATCH_IMPL_METHOD || | |
532 !parent->GetTraceDispatchMethod()) { | 531 !parent->GetTraceDispatchMethod()) { |
533 CheckTraceMethod(parent, method, trace_type); | 532 CheckTraceMethod(parent, method, trace_type); |
534 } | 533 } |
535 // Dispatch methods are checked when we identify subclasses. | 534 // Dispatch methods are checked when we identify subclasses. |
536 } | 535 } |
537 | 536 |
538 void BlinkGCPluginConsumer::CheckTraceMethod( | 537 void BlinkGCPluginConsumer::CheckTraceMethod( |
539 RecordInfo* parent, | 538 RecordInfo* parent, |
540 CXXMethodDecl* trace, | 539 CXXMethodDecl* trace, |
541 Config::TraceMethodType trace_type) { | 540 Config::TraceMethodType trace_type) { |
542 // A trace method must not override any non-virtual trace methods. | 541 // A trace method must not override any non-virtual trace methods. |
543 if (trace_type == Config::TRACE_METHOD) { | 542 if (trace_type == Config::TRACE_METHOD) { |
544 for (auto& base : parent->GetBases()) | 543 for (auto& base : parent->GetBases()) |
545 if (CXXMethodDecl* other = base.second.info()->InheritsNonVirtualTrace()) | 544 if (CXXMethodDecl* other = base.second.info()->InheritsNonVirtualTrace()) |
546 reporter_.OverriddenNonVirtualTrace(parent, trace, other); | 545 reporter_.OverriddenNonVirtualTrace(parent, trace, other); |
547 } | 546 } |
548 | 547 |
549 CheckTraceVisitor visitor(trace, parent, &cache_); | 548 CheckTraceVisitor visitor(trace, parent, &cache_); |
550 visitor.TraverseCXXMethodDecl(trace); | 549 visitor.TraverseCXXMethodDecl(trace); |
551 | 550 |
552 // Skip reporting if this trace method is a just delegate to | |
553 // traceImpl (or traceAfterDispatchImpl) method. We will report on | |
554 // CheckTraceMethod on traceImpl method. | |
555 if (visitor.delegates_to_traceimpl()) | |
556 return; | |
557 | |
558 for (auto& base : parent->GetBases()) | 551 for (auto& base : parent->GetBases()) |
559 if (!base.second.IsProperlyTraced()) | 552 if (!base.second.IsProperlyTraced()) |
560 reporter_.BaseRequiresTracing(parent, trace, base.first); | 553 reporter_.BaseRequiresTracing(parent, trace, base.first); |
561 | 554 |
562 for (auto& field : parent->GetFields()) { | 555 for (auto& field : parent->GetFields()) { |
563 if (!field.second.IsProperlyTraced() || | 556 if (!field.second.IsProperlyTraced() || |
564 field.second.IsInproperlyTraced()) { | 557 field.second.IsInproperlyTraced()) { |
565 // Report one or more tracing-related field errors. | 558 // Report one or more tracing-related field errors. |
566 reporter_.FieldsImproperlyTraced(parent, trace); | 559 reporter_.FieldsImproperlyTraced(parent, trace); |
567 break; | 560 break; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 SourceLocation spelling_location = source_manager.getSpellingLoc(loc); | 715 SourceLocation spelling_location = source_manager.getSpellingLoc(loc); |
723 PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location); | 716 PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location); |
724 if (ploc.isInvalid()) { | 717 if (ploc.isInvalid()) { |
725 // If we're in an invalid location, we're looking at things that aren't | 718 // If we're in an invalid location, we're looking at things that aren't |
726 // actually stated in the source. | 719 // actually stated in the source. |
727 return false; | 720 return false; |
728 } | 721 } |
729 *filename = ploc.getFilename(); | 722 *filename = ploc.getFilename(); |
730 return true; | 723 return true; |
731 } | 724 } |
OLD | NEW |