[llvm-commits] [llvm] r133093 - /llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp

John McCall rjmccall at apple.com
Wed Jun 15 14:43:52 PDT 2011


Author: rjmccall
Date: Wed Jun 15 16:43:52 2011
New Revision: 133093

URL: http://llvm.org/viewvc/llvm-project?rev=133093&view=rev
Log:
Update the Clang diagnostic emitter to emit IDs for diagnostic categories.

Patch by Argyrios Kyrtzidis.


Modified:
    llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp

Modified: llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp?rev=133093&r1=133092&r2=133093&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp Wed Jun 15 16:43:52 2011
@@ -18,6 +18,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/VectorExtras.h"
 #include <map>
 #include <algorithm>
@@ -195,6 +196,15 @@
 // Warning Group Tables generation
 //===----------------------------------------------------------------------===//
 
+static std::string getDiagCategoryEnum(llvm::StringRef name) {
+  if (name.empty())
+    return "DiagCat_None";
+  llvm::SmallString<256> enumName = llvm::StringRef("DiagCat_");
+  for (llvm::StringRef::iterator I = name.begin(), E = name.end(); I != E; ++I)
+    enumName += isalnum(*I) ? *I : '_';
+  return enumName.str();
+}
+
 namespace {
 struct GroupInfo {
   std::vector<const Record*> DiagsInGroup;
@@ -301,7 +311,7 @@
   OS << "\n#ifdef GET_CATEGORY_TABLE\n";
   for (DiagCategoryIDMap::iterator I = CategoriesByID.begin(),
        E = CategoriesByID.end(); I != E; ++I)
-    OS << "CATEGORY(\"" << *I << "\")\n";
+    OS << "CATEGORY(\"" << *I << "\", " << getDiagCategoryEnum(*I) << ")\n";
   OS << "#endif // GET_CATEGORY_TABLE\n\n";
 }
 





More information about the llvm-commits mailing list