[cfe-commits] r138842 - in /cfe/trunk: include/clang/Basic/DiagnosticLexKinds.td include/clang/Lex/Preprocessor.h lib/Frontend/DependencyFile.cpp lib/Lex/PPDirectives.cpp lib/Lex/Pragma.cpp test/Misc/warning-flags.c test/Preprocessor/missing-system-header.c test/Preprocessor/missing-system-header.h

Eli Friedman eli.friedman at gmail.com
Tue Aug 30 16:07:51 PDT 2011


Author: efriedma
Date: Tue Aug 30 18:07:51 2011
New Revision: 138842

URL: http://llvm.org/viewvc/llvm-project?rev=138842&view=rev
Log:
Change err_pp_file_not_found back to an Error; when it's a Warning, we suppress it in system headers.  And it is not a good idea to suppress it in system headers.  (This was originally changed in r134996 to implement -MG.)

Fixes <rdar://10041960>.  And also brings down the number of warnings without a flag by one :)


Added:
    cfe/trunk/test/Preprocessor/missing-system-header.c
    cfe/trunk/test/Preprocessor/missing-system-header.h
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
    cfe/trunk/include/clang/Lex/Preprocessor.h
    cfe/trunk/lib/Frontend/DependencyFile.cpp
    cfe/trunk/lib/Lex/PPDirectives.cpp
    cfe/trunk/lib/Lex/Pragma.cpp
    cfe/trunk/test/Misc/warning-flags.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=138842&r1=138841&r2=138842&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Aug 30 18:07:51 2011
@@ -186,7 +186,7 @@
 
 def err_pp_invalid_directive : Error<"invalid preprocessing directive">;
 def err_pp_hash_error : Error<"#error%0">;
-def warn_pp_file_not_found : Warning<"'%0' file not found">, DefaultFatal;
+def err_pp_file_not_found : Error<"'%0' file not found">, DefaultFatal;
 def err_pp_error_opening_file : Error<
   "error opening file '%0': %1">, DefaultFatal;
 def err_pp_empty_filename : Error<"empty filename">;

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=138842&r1=138841&r2=138842&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Tue Aug 30 18:07:51 2011
@@ -105,6 +105,7 @@
   // State that is set before the preprocessor begins.
   bool KeepComments : 1;
   bool KeepMacroComments : 1;
+  bool SuppressIncludeNotFoundError : 1;
 
   // State that changes while the preprocessor runs:
   bool InMacroArgs : 1;            // True if parsing fn macro invocation args.
@@ -344,6 +345,14 @@
 
   bool getCommentRetentionState() const { return KeepComments; }
 
+  void SetSuppressIncludeNotFoundError(bool Suppress) {
+    SuppressIncludeNotFoundError = Suppress;
+  }
+
+  bool GetSuppressIncludeNotFoundError() {
+    return SuppressIncludeNotFoundError;
+  }
+
   /// isCurrentLexer - Return true if we are lexing directly from the specified
   /// lexer.
   bool isCurrentLexer(const PreprocessorLexer *L) const {

Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=138842&r1=138841&r2=138842&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)
+++ cfe/trunk/lib/Frontend/DependencyFile.cpp Tue Aug 30 18:07:51 2011
@@ -86,14 +86,8 @@
   }
 
   // Disable the "file not found" diagnostic if the -MG option was given.
-  // FIXME: Ideally this would live in the driver, but we don't have the ability
-  // to remap individual diagnostics there without creating a DiagGroup, in
-  // which case we would need to prevent the group name from showing up in
-  // diagnostics.
-  if (Opts.AddMissingHeaderDeps) {
-    PP.getDiagnostics().setDiagnosticMapping(diag::warn_pp_file_not_found,
-                                            diag::MAP_IGNORE, SourceLocation());
-  }
+  if (Opts.AddMissingHeaderDeps)
+    PP.SetSuppressIncludeNotFoundError(true);
 
   PP.addPPCallbacks(new DependencyFileCallback(&PP, OS, Opts));
 }

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=138842&r1=138841&r2=138842&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Tue Aug 30 18:07:51 2011
@@ -1187,7 +1187,8 @@
                                   End, SearchPath, RelativePath);
 
   if (File == 0) {
-    Diag(FilenameTok, diag::warn_pp_file_not_found) << Filename;
+    if (!SuppressIncludeNotFoundError)
+      Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
     return;
   }
 

Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=138842&r1=138841&r2=138842&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Tue Aug 30 18:07:51 2011
@@ -368,7 +368,8 @@
   const DirectoryLookup *CurDir;
   const FileEntry *File = LookupFile(Filename, isAngled, 0, CurDir, NULL, NULL);
   if (File == 0) {
-    Diag(FilenameTok, diag::warn_pp_file_not_found) << Filename;
+    if (!SuppressIncludeNotFoundError)
+      Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
     return;
   }
 

Modified: cfe/trunk/test/Misc/warning-flags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags.c?rev=138842&r1=138841&r2=138842&view=diff
==============================================================================
--- cfe/trunk/test/Misc/warning-flags.c (original)
+++ cfe/trunk/test/Misc/warning-flags.c Tue Aug 30 18:07:51 2011
@@ -17,7 +17,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (313):
+CHECK: Warnings without flags (312):
 CHECK-NEXT:   auto_storage_class
 CHECK-NEXT:   backslash_newline_space
 CHECK-NEXT:   charize_microsoft_ext
@@ -253,7 +253,6 @@
 CHECK-NEXT:   warn_pp_convert_lhs_to_positive
 CHECK-NEXT:   warn_pp_convert_rhs_to_positive
 CHECK-NEXT:   warn_pp_expr_overflow
-CHECK-NEXT:   warn_pp_file_not_found
 CHECK-NEXT:   warn_pp_line_decimal
 CHECK-NEXT:   warn_pragma_align_expected_equal
 CHECK-NEXT:   warn_pragma_align_invalid_option

Added: cfe/trunk/test/Preprocessor/missing-system-header.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/missing-system-header.c?rev=138842&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/missing-system-header.c (added)
+++ cfe/trunk/test/Preprocessor/missing-system-header.c Tue Aug 30 18:07:51 2011
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+#include "missing-system-header.h"

Added: cfe/trunk/test/Preprocessor/missing-system-header.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/missing-system-header.h?rev=138842&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/missing-system-header.h (added)
+++ cfe/trunk/test/Preprocessor/missing-system-header.h Tue Aug 30 18:07:51 2011
@@ -0,0 +1,2 @@
+#pragma clang system_header
+#include "not exist"  // expected-error {{file not found}}





More information about the cfe-commits mailing list