[cfe-commits] r129951 - in /cfe/trunk: include/clang/Basic/Diagnostic.td include/clang/Basic/DiagnosticIDs.h include/clang/Basic/DiagnosticLexKinds.td lib/Basic/DiagnosticIDs.cpp test/Misc/warn-in-system-header.c test/Misc/warn-in-system-header.h
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Apr 21 16:08:23 PDT 2011
Author: akirtzidis
Date: Thu Apr 21 18:08:23 2011
New Revision: 129951
URL: http://llvm.org/viewvc/llvm-project?rev=129951&view=rev
Log:
Don't hide #warnings in a system header, same as gcc. Fixes rdar://8495837.
Added:
cfe/trunk/test/Misc/warn-in-system-header.c
cfe/trunk/test/Misc/warn-in-system-header.h
Modified:
cfe/trunk/include/clang/Basic/Diagnostic.td
cfe/trunk/include/clang/Basic/DiagnosticIDs.h
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Basic/DiagnosticIDs.cpp
Modified: cfe/trunk/include/clang/Basic/Diagnostic.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.td?rev=129951&r1=129950&r2=129951&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.td (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.td Thu Apr 21 18:08:23 2011
@@ -18,7 +18,8 @@
def MAP_WARNING : DiagMapping;
def MAP_ERROR : DiagMapping;
def MAP_FATAL : DiagMapping;
-def MAP_WARNING_NO_WERROR : DiagMapping;
+def MAP_WARNING_NO_WERROR : DiagMapping;
+def MAP_WARNING_SHOW_IN_SYSTEM_HEADER : DiagMapping;
// Define the diagnostic classes.
class DiagClass;
@@ -76,7 +77,10 @@
class DefaultWarn { DiagMapping DefaultMapping = MAP_WARNING; }
class DefaultError { DiagMapping DefaultMapping = MAP_ERROR; }
class DefaultFatal { DiagMapping DefaultMapping = MAP_FATAL; }
-class DefaultWarnNoWerror { DiagMapping DefaultMapping = MAP_WARNING_NO_WERROR; }
+class DefaultWarnNoWerror { DiagMapping DefaultMapping= MAP_WARNING_NO_WERROR; }
+class DefaultWarnShowInSystemHeader {
+ DiagMapping DefaultMapping = MAP_WARNING_SHOW_IN_SYSTEM_HEADER;
+}
class NoSFINAE { bit SFINAE = 0; }
class AccessControl { bit AccessControl = 1; }
Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=129951&r1=129950&r2=129951&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Thu Apr 21 18:08:23 2011
@@ -64,9 +64,12 @@
/// Map this diagnostic to "warning", but make it immune to -Werror. This
/// happens when you specify -Wno-error=foo.
MAP_WARNING_NO_WERROR = 5,
+ /// Map this diagnostic to "warning", but make it immune to
+ /// -Wno-system-headers.
+ MAP_WARNING_SHOW_IN_SYSTEM_HEADER = 6,
/// Map this diagnostic to "error", but make it immune to -Wfatal-errors.
/// This happens for -Wno-fatal-errors=foo.
- MAP_ERROR_NO_WFATAL = 6
+ MAP_ERROR_NO_WFATAL = 7
};
}
Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=129951&r1=129950&r2=129951&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Thu Apr 21 18:08:23 2011
@@ -114,7 +114,8 @@
//===----------------------------------------------------------------------===//
// Preprocessor Diagnostics
//===----------------------------------------------------------------------===//
-def pp_hash_warning : Warning<"#warning%0">, InGroup<PoundWarning>;
+def pp_hash_warning : Warning<"#warning%0">,
+ InGroup<PoundWarning>, DefaultWarnShowInSystemHeader;
def pp_include_next_in_primary : Warning<
"#include_next in primary source file">;
def pp_include_macros_out_of_predefines : Error<
Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=129951&r1=129950&r2=129951&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Thu Apr 21 18:08:23 2011
@@ -404,6 +404,8 @@
if (mapping)
*mapping = (diag::Mapping) (MappingInfo & 7);
+ bool ShouldEmitInSystemHeader = false;
+
switch (MappingInfo & 7) {
default: assert(0 && "Unknown mapping!");
case diag::MAP_IGNORE:
@@ -426,6 +428,9 @@
case diag::MAP_FATAL:
Result = DiagnosticIDs::Fatal;
break;
+ case diag::MAP_WARNING_SHOW_IN_SYSTEM_HEADER:
+ ShouldEmitInSystemHeader = true;
+ // continue as MAP_WARNING.
case diag::MAP_WARNING:
// If warnings are globally mapped to ignore or error, do it.
if (Diag.IgnoreAllWarnings)
@@ -477,6 +482,7 @@
DiagClass != CLASS_ERROR &&
// Custom diagnostics always are emitted in system headers.
DiagID < diag::DIAG_UPPER_LIMIT &&
+ !ShouldEmitInSystemHeader &&
Diag.SuppressSystemWarnings &&
Loc.isValid() &&
Diag.getSourceManager().isInSystemHeader(
Added: cfe/trunk/test/Misc/warn-in-system-header.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warn-in-system-header.c?rev=129951&view=auto
==============================================================================
--- cfe/trunk/test/Misc/warn-in-system-header.c (added)
+++ cfe/trunk/test/Misc/warn-in-system-header.c Thu Apr 21 18:08:23 2011
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -isystem %S %s -fsyntax-only -verify
+
+#include <warn-in-system-header.h>
+// expected-warning {{#warning}}
Added: cfe/trunk/test/Misc/warn-in-system-header.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warn-in-system-header.h?rev=129951&view=auto
==============================================================================
--- cfe/trunk/test/Misc/warn-in-system-header.h (added)
+++ cfe/trunk/test/Misc/warn-in-system-header.h Thu Apr 21 18:08:23 2011
@@ -0,0 +1,4 @@
+
+
+
+#warning the cake is a lie
More information about the cfe-commits
mailing list