@@ -165,32 +165,32 @@ FileSpecificDiagnosticConsumer::subconsumerForLocation(SourceManager &SM,
165
165
void FileSpecificDiagnosticConsumer::handleDiagnostic (
166
166
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
167
167
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
168
- const DiagnosticInfo &Info, StringRef currentPrimaryInput ) {
168
+ const DiagnosticInfo &Info, const SourceLoc defaultDiagnosticLoc ) {
169
169
170
170
HasAnErrorBeenConsumed |= Kind == DiagnosticKind::Error;
171
171
172
172
auto subconsumer =
173
- findSubconsumerForAnyKind (SM, Loc, Kind, currentPrimaryInput );
173
+ findSubconsumerForAnyKind (SM, Loc, Kind, defaultDiagnosticLoc );
174
174
if (subconsumer) {
175
175
subconsumer.getValue ()->handleDiagnostic (
176
- SM, Loc, Kind, FormatString, FormatArgs, Info, currentPrimaryInput );
176
+ SM, Loc, Kind, FormatString, FormatArgs, Info, defaultDiagnosticLoc );
177
177
return ;
178
178
}
179
179
// Last resort: spray it everywhere
180
180
for (auto &subconsumer : Subconsumers)
181
181
subconsumer.handleDiagnostic (SM, Loc, Kind, FormatString, FormatArgs, Info,
182
- currentPrimaryInput );
182
+ defaultDiagnosticLoc );
183
183
}
184
184
185
185
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
186
186
FileSpecificDiagnosticConsumer::findSubconsumerForAnyKind (
187
187
SourceManager &SM, SourceLoc loc, DiagnosticKind Kind,
188
- StringRef currentPrimaryInput ) {
188
+ SourceLoc defaultDiagnosticLoc ) {
189
189
switch (Kind) {
190
190
case DiagnosticKind::Error:
191
191
case DiagnosticKind::Warning:
192
192
case DiagnosticKind::Remark: {
193
- auto subconsumer = findSubconsumerForNonNote (SM, loc, currentPrimaryInput );
193
+ auto subconsumer = findSubconsumerForNonNote (SM, loc, defaultDiagnosticLoc );
194
194
SubconsumerForSubsequentNotes = subconsumer;
195
195
return subconsumer;
196
196
}
@@ -201,33 +201,21 @@ FileSpecificDiagnosticConsumer::findSubconsumerForAnyKind(
201
201
202
202
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
203
203
FileSpecificDiagnosticConsumer::findSubconsumerForNonNote (
204
- SourceManager &SM, const SourceLoc loc, StringRef currentPrimaryInput ) {
204
+ SourceManager &SM, const SourceLoc loc, const SourceLoc defaultDiagnosticLoc ) {
205
205
const auto subconsumer = subconsumerForLocation (SM, loc);
206
206
if (!subconsumer)
207
207
return None; // No place to put it
208
208
if ((*subconsumer)->getConsumer ())
209
209
return subconsumer; // A primary file with a .dia file
210
- const auto locInPrimary =
211
- findLocationOfCurrentPrimaryFile (SM, currentPrimaryInput);
212
- if (locInPrimary.isInvalid ())
210
+ if (defaultDiagnosticLoc.isInvalid ())
213
211
return None;
214
212
const auto currentPrimarySubconsumer =
215
- subconsumerForLocation (SM, locInPrimary );
213
+ subconsumerForLocation (SM, defaultDiagnosticLoc );
216
214
assert (currentPrimarySubconsumer && (*subconsumer)->getConsumer () &&
217
215
" current primary must have a .dia file" );
218
216
return currentPrimarySubconsumer;
219
217
}
220
218
221
- SourceLoc FileSpecificDiagnosticConsumer::findLocationOfCurrentPrimaryFile (
222
- SourceManager &SM, StringRef currentPrimaryInput) {
223
- if (currentPrimaryInput.empty ())
224
- return SourceLoc ();
225
- auto id = SM.getIDForBufferIdentifier (currentPrimaryInput);
226
- if (!id)
227
- return SourceLoc ();
228
- return SM.getLocForBufferStart (*id);
229
- }
230
-
231
219
bool FileSpecificDiagnosticConsumer::finishProcessing () {
232
220
tellSubconsumersToInformDriverOfIncompleteBatchModeCompilation ();
233
221
@@ -252,7 +240,7 @@ void FileSpecificDiagnosticConsumer::
252
240
void NullDiagnosticConsumer::handleDiagnostic (
253
241
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
254
242
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
255
- const DiagnosticInfo &Info, StringRef ) {
243
+ const DiagnosticInfo &Info, const SourceLoc ) {
256
244
LLVM_DEBUG ({
257
245
llvm::dbgs () << " NullDiagnosticConsumer received diagnostic: " ;
258
246
DiagnosticEngine::formatDiagnosticText (llvm::dbgs (), FormatString,
@@ -267,7 +255,7 @@ ForwardingDiagnosticConsumer::ForwardingDiagnosticConsumer(DiagnosticEngine &Tar
267
255
void ForwardingDiagnosticConsumer::handleDiagnostic (
268
256
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
269
257
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
270
- const DiagnosticInfo &Info, StringRef currentPrimaryInput ) {
258
+ const DiagnosticInfo &Info, const SourceLoc defaultDiagnosticLoc ) {
271
259
LLVM_DEBUG ({
272
260
llvm::dbgs () << " ForwardingDiagnosticConsumer received diagnostic: " ;
273
261
DiagnosticEngine::formatDiagnosticText (llvm::dbgs (), FormatString,
@@ -276,6 +264,6 @@ void ForwardingDiagnosticConsumer::handleDiagnostic(
276
264
});
277
265
for (auto *C : TargetEngine.getConsumers ()) {
278
266
C->handleDiagnostic (SM, Loc, Kind, FormatString, FormatArgs, Info,
279
- currentPrimaryInput );
267
+ defaultDiagnosticLoc );
280
268
}
281
269
}
0 commit comments