From 08c6695f6018fb6cb1a7c7d311a851aa5c233bc0 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 7 Apr 2011 18:11:14 +0000 Subject: [PATCH] Frontend: Sketch support for -diagnostic-log-file, which still doesn't do anything. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129086 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticFrontendKinds.td | 2 +- include/clang/Driver/CC1Options.td | 2 ++ include/clang/Frontend/DiagnosticOptions.h | 3 +++ lib/Frontend/CompilerInvocation.cpp | 5 +++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td index 6ad9529c5f..d93502c774 100644 --- a/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/include/clang/Basic/DiagnosticFrontendKinds.td @@ -79,7 +79,7 @@ def warn_fe_macro_contains_embedded_newline : Warning< "macro '%0' contains embedded newline, text after the newline is ignored.">; def warn_fe_cc_print_header_failure : Warning< "unable to open CC_PRINT_HEADERS file: %0 (using stderr)">; -def warn_fe_cc_log_diagnositcs_failure : Warning< +def warn_fe_cc_log_diagnostics_failure : Warning< "unable to open CC_LOG_DIAGNOSTICS file: %0 (using stderr)">; def err_verify_missing_start : Error< diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index 7c1a9f071e..f2aba0dfcb 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -201,6 +201,8 @@ def MP : Flag<"-MP">, def dump_build_information : Separate<"-dump-build-information">, MetaVarName<"">, HelpText<"output a dump of some build information to a file">; +def diagnostic_log_file : Separate<"-diagnostic-log-file">, + HelpText<"Filename (or -) to log diagnostics to">; def fno_show_column : Flag<"-fno-show-column">, HelpText<"Do not include column number on diagnostics">; def fno_show_source_location : Flag<"-fno-show-source-location">, diff --git a/include/clang/Frontend/DiagnosticOptions.h b/include/clang/Frontend/DiagnosticOptions.h index 4e46b4fbf0..2193591368 100644 --- a/include/clang/Frontend/DiagnosticOptions.h +++ b/include/clang/Frontend/DiagnosticOptions.h @@ -61,6 +61,9 @@ public: /// testing and analysis. std::string DumpBuildInformation; + /// The file to log diagnostic output to. + std::string DiagnosticLogFile; + /// The list of -W... options used to alter the diagnostic mappings, with the /// prefixes removed. std::vector Warnings; diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 4fc8b5bdf7..df876d80c7 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -273,6 +273,10 @@ static void DiagnosticOptsToArgs(const DiagnosticOptions &Opts, Res.push_back("-ferror-limit"); Res.push_back(llvm::utostr(Opts.ErrorLimit)); } + if (!Opts.DiagnosticLogFile.empty()) { + Res.push_back("-diagnostic-log-file"); + Res.push_back(Opts.DiagnosticLogFile); + } if (Opts.MacroBacktraceLimit != DiagnosticOptions::DefaultMacroBacktraceLimit) { Res.push_back("-fmacro-backtrace-limit"); @@ -981,6 +985,7 @@ static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts, static void ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args, Diagnostic &Diags) { using namespace cc1options; + Opts.DiagnosticLogFile = Args.getLastArgValue(OPT_diagnostic_log_file); Opts.IgnoreWarnings = Args.hasArg(OPT_w); Opts.NoRewriteMacros = Args.hasArg(OPT_Wno_rewrite_macros); Opts.Pedantic = Args.hasArg(OPT_pedantic); -- 2.50.1