[cfe-commits] r103056 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Driver/Options.td include/clang/Frontend/DiagnosticOptions.h lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/TextDiagnosticPrinter.cpp
Chris Lattner
sabre at nondot.org
Tue May 4 14:55:25 PDT 2010
Author: lattner
Date: Tue May 4 16:55:25 2010
New Revision: 103056
URL: http://llvm.org/viewvc/llvm-project?rev=103056&view=rev
Log:
add a new -fdiagnostics-show-category=none/id/name option, giving control
over choice of:
t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat]
t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,1]
t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,Format String]
dox to come.
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/DiagnosticOptions.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=103056&r1=103055&r2=103056&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Tue May 4 16:55:25 2010
@@ -196,6 +196,9 @@
HelpText<"Print source range spans in numeric form">;
def fdiagnostics_show_option : Flag<"-fdiagnostics-show-option">,
HelpText<"Print diagnostic name with mappable diagnostics">;
+def fdiagnostics_show_category : Separate<"-fdiagnostics-show-category">,
+ HelpText<"Print diagnostic category">;
+
def ftabstop : Separate<"-ftabstop">, MetaVarName<"<N>">,
HelpText<"Set the tab stop distance.">;
def ferror_limit : Separate<"-ferror-limit">, MetaVarName<"<N>">,
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=103056&r1=103055&r2=103056&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue May 4 16:55:25 2010
@@ -257,6 +257,7 @@
def fdiagnostics_fixit_info : Flag<"-fdiagnostics-fixit-info">, Group<f_Group>;
def fdiagnostics_print_source_range_info : Flag<"-fdiagnostics-print-source-range-info">, Group<f_Group>;
def fdiagnostics_show_option : Flag<"-fdiagnostics-show-option">, Group<f_Group>;
+def fdiagnostics_show_category_EQ : Joined<"-fdiagnostics-show-category=">, Group<f_Group>;
def fdollars_in_identifiers : Flag<"-fdollars-in-identifiers">, Group<f_Group>;
def feliminate_unused_debug_symbols : Flag<"-feliminate-unused-debug-symbols">, Group<f_Group>;
def femit_all_decls : Flag<"-femit-all-decls">, Group<f_Group>;
Modified: cfe/trunk/include/clang/Frontend/DiagnosticOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DiagnosticOptions.h?rev=103056&r1=103055&r2=103056&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/DiagnosticOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/DiagnosticOptions.h Tue May 4 16:55:25 2010
@@ -30,6 +30,8 @@
unsigned ShowSourceRanges : 1; /// Show source ranges in numeric form.
unsigned ShowOptionNames : 1; /// Show the diagnostic name for mappable
/// diagnostics.
+ unsigned ShowCategories : 2; /// Show categories: 0 -> none, 1 -> Number,
+ /// 2 -> Full Name.
unsigned ShowColors : 1; /// Show diagnostics with ANSI color sequences.
unsigned VerifyDiagnostics: 1; /// Check that diagnostics match the expected
/// diagnostics, indicated by markers in the
@@ -74,6 +76,7 @@
ShowFixits = 1;
ShowLocation = 1;
ShowOptionNames = 0;
+ ShowCategories = 0;
ShowSourceRanges = 0;
VerifyDiagnostics = 0;
BinaryOutput = 0;
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=103056&r1=103055&r2=103056&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue May 4 16:55:25 2010
@@ -1320,6 +1320,12 @@
options::OPT_fno_diagnostics_show_option))
CmdArgs.push_back("-fdiagnostics-show-option");
+ if (const Arg *A =
+ Args.getLastArg(options::OPT_fdiagnostics_show_category_EQ)) {
+ CmdArgs.push_back("-fdiagnostics-show-category");
+ CmdArgs.push_back(A->getValue(Args));
+ }
+
// Color diagnostics are the default, unless the terminal doesn't support
// them.
if (Args.hasFlag(options::OPT_fcolor_diagnostics,
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=103056&r1=103055&r2=103056&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue May 4 16:55:25 2010
@@ -243,6 +243,10 @@
Res.push_back("-fdiagnostics-binary");
if (Opts.ShowOptionNames)
Res.push_back("-fdiagnostics-show-option");
+ if (Opts.ShowCategories == 1)
+ Res.push_back("-fdiagnostics-show-category=id");
+ else if (Opts.ShowCategories == 2)
+ Res.push_back("-fdiagnostics-show-category=name");
if (Opts.ErrorLimit) {
Res.push_back("-ferror-limit");
Res.push_back(llvm::utostr(Opts.ErrorLimit));
@@ -879,6 +883,20 @@
Opts.ShowFixits = !Args.hasArg(OPT_fno_diagnostics_fixit_info);
Opts.ShowLocation = !Args.hasArg(OPT_fno_show_source_location);
Opts.ShowOptionNames = Args.hasArg(OPT_fdiagnostics_show_option);
+
+ llvm::StringRef ShowCategory =
+ getLastArgValue(Args, OPT_fdiagnostics_show_category, "none");
+ if (ShowCategory == "none")
+ Opts.ShowCategories = 0;
+ else if (ShowCategory == "id")
+ Opts.ShowCategories = 1;
+ else if (ShowCategory == "name")
+ Opts.ShowCategories = 2;
+ else
+ Diags.Report(diag::err_drv_invalid_value)
+ << Args.getLastArg(OPT_fdiagnostics_show_category)->getAsString(Args)
+ << ShowCategory;
+
Opts.ShowSourceRanges = Args.hasArg(OPT_fdiagnostics_print_source_range_info);
Opts.VerifyDiagnostics = Args.hasArg(OPT_verify);
Opts.BinaryOutput = Args.hasArg(OPT_fdiagnostics_binary);
Modified: cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp?rev=103056&r1=103055&r2=103056&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Tue May 4 16:55:25 2010
@@ -837,7 +837,7 @@
// If the user wants to see category information, include it too.
unsigned DiagCategory = 0;
- if (DiagOpts->ShowSourceRanges)
+ if (DiagOpts->ShowCategories)
DiagCategory = Diagnostic::getCategoryNumberForDiag(Info.getID());
// If there is any categorization information, include it.
@@ -852,7 +852,12 @@
if (DiagCategory) {
if (NeedsComma) OutStr += ',';
- OutStr += llvm::utostr(DiagCategory);
+ if (DiagOpts->ShowCategories == 1)
+ OutStr += llvm::utostr(DiagCategory);
+ else {
+ assert(DiagOpts->ShowCategories == 2 && "Invalid ShowCategories value");
+ OutStr += Diagnostic::getCategoryNameFromID(DiagCategory);
+ }
}
OutStr += "]";
More information about the cfe-commits
mailing list