@@ -137,42 +137,46 @@ class NullDiagnosticConsumer : public DiagnosticConsumer {
137
137
class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
138
138
public:
139
139
class Subconsumer ;
140
-
141
- // / Given a vector of subconsumers, return the most specific DiagnosticConsumer for that vector.
142
- // / That will be a FileSpecificDiagnosticConsumer if the vector has > 1 subconsumer,
143
- // / the subconsumer itself if the vector has just one, or a null pointer if there are no subconsumers.
144
- // / Takes ownership of the DiagnosticConsumers specified in \p subconsumers.
145
- static std::unique_ptr<DiagnosticConsumer> consolidateSubconsumers (SmallVectorImpl<Subconsumer> &subconsumers);
146
-
140
+
141
+ // / Given a vector of subconsumers, return the most specific
142
+ // / DiagnosticConsumer for that vector. That will be a
143
+ // / FileSpecificDiagnosticConsumer if the vector has > 1 subconsumer, the
144
+ // / subconsumer itself if the vector has just one, or a null pointer if there
145
+ // / are no subconsumers. Takes ownership of the DiagnosticConsumers specified
146
+ // / in \p subconsumers.
147
+ static std::unique_ptr<DiagnosticConsumer>
148
+ consolidateSubconsumers (SmallVectorImpl<Subconsumer> &subconsumers);
149
+
147
150
// / A diagnostic consumer, along with the name of the buffer that it should
148
151
// / be associated with.
149
152
class Subconsumer {
150
- friend std::unique_ptr<DiagnosticConsumer> FileSpecificDiagnosticConsumer::consolidateSubconsumers (SmallVectorImpl<Subconsumer> &subconsumers);
151
-
153
+ friend std::unique_ptr<DiagnosticConsumer>
154
+ FileSpecificDiagnosticConsumer::consolidateSubconsumers (
155
+ SmallVectorImpl<Subconsumer> &subconsumers);
156
+
152
157
// / The name of the input file that a consumer and diagnostics should
153
158
// / be associated with. An empty string means that a consumer is not
154
159
// / associated with any particular buffer, and should only receive
155
160
// / diagnostics that are not in any of the other consumers' files.
156
161
std::string inputFileName;
157
-
162
+
158
163
// / The consumer (if any) for diagnostics associated with the inputFileName.
159
164
// / A null pointer for the DiagnosticConsumer means that diagnostics for
160
165
// / this file should not be emitted.
161
166
std::unique_ptr<DiagnosticConsumer> consumer;
162
-
167
+
163
168
// Has this subconsumer ever handled a diagnostic that is an error?
164
169
bool hasAnErrorBeenConsumed = false ;
165
170
166
-
167
171
public:
168
172
std::string getInputFileName () const { return inputFileName; }
169
-
173
+
170
174
DiagnosticConsumer *getConsumer () const { return consumer.get (); }
171
175
172
176
Subconsumer (std::string inputFileName,
173
177
std::unique_ptr<DiagnosticConsumer> consumer)
174
178
: inputFileName(inputFileName), consumer(std::move(consumer)) {}
175
-
179
+
176
180
void handleDiagnostic (SourceManager &SM, SourceLoc Loc,
177
181
DiagnosticKind Kind,
178
182
StringRef FormatString,
@@ -181,7 +185,8 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
181
185
if (!getConsumer ())
182
186
return ; // Suppress non-primary diagnostic in batch mode.
183
187
hasAnErrorBeenConsumed |= Kind == DiagnosticKind::Error;
184
- getConsumer ()->handleDiagnostic (SM, Loc, Kind, FormatString, FormatArgs, Info);
188
+ getConsumer ()->handleDiagnostic (SM, Loc, Kind, FormatString, FormatArgs,
189
+ Info);
185
190
}
186
191
187
192
void informDriverOfIncompleteBatchModeCompilation () {
@@ -205,38 +210,36 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
205
210
206
211
// / Index into Subconsumers vector for this subconsumer.
207
212
/* const*/ unsigned subconsumerIndex;
208
-
213
+
209
214
public:
210
215
ConsumerSpecificInformation (const CharSourceRange range,
211
216
unsigned subconsumerIndex)
212
- : range(range), subconsumerIndex(subconsumerIndex) {}
217
+ : range(range), subconsumerIndex(subconsumerIndex) {}
213
218
214
219
Subconsumer &subconsumer (FileSpecificDiagnosticConsumer &c) const {
215
220
return c.Subconsumers [subconsumerIndex];
216
221
}
217
-
222
+
218
223
// / Compare according to range:
219
- bool operator < (const ConsumerSpecificInformation &right) const {
224
+ bool operator < (const ConsumerSpecificInformation &right) const {
220
225
auto compare = std::less<const char *>();
221
- return compare (getRawLoc ( range.getEnd ()).getPointer (),
226
+ return compare (getRawLoc (range.getEnd ()).getPointer (),
222
227
getRawLoc (right.range .getEnd ()).getPointer ());
223
228
}
224
-
229
+
225
230
// / Overlaps by range:
226
231
bool overlaps (const ConsumerSpecificInformation &other) const {
227
232
return range.overlaps (other.range );
228
233
}
229
-
234
+
230
235
// / Does my range end after \p loc?
231
236
bool endsAfter (const SourceLoc loc) const {
232
237
auto compare = std::less<const char *>();
233
238
return compare (getRawLoc (range.getEnd ()).getPointer (),
234
239
getRawLoc (loc).getPointer ());
235
240
}
236
-
237
- bool contains (const SourceLoc loc) const {
238
- return range.contains (loc);
239
- }
241
+
242
+ bool contains (const SourceLoc loc) const { return range.contains (loc); }
240
243
};
241
244
242
245
private:
@@ -262,19 +265,15 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
262
265
ConsumerSpecificInfoForSubsequentNotes = None;
263
266
264
267
bool HasAnErrorBeenConsumed = false ;
265
-
266
-
268
+
267
269
// / Takes ownership of the DiagnosticConsumers specified in \p consumers.
268
270
// /
269
271
// / There must not be two consumers for the same file (i.e., having the same
270
272
// / buffer name).
271
273
explicit FileSpecificDiagnosticConsumer (
272
- SmallVectorImpl<Subconsumer> &consumers);
274
+ SmallVectorImpl<Subconsumer> &consumers);
273
275
274
276
public:
275
-
276
-
277
-
278
277
void handleDiagnostic (SourceManager &SM, SourceLoc Loc,
279
278
DiagnosticKind Kind,
280
279
StringRef FormatString,
0 commit comments