@@ -45,6 +45,13 @@ struct DiagnosticInfo {
4545 DiagnosticKind Kind;
4646 StringRef FormatString;
4747 ArrayRef<DiagnosticArgument> FormatArgs;
48+
49+ // / Only used when directing diagnostics to different outputs.
50+ // / In batch mode a diagnostic may be
51+ // / located in a non-primary file, but there will be no .dia file for a
52+ // / non-primary. If valid, this argument contains a location within a buffer
53+ // / that corresponds to a primary input. The .dia file for that primary can be
54+ // / used for the diagnostic, as if it had occurred at this location.
4855 SourceLoc BufferIndirectlyCausingDiagnostic;
4956
5057 // / DiagnosticInfo of notes which are children of this diagnostic, if any
@@ -109,29 +116,9 @@ class DiagnosticConsumer {
109116 // / \param SM The source manager associated with the source locations in
110117 // / this diagnostic.
111118 // /
112- // / \param Loc The source location associated with this diagnostic. This
113- // / location may be invalid, if the diagnostic is not directly related to
114- // / the source (e.g., if it comes from command-line parsing).
115- // /
116- // / \param Kind The severity of the diagnostic (error, warning, note).
117- // /
118- // / \param FormatArgs The diagnostic format string arguments.
119- // /
120- // / \param Info Extra information associated with the diagnostic.
121- // /
122- // / \param bufferIndirectlyCausingDiagnostic Only used when directing
123- // / diagnostics to different outputs.
124- // / In batch mode a diagnostic may be
125- // / located in a non-primary file, but there will be no .dia file for a
126- // / non-primary. If valid, this argument contains a location within a buffer
127- // / that corresponds to a primary input. The .dia file for that primary can be
128- // / used for the diagnostic, as if it had occurred at this location.
129- virtual void
130- handleDiagnostic (SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
131- StringRef FormatString,
132- ArrayRef<DiagnosticArgument> FormatArgs,
133- const DiagnosticInfo &Info,
134- SourceLoc bufferIndirectlyCausingDiagnostic) = 0 ;
119+ // / \param Info Information describing the diagnostic.
120+ virtual void handleDiagnostic (SourceManager &SM,
121+ const DiagnosticInfo &Info) = 0;
135122
136123 // / \returns true if an error occurred while finishing-up.
137124 virtual bool finishProcessing () { return false ; }
@@ -149,11 +136,7 @@ class DiagnosticConsumer {
149136// / DiagnosticConsumer that discards all diagnostics.
150137class NullDiagnosticConsumer : public DiagnosticConsumer {
151138public:
152- void handleDiagnostic (SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
153- StringRef FormatString,
154- ArrayRef<DiagnosticArgument> FormatArgs,
155- const DiagnosticInfo &Info,
156- SourceLoc bufferIndirectlyCausingDiagnostic) override ;
139+ void handleDiagnostic (SourceManager &SM, const DiagnosticInfo &Info) override ;
157140};
158141
159142// / DiagnosticConsumer that forwards diagnostics to the consumers of
@@ -162,11 +145,7 @@ class ForwardingDiagnosticConsumer : public DiagnosticConsumer {
162145 DiagnosticEngine &TargetEngine;
163146public:
164147 ForwardingDiagnosticConsumer (DiagnosticEngine &Target);
165- void handleDiagnostic (SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
166- StringRef FormatString,
167- ArrayRef<DiagnosticArgument> FormatArgs,
168- const DiagnosticInfo &Info,
169- SourceLoc bufferIndirectlyCausingDiagnostic) override ;
148+ void handleDiagnostic (SourceManager &SM, const DiagnosticInfo &Info) override ;
170149};
171150
172151// / DiagnosticConsumer that funnels diagnostics in certain files to
@@ -228,18 +207,13 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
228207 std::unique_ptr<DiagnosticConsumer> consumer)
229208 : inputFileName(inputFileName), consumer(std::move(consumer)) {}
230209
231- void handleDiagnostic (SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
232- StringRef FormatString,
233- ArrayRef<DiagnosticArgument> FormatArgs,
234- const DiagnosticInfo &Info,
235- const SourceLoc bufferIndirectlyCausingDiagnostic) {
210+ void handleDiagnostic (SourceManager &SM, const DiagnosticInfo &Info) {
236211 if (!getConsumer ())
237212 return ;
238- hasAnErrorBeenConsumed |= Kind == DiagnosticKind::Error;
239- getConsumer ()->handleDiagnostic (SM, Loc, Kind, FormatString, FormatArgs,
240- Info, bufferIndirectlyCausingDiagnostic);
213+ hasAnErrorBeenConsumed |= Info.Kind == DiagnosticKind::Error;
214+ getConsumer ()->handleDiagnostic (SM, Info);
241215 }
242-
216+
243217 void informDriverOfIncompleteBatchModeCompilation () {
244218 if (!hasAnErrorBeenConsumed && getConsumer ())
245219 getConsumer ()->informDriverOfIncompleteBatchModeCompilation ();
@@ -324,11 +298,7 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
324298 SmallVectorImpl<Subconsumer> &consumers);
325299
326300public:
327- void handleDiagnostic (SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
328- StringRef FormatString,
329- ArrayRef<DiagnosticArgument> FormatArgs,
330- const DiagnosticInfo &Info,
331- SourceLoc bufferIndirectlyCausingDiagnostic) override ;
301+ void handleDiagnostic (SourceManager &SM, const DiagnosticInfo &Info) override ;
332302
333303 bool finishProcessing () override ;
334304
@@ -348,12 +318,10 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
348318 subconsumerForLocation (SourceManager &SM, SourceLoc loc);
349319
350320 Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
351- findSubconsumer (SourceManager &SM, SourceLoc loc, DiagnosticKind Kind,
352- SourceLoc bufferIndirectlyCausingDiagnostic);
321+ findSubconsumer (SourceManager &SM, const DiagnosticInfo &Info);
353322
354323 Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
355- findSubconsumerForNonNote (SourceManager &SM, SourceLoc loc,
356- SourceLoc bufferIndirectlyCausingDiagnostic);
324+ findSubconsumerForNonNote (SourceManager &SM, const DiagnosticInfo &Info);
357325};
358326
359327} // end namespace swift
0 commit comments