r210515 - Don't suppress backend diagnostics in system headers

Alp Toker alp at nuanti.com
Tue Jun 10 00:03:25 PDT 2014


Author: alp
Date: Tue Jun 10 02:03:25 2014
New Revision: 210515

URL: http://llvm.org/viewvc/llvm-project?rev=210515&view=rev
Log:
Don't suppress backend diagnostics in system headers

Doing so would be inconsistent with the common fallback case where backend
diagnostics without source locations are emitted unconditionally.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
    cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=210515&r1=210514&r2=210515&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Tue Jun 10 02:03:25 2014
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+class BackendInfo : CatBackend, DefaultWarnShowInSystemHeader;
+
 let Component = "Frontend" in {
 
 def err_fe_error_opening : Error<"error opening '%0': %1">;
@@ -14,7 +16,6 @@ def err_fe_error_reading : Error<"error
 def err_fe_error_reading_stdin : Error<"error reading stdin: %0">;
 def err_fe_error_backend : Error<"error in backend: %0">, DefaultFatal;
 
-// Error generated by the backend.
 def err_fe_inline_asm : Error<"%0">, CatInlineAsm;
 def warn_fe_inline_asm : Warning<"%0">, CatInlineAsm, InGroup<BackendInlineAsm>;
 def note_fe_inline_asm : Note<"%0">, CatInlineAsm;
@@ -23,21 +24,22 @@ def err_fe_cannot_link_module : Error<"c
   DefaultFatal;
 
 def warn_fe_frame_larger_than : Warning<"stack frame size of %0 bytes in %q1">,
-    CatBackend, InGroup<BackendFrameLargerThanEQ>;
-def warn_fe_backend_frame_larger_than: Warning<"%0">, CatBackend, InGroup<BackendFrameLargerThanEQ>;
-def err_fe_backend_frame_larger_than: Error<"%0">, CatBackend;
-def note_fe_backend_frame_larger_than: Note<"%0">, CatBackend;
-
-def warn_fe_backend_plugin: Warning<"%0">, CatBackend, InGroup<BackendPlugin>;
-def err_fe_backend_plugin: Error<"%0">, CatBackend;
-def remark_fe_backend_plugin: Remark<"%0">, CatBackend, InGroup<RemarkBackendPlugin>;
-def note_fe_backend_plugin: Note<"%0">, CatBackend;
+    BackendInfo, InGroup<BackendFrameLargerThanEQ>;
+def warn_fe_backend_frame_larger_than: Warning<"%0">,
+    BackendInfo, InGroup<BackendFrameLargerThanEQ>;
+def err_fe_backend_frame_larger_than: Error<"%0">, BackendInfo;
+def note_fe_backend_frame_larger_than: Note<"%0">, BackendInfo;
+
+def warn_fe_backend_plugin: Warning<"%0">, BackendInfo, InGroup<BackendPlugin>;
+def err_fe_backend_plugin: Error<"%0">, BackendInfo;
+def remark_fe_backend_plugin: Remark<"%0">, BackendInfo, InGroup<RemarkBackendPlugin>;
+def note_fe_backend_plugin: Note<"%0">, BackendInfo;
 
-def remark_fe_backend_optimization_remark : Remark<"%0">, CatBackend,
+def remark_fe_backend_optimization_remark : Remark<"%0">, BackendInfo,
     InGroup<BackendOptimizationRemark>, DefaultRemark;
-def remark_fe_backend_optimization_remark_missed : Remark<"%0">, CatBackend,
+def remark_fe_backend_optimization_remark_missed : Remark<"%0">, BackendInfo,
     InGroup<BackendOptimizationRemarkMissed>, DefaultRemark;
-def remark_fe_backend_optimization_remark_analysis : Remark<"%0">, CatBackend,
+def remark_fe_backend_optimization_remark_analysis : Remark<"%0">, BackendInfo,
     InGroup<BackendOptimizationRemarkAnalysis>, DefaultRemark;
 def note_fe_backend_optimization_remark_missing_loc : Note<"use "
   "-gline-tables-only -gcolumn-info to track source location information "

Modified: cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp?rev=210515&r1=210514&r2=210515&view=diff
==============================================================================
--- cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp (original)
+++ cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp Tue Jun 10 02:03:25 2014
@@ -1,5 +1,6 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang -target i386-apple-darwin -std=c++11 -fblocks -Wframe-larger-than=70 -Xclang -verify -o /dev/null -c %s
+// RUN: %clang -target i386-apple-darwin -std=c++11 -fblocks -Wframe-larger-than=70 -Xclang -verify -o /dev/null -c %s -DIS_SYSHEADER
 
 // Test that:
 //  * The driver passes the option through to the backend.
@@ -7,6 +8,14 @@
 
 // TODO: Support rich backend diagnostics for Objective-C methods.
 
+// Backend diagnostics aren't suppressed in system headers because such results
+// are significant and actionable.
+#ifdef IS_HEADER
+
+#ifdef IS_SYSHEADER
+#pragma clang system_header
+#endif
+
 extern void doIt(char *);
 
 void frameSizeWarning(int, int) {}
@@ -24,14 +33,19 @@ void frameSizeWarning(int) {}
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wframe-larger-than="
-// expected-warning at +1 {{unknown warning group '-Wframe-larger-than'}}
-#pragma GCC diagnostic ignored "-Wframe-larger-than"
 void frameSizeWarningIgnored() {
   char buffer[80];
   doIt(buffer);
 }
 #pragma GCC diagnostic pop
 
+#pragma GCC diagnostic push
+#ifndef IS_SYSHEADER
+// expected-warning at +2 {{unknown warning group '-Wframe-larger-than'}}
+#endif
+#pragma GCC diagnostic ignored "-Wframe-larger-than"
+#pragma GCC diagnostic pop
+
 void frameSizeLocalClassWarning() {
   struct S {
     S() { // expected-warning-re {{stack frame size of {{[0-9]+}} bytes in function 'frameSizeLocalClassWarning()::S::S'}}
@@ -59,3 +73,9 @@ void frameSizeBlocksWarning() {
   };
   fn();
 }
+
+#else
+
+#define IS_HEADER
+#include __FILE__
+#endif





More information about the cfe-commits mailing list