@@ -111,9 +111,9 @@ void FileSpecificDiagnosticConsumer::computeConsumersOrderedByRange(
111
111
" overlapping ranges despite having distinct files" );
112
112
}
113
113
114
- Optional<FileSpecificDiagnosticConsumer::ConsumerAndRange *>
115
- FileSpecificDiagnosticConsumer::consumerAndRangeForLocation (
116
- SourceManager &SM, SourceLoc loc) const {
114
+ Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
115
+ FileSpecificDiagnosticConsumer::subconsumerForLocation (SourceManager &SM,
116
+ SourceLoc loc) {
117
117
// Diagnostics with invalid locations always go to every consumer.
118
118
if (loc.isInvalid ())
119
119
return None;
@@ -154,7 +154,9 @@ FileSpecificDiagnosticConsumer::consumerAndRangeForLocation(
154
154
155
155
if (possiblyContainingRangeIter != ConsumersOrderedByRange.end () &&
156
156
possiblyContainingRangeIter->contains (loc)) {
157
- return const_cast <ConsumerAndRange *>(possiblyContainingRangeIter);
157
+ auto *consumerAndRangeForLocation =
158
+ const_cast <ConsumerAndRange *>(possiblyContainingRangeIter);
159
+ return &(*this )[*consumerAndRangeForLocation];
158
160
}
159
161
160
162
return None;
@@ -167,21 +169,21 @@ void FileSpecificDiagnosticConsumer::handleDiagnostic(
167
169
168
170
HasAnErrorBeenConsumed |= Kind == DiagnosticKind::Error;
169
171
170
- Optional<ConsumerAndRange *> consumerAndRange ;
172
+ Optional<FileSpecificDiagnosticConsumer::Subconsumer *> subconsumer ;
171
173
switch (Kind) {
172
174
case DiagnosticKind::Error:
173
175
case DiagnosticKind::Warning:
174
176
case DiagnosticKind::Remark:
175
- consumerAndRange = consumerAndRangeForLocation (SM, Loc);
176
- ConsumerSpecificInfoForSubsequentNotes = consumerAndRange ;
177
+ subconsumer = subconsumerForLocation (SM, Loc);
178
+ SubconsumerForSubsequentNotes = subconsumer ;
177
179
break ;
178
180
case DiagnosticKind::Note:
179
- consumerAndRange = ConsumerSpecificInfoForSubsequentNotes ;
181
+ subconsumer = SubconsumerForSubsequentNotes ;
180
182
break ;
181
183
}
182
- if (consumerAndRange .hasValue ()) {
183
- (* this )[*consumerAndRange .getValue ()]. handleDiagnostic (
184
- SM, Loc, Kind, FormatString, FormatArgs, Info);
184
+ if (subconsumer .hasValue ()) {
185
+ subconsumer .getValue ()-> handleDiagnostic (SM, Loc, Kind, FormatString,
186
+ FormatArgs, Info);
185
187
return ;
186
188
}
187
189
for (auto &subconsumer : Subconsumers)
0 commit comments