Skip to content

Commit c90d9e6

Browse files
author
David Ungar
committed
Format
1 parent 7a0e0ff commit c90d9e6

17 files changed

+65
-94
lines changed

include/swift/AST/DiagnosticConsumer.h

+7-13
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ class DiagnosticConsumer {
9595
///
9696
/// \param Info Extra information associated with the diagnostic.
9797
virtual void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
98-
DiagnosticKind Kind,
99-
StringRef FormatString,
98+
DiagnosticKind Kind, StringRef FormatString,
10099
ArrayRef<DiagnosticArgument> FormatArgs,
101100
const DiagnosticInfo &Info,
102101
StringRef currentPrimaryInput) = 0;
@@ -117,8 +116,7 @@ class DiagnosticConsumer {
117116
/// DiagnosticConsumer that discards all diagnostics.
118117
class NullDiagnosticConsumer : public DiagnosticConsumer {
119118
public:
120-
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
121-
DiagnosticKind Kind,
119+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
122120
StringRef FormatString,
123121
ArrayRef<DiagnosticArgument> FormatArgs,
124122
const DiagnosticInfo &Info,
@@ -131,8 +129,7 @@ class ForwardingDiagnosticConsumer : public DiagnosticConsumer {
131129
DiagnosticEngine &TargetEngine;
132130
public:
133131
ForwardingDiagnosticConsumer(DiagnosticEngine &Target);
134-
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
135-
DiagnosticKind Kind,
132+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
136133
StringRef FormatString,
137134
ArrayRef<DiagnosticArgument> FormatArgs,
138135
const DiagnosticInfo &Info,
@@ -194,8 +191,7 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
194191
std::unique_ptr<DiagnosticConsumer> consumer)
195192
: inputFileName(inputFileName), consumer(std::move(consumer)) {}
196193

197-
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
198-
DiagnosticKind Kind,
194+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
199195
StringRef FormatString,
200196
ArrayRef<DiagnosticArgument> FormatArgs,
201197
const DiagnosticInfo &Info,
@@ -291,8 +287,7 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
291287
SmallVectorImpl<Subconsumer> &consumers);
292288

293289
public:
294-
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
295-
DiagnosticKind Kind,
290+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
296291
StringRef FormatString,
297292
ArrayRef<DiagnosticArgument> FormatArgs,
298293
const DiagnosticInfo &Info,
@@ -320,9 +315,8 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
320315
DiagnosticKind Kind);
321316

322317
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
323-
findSubconsumerForPrimaryCausingErrorInNonprimary(SourceManager &SM,
324-
DiagnosticKind Kind,
325-
StringRef currentPrimaryInput);
318+
findSubconsumerForPrimaryCausingErrorInNonprimary(
319+
SourceManager &SM, DiagnosticKind Kind, StringRef currentPrimaryInput);
326320
};
327321

328322
} // end namespace swift

include/swift/AST/DiagnosticEngine.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ namespace swift {
560560
/// The number of open diagnostic transactions. Diagnostics are only
561561
/// emitted once all transactions have closed.
562562
unsigned TransactionCount = 0;
563-
563+
564564
/// For batch mode, use this to know where to output a diagnostic
565565
/// from a non-primary file.
566566
std::string CurrentPrimaryInput;
@@ -803,24 +803,24 @@ namespace swift {
803803

804804
public:
805805
static const char *diagnosticStringFor(const DiagID id);
806-
806+
807807
StringRef getCurrentPrimaryInput() const { return CurrentPrimaryInput; }
808808
void setCurrentPrimaryInput(std::string s) { CurrentPrimaryInput = s; }
809809
};
810-
810+
811811
class CurrentPrimaryInputRAII {
812812
private:
813813
DiagnosticEngine &Diags;
814-
814+
815815
public:
816-
CurrentPrimaryInputRAII(DiagnosticEngine &Diags, StringRef currentPrimaryInput)
817-
: Diags(Diags) {
818-
Diags.setCurrentPrimaryInput( currentPrimaryInput );
816+
CurrentPrimaryInputRAII(DiagnosticEngine &Diags,
817+
StringRef currentPrimaryInput)
818+
: Diags(Diags) {
819+
Diags.setCurrentPrimaryInput(currentPrimaryInput);
819820
}
820821
~CurrentPrimaryInputRAII() { Diags.setCurrentPrimaryInput(""); }
821822
};
822823

823-
824824
/// Represents a diagnostic transaction. While a transaction is
825825
/// open, all recorded diagnostics are saved until the transaction commits,
826826
/// at which point they are emitted. If the transaction is instead aborted,

include/swift/Frontend/PrintingDiagnosticConsumer.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class PrintingDiagnosticConsumer : public DiagnosticConsumer {
3636
Stream(stream) { }
3737

3838
virtual void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
39-
DiagnosticKind Kind,
40-
StringRef FormatString,
39+
DiagnosticKind Kind, StringRef FormatString,
4140
ArrayRef<DiagnosticArgument> FormatArgs,
4241
const DiagnosticInfo &Info,
4342
StringRef currentPrimaryInput) override;

include/swift/Migrator/FixitApplyDiagnosticConsumer.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ class FixitApplyDiagnosticConsumer final
6262
/// output stream.
6363
void printResult(llvm::raw_ostream &OS) const;
6464

65-
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
66-
DiagnosticKind Kind,
65+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
6766
StringRef FormatString,
6867
ArrayRef<DiagnosticArgument> FormatArgs,
6968
const DiagnosticInfo &Info,

lib/AST/DiagnosticConsumer.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,17 @@ void FileSpecificDiagnosticConsumer::handleDiagnostic(
171171

172172
auto subconsumer = findSubconsumerAndRememberItForNotes(SM, Loc, Kind);
173173
if (subconsumer.hasValue() && !(*subconsumer)->getConsumer())
174-
subconsumer = findSubconsumerForPrimaryCausingErrorInNonprimary(SM, Kind, currentPrimaryInput);
174+
subconsumer = findSubconsumerForPrimaryCausingErrorInNonprimary(
175+
SM, Kind, currentPrimaryInput);
175176
if (subconsumer) {
176-
subconsumer.getValue()->handleDiagnostic(SM, Loc, Kind, FormatString,
177-
FormatArgs, Info, currentPrimaryInput);
177+
subconsumer.getValue()->handleDiagnostic(
178+
SM, Loc, Kind, FormatString, FormatArgs, Info, currentPrimaryInput);
178179
return;
179180
}
180181
// Last resort: spray it everywhere
181182
for (auto &subconsumer : Subconsumers)
182-
subconsumer.handleDiagnostic(SM, Loc, Kind, FormatString, FormatArgs, Info, currentPrimaryInput);
183+
subconsumer.handleDiagnostic(SM, Loc, Kind, FormatString, FormatArgs, Info,
184+
currentPrimaryInput);
183185
}
184186

185187
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
@@ -200,9 +202,8 @@ FileSpecificDiagnosticConsumer::findSubconsumerAndRememberItForNotes(
200202

201203
Optional<FileSpecificDiagnosticConsumer::Subconsumer *>
202204
FileSpecificDiagnosticConsumer::
203-
findSubconsumerForPrimaryCausingErrorInNonprimary(SourceManager &SM,
204-
DiagnosticKind Kind,
205-
StringRef currentPrimaryInput) {
205+
findSubconsumerForPrimaryCausingErrorInNonprimary(
206+
SourceManager &SM, DiagnosticKind Kind, StringRef currentPrimaryInput) {
206207
if (currentPrimaryInput.empty())
207208
return None;
208209
auto id = SM.getIDForBufferIdentifier(currentPrimaryInput);
@@ -259,6 +260,7 @@ void ForwardingDiagnosticConsumer::handleDiagnostic(
259260
llvm::dbgs() << "\n";
260261
});
261262
for (auto *C : TargetEngine.getConsumers()) {
262-
C->handleDiagnostic(SM, Loc, Kind, FormatString, FormatArgs, Info, currentPrimaryInput);
263+
C->handleDiagnostic(SM, Loc, Kind, FormatString, FormatArgs, Info,
264+
currentPrimaryInput);
263265
}
264266
}

lib/Frontend/PrintingDiagnosticConsumer.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ namespace {
6666
void PrintingDiagnosticConsumer::handleDiagnostic(
6767
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
6868
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
69-
const DiagnosticInfo &Info,
70-
StringRef currentPrimaryInput) {
69+
const DiagnosticInfo &Info, StringRef currentPrimaryInput) {
7170
// Determine what kind of diagnostic we're emitting.
7271
llvm::SourceMgr::DiagKind SMKind;
7372
switch (Kind) {

lib/Frontend/SerializedDiagnosticConsumer.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,11 @@ class SerializedDiagnosticConsumer : public DiagnosticConsumer {
191191
CompilationWasComplete = false;
192192
}
193193

194-
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
195-
DiagnosticKind Kind,
196-
StringRef FormatString,
197-
ArrayRef<DiagnosticArgument> FormatArgs,
198-
const DiagnosticInfo &Info,
199-
StringRef currentPrimaryInput) override;
194+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
195+
StringRef FormatString,
196+
ArrayRef<DiagnosticArgument> FormatArgs,
197+
const DiagnosticInfo &Info,
198+
StringRef currentPrimaryInput) override;
200199

201200
/// The version of the diagnostics file.
202201
enum { Version = 1 };
@@ -546,8 +545,7 @@ emitDiagnosticMessage(SourceManager &SM,
546545
void SerializedDiagnosticConsumer::handleDiagnostic(
547546
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
548547
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
549-
const DiagnosticInfo &Info,
550-
StringRef currentPrimaryInput) {
548+
const DiagnosticInfo &Info, StringRef currentPrimaryInput) {
551549

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

lib/FrontendTool/FrontendTool.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,7 @@ class JSONFixitWriter
406406
FixitAll(DiagOpts.FixitCodeForAllDiagnostics) {}
407407

408408
private:
409-
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
410-
DiagnosticKind Kind,
409+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
411410
StringRef FormatString,
412411
ArrayRef<DiagnosticArgument> FormatArgs,
413412
const DiagnosticInfo &Info,
@@ -1218,8 +1217,9 @@ static bool performCompileStepsPostSILGen(
12181217
ASTContext &Context = Instance.getASTContext();
12191218
SILOptions &SILOpts = Invocation.getSILOptions();
12201219
IRGenOptions &IRGenOpts = Invocation.getIRGenOptions();
1221-
1222-
CurrentPrimaryInputRAII cpi(Context.Diags, PSPs.MainInputFilenameForDebugInfo);
1220+
1221+
CurrentPrimaryInputRAII cpi(Context.Diags,
1222+
PSPs.MainInputFilenameForDebugInfo);
12231223

12241224
if (Stats)
12251225
countStatsPostSILGen(*Stats, *SM);
@@ -1630,10 +1630,9 @@ int swift::performFrontend(ArrayRef<const char *> Args,
16301630

16311631
PDC.handleDiagnostic(dummyMgr, SourceLoc(), DiagnosticKind::Error,
16321632
"fatal error encountered during compilation; please "
1633-
"file a bug report with your project and the crash "
1634-
"log", {},
1635-
DiagnosticInfo(),
1636-
"");
1633+
"file a bug report with your project and the crash "
1634+
"log",
1635+
{}, DiagnosticInfo(), "");
16371636
PDC.handleDiagnostic(dummyMgr, SourceLoc(), DiagnosticKind::Note, reason,
16381637
{}, DiagnosticInfo(), "");
16391638
if (shouldCrash)

lib/Migrator/FixitApplyDiagnosticConsumer.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,10 @@ void FixitApplyDiagnosticConsumer::printResult(llvm::raw_ostream &OS) const {
3131
RewriteBuf.write(OS);
3232
}
3333

34-
void FixitApplyDiagnosticConsumer::
35-
handleDiagnostic(SourceManager &SM, SourceLoc Loc,
36-
DiagnosticKind Kind,
37-
StringRef FormatString,
38-
ArrayRef<DiagnosticArgument> FormatArgs,
39-
const DiagnosticInfo &Info,
40-
StringRef currentPrimaryInput) {
34+
void FixitApplyDiagnosticConsumer::handleDiagnostic(
35+
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
36+
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
37+
const DiagnosticInfo &Info, StringRef currentPrimaryInput) {
4138
if (Loc.isInvalid()) {
4239
return;
4340
}

lib/Sema/InstrumenterSupport.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ class ErrorGatherer : public DiagnosticConsumer {
3333
diags.addConsumer(*this);
3434
}
3535
~ErrorGatherer() override { diags.takeConsumers(); }
36-
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
37-
DiagnosticKind Kind,
36+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
3837
StringRef FormatString,
3938
ArrayRef<DiagnosticArgument> FormatArgs,
4039
const DiagnosticInfo &Info,

lib/Sema/TypeChecker.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,6 @@ void swift::typeCheckExternalDefinitions(SourceFile &SF) {
449449
typeCheckFunctionsAndExternalDecls(SF, createTypeChecker(Ctx));
450450
}
451451

452-
453452
void swift::performTypeChecking(SourceFile &SF, TopLevelContext &TLC,
454453
OptionSet<TypeCheckingFlags> Options,
455454
unsigned StartElem,

tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ class StreamDiagConsumer : public DiagnosticConsumer {
4646
public:
4747
StreamDiagConsumer(llvm::raw_ostream &OS) : OS(OS) {}
4848

49-
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
50-
DiagnosticKind Kind,
49+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
5150
StringRef FormatString,
5251
ArrayRef<DiagnosticArgument> FormatArgs,
5352
const DiagnosticInfo &Info,

tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp

+8-14
Original file line numberDiff line numberDiff line change
@@ -1180,12 +1180,10 @@ accept(SourceManager &SM, RegionType RegionType,
11801180
Impl.accept(SM, RegionType, Replacements);
11811181
}
11821182

1183-
void RequestRefactoringEditConsumer::
1184-
handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
1185-
StringRef FormatString,
1186-
ArrayRef<DiagnosticArgument> FormatArgs,
1187-
const DiagnosticInfo &Info,
1188-
StringRef currentPrimaryInput) {
1183+
void RequestRefactoringEditConsumer::handleDiagnostic(
1184+
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
1185+
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
1186+
const DiagnosticInfo &Info, StringRef currentPrimaryInput) {
11891187
Impl.DiagConsumer.handleDiagnostic(SM, Loc, Kind, FormatString, FormatArgs,
11901188
Info, currentPrimaryInput);
11911189
}
@@ -1241,14 +1239,10 @@ void RequestRenameRangeConsumer::accept(
12411239
Impl.accept(SM, RegionType, Ranges);
12421240
}
12431241

1244-
void RequestRenameRangeConsumer::
1245-
handleDiagnostic(SourceManager &SM,
1246-
SourceLoc Loc,
1247-
DiagnosticKind Kind,
1248-
StringRef FormatString,
1249-
ArrayRef<DiagnosticArgument> FormatArgs,
1250-
const DiagnosticInfo &Info,
1251-
StringRef currentPrimaryInput) {
1242+
void RequestRenameRangeConsumer::handleDiagnostic(
1243+
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
1244+
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
1245+
const DiagnosticInfo &Info, StringRef currentPrimaryInput) {
12521246
Impl.DiagConsumer.handleDiagnostic(SM, Loc, Kind, FormatString, FormatArgs,
12531247
Info, currentPrimaryInput);
12541248
}

tools/SourceKit/lib/SwiftLang/SwiftEditorDiagConsumer.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ class EditorDiagConsumer : public swift::DiagnosticConsumer {
6767
bool hadAnyError() const { return HadAnyError; }
6868

6969
void handleDiagnostic(swift::SourceManager &SM, swift::SourceLoc Loc,
70-
swift::DiagnosticKind Kind,
71-
StringRef FormatString,
70+
swift::DiagnosticKind Kind, StringRef FormatString,
7271
ArrayRef<swift::DiagnosticArgument> FormatArgs,
7372
const swift::DiagnosticInfo &Info,
7473
StringRef currentPrimaryInput) override;

tools/SourceKit/lib/SwiftLang/SwiftLangSupport.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ class RequestRefactoringEditConsumer: public swift::ide::SourceEditConsumer,
247247
void accept(swift::SourceManager &SM, swift::ide::RegionType RegionType,
248248
ArrayRef<swift::ide::Replacement> Replacements) override;
249249
void handleDiagnostic(swift::SourceManager &SM, swift::SourceLoc Loc,
250-
swift::DiagnosticKind Kind,
251-
StringRef FormatString,
250+
swift::DiagnosticKind Kind, StringRef FormatString,
252251
ArrayRef<swift::DiagnosticArgument> FormatArgs,
253252
const swift::DiagnosticInfo &Info,
254253
StringRef currentPrimaryInput) override;
@@ -265,8 +264,7 @@ class RequestRenameRangeConsumer : public swift::ide::FindRenameRangesConsumer,
265264
void accept(swift::SourceManager &SM, swift::ide::RegionType RegionType,
266265
ArrayRef<swift::ide::RenameRangeDetail> Ranges) override;
267266
void handleDiagnostic(swift::SourceManager &SM, swift::SourceLoc Loc,
268-
swift::DiagnosticKind Kind,
269-
StringRef FormatString,
267+
swift::DiagnosticKind Kind, StringRef FormatString,
270268
ArrayRef<swift::DiagnosticArgument> FormatArgs,
271269
const swift::DiagnosticInfo &Info,
272270
StringRef currentPrimaryInput) override;

tools/libSwiftSyntaxParser/libSwiftSyntaxParser.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ struct SynParserDiagConsumer: public DiagnosticConsumer {
229229
const unsigned BufferID;
230230
SynParserDiagConsumer(SynParser &Parser, unsigned BufferID):
231231
Parser(Parser), BufferID(BufferID) {}
232-
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
233-
DiagnosticKind Kind,
232+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
234233
StringRef FormatString,
235234
ArrayRef<DiagnosticArgument> FormatArgs,
236235
const DiagnosticInfo &Info,

tools/swift-api-digester/ModuleDiagsConsumer.cpp

+6-9
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,14 @@ ModuleDifferDiagsConsumer::ModuleDifferDiagsConsumer(bool DiagnoseModuleDiff,
8989
#include "swift/AST/DiagnosticsModuleDiffer.def"
9090
}
9191

92-
void swift::ide::api::
93-
ModuleDifferDiagsConsumer::handleDiagnostic(SourceManager &SM, SourceLoc Loc,
94-
DiagnosticKind Kind,
95-
StringRef FormatString,
96-
ArrayRef<DiagnosticArgument> FormatArgs,
97-
const DiagnosticInfo &Info,
98-
StringRef currentPrimaryInput) {
92+
void swift::ide::api::ModuleDifferDiagsConsumer::handleDiagnostic(
93+
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
94+
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
95+
const DiagnosticInfo &Info, StringRef currentPrimaryInput) {
9996
auto Category = getCategoryName((uint32_t)Info.ID);
10097
if (Category.empty()) {
101-
PrintingDiagnosticConsumer::handleDiagnostic(SM, Loc, Kind, FormatString,
102-
FormatArgs, Info, currentPrimaryInput);
98+
PrintingDiagnosticConsumer::handleDiagnostic(
99+
SM, Loc, Kind, FormatString, FormatArgs, Info, currentPrimaryInput);
103100
return;
104101
}
105102
if (!DiagnoseModuleDiff)

0 commit comments

Comments
 (0)