]> granicus.if.org Git - clang/commitdiff
don't emit any diagnostics after a fatal one.
authorChris Lattner <sabre@nondot.org>
Fri, 6 Feb 2009 04:16:02 +0000 (04:16 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 6 Feb 2009 04:16:02 +0000 (04:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63914 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Diagnostic.h
lib/Basic/Diagnostic.cpp

index 90b9e2ca31d3b7a0e14c9c89e952a791401bc18a..4ab47d0be0ec0fbfa01fd689cfe840f7a5bd841b 100644 (file)
@@ -102,9 +102,10 @@ private:
   /// 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 @@ public:
   }
   
   bool hasErrorOccurred() const { return ErrorOccurred; }
+  bool hasFatalErrorOccurred() const { return FatalErrorOccurred; }
 
   unsigned getNumErrors() const { return NumErrors; }
   unsigned getNumDiagnostics() const { return NumDiagnostics; }
index ae23278f6ca8feee62933e8fe0a8a142de17e387..ff110711f5a57ebcaba21b5c6b0cced0b1d2ced4 100644 (file)
@@ -191,6 +191,7 @@ Diagnostic::Diagnostic(DiagnosticClient *client) : Client(client) {
   memset(DiagMappings, 0, sizeof(DiagMappings));
   
   ErrorOccurred = false;
+  FatalErrorOccurred = false;
   NumDiagnostics = 0;
   NumErrors = 0;
   CustomDiagInfo = 0;
@@ -300,6 +301,11 @@ Diagnostic::Level Diagnostic::getDiagnosticLevel(unsigned DiagID) const {
 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 @@ void Diagnostic::ProcessDiag() {
   
   if (DiagLevel >= Diagnostic::Error) {
     ErrorOccurred = true;
-
     ++NumErrors;
+    
+    if (DiagLevel == Diagnostic::Fatal)
+      FatalErrorOccurred = true;
   }
 
   // Finally, report it.