Skip to content

Commit 9cc3a4a

Browse files
author
David Ungar
committed
Rename defaultDiagnosticLoc to bufferIndirectlyCausingDiagnostic.
1 parent c8341fa commit 9cc3a4a

23 files changed

+63
-61
lines changed

include/swift/AST/DiagnosticConsumer.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class DiagnosticConsumer {
9898
DiagnosticKind Kind, StringRef FormatString,
9999
ArrayRef<DiagnosticArgument> FormatArgs,
100100
const DiagnosticInfo &Info,
101-
SourceLoc defaultDiagnosticLoc) = 0;
101+
SourceLoc bufferIndirectlyCausingDiagnostic) = 0;
102102

103103
/// \returns true if an error occurred while finishing-up.
104104
virtual bool finishProcessing() { return false; }
@@ -120,7 +120,7 @@ class NullDiagnosticConsumer : public DiagnosticConsumer {
120120
StringRef FormatString,
121121
ArrayRef<DiagnosticArgument> FormatArgs,
122122
const DiagnosticInfo &Info,
123-
SourceLoc defaultDiagnosticLoc) override;
123+
SourceLoc bufferIndirectlyCausingDiagnostic) override;
124124
};
125125

126126
/// DiagnosticConsumer that forwards diagnostics to the consumers of
@@ -133,7 +133,7 @@ class ForwardingDiagnosticConsumer : public DiagnosticConsumer {
133133
StringRef FormatString,
134134
ArrayRef<DiagnosticArgument> FormatArgs,
135135
const DiagnosticInfo &Info,
136-
SourceLoc defaultDiagnosticLoc) override;
136+
SourceLoc bufferIndirectlyCausingDiagnostic) override;
137137
};
138138

139139
/// DiagnosticConsumer that funnels diagnostics in certain files to
@@ -196,10 +196,10 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
196196
StringRef FormatString,
197197
ArrayRef<DiagnosticArgument> FormatArgs,
198198
const DiagnosticInfo &Info,
199-
const SourceLoc defaultDiagnosticLoc) {
199+
const SourceLoc bufferIndirectlyCausingDiagnostic) {
200200
hasAnErrorBeenConsumed |= Kind == DiagnosticKind::Error;
201201
getConsumer()->handleDiagnostic(SM, Loc, Kind, FormatString, FormatArgs,
202-
Info, defaultDiagnosticLoc);
202+
Info, bufferIndirectlyCausingDiagnostic);
203203
}
204204

205205
void informDriverOfIncompleteBatchModeCompilation() {
@@ -290,7 +290,7 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
290290
StringRef FormatString,
291291
ArrayRef<DiagnosticArgument> FormatArgs,
292292
const DiagnosticInfo &Info,
293-
SourceLoc defaultDiagnosticLoc) override;
293+
SourceLoc bufferIndirectlyCausingDiagnostic) override;
294294

295295
bool finishProcessing() override;
296296

@@ -312,11 +312,11 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
312312
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
313313
findSubconsumer(SourceManager &SM, SourceLoc loc,
314314
DiagnosticKind Kind,
315-
SourceLoc defaultDiagnosticLoc);
315+
SourceLoc bufferIndirectlyCausingDiagnostic);
316316

317317
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
318318
findSubconsumerForNonNote(SourceManager &SM, SourceLoc loc,
319-
SourceLoc defaultDiagnosticLoc);
319+
SourceLoc bufferIndirectlyCausingDiagnostic);
320320
};
321321

322322
} // end namespace swift

include/swift/AST/DiagnosticEngine.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,11 @@ namespace swift {
561561
/// emitted once all transactions have closed.
562562
unsigned TransactionCount = 0;
563563

564-
/// For batch mode, use this to know where to output a diagnostic
565-
/// from a non-primary file. May be invalid.
566-
SourceLoc defaultDiagnosticLoc;
564+
/// For batch mode, use this to know where to output a diagnostic from a
565+
/// non-primary file. It's any location in the buffer of the current primary
566+
/// input being compiled.
567+
/// May be invalid.
568+
SourceLoc bufferIndirectlyCausingDiagnostic;
567569

568570
friend class InFlightDiagnostic;
569571
friend class DiagnosticTransaction;
@@ -809,22 +811,22 @@ namespace swift {
809811
/// In particular, in batch mode when a diagnostic is located in
810812
/// a non-primary file, use this affordance to place it in the .dia
811813
/// file for the primary that is currently being worked on.
812-
void setDefaultDiagnosticLocToInput(StringRef defaultDiagnosticInputFile);
813-
void resetDefaultDiagnosticLoc();
814-
SourceLoc getDefaultDiagnostLoc() const { return defaultDiagnosticLoc; }
814+
void setBufferIndirectlyCausingDiagnosticToInput(StringRef defaultDiagnosticInputFile);
815+
void resetBufferIndirectlyCausingDiagnostic();
816+
SourceLoc getDefaultDiagnostLoc() const { return bufferIndirectlyCausingDiagnostic; }
815817
};
816818

817-
class DefaultDiagnosticLocRAII {
819+
class BufferIndirectlyCausingDiagnosticRAII {
818820
private:
819821
DiagnosticEngine &Diags;
820822

821823
public:
822-
DefaultDiagnosticLocRAII(DiagnosticEngine &Diags,
824+
BufferIndirectlyCausingDiagnosticRAII(DiagnosticEngine &Diags,
823825
StringRef defaultDiagnosticInputFile)
824826
: Diags(Diags) {
825-
Diags.setDefaultDiagnosticLocToInput(defaultDiagnosticInputFile);
827+
Diags.setBufferIndirectlyCausingDiagnosticToInput(defaultDiagnosticInputFile);
826828
}
827-
~DefaultDiagnosticLocRAII() { Diags.resetDefaultDiagnosticLoc(); }
829+
~BufferIndirectlyCausingDiagnosticRAII() { Diags.resetBufferIndirectlyCausingDiagnostic(); }
828830
};
829831

830832
/// Represents a diagnostic transaction. While a transaction is

include/swift/Frontend/PrintingDiagnosticConsumer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class PrintingDiagnosticConsumer : public DiagnosticConsumer {
3939
DiagnosticKind Kind, StringRef FormatString,
4040
ArrayRef<DiagnosticArgument> FormatArgs,
4141
const DiagnosticInfo &Info,
42-
SourceLoc defaultDiagnosticLoc) override;
42+
SourceLoc bufferIndirectlyCausingDiagnostic) override;
4343

4444
void forceColors() {
4545
ForceColors = true;

include/swift/Migrator/FixitApplyDiagnosticConsumer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class FixitApplyDiagnosticConsumer final
6666
StringRef FormatString,
6767
ArrayRef<DiagnosticArgument> FormatArgs,
6868
const DiagnosticInfo &Info,
69-
SourceLoc defaultDiagnosticLoc) override;
69+
SourceLoc bufferIndirectlyCausingDiagnostic) override;
7070

7171
unsigned getNumFixitsApplied() const {
7272
return NumFixitsApplied;

lib/AST/DiagnosticConsumer.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,33 +165,33 @@ FileSpecificDiagnosticConsumer::subconsumerForLocation(SourceManager &SM,
165165
void FileSpecificDiagnosticConsumer::handleDiagnostic(
166166
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
167167
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
168-
const DiagnosticInfo &Info, const SourceLoc defaultDiagnosticLoc) {
168+
const DiagnosticInfo &Info, const SourceLoc bufferIndirectlyCausingDiagnostic) {
169169

170170
HasAnErrorBeenConsumed |= Kind == DiagnosticKind::Error;
171171

172172
auto subconsumer =
173-
findSubconsumer(SM, Loc, Kind, defaultDiagnosticLoc);
173+
findSubconsumer(SM, Loc, Kind, bufferIndirectlyCausingDiagnostic);
174174
if (subconsumer) {
175175
subconsumer.getValue()->handleDiagnostic(
176-
SM, Loc, Kind, FormatString, FormatArgs, Info, defaultDiagnosticLoc);
176+
SM, Loc, Kind, FormatString, FormatArgs, Info, bufferIndirectlyCausingDiagnostic);
177177
return;
178178
}
179179
// Last resort: spray it everywhere
180180
for (auto &subconsumer : Subconsumers)
181181
subconsumer.handleDiagnostic(SM, Loc, Kind, FormatString, FormatArgs, Info,
182-
defaultDiagnosticLoc);
182+
bufferIndirectlyCausingDiagnostic);
183183
}
184184

185185
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
186186
FileSpecificDiagnosticConsumer::findSubconsumer(
187187
SourceManager &SM, SourceLoc loc, DiagnosticKind Kind,
188-
SourceLoc defaultDiagnosticLoc) {
188+
SourceLoc bufferIndirectlyCausingDiagnostic) {
189189
// Ensure that a note goes to the same place as the preceeding non-note.
190190
switch (Kind) {
191191
case DiagnosticKind::Error:
192192
case DiagnosticKind::Warning:
193193
case DiagnosticKind::Remark: {
194-
auto subconsumer = findSubconsumerForNonNote(SM, loc, defaultDiagnosticLoc);
194+
auto subconsumer = findSubconsumerForNonNote(SM, loc, bufferIndirectlyCausingDiagnostic);
195195
SubconsumerForSubsequentNotes = subconsumer;
196196
return subconsumer;
197197
}
@@ -203,13 +203,13 @@ FileSpecificDiagnosticConsumer::findSubconsumer(
203203
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
204204
FileSpecificDiagnosticConsumer::findSubconsumerForNonNote(
205205
SourceManager &SM, const SourceLoc loc,
206-
const SourceLoc defaultDiagnosticLoc) {
206+
const SourceLoc bufferIndirectlyCausingDiagnostic) {
207207
if (auto subconsumer = subconsumerForLocation(SM, loc))
208208
return subconsumer; // A primary file with a .dia file
209209
// The diagnostic is located in a non-primary.
210210
// Try to put it in the current primary file's .dia file.
211-
if (defaultDiagnosticLoc.isValid())
212-
return subconsumerForLocation(SM, defaultDiagnosticLoc);
211+
if (bufferIndirectlyCausingDiagnostic.isValid())
212+
return subconsumerForLocation(SM, bufferIndirectlyCausingDiagnostic);
213213
return None;
214214
}
215215

@@ -252,7 +252,7 @@ ForwardingDiagnosticConsumer::ForwardingDiagnosticConsumer(DiagnosticEngine &Tar
252252
void ForwardingDiagnosticConsumer::handleDiagnostic(
253253
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
254254
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
255-
const DiagnosticInfo &Info, const SourceLoc defaultDiagnosticLoc) {
255+
const DiagnosticInfo &Info, const SourceLoc bufferIndirectlyCausingDiagnostic) {
256256
LLVM_DEBUG({
257257
llvm::dbgs() << "ForwardingDiagnosticConsumer received diagnostic: ";
258258
DiagnosticEngine::formatDiagnosticText(llvm::dbgs(), FormatString,
@@ -261,6 +261,6 @@ void ForwardingDiagnosticConsumer::handleDiagnostic(
261261
});
262262
for (auto *C : TargetEngine.getConsumers()) {
263263
C->handleDiagnostic(SM, Loc, Kind, FormatString, FormatArgs, Info,
264-
defaultDiagnosticLoc);
264+
bufferIndirectlyCausingDiagnostic);
265265
}
266266
}

lib/AST/DiagnosticEngine.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -847,20 +847,20 @@ const char *DiagnosticEngine::diagnosticStringFor(const DiagID id) {
847847
return diagnosticStrings[(unsigned)id];
848848
}
849849

850-
void DiagnosticEngine::setDefaultDiagnosticLocToInput(StringRef input) {
850+
void DiagnosticEngine::setBufferIndirectlyCausingDiagnosticToInput(StringRef input) {
851851
if (input.empty()) {
852-
resetDefaultDiagnosticLoc();
852+
resetBufferIndirectlyCausingDiagnostic();
853853
return;
854854
}
855855
auto id = SourceMgr.getIDForBufferIdentifier(input);
856856
if (!id) {
857-
resetDefaultDiagnosticLoc();
857+
resetBufferIndirectlyCausingDiagnostic();
858858
return;
859859
}
860-
defaultDiagnosticLoc = SourceMgr.getLocForBufferStart(*id);
860+
bufferIndirectlyCausingDiagnostic = SourceMgr.getLocForBufferStart(*id);
861861
}
862-
void DiagnosticEngine::resetDefaultDiagnosticLoc() {
863-
defaultDiagnosticLoc = SourceLoc();
862+
void DiagnosticEngine::resetBufferIndirectlyCausingDiagnostic() {
863+
bufferIndirectlyCausingDiagnostic = SourceLoc();
864864
}
865865

866866
DiagnosticSuppression::DiagnosticSuppression(DiagnosticEngine &diags)

lib/Frontend/PrintingDiagnosticConsumer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace {
6666
void PrintingDiagnosticConsumer::handleDiagnostic(
6767
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
6868
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
69-
const DiagnosticInfo &Info, const SourceLoc defaultDiagnosticLoc) {
69+
const DiagnosticInfo &Info, const SourceLoc bufferIndirectlyCausingDiagnostic) {
7070
// Determine what kind of diagnostic we're emitting.
7171
llvm::SourceMgr::DiagKind SMKind;
7272
switch (Kind) {

lib/Frontend/SerializedDiagnosticConsumer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class SerializedDiagnosticConsumer : public DiagnosticConsumer {
195195
StringRef FormatString,
196196
ArrayRef<DiagnosticArgument> FormatArgs,
197197
const DiagnosticInfo &Info,
198-
SourceLoc defaultDiagnosticLoc) override;
198+
SourceLoc bufferIndirectlyCausingDiagnostic) override;
199199

200200
/// The version of the diagnostics file.
201201
enum { Version = 1 };
@@ -545,7 +545,7 @@ emitDiagnosticMessage(SourceManager &SM,
545545
void SerializedDiagnosticConsumer::handleDiagnostic(
546546
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
547547
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
548-
const DiagnosticInfo &Info, const SourceLoc defaultDiagnosticLoc) {
548+
const DiagnosticInfo &Info, const SourceLoc bufferIndirectlyCausingDiagnostic) {
549549

550550
// Enter the block for a non-note diagnostic immediately, rather
551551
// than waiting for beginDiagnostic, in case associated notes

lib/FrontendTool/FrontendTool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ class JSONFixitWriter
410410
StringRef FormatString,
411411
ArrayRef<DiagnosticArgument> FormatArgs,
412412
const DiagnosticInfo &Info,
413-
const SourceLoc defaultDiagnosticLoc) override {
413+
const SourceLoc bufferIndirectlyCausingDiagnostic) override {
414414
if (!(FixitAll || shouldTakeFixit(Kind, Info)))
415415
return;
416416
for (const auto &Fix : Info.FixIts) {
@@ -1218,7 +1218,7 @@ static bool performCompileStepsPostSILGen(
12181218
SILOptions &SILOpts = Invocation.getSILOptions();
12191219
IRGenOptions &IRGenOpts = Invocation.getIRGenOptions();
12201220

1221-
DefaultDiagnosticLocRAII cpi(Context.Diags,
1221+
BufferIndirectlyCausingDiagnosticRAII cpi(Context.Diags,
12221222
PSPs.MainInputFilenameForDebugInfo);
12231223

12241224
if (Stats)

lib/Migrator/FixitApplyDiagnosticConsumer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void FixitApplyDiagnosticConsumer::printResult(llvm::raw_ostream &OS) const {
3434
void FixitApplyDiagnosticConsumer::handleDiagnostic(
3535
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
3636
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
37-
const DiagnosticInfo &Info, const SourceLoc defaultDiagnosticLoc) {
37+
const DiagnosticInfo &Info, const SourceLoc bufferIndirectlyCausingDiagnostic) {
3838
if (Loc.isInvalid()) {
3939
return;
4040
}

0 commit comments

Comments
 (0)