Index: tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp |
diff --git a/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp b/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp |
index c90510e93d76fc67c8c98b886e7981f8bf61c4c0..6c52c7712a722b70ea744acc68675f01bb5d0e4f 100644 |
--- a/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp |
+++ b/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp |
@@ -973,19 +973,23 @@ void BlinkGCPluginConsumer::ReportClassRequiresTraceMethod(RecordInfo* info) { |
diag_class_requires_trace_method_) |
<< info->record(); |
- for (RecordInfo::Bases::iterator it = info->GetBases().begin(); |
- it != info->GetBases().end(); |
- ++it) { |
- if (it->second.NeedsTracing().IsNeeded()) |
- NoteBaseRequiresTracing(&it->second); |
+ // Use an intermediate map to sort the notes by source location. |
+ std::map<clang::SourceLocation, BasePoint*> BaseNotes; |
+ for (auto& pair : info->GetBases()) { |
+ if (pair.second.NeedsTracing().IsNeeded()) |
+ BaseNotes.insert(std::make_pair(pair.first->getLocStart(), &pair.second)); |
} |
- |
- for (RecordInfo::Fields::iterator it = info->GetFields().begin(); |
- it != info->GetFields().end(); |
- ++it) { |
- if (!it->second.IsProperlyTraced()) |
- NoteFieldRequiresTracing(info, it->first); |
+ for (auto& pair : BaseNotes) |
+ NoteBaseRequiresTracing(pair.second); |
+ |
+ // Use an intermediate map to sort the notes by source location. |
+ std::map<clang::SourceLocation, clang::FieldDecl*> FieldNotes; |
+ for (auto& pair : info->GetFields()) { |
+ if (!pair.second.IsProperlyTraced()) |
+ FieldNotes.insert(std::make_pair(pair.first->getLocStart(), pair.first)); |
} |
+ for (auto& pair : FieldNotes) |
+ NoteFieldRequiresTracing(info, pair.second); |
} |
void BlinkGCPluginConsumer::ReportBaseRequiresTracing( |