Skip to content

Commit 9c7639d

Browse files
authored
Merge pull request swiftlang#68289 from DougGregor/swiftsyntax-diags-cleanup
2 parents 33be23e + eb9b736 commit 9c7639d

9 files changed

+85
-903
lines changed

include/swift/Basic/SourceManager.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,6 @@ class SourceManager {
410410
SourceLoc();
411411
}
412412

413-
std::string getLineString(unsigned BufferID, unsigned LineNumber);
414-
415413
/// Retrieve the buffer ID for \p Path, loading if necessary.
416414
unsigned getExternalSourceBufferID(StringRef Path);
417415

include/swift/Frontend/PrintingDiagnosticConsumer.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "llvm/Support/Process.h"
2828

2929
namespace swift {
30-
class AnnotatedSourceSnippet;
3130

3231
/// Diagnostic consumer that displays diagnostics to standard error.
3332
class PrintingDiagnosticConsumer : public DiagnosticConsumer {
@@ -38,10 +37,6 @@ class PrintingDiagnosticConsumer : public DiagnosticConsumer {
3837
bool DidErrorOccur = false;
3938
DiagnosticOptions::FormattingStyle FormattingStyle =
4039
DiagnosticOptions::FormattingStyle::LLVM;
41-
// The current snippet used to display an error/warning/remark and the notes
42-
// implicitly associated with it. Uses `std::unique_ptr` so that
43-
// `AnnotatedSourceSnippet` can be forward declared.
44-
std::unique_ptr<AnnotatedSourceSnippet> currentSnippet;
4540
// Educational notes which are buffered until the consumer is finished
4641
// constructing a snippet.
4742
SmallVector<std::string, 1> BufferedEducationalNotes;

lib/ASTGen/Sources/ASTGen/Diagnostics.swift

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ fileprivate func emitDiagnosticParts(
1414
let bridgedDiagEngine = BridgedDiagnosticEngine(raw: diagEnginePtr)
1515

1616
// Map severity
17-
let bridgedSeverity: BridgedDiagnosticSeverity
18-
switch severity {
19-
case .error: bridgedSeverity = .error
20-
case .note: bridgedSeverity = .note
21-
case .warning: bridgedSeverity = .warning
22-
}
17+
let bridgedSeverity = severity.bridged
2318

2419
func bridgedSourceLoc(at position: AbsolutePosition) -> BridgedSourceLoc {
2520
return BridgedSourceLoc(at: position, in: sourceFileBuffer)
@@ -119,6 +114,18 @@ func emitDiagnostic(
119114
}
120115
}
121116

117+
extension DiagnosticSeverity {
118+
var bridged: BridgedDiagnosticSeverity {
119+
switch self {
120+
case .error: return .error
121+
case .note: return .note
122+
case .warning: return .warning
123+
case .remark: return .remark
124+
@unknown default: return .error
125+
}
126+
}
127+
}
128+
122129
extension SourceManager {
123130
private func diagnoseSingle<Node: SyntaxProtocol>(
124131
message: String,
@@ -129,12 +136,7 @@ extension SourceManager {
129136
fixItChanges: [FixIt.Change] = []
130137
) {
131138
// Map severity
132-
let bridgedSeverity: BridgedDiagnosticSeverity
133-
switch severity {
134-
case .error: bridgedSeverity = .error
135-
case .note: bridgedSeverity = .note
136-
case .warning: bridgedSeverity = .warning
137-
}
139+
let bridgedSeverity = severity.bridged
138140

139141
// Emit the diagnostic
140142
var mutableMessage = message
@@ -292,7 +294,7 @@ extension BridgedDiagnosticSeverity {
292294
case .fatalError: return .error
293295
case .error: return .error
294296
case .warning: return .warning
295-
case .remark: return .warning // FIXME
297+
case .remark: return .remark
296298
case .note: return .note
297299
@unknown default: return .error
298300
}
@@ -443,7 +445,7 @@ public func addQueuedDiagnostic(
443445

444446
/// Render the queued diagnostics into a UTF-8 string.
445447
@_cdecl("swift_ASTGen_renderQueuedDiagnostics")
446-
public func renterQueuedDiagnostics(
448+
public func renderQueuedDiagnostics(
447449
queuedDiagnosticsPtr: UnsafeMutablePointer<UInt8>,
448450
contextSize: Int,
449451
colorize: Int,

lib/ASTGen/Sources/ASTGen/PluginHost.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ class PluginDiagnosticsEngine {
269269
case .error: bridgedSeverity = .error
270270
case .note: bridgedSeverity = .note
271271
case .warning: bridgedSeverity = .warning
272+
case .remark: bridgedSeverity = .remark
273+
@unknown default: bridgedSeverity = .error
272274
}
273275

274276
// Emit the diagnostic

0 commit comments

Comments
 (0)