Skip to content

Commit 7e19f78

Browse files
committed
consumerAndRangeForLocation -> subconsumerForLocation
1 parent b4d9429 commit 7e19f78

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

include/swift/AST/DiagnosticConsumer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
251251
/// This allows diagnostics to be emitted before files are actually opened,
252252
/// as long as they don't have source locations.
253253
///
254-
/// \see #consumerAndRangeForLocation
254+
/// \see #subconsumerForLocation
255255
SmallVector<ConsumerAndRange, 4> ConsumersOrderedByRange;
256256

257257
/// Indicates which consumer to send Note diagnostics too.
@@ -261,7 +261,7 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
261261
///
262262
/// If None, Note diagnostics are sent to every consumer.
263263
/// If null, diagnostics are suppressed.
264-
Optional<ConsumerAndRange *> ConsumerSpecificInfoForSubsequentNotes = None;
264+
Optional<Subconsumer *> SubconsumerForSubsequentNotes = None;
265265

266266
bool HasAnErrorBeenConsumed = false;
267267

@@ -293,8 +293,8 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
293293
/// Returns nullptr if diagnostic is to be suppressed,
294294
/// None if diagnostic is to be distributed to every consumer,
295295
/// a particular consumer if diagnostic goes there.
296-
Optional<ConsumerAndRange *> consumerAndRangeForLocation(SourceManager &SM,
297-
SourceLoc loc) const;
296+
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
297+
subconsumerForLocation(SourceManager &SM, SourceLoc loc);
298298
};
299299

300300
} // end namespace swift

lib/AST/DiagnosticConsumer.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ void FileSpecificDiagnosticConsumer::computeConsumersOrderedByRange(
111111
"overlapping ranges despite having distinct files");
112112
}
113113

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) {
117117
// Diagnostics with invalid locations always go to every consumer.
118118
if (loc.isInvalid())
119119
return None;
@@ -154,7 +154,9 @@ FileSpecificDiagnosticConsumer::consumerAndRangeForLocation(
154154

155155
if (possiblyContainingRangeIter != ConsumersOrderedByRange.end() &&
156156
possiblyContainingRangeIter->contains(loc)) {
157-
return const_cast<ConsumerAndRange *>(possiblyContainingRangeIter);
157+
auto *consumerAndRangeForLocation =
158+
const_cast<ConsumerAndRange *>(possiblyContainingRangeIter);
159+
return &(*this)[*consumerAndRangeForLocation];
158160
}
159161

160162
return None;
@@ -167,21 +169,21 @@ void FileSpecificDiagnosticConsumer::handleDiagnostic(
167169

168170
HasAnErrorBeenConsumed |= Kind == DiagnosticKind::Error;
169171

170-
Optional<ConsumerAndRange *> consumerAndRange;
172+
Optional<FileSpecificDiagnosticConsumer::Subconsumer *> subconsumer;
171173
switch (Kind) {
172174
case DiagnosticKind::Error:
173175
case DiagnosticKind::Warning:
174176
case DiagnosticKind::Remark:
175-
consumerAndRange = consumerAndRangeForLocation(SM, Loc);
176-
ConsumerSpecificInfoForSubsequentNotes = consumerAndRange;
177+
subconsumer = subconsumerForLocation(SM, Loc);
178+
SubconsumerForSubsequentNotes = subconsumer;
177179
break;
178180
case DiagnosticKind::Note:
179-
consumerAndRange = ConsumerSpecificInfoForSubsequentNotes;
181+
subconsumer = SubconsumerForSubsequentNotes;
180182
break;
181183
}
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);
185187
return;
186188
}
187189
for (auto &subconsumer : Subconsumers)

0 commit comments

Comments
 (0)