@@ -887,19 +887,33 @@ static bool ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
887887 Opts.SkipDiagnosticPasses |= Args.hasArg (OPT_disable_diagnostic_passes);
888888 Opts.ShowDiagnosticsAfterFatalError |=
889889 Args.hasArg (OPT_show_diagnostics_after_fatal);
890+
890891 Opts.UseColor |=
891892 Args.hasFlag (OPT_color_diagnostics,
892893 OPT_no_color_diagnostics,
893894 /* Default=*/ llvm::sys::Process::StandardErrHasColors ());
895+ // If no style options are specified, default to LLVM style.
896+ Opts.PrintedFormattingStyle = DiagnosticOptions::FormattingStyle::LLVM;
897+ if (const Arg *arg = Args.getLastArg (OPT_diagnostic_style)) {
898+ StringRef contents = arg->getValue ();
899+ if (contents == " llvm" ) {
900+ Opts.PrintedFormattingStyle = DiagnosticOptions::FormattingStyle::LLVM;
901+ } else if (contents == " swift" ) {
902+ Opts.PrintedFormattingStyle = DiagnosticOptions::FormattingStyle::Swift;
903+ } else {
904+ Diags.diagnose (SourceLoc (), diag::error_unsupported_option_argument,
905+ arg->getOption ().getPrefixedName (), arg->getValue ());
906+ return true ;
907+ }
908+ }
909+
894910 Opts.FixitCodeForAllDiagnostics |= Args.hasArg (OPT_fixit_all);
895911 Opts.SuppressWarnings |= Args.hasArg (OPT_suppress_warnings);
896912 Opts.WarningsAsErrors = Args.hasFlag (options::OPT_warnings_as_errors,
897913 options::OPT_no_warnings_as_errors,
898914 false );
899915 Opts.PrintDiagnosticNames |= Args.hasArg (OPT_debug_diagnostic_names);
900916 Opts.PrintEducationalNotes |= Args.hasArg (OPT_print_educational_notes);
901- Opts.EnableExperimentalFormatting |=
902- Args.hasArg (OPT_enable_experimental_diagnostic_formatting);
903917 if (Arg *A = Args.getLastArg (OPT_diagnostic_documentation_path)) {
904918 Opts.DiagnosticDocumentationPath = A->getValue ();
905919 }
0 commit comments