[cfe-commits] r133094 - in /cfe/trunk: include/clang/Basic/DiagnosticCategories.h lib/Basic/DiagnosticIDs.cpp
John McCall
rjmccall at apple.com
Wed Jun 15 14:46:43 PDT 2011
Author: rjmccall
Date: Wed Jun 15 16:46:43 2011
New Revision: 133094
URL: http://llvm.org/viewvc/llvm-project?rev=133094&view=rev
Log:
Generate enumerators for diagnostic categories. Patch by Argyrios!
Depends on LLVM r133093.
Added:
cfe/trunk/include/clang/Basic/DiagnosticCategories.h
Modified:
cfe/trunk/lib/Basic/DiagnosticIDs.cpp
Added: cfe/trunk/include/clang/Basic/DiagnosticCategories.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCategories.h?rev=133094&view=auto
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticCategories.h (added)
+++ cfe/trunk/include/clang/Basic/DiagnosticCategories.h Wed Jun 15 16:46:43 2011
@@ -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
Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=133094&r1=133093&r2=133094&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Wed Jun 15 16:46:43 2011
@@ -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 @@
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 @@
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 @@
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;
+}
More information about the cfe-commits
mailing list