[cfe-commits] r63914 - in /cfe/trunk: include/clang/Basic/Diagnostic.h lib/Basic/Diagnostic.cpp

Chris Lattner sabre at nondot.org
Thu Feb 5 20:16:06 PST 2009


Author: lattner
Date: Thu Feb  5 22:16:02 2009
New Revision: 63914

URL: http://llvm.org/viewvc/llvm-project?rev=63914&view=rev
Log:
don't emit any diagnostics after a fatal one.

Modified:
    cfe/trunk/include/clang/Basic/Diagnostic.h
    cfe/trunk/lib/Basic/Diagnostic.cpp

Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=63914&r1=63913&r2=63914&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Thu Feb  5 22:16:02 2009
@@ -102,9 +102,10 @@
   /// packed into four bits per diagnostic.
   unsigned char DiagMappings[diag::DIAG_UPPER_LIMIT/2];
   
-  /// ErrorOccurred - This is set to true when an error is emitted, and is
-  /// sticky.
+  /// ErrorOccurred / FatalErrorOccurred - This is set to true when an error or
+  /// fatal error is emitted, and is sticky.
   bool ErrorOccurred;
+  bool FatalErrorOccurred;
 
   unsigned NumDiagnostics;    // Number of diagnostics reported
   unsigned NumErrors;         // Number of diagnostics that are errors
@@ -179,6 +180,7 @@
   }
   
   bool hasErrorOccurred() const { return ErrorOccurred; }
+  bool hasFatalErrorOccurred() const { return FatalErrorOccurred; }
 
   unsigned getNumErrors() const { return NumErrors; }
   unsigned getNumDiagnostics() const { return NumDiagnostics; }

Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=63914&r1=63913&r2=63914&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Thu Feb  5 22:16:02 2009
@@ -191,6 +191,7 @@
   memset(DiagMappings, 0, sizeof(DiagMappings));
   
   ErrorOccurred = false;
+  FatalErrorOccurred = false;
   NumDiagnostics = 0;
   NumErrors = 0;
   CustomDiagInfo = 0;
@@ -300,6 +301,11 @@
 void Diagnostic::ProcessDiag() {
   DiagnosticInfo Info(this);
   
+  // If a fatal error has already been emitted, silence all subsequent
+  // diagnostics.
+  if (FatalErrorOccurred)
+    return;
+  
   // Figure out the diagnostic level of this message.
   Diagnostic::Level DiagLevel = getDiagnosticLevel(Info.getID());
   
@@ -320,8 +326,10 @@
   
   if (DiagLevel >= Diagnostic::Error) {
     ErrorOccurred = true;
-
     ++NumErrors;
+    
+    if (DiagLevel == Diagnostic::Fatal)
+      FatalErrorOccurred = true;
   }
 
   // Finally, report it.





More information about the cfe-commits mailing list