| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 " is not permitted to declare a pure-virtual trace method."; | 140 " is not permitted to declare a pure-virtual trace method."; |
| 141 | 141 |
| 142 const char kLeftMostBaseMustBePolymorphic[] = | 142 const char kLeftMostBaseMustBePolymorphic[] = |
| 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[] = |
| 151 "[blink-gc] Iterator field %0 to a GC managed collection declared here:"; |
| 152 |
| 150 } // namespace | 153 } // namespace |
| 151 | 154 |
| 152 DiagnosticBuilder DiagnosticsReporter::ReportDiagnostic( | 155 DiagnosticBuilder DiagnosticsReporter::ReportDiagnostic( |
| 153 SourceLocation location, | 156 SourceLocation location, |
| 154 unsigned diag_id) { | 157 unsigned diag_id) { |
| 155 SourceManager& manager = instance_.getSourceManager(); | 158 SourceManager& manager = instance_.getSourceManager(); |
| 156 FullSourceLoc full_loc(location, manager); | 159 FullSourceLoc full_loc(location, manager); |
| 157 return diagnostic_.Report(full_loc, diag_id); | 160 return diagnostic_.Report(full_loc, diag_id); |
| 158 } | 161 } |
| 159 | 162 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 diag_user_declared_finalizer_note_ = diagnostic_.getCustomDiagID( | 249 diag_user_declared_finalizer_note_ = diagnostic_.getCustomDiagID( |
| 247 DiagnosticsEngine::Note, kUserDeclaredFinalizerNote); | 250 DiagnosticsEngine::Note, kUserDeclaredFinalizerNote); |
| 248 diag_base_requires_finalization_note_ = diagnostic_.getCustomDiagID( | 251 diag_base_requires_finalization_note_ = diagnostic_.getCustomDiagID( |
| 249 DiagnosticsEngine::Note, kBaseRequiresFinalizationNote); | 252 DiagnosticsEngine::Note, kBaseRequiresFinalizationNote); |
| 250 diag_field_requires_finalization_note_ = diagnostic_.getCustomDiagID( | 253 diag_field_requires_finalization_note_ = diagnostic_.getCustomDiagID( |
| 251 DiagnosticsEngine::Note, kFieldRequiresFinalizationNote); | 254 DiagnosticsEngine::Note, kFieldRequiresFinalizationNote); |
| 252 diag_overridden_non_virtual_trace_note_ = diagnostic_.getCustomDiagID( | 255 diag_overridden_non_virtual_trace_note_ = diagnostic_.getCustomDiagID( |
| 253 DiagnosticsEngine::Note, kOverriddenNonVirtualTraceNote); | 256 DiagnosticsEngine::Note, kOverriddenNonVirtualTraceNote); |
| 254 diag_manual_dispatch_method_note_ = diagnostic_.getCustomDiagID( | 257 diag_manual_dispatch_method_note_ = diagnostic_.getCustomDiagID( |
| 255 DiagnosticsEngine::Note, kManualDispatchMethodNote); | 258 DiagnosticsEngine::Note, kManualDispatchMethodNote); |
| 259 diag_iterator_to_gc_managed_collection_note_ = diagnostic_.getCustomDiagID( |
| 260 DiagnosticsEngine::Note, kIteratorToGCManagedCollectionNote); |
| 256 } | 261 } |
| 257 | 262 |
| 258 bool DiagnosticsReporter::hasErrorOccurred() const | 263 bool DiagnosticsReporter::hasErrorOccurred() const |
| 259 { | 264 { |
| 260 return diagnostic_.hasErrorOccurred(); | 265 return diagnostic_.hasErrorOccurred(); |
| 261 } | 266 } |
| 262 | 267 |
| 263 DiagnosticsEngine::Level DiagnosticsReporter::getErrorLevel() const { | 268 DiagnosticsEngine::Level DiagnosticsReporter::getErrorLevel() const { |
| 264 return diagnostic_.getWarningsAsErrors() ? DiagnosticsEngine::Error | 269 return diagnostic_.getWarningsAsErrors() ? DiagnosticsEngine::Error |
| 265 : DiagnosticsEngine::Warning; | 270 : DiagnosticsEngine::Warning; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 } else if (error.second == CheckFieldsVisitor::kUniquePtrToGCManaged) { | 341 } else if (error.second == CheckFieldsVisitor::kUniquePtrToGCManaged) { |
| 337 note = diag_unique_ptr_to_gc_managed_class_note_; | 342 note = diag_unique_ptr_to_gc_managed_class_note_; |
| 338 } else if (error.second == CheckFieldsVisitor::kMemberToGCUnmanaged) { | 343 } else if (error.second == CheckFieldsVisitor::kMemberToGCUnmanaged) { |
| 339 note = diag_member_to_gc_unmanaged_class_note_; | 344 note = diag_member_to_gc_unmanaged_class_note_; |
| 340 } else if (error.second == CheckFieldsVisitor::kMemberInUnmanaged) { | 345 } else if (error.second == CheckFieldsVisitor::kMemberInUnmanaged) { |
| 341 note = diag_member_in_unmanaged_class_note_; | 346 note = diag_member_in_unmanaged_class_note_; |
| 342 } else if (error.second == CheckFieldsVisitor::kPtrFromHeapToStack) { | 347 } else if (error.second == CheckFieldsVisitor::kPtrFromHeapToStack) { |
| 343 note = diag_stack_allocated_field_note_; | 348 note = diag_stack_allocated_field_note_; |
| 344 } else if (error.second == CheckFieldsVisitor::kGCDerivedPartObject) { | 349 } else if (error.second == CheckFieldsVisitor::kGCDerivedPartObject) { |
| 345 note = diag_part_object_to_gc_derived_class_note_; | 350 note = diag_part_object_to_gc_derived_class_note_; |
| 351 } else if (error.second == CheckFieldsVisitor::kIteratorToGCManaged) { |
| 352 note = diag_iterator_to_gc_managed_collection_note_; |
| 346 } else { | 353 } else { |
| 347 assert(false && "Unknown field error"); | 354 assert(false && "Unknown field error"); |
| 348 } | 355 } |
| 349 NoteField(error.first, note); | 356 NoteField(error.first, note); |
| 350 } | 357 } |
| 351 } | 358 } |
| 352 | 359 |
| 353 void DiagnosticsReporter::ClassContainsGCRoots( | 360 void DiagnosticsReporter::ClassContainsGCRoots( |
| 354 RecordInfo* info, | 361 RecordInfo* info, |
| 355 const CheckGCRootsVisitor::Errors& errors) { | 362 const CheckGCRootsVisitor::Errors& errors) { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 void DiagnosticsReporter::NoteField(FieldDecl* field, unsigned note) { | 559 void DiagnosticsReporter::NoteField(FieldDecl* field, unsigned note) { |
| 553 ReportDiagnostic(field->getLocStart(), note) << field; | 560 ReportDiagnostic(field->getLocStart(), note) << field; |
| 554 } | 561 } |
| 555 | 562 |
| 556 void DiagnosticsReporter::NoteOverriddenNonVirtualTrace( | 563 void DiagnosticsReporter::NoteOverriddenNonVirtualTrace( |
| 557 CXXMethodDecl* overridden) { | 564 CXXMethodDecl* overridden) { |
| 558 ReportDiagnostic(overridden->getLocStart(), | 565 ReportDiagnostic(overridden->getLocStart(), |
| 559 diag_overridden_non_virtual_trace_note_) | 566 diag_overridden_non_virtual_trace_note_) |
| 560 << overridden; | 567 << overridden; |
| 561 } | 568 } |
| OLD | NEW |