OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "DiagnosticsReporter.h" | 5 #include "DiagnosticsReporter.h" |
6 | 6 |
7 using namespace clang; | 7 using namespace clang; |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 "[blink-gc] Left-most base class %0 of derived class %1" | 143 "[blink-gc] Left-most base class %0 of derived class %1" |
144 " must be polymorphic."; | 144 " must be polymorphic."; |
145 | 145 |
146 const char kBaseClassMustDeclareVirtualTrace[] = | 146 const char kBaseClassMustDeclareVirtualTrace[] = |
147 "[blink-gc] Left-most base class %0 of derived class %1" | 147 "[blink-gc] Left-most base class %0 of derived class %1" |
148 " must define a virtual trace method."; | 148 " must define a virtual trace method."; |
149 | 149 |
150 const char kIteratorToGCManagedCollectionNote[] = | 150 const char kIteratorToGCManagedCollectionNote[] = |
151 "[blink-gc] Iterator field %0 to a GC managed collection declared here:"; | 151 "[blink-gc] Iterator field %0 to a GC managed collection declared here:"; |
152 | 152 |
| 153 const char kTraceMethodOfStackAllocatedParentNote[] = |
| 154 "[blink-gc] The stack allocated class %0 provides an unnecessary " |
| 155 "trace method:"; |
| 156 |
153 } // namespace | 157 } // namespace |
154 | 158 |
155 DiagnosticBuilder DiagnosticsReporter::ReportDiagnostic( | 159 DiagnosticBuilder DiagnosticsReporter::ReportDiagnostic( |
156 SourceLocation location, | 160 SourceLocation location, |
157 unsigned diag_id) { | 161 unsigned diag_id) { |
158 SourceManager& manager = instance_.getSourceManager(); | 162 SourceManager& manager = instance_.getSourceManager(); |
159 FullSourceLoc full_loc(location, manager); | 163 FullSourceLoc full_loc(location, manager); |
160 return diagnostic_.Report(full_loc, diag_id); | 164 return diagnostic_.Report(full_loc, diag_id); |
161 } | 165 } |
162 | 166 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 diag_class_overrides_new_ = | 209 diag_class_overrides_new_ = |
206 diagnostic_.getCustomDiagID(getErrorLevel(), kClassOverridesNew); | 210 diagnostic_.getCustomDiagID(getErrorLevel(), kClassOverridesNew); |
207 diag_class_declares_pure_virtual_trace_ = diagnostic_.getCustomDiagID( | 211 diag_class_declares_pure_virtual_trace_ = diagnostic_.getCustomDiagID( |
208 getErrorLevel(), kClassDeclaresPureVirtualTrace); | 212 getErrorLevel(), kClassDeclaresPureVirtualTrace); |
209 diag_left_most_base_must_be_polymorphic_ = diagnostic_.getCustomDiagID( | 213 diag_left_most_base_must_be_polymorphic_ = diagnostic_.getCustomDiagID( |
210 getErrorLevel(), kLeftMostBaseMustBePolymorphic); | 214 getErrorLevel(), kLeftMostBaseMustBePolymorphic); |
211 diag_base_class_must_declare_virtual_trace_ = diagnostic_.getCustomDiagID( | 215 diag_base_class_must_declare_virtual_trace_ = diagnostic_.getCustomDiagID( |
212 getErrorLevel(), kBaseClassMustDeclareVirtualTrace); | 216 getErrorLevel(), kBaseClassMustDeclareVirtualTrace); |
213 diag_iterator_to_gc_managed_collection_note_ = diagnostic_.getCustomDiagID( | 217 diag_iterator_to_gc_managed_collection_note_ = diagnostic_.getCustomDiagID( |
214 getErrorLevel(), kIteratorToGCManagedCollectionNote); | 218 getErrorLevel(), kIteratorToGCManagedCollectionNote); |
| 219 diag_trace_method_of_stack_allocated_parent_ = diagnostic_.getCustomDiagID( |
| 220 getErrorLevel(), kTraceMethodOfStackAllocatedParentNote); |
215 | 221 |
216 // Register note messages. | 222 // Register note messages. |
217 diag_base_requires_tracing_note_ = diagnostic_.getCustomDiagID( | 223 diag_base_requires_tracing_note_ = diagnostic_.getCustomDiagID( |
218 DiagnosticsEngine::Note, kBaseRequiresTracingNote); | 224 DiagnosticsEngine::Note, kBaseRequiresTracingNote); |
219 diag_field_requires_tracing_note_ = diagnostic_.getCustomDiagID( | 225 diag_field_requires_tracing_note_ = diagnostic_.getCustomDiagID( |
220 DiagnosticsEngine::Note, kFieldRequiresTracingNote); | 226 DiagnosticsEngine::Note, kFieldRequiresTracingNote); |
221 diag_field_should_not_be_traced_note_ = diagnostic_.getCustomDiagID( | 227 diag_field_should_not_be_traced_note_ = diagnostic_.getCustomDiagID( |
222 DiagnosticsEngine::Note, kFieldShouldNotBeTracedNote); | 228 DiagnosticsEngine::Note, kFieldShouldNotBeTracedNote); |
223 diag_raw_ptr_to_gc_managed_class_note_ = diagnostic_.getCustomDiagID( | 229 diag_raw_ptr_to_gc_managed_class_note_ = diagnostic_.getCustomDiagID( |
224 DiagnosticsEngine::Note, kRawPtrToGCManagedClassNote); | 230 DiagnosticsEngine::Note, kRawPtrToGCManagedClassNote); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 } | 498 } |
493 | 499 |
494 void DiagnosticsReporter::BaseClassMustDeclareVirtualTrace( | 500 void DiagnosticsReporter::BaseClassMustDeclareVirtualTrace( |
495 RecordInfo* derived, | 501 RecordInfo* derived, |
496 CXXRecordDecl* base) { | 502 CXXRecordDecl* base) { |
497 ReportDiagnostic(base->getLocStart(), | 503 ReportDiagnostic(base->getLocStart(), |
498 diag_base_class_must_declare_virtual_trace_) | 504 diag_base_class_must_declare_virtual_trace_) |
499 << base << derived->record(); | 505 << base << derived->record(); |
500 } | 506 } |
501 | 507 |
| 508 void DiagnosticsReporter::TraceMethodForStackAllocatedClass( |
| 509 RecordInfo* info, |
| 510 CXXMethodDecl* trace) { |
| 511 ReportDiagnostic(trace->getLocStart(), |
| 512 diag_trace_method_of_stack_allocated_parent_) |
| 513 << info->record(); |
| 514 } |
| 515 |
502 void DiagnosticsReporter::NoteManualDispatchMethod(CXXMethodDecl* dispatch) { | 516 void DiagnosticsReporter::NoteManualDispatchMethod(CXXMethodDecl* dispatch) { |
503 ReportDiagnostic(dispatch->getLocStart(), | 517 ReportDiagnostic(dispatch->getLocStart(), |
504 diag_manual_dispatch_method_note_) | 518 diag_manual_dispatch_method_note_) |
505 << dispatch; | 519 << dispatch; |
506 } | 520 } |
507 | 521 |
508 void DiagnosticsReporter::NoteBaseRequiresTracing(BasePoint* base) { | 522 void DiagnosticsReporter::NoteBaseRequiresTracing(BasePoint* base) { |
509 ReportDiagnostic(base->spec().getLocStart(), | 523 ReportDiagnostic(base->spec().getLocStart(), |
510 diag_base_requires_tracing_note_) | 524 diag_base_requires_tracing_note_) |
511 << base->info()->record(); | 525 << base->info()->record(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 void DiagnosticsReporter::NoteField(FieldDecl* field, unsigned note) { | 573 void DiagnosticsReporter::NoteField(FieldDecl* field, unsigned note) { |
560 ReportDiagnostic(field->getLocStart(), note) << field; | 574 ReportDiagnostic(field->getLocStart(), note) << field; |
561 } | 575 } |
562 | 576 |
563 void DiagnosticsReporter::NoteOverriddenNonVirtualTrace( | 577 void DiagnosticsReporter::NoteOverriddenNonVirtualTrace( |
564 CXXMethodDecl* overridden) { | 578 CXXMethodDecl* overridden) { |
565 ReportDiagnostic(overridden->getLocStart(), | 579 ReportDiagnostic(overridden->getLocStart(), |
566 diag_overridden_non_virtual_trace_note_) | 580 diag_overridden_non_virtual_trace_note_) |
567 << overridden; | 581 << overridden; |
568 } | 582 } |
OLD | NEW |