[cfe-commits] r100687 - in /cfe/trunk: include/clang/Basic/Diagnostic.h include/clang/Driver/CC1Options.td include/clang/Frontend/DiagnosticOptions.h lib/Basic/Diagnostic.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/Warnings.cpp
Chris Lattner
sabre at nondot.org
Wed Apr 7 13:37:06 PDT 2010
Author: lattner
Date: Wed Apr 7 15:37:06 2010
New Revision: 100687
URL: http://llvm.org/viewvc/llvm-project?rev=100687&view=rev
Log:
add clang -cc1 level support for "-ferror-limit 42"
Modified:
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/DiagnosticOptions.h
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/Warnings.cpp
Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=100687&r1=100686&r2=100687&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Wed Apr 7 15:37:06 2010
@@ -188,7 +188,7 @@
bool ErrorsAsFatal; // Treat errors like fatal errors.
bool SuppressSystemWarnings; // Suppress warnings in system headers.
bool SuppressAllDiagnostics; // Suppress all diagnostics.
- unsigned MaxErrorsEmitted; // Cap of # errors emitted, 0 -> no limit.
+ unsigned ErrorLimit; // Cap of # errors emitted, 0 -> no limit.
ExtensionHandling ExtBehavior; // Map extensions onto warnings or errors?
DiagnosticClient *Client;
@@ -271,9 +271,9 @@
void setClient(DiagnosticClient* client) { Client = client; }
- /// setMaxErrorsEmitted - Specify a limit for the number of errors we should
+ /// setErrorLimit - Specify a limit for the number of errors we should
/// emit before giving up. Zero disables the limit.
- void setMaxErrorsEmitted(unsigned Limit) { MaxErrorsEmitted = Limit; }
+ void setErrorLimit(unsigned Limit) { ErrorLimit = Limit; }
/// setIgnoreAllWarnings - When set to true, any unmapped warnings are
/// ignored. If this and WarningsAsErrors are both set, then this one wins.
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=100687&r1=100686&r2=100687&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Wed Apr 7 15:37:06 2010
@@ -192,6 +192,8 @@
HelpText<"Print diagnostic name with mappable diagnostics">;
def ftabstop : Separate<"-ftabstop">, MetaVarName<"<N>">,
HelpText<"Set the tab stop distance.">;
+def ferror_limit : Separate<"-ferror-limit">, MetaVarName<"<N>">,
+ HelpText<"Set the maximum number of errors to emit before stopping (0 = no limit).">;
def fmessage_length : Separate<"-fmessage-length">, MetaVarName<"<N>">,
HelpText<"Format message diagnostics so that they fit within N columns or fewer, when possible.">;
def fcolor_diagnostics : Flag<"-fcolor-diagnostics">,
Modified: cfe/trunk/include/clang/Frontend/DiagnosticOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DiagnosticOptions.h?rev=100687&r1=100686&r2=100687&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/DiagnosticOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/DiagnosticOptions.h Wed Apr 7 15:37:06 2010
@@ -38,6 +38,8 @@
/// binary serialization mechanism, to be
/// deserialized by, e.g., the CIndex library.
+ unsigned ErrorLimit; /// Limit # errors emitted.
+
/// The distance between tab stops.
unsigned TabStop;
enum { DefaultTabStop = 8, MaxTabStop = 100 };
@@ -70,6 +72,7 @@
ShowSourceRanges = 0;
VerifyDiagnostics = 0;
BinaryOutput = 0;
+ ErrorLimit = 0;
}
};
Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=100687&r1=100686&r2=100687&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Wed Apr 7 15:37:06 2010
@@ -223,7 +223,7 @@
ErrorOccurred = false;
FatalErrorOccurred = false;
- MaxErrorsEmitted = 0;
+ ErrorLimit = 0;
NumWarnings = 0;
NumErrors = 0;
@@ -555,7 +555,7 @@
// If we've emitted a lot of errors, emit a fatal error after it to stop a
// flood of bogus errors.
- if (MaxErrorsEmitted && NumErrors >= MaxErrorsEmitted &&
+ if (ErrorLimit && NumErrors >= ErrorLimit &&
DiagLevel == Diagnostic::Error)
SetDelayedDiagnostic(diag::fatal_too_many_errors);
}
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=100687&r1=100686&r2=100687&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Apr 7 15:37:06 2010
@@ -232,6 +232,10 @@
Res.push_back("-fdiagnostics-binary");
if (Opts.ShowOptionNames)
Res.push_back("-fdiagnostics-show-option");
+ if (Opts.ErrorLimit) {
+ Res.push_back("-ferror-limit");
+ Res.push_back(llvm::utostr(Opts.ErrorLimit));
+ }
if (Opts.TabStop != DiagnosticOptions::DefaultTabStop) {
Res.push_back("-ftabstop");
Res.push_back(llvm::utostr(Opts.TabStop));
@@ -830,6 +834,7 @@
Opts.ShowSourceRanges = Args.hasArg(OPT_fdiagnostics_print_source_range_info);
Opts.VerifyDiagnostics = Args.hasArg(OPT_verify);
Opts.BinaryOutput = Args.hasArg(OPT_fdiagnostics_binary);
+ Opts.ErrorLimit = getLastArgIntValue(Args, OPT_ferror_limit, 0, Diags);
Opts.TabStop = getLastArgIntValue(Args, OPT_ftabstop,
DiagnosticOptions::DefaultTabStop, Diags);
if (Opts.TabStop == 0 || Opts.TabStop > DiagnosticOptions::MaxTabStop) {
Modified: cfe/trunk/lib/Frontend/Warnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Warnings.cpp?rev=100687&r1=100686&r2=100687&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/Warnings.cpp (original)
+++ cfe/trunk/lib/Frontend/Warnings.cpp Wed Apr 7 15:37:06 2010
@@ -35,6 +35,10 @@
const DiagnosticOptions &Opts) {
Diags.setSuppressSystemWarnings(true); // Default to -Wno-system-headers
Diags.setIgnoreAllWarnings(Opts.IgnoreWarnings);
+
+ // Handle -ferror-limit
+ if (Opts.ErrorLimit)
+ Diags.setErrorLimit(Opts.ErrorLimit);
// If -pedantic or -pedantic-errors was specified, then we want to map all
// extension diagnostics onto WARNING or ERROR unless the user has futz'd
More information about the cfe-commits
mailing list