@@ -45,6 +45,13 @@ struct DiagnosticInfo {
45
45
DiagnosticKind Kind;
46
46
StringRef FormatString;
47
47
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.
48
55
SourceLoc BufferIndirectlyCausingDiagnostic;
49
56
50
57
// / DiagnosticInfo of notes which are children of this diagnostic, if any
@@ -109,29 +116,9 @@ class DiagnosticConsumer {
109
116
// / \param SM The source manager associated with the source locations in
110
117
// / this diagnostic.
111
118
// /
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;
135
122
136
123
// / \returns true if an error occurred while finishing-up.
137
124
virtual bool finishProcessing () { return false ; }
@@ -149,11 +136,7 @@ class DiagnosticConsumer {
149
136
// / DiagnosticConsumer that discards all diagnostics.
150
137
class NullDiagnosticConsumer : public DiagnosticConsumer {
151
138
public:
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 ;
157
140
};
158
141
159
142
// / DiagnosticConsumer that forwards diagnostics to the consumers of
@@ -162,11 +145,7 @@ class ForwardingDiagnosticConsumer : public DiagnosticConsumer {
162
145
DiagnosticEngine &TargetEngine;
163
146
public:
164
147
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 ;
170
149
};
171
150
172
151
// / DiagnosticConsumer that funnels diagnostics in certain files to
@@ -228,18 +207,13 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
228
207
std::unique_ptr<DiagnosticConsumer> consumer)
229
208
: inputFileName(inputFileName), consumer(std::move(consumer)) {}
230
209
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) {
236
211
if (!getConsumer ())
237
212
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);
241
215
}
242
-
216
+
243
217
void informDriverOfIncompleteBatchModeCompilation () {
244
218
if (!hasAnErrorBeenConsumed && getConsumer ())
245
219
getConsumer ()->informDriverOfIncompleteBatchModeCompilation ();
@@ -324,11 +298,7 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
324
298
SmallVectorImpl<Subconsumer> &consumers);
325
299
326
300
public:
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 ;
332
302
333
303
bool finishProcessing () override ;
334
304
@@ -348,12 +318,10 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
348
318
subconsumerForLocation (SourceManager &SM, SourceLoc loc);
349
319
350
320
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
351
- findSubconsumer (SourceManager &SM, SourceLoc loc, DiagnosticKind Kind,
352
- SourceLoc bufferIndirectlyCausingDiagnostic);
321
+ findSubconsumer (SourceManager &SM, const DiagnosticInfo &Info);
353
322
354
323
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
355
- findSubconsumerForNonNote (SourceManager &SM, SourceLoc loc,
356
- SourceLoc bufferIndirectlyCausingDiagnostic);
324
+ findSubconsumerForNonNote (SourceManager &SM, const DiagnosticInfo &Info);
357
325
};
358
326
359
327
} // end namespace swift
0 commit comments