@@ -1062,18 +1062,21 @@ DiagnosticEngine::diagnosticInfoForDiagnostic(const Diagnostic &diagnostic) {
1062
1062
void DiagnosticEngine::emitDiagnostic (const Diagnostic &diagnostic) {
1063
1063
if (auto info = diagnosticInfoForDiagnostic (diagnostic)) {
1064
1064
SmallVector<DiagnosticInfo, 1 > childInfo;
1065
- TinyPtrVector<DiagnosticInfo *> childInfoPtrs;
1066
1065
auto childNotes = diagnostic.getChildNotes ();
1067
- for (unsigned idx = 0 ; idx < childNotes.size (); ++idx) {
1068
- if (auto child = diagnosticInfoForDiagnostic (childNotes[idx])) {
1069
- childInfo.push_back (*child);
1070
- childInfoPtrs.push_back (&childInfo[idx]);
1071
- }
1066
+ for (unsigned i : indices (childNotes)) {
1067
+ auto child = diagnosticInfoForDiagnostic (childNotes[i]);
1068
+ assert (child);
1069
+ assert (child->Kind == DiagnosticKind::Note &&
1070
+ " Expected child diagnostics to all be notes?!" );
1071
+ childInfo.push_back (*child);
1072
+ }
1073
+ TinyPtrVector<DiagnosticInfo *> childInfoPtrs;
1074
+ for (unsigned i : indices (childInfo)) {
1075
+ childInfoPtrs.push_back (&childInfo[i]);
1072
1076
}
1073
1077
info->ChildDiagnosticInfo = childInfoPtrs;
1074
-
1075
- SmallVector<std::string, 1 > educationalNotePaths;
1076
1078
1079
+ SmallVector<std::string, 1 > educationalNotePaths;
1077
1080
auto associatedNotes = educationalNotes[(uint32_t )diagnostic.getID ()];
1078
1081
while (associatedNotes && *associatedNotes) {
1079
1082
SmallString<128 > notePath (getDiagnosticDocumentationPath ());
0 commit comments