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
This commit is contained in:
John McCall 2011-06-15 21:43:52 +00:00
parent cff6193ebd
commit f14bacc862

View File

@ -18,6 +18,7 @@
#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringMap.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/VectorExtras.h" #include "llvm/ADT/VectorExtras.h"
#include <map> #include <map>
#include <algorithm> #include <algorithm>
@ -195,6 +196,15 @@ void ClangDiagsDefsEmitter::run(raw_ostream &OS) {
// Warning Group Tables generation // 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 { namespace {
struct GroupInfo { struct GroupInfo {
std::vector<const Record*> DiagsInGroup; std::vector<const Record*> DiagsInGroup;
@ -301,7 +311,7 @@ void ClangDiagGroupsEmitter::run(raw_ostream &OS) {
OS << "\n#ifdef GET_CATEGORY_TABLE\n"; OS << "\n#ifdef GET_CATEGORY_TABLE\n";
for (DiagCategoryIDMap::iterator I = CategoriesByID.begin(), for (DiagCategoryIDMap::iterator I = CategoriesByID.begin(),
E = CategoriesByID.end(); I != E; ++I) E = CategoriesByID.end(); I != E; ++I)
OS << "CATEGORY(\"" << *I << "\")\n"; OS << "CATEGORY(\"" << *I << "\", " << getDiagCategoryEnum(*I) << ")\n";
OS << "#endif // GET_CATEGORY_TABLE\n\n"; OS << "#endif // GET_CATEGORY_TABLE\n\n";
} }