Implement '-Weverything', which enables all warnings except those explicitly mapped to be ignored.
Currently this includes -pedantic warnings as well; we'll need to consider whether these should
be included.
This works as expected with -Werror.
Test cases were added to Sema/warn-unused-parameters.c, but they should probably be broken off into
their own test file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137910 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Basic/DiagnosticIDs.cpp b/lib/Basic/DiagnosticIDs.cpp
index fa397c9..ace92ac 100644
--- a/lib/Basic/DiagnosticIDs.cpp
+++ b/lib/Basic/DiagnosticIDs.cpp
@@ -496,14 +496,27 @@
switch (MappingInfo & 7) {
default: assert(0 && "Unknown mapping!");
case diag::MAP_IGNORE:
- // Ignore this, unless this is an extension diagnostic and we're mapping
- // them onto warnings or errors.
- if (!isBuiltinExtensionDiag(DiagID) || // Not an extension
- Diag.ExtBehavior == Diagnostic::Ext_Ignore || // Ext ignored
- (MappingInfo & 8) != 0) // User explicitly mapped it.
+ if (Diag.EnableAllWarnings) {
+ // Leave the warning disabled if it was explicitly ignored.
+ if ((MappingInfo & 8) != 0)
+ return DiagnosticIDs::Ignored;
+
+ Result = Diag.WarningsAsErrors ? DiagnosticIDs::Error
+ : DiagnosticIDs::Warning;
+ }
+ // Otherwise, ignore this diagnostic unless this is an extension diagnostic
+ // and we're mapping them onto warnings or errors.
+ else if (!isBuiltinExtensionDiag(DiagID) || // Not an extension
+ Diag.ExtBehavior == Diagnostic::Ext_Ignore || // Ext ignored
+ (MappingInfo & 8) != 0) { // User explicitly mapped it.
return DiagnosticIDs::Ignored;
- Result = DiagnosticIDs::Warning;
- if (Diag.ExtBehavior == Diagnostic::Ext_Error) Result = DiagnosticIDs::Error;
+ }
+ else {
+ Result = DiagnosticIDs::Warning;
+ }
+
+ if (Diag.ExtBehavior == Diagnostic::Ext_Error)
+ Result = DiagnosticIDs::Error;
if (Result == DiagnosticIDs::Error && Diag.ErrorsAsFatal)
Result = DiagnosticIDs::Fatal;
break;