diff options
author | John McCall <rjmccall@apple.com> | 2011-06-15 21:43:52 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-06-15 21:43:52 +0000 |
commit | f14bacc862eb69c7c779858746cc020386ce5590 (patch) | |
tree | f0de51f5c6022ea1e9a0a87fe34ef1aba4a4bc6b /utils/TableGen/ClangDiagnosticsEmitter.cpp | |
parent | cff6193ebd2cc8975d4f2888d03e6a2923862311 (diff) |
Update the Clang diagnostic emitter to emit IDs for diagnostic categories.
Patch by Argyrios Kyrtzidis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/ClangDiagnosticsEmitter.cpp')
-rw-r--r-- | utils/TableGen/ClangDiagnosticsEmitter.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/utils/TableGen/ClangDiagnosticsEmitter.cpp b/utils/TableGen/ClangDiagnosticsEmitter.cpp index acaa1f8f8f..0a48e75681 100644 --- a/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -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 @@ void ClangDiagsDefsEmitter::run(raw_ostream &OS) { // 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 @@ void ClangDiagGroupsEmitter::run(raw_ostream &OS) { 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"; } |