summaryrefslogtreecommitdiffstats
path: root/lib/Basic/DiagnosticIDs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Basic/DiagnosticIDs.cpp')
-rw-r--r--lib/Basic/DiagnosticIDs.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/Basic/DiagnosticIDs.cpp b/lib/Basic/DiagnosticIDs.cpp
index 8f2c3d06a5..e8a99d08a9 100644
--- a/lib/Basic/DiagnosticIDs.cpp
+++ b/lib/Basic/DiagnosticIDs.cpp
@@ -1,9 +1,8 @@
//===--- DiagnosticIDs.cpp - Diagnostic IDs Handling ----------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -457,12 +456,17 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc,
if (Result == diag::Severity::Ignored)
return Result;
- // Honor -w, which is lower in priority than pedantic-errors, but higher than
- // -Werror.
- // FIXME: Under GCC, this also suppresses warnings that have been mapped to
- // errors by -W flags and #pragma diagnostic.
- if (Result == diag::Severity::Warning && State->IgnoreAllWarnings)
- return diag::Severity::Ignored;
+ // Honor -w: this disables all messages which which are not Error/Fatal by
+ // default (disregarding attempts to upgrade severity from Warning to Error),
+ // as well as disabling all messages which are currently mapped to Warning
+ // (whether by default or downgraded from Error via e.g. -Wno-error or #pragma
+ // diagnostic.)
+ if (State->IgnoreAllWarnings) {
+ if (Result == diag::Severity::Warning ||
+ (Result >= diag::Severity::Error &&
+ !isDefaultMappingAsError((diag::kind)DiagID)))
+ return diag::Severity::Ignored;
+ }
// If -Werror is enabled, map warnings to errors unless explicitly disabled.
if (Result == diag::Severity::Warning) {
@@ -477,6 +481,11 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc,
Result = diag::Severity::Fatal;
}
+ // If explicitly requested, map fatal errors to errors.
+ if (Result == diag::Severity::Fatal &&
+ Diag.CurDiagID != diag::fatal_too_many_errors && Diag.FatalsAsError)
+ Result = diag::Severity::Error;
+
// Custom diagnostics always are emitted in system headers.
bool ShowInSystemHeader =
!GetDiagInfo(DiagID) || GetDiagInfo(DiagID)->WarnShowInSystemHeader;
@@ -656,7 +665,7 @@ bool DiagnosticIDs::ProcessDiag(DiagnosticsEngine &Diag) const {
// If a fatal error has already been emitted, silence all subsequent
// diagnostics.
- if (Diag.FatalErrorOccurred && Diag.SuppressAfterFatalError) {
+ if (Diag.FatalErrorOccurred) {
if (DiagLevel >= DiagnosticIDs::Error &&
Diag.Client->IncludeInDiagnosticCounts()) {
++Diag.NumErrors;