]> granicus.if.org Git - clang/commitdiff
Generate enumerators for diagnostic categories. Patch by Argyrios!
authorJohn McCall <rjmccall@apple.com>
Wed, 15 Jun 2011 21:46:43 +0000 (21:46 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 15 Jun 2011 21:46:43 +0000 (21:46 +0000)
Depends on LLVM r133093.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133094 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticCategories.h [new file with mode: 0644]
lib/Basic/DiagnosticIDs.cpp

diff --git a/include/clang/Basic/DiagnosticCategories.h b/include/clang/Basic/DiagnosticCategories.h
new file mode 100644 (file)
index 0000000..4dd067b
--- /dev/null
@@ -0,0 +1,26 @@
+//===- DiagnosticCategories.h - Diagnostic Categories Enumerators-*- C++ -*===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_BASIC_DIAGNOSTICCATEGORIES_H
+#define LLVM_CLANG_BASIC_DIAGNOSTICCATEGORIES_H
+
+namespace clang {
+  namespace diag {
+    enum {
+#define GET_CATEGORY_TABLE
+#define CATEGORY(X, ENUM) ENUM,
+#include "clang/Basic/DiagnosticGroups.inc"
+#undef CATEGORY
+#undef GET_CATEGORY_TABLE
+      DiagCat_NUM_CATEGORIES
+    };
+  }  // end namespace diag
+}  // end namespace clang
+
+#endif
index 61c046066352f4424993337b72381a71f81ec805..25dbcf0a6fed26b36c8f6e54bf175233ea99f557 100644 (file)
@@ -14,6 +14,7 @@
 #include "clang/AST/ASTDiagnostic.h"
 #include "clang/Analysis/AnalysisDiagnostic.h"
 #include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/DiagnosticCategories.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
@@ -213,7 +214,7 @@ namespace {
 
 static const StaticDiagCategoryRec CategoryNameTable[] = {
 #define GET_CATEGORY_TABLE
-#define CATEGORY(X) { X, STR_SIZE(X, uint8_t) },
+#define CATEGORY(X, ENUM) { X, STR_SIZE(X, uint8_t) },
 #include "clang/Basic/DiagnosticGroups.inc"
 #undef GET_CATEGORY_TABLE
   { 0, 0 }
@@ -684,6 +685,10 @@ bool DiagnosticIDs::ProcessDiag(Diagnostic &Diag) const {
     return false;
 
   if (DiagLevel >= DiagnosticIDs::Error) {
+    Diag.TrapErrorOccurred = true;
+    if (isUnrecoverable(DiagID))
+      Diag.TrapUnrecoverableErrorOccurred = true;
+
     if (Diag.Client->IncludeInDiagnosticCounts()) {
       Diag.ErrorOccurred = true;
       ++Diag.NumErrors;
@@ -720,3 +725,20 @@ bool DiagnosticIDs::ProcessDiag(Diagnostic &Diag) const {
 
   return true;
 }
+
+bool DiagnosticIDs::isUnrecoverable(unsigned DiagID) const {
+  if (DiagID >= diag::DIAG_UPPER_LIMIT) {
+    // Custom diagnostics.
+    return CustomDiagInfo->getLevel(DiagID) >= DiagnosticIDs::Error;
+  }
+
+  // Only errors may be unrecoverable.
+  if (getBuiltinDiagClass(DiagID) < DiagnosticIDs::Error)
+    return false;
+
+  if (DiagID == diag::err_unavailable ||
+      DiagID == diag::err_unavailable_message)
+    return false;
+
+  return true;
+}