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

Chris Lattner sabre at nondot.org
Thu Feb 5 14:47:07 PST 2009


Author: lattner
Date: Thu Feb  5 16:47:05 2009
New Revision: 63894

URL: http://llvm.org/viewvc/llvm-project?rev=63894&view=rev
Log:
add support to the diagnostics machinery for mapping warnings and
errors to 'fatal' error severity.

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=63894&r1=63893&r2=63894&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Thu Feb  5 16:47:05 2009
@@ -56,12 +56,15 @@
       
     /// Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs
     /// to either MAP_IGNORE (nothing), MAP_WARNING (emit a warning), MAP_ERROR
-    /// (emit as an error), or MAP_DEFAULT (handle the default way).
+    /// (emit as an error), or MAP_DEFAULT (handle the default way).  It allows
+    /// clients to map errors to MAP_ERROR/MAP_DEFAULT or MAP_FATAL (stop
+    /// emitting diagnostics after this one).
     enum Mapping {
       MAP_DEFAULT = 0,     //< Do not map this diagnostic.
       MAP_IGNORE  = 1,     //< Map this diagnostic to nothing, ignore it.
       MAP_WARNING = 2,     //< Map this diagnostic to a warning.
-      MAP_ERROR   = 3      //< Map this diagnostic to an error.
+      MAP_ERROR   = 3,     //< Map this diagnostic to an error.
+      MAP_FATAL   = 4      //< Map this diagnostic to a fatal error.
     };
   }
   
@@ -73,7 +76,7 @@
 public:
   /// Level - The level of the diagnostic, after it has been through mapping.
   enum Level {
-    Ignored, Note, Warning, Error
+    Ignored, Note, Warning, Error, Fatal
   };
   
   enum ArgumentKind {
@@ -96,8 +99,8 @@
   DiagnosticClient *Client;
 
   /// DiagMappings - Mapping information for diagnostics.  Mapping info is
-  /// packed into two bits per diagnostic.
-  unsigned char DiagMappings[diag::DIAG_UPPER_LIMIT/4];
+  /// 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.
@@ -162,16 +165,16 @@
     assert(Diag < diag::DIAG_UPPER_LIMIT &&
            "Can only map builtin diagnostics");
     assert(isBuiltinNoteWarningOrExtension(Diag) && "Cannot map errors!");
-    unsigned char &Slot = DiagMappings[Diag/4];
-    unsigned Bits = (Diag & 3)*2;
-    Slot &= ~(3 << Bits);
+    unsigned char &Slot = DiagMappings[Diag/2];
+    unsigned Bits = (Diag & 1)*4;
+    Slot &= ~(7 << Bits);
     Slot |= Map << Bits;
   }
 
   /// getDiagnosticMapping - Return the mapping currently set for the specified
   /// diagnostic.
   diag::Mapping getDiagnosticMapping(diag::kind Diag) const {
-    return (diag::Mapping)((DiagMappings[Diag/4] >> (Diag & 3)*2) & 3);
+    return (diag::Mapping)((DiagMappings[Diag/2] >> (Diag & 1)*4) & 7);
   }
   
   bool hasErrorOccurred() const { return ErrorOccurred; }

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

==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Thu Feb  5 16:47:05 2009
@@ -33,6 +33,7 @@
   EXTENSION  = 0x03,
   EXTWARN    = 0x04,
   ERROR      = 0x05,
+  FATAL      = 0x06,
   class_mask = 0x07
 };
 
@@ -259,7 +260,10 @@
     case diag::MAP_IGNORE:  return Diagnostic::Ignored;
     case diag::MAP_WARNING: DiagClass = WARNING; break;
     case diag::MAP_ERROR:   DiagClass = ERROR; break;
+    case diag::MAP_FATAL:   DiagClass = FATAL; break;
     }
+  } else if (getDiagnosticMapping((diag::kind)DiagID) == diag::MAP_FATAL) {
+    DiagClass = FATAL;
   }
   
   // Map diagnostic classes based on command line argument settings.
@@ -287,6 +291,7 @@
   case NOTE:        return Diagnostic::Note;
   case WARNING:     return Diagnostic::Warning;
   case ERROR:       return Diagnostic::Error;
+  case FATAL:       return Diagnostic::Fatal;
   }
 }
 





More information about the cfe-commits mailing list