summaryrefslogtreecommitdiffstats
path: root/lib/Frontend/Warnings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Frontend/Warnings.cpp')
-rw-r--r--lib/Frontend/Warnings.cpp37
1 files changed, 29 insertions, 8 deletions
diff --git a/lib/Frontend/Warnings.cpp b/lib/Frontend/Warnings.cpp
index ff44c90..4bf507d 100644
--- a/lib/Frontend/Warnings.cpp
+++ b/lib/Frontend/Warnings.cpp
@@ -13,12 +13,12 @@
//
// This file is responsible for handling all warning options. This includes
// a number of -Wfoo options and their variants, which are driven by TableGen-
-// generated data, and the special cases -pedantic, -pedantic-errors, -w and
-// -Werror.
+// generated data, and the special cases -pedantic, -pedantic-errors, -w,
+// -Werror and -Wfatal-errors.
//
// Each warning option controls any number of actual warnings.
// Given a warning option 'foo', the following are valid:
-// -Wfoo, -Wno-foo, -Werror=foo
+// -Wfoo, -Wno-foo, -Werror=foo, -Wfatal-errors=foo
//
#include "clang/Frontend/Utils.h"
#include "clang/Basic/Diagnostic.h"
@@ -26,7 +26,6 @@
#include "clang/Lex/LexDiagnostic.h"
#include "clang/Frontend/DiagnosticOptions.h"
#include "clang/Frontend/FrontendDiagnostic.h"
-#include <cstdio>
#include <cstring>
#include <utility>
#include <algorithm>
@@ -47,8 +46,6 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags,
else
Diags.setExtensionHandlingBehavior(Diagnostic::Ext_Ignore);
- // FIXME: -Wfatal-errors / -Wfatal-errors=foo
-
for (unsigned i = 0, e = Opts.Warnings.size(); i != e; ++i) {
const std::string &Opt = Opts.Warnings[i];
const char *OptStart = &Opt[0];
@@ -81,8 +78,8 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags,
if (OptEnd-OptStart != 5) { // Specifier must be present.
if ((OptStart[5] != '=' && OptStart[5] != '-') ||
OptEnd-OptStart == 6) {
- fprintf(stderr, "warning: unknown -Werror warning specifier: -W%s\n",
- Opt.c_str());
+ Diags.Report(diag::warn_unknown_warning_specifier)
+ << "-Werror" << ("-W" + Opt);
continue;
}
Specifier = OptStart+6;
@@ -98,6 +95,30 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags,
OptStart = Specifier;
}
+ // -Wfatal-errors is yet another special case.
+ if (OptEnd-OptStart >= 12 && memcmp(OptStart, "fatal-errors", 12) == 0) {
+ const char* Specifier = 0;
+ if (OptEnd-OptStart != 12) {
+ if ((OptStart[12] != '=' && OptStart[12] != '-') ||
+ OptEnd-OptStart == 13) {
+ Diags.Report(diag::warn_unknown_warning_specifier)
+ << "-Wfatal-errors" << ("-W" + Opt);
+ continue;
+ }
+ Specifier = OptStart + 13;
+ }
+
+ if (Specifier == 0) {
+ Diags.setErrorsAsFatal(isPositive);
+ continue;
+ }
+
+ // -Wfatal-errors=foo maps foo to Fatal, -Wno-fatal-errors=foo
+ // maps it to Error.
+ Mapping = isPositive ? diag::MAP_FATAL : diag::MAP_ERROR_NO_WFATAL;
+ OptStart = Specifier;
+ }
+
if (Diags.setDiagnosticGroupMapping(OptStart, Mapping))
Diags.Report(diag::warn_unknown_warning_option) << ("-W" + Opt);
}
OpenPOWER on IntegriCloud