aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-07 20:37:06 +0000
committerChris Lattner <sabre@nondot.org>2010-04-07 20:37:06 +0000
commitc100214fdc41a7ea215f75d433eb1cb829fd4330 (patch)
treea9fbde6b08a2037f5454b5ffa50422c9f7296b12
parentfc2ca56874e1c8186ac30c0c3af13dc5e806cf74 (diff)
add clang -cc1 level support for "-ferror-limit 42"
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100687 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/Diagnostic.h6
-rw-r--r--include/clang/Driver/CC1Options.td2
-rw-r--r--include/clang/Frontend/DiagnosticOptions.h3
-rw-r--r--lib/Basic/Diagnostic.cpp4
-rw-r--r--lib/Frontend/CompilerInvocation.cpp5
-rw-r--r--lib/Frontend/Warnings.cpp4
6 files changed, 19 insertions, 5 deletions
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h
index 8eb68a396a..e088965996 100644
--- a/include/clang/Basic/Diagnostic.h
+++ b/include/clang/Basic/Diagnostic.h
@@ -188,7 +188,7 @@ private:
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 @@ public:
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.
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index 124288a763..93cf495b52 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -192,6 +192,8 @@ def fdiagnostics_show_option : Flag<"-fdiagnostics-show-option">,
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">,
diff --git a/include/clang/Frontend/DiagnosticOptions.h b/include/clang/Frontend/DiagnosticOptions.h
index b37c18057f..d8ec14f9a3 100644
--- a/include/clang/Frontend/DiagnosticOptions.h
+++ b/include/clang/Frontend/DiagnosticOptions.h
@@ -38,6 +38,8 @@ public:
/// 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 @@ public:
ShowSourceRanges = 0;
VerifyDiagnostics = 0;
BinaryOutput = 0;
+ ErrorLimit = 0;
}
};
diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp
index 388875cf63..738c27ccae 100644
--- a/lib/Basic/Diagnostic.cpp
+++ b/lib/Basic/Diagnostic.cpp
@@ -223,7 +223,7 @@ Diagnostic::Diagnostic(DiagnosticClient *client) : Client(client) {
ErrorOccurred = false;
FatalErrorOccurred = false;
- MaxErrorsEmitted = 0;
+ ErrorLimit = 0;
NumWarnings = 0;
NumErrors = 0;
@@ -555,7 +555,7 @@ bool Diagnostic::ProcessDiag() {
// 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);
}
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index dc2c6bf361..b9afcb5cfa 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -232,6 +232,10 @@ static void DiagnosticOptsToArgs(const DiagnosticOptions &Opts,
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 @@ static void ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
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) {
diff --git a/lib/Frontend/Warnings.cpp b/lib/Frontend/Warnings.cpp
index ea9635e798..39cda8783b 100644
--- a/lib/Frontend/Warnings.cpp
+++ b/lib/Frontend/Warnings.cpp
@@ -35,6 +35,10 @@ void clang::ProcessWarningOptions(Diagnostic &Diags,
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