[Diagnostics] Add a swift-syntax diagnostic style

The SwiftDiagnostics module within swift-syntax has a diagnostic
pretty-printer that does a nice rendering of the source code with
diagnostics placed inside gaps between the code lines.
Introduce another `-diagnostic-style` argument, `swift-syntax`,
to bridge from the pretty-printed C++ diagnostics over to the
swift-syntax diagnostics engine.
This commit is contained in:
Doug Gregor
2023-01-21 22:50:55 -08:00
parent ad49d2e7a2
commit bdf1183757
6 changed files with 267 additions and 6 deletions

View File

@@ -1466,6 +1466,9 @@ static bool ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
Opts.PrintedFormattingStyle = DiagnosticOptions::FormattingStyle::LLVM;
} else if (contents == "swift") {
Opts.PrintedFormattingStyle = DiagnosticOptions::FormattingStyle::Swift;
} else if (contents == "swift-syntax") {
Opts.PrintedFormattingStyle =
DiagnosticOptions::FormattingStyle::SwiftSyntax;
} else {
Diags.diagnose(SourceLoc(), diag::error_unsupported_option_argument,
arg->getOption().getPrefixedName(), arg->getValue());