summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-16 03:16:12 +0000
committerChris Lattner <sabre@nondot.org>2009-04-16 03:16:12 +0000
commit9efac568f08de669c8e0003b33b80998cedaf8b6 (patch)
treeb5feaa68fe3bdaf04a8c90b95eb26c1cc404a089 /utils
parent16f2ffd1580a168a7fdd78bf48b26f0995e1c109 (diff)
downloadllvm-9efac568f08de669c8e0003b33b80998cedaf8b6.tar.gz
llvm-9efac568f08de669c8e0003b33b80998cedaf8b6.tar.bz2
llvm-9efac568f08de669c8e0003b33b80998cedaf8b6.tar.xz
encode subgroups into the clang .inc file. -Wall now works!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69257 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/ClangDiagnosticsEmitter.cpp41
1 files changed, 30 insertions, 11 deletions
diff --git a/utils/TableGen/ClangDiagnosticsEmitter.cpp b/utils/TableGen/ClangDiagnosticsEmitter.cpp
index 88d54eccde..4d7f92968c 100644
--- a/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -64,6 +64,7 @@ void ClangDiagsDefsEmitter::run(std::ostream &OS) {
struct GroupInfo {
std::vector<const Record*> DiagsInGroup;
std::vector<std::string> SubGroups;
+ unsigned IDNo;
};
void ClangDiagGroupsEmitter::run(std::ostream &OS) {
@@ -93,29 +94,44 @@ void ClangDiagGroupsEmitter::run(std::ostream &OS) {
GI.SubGroups.push_back(SubGroups[j]->getValueAsString("GroupName"));
}
+ // Assign unique ID numbers to the groups.
+ unsigned IDNo = 0;
+ for (std::map<std::string, GroupInfo>::iterator
+ I = DiagsInGroup.begin(), E = DiagsInGroup.end(); I != E; ++I, ++IDNo)
+ I->second.IDNo = IDNo;
+
// Walk through the groups emitting an array for each diagnostic of the diags
// that are mapped to.
OS << "\n#ifdef GET_DIAG_ARRAYS\n";
- unsigned IDNo = 0;
unsigned MaxLen = 0;
for (std::map<std::string, GroupInfo>::iterator
I = DiagsInGroup.begin(), E = DiagsInGroup.end(); I != E; ++I) {
MaxLen = std::max(MaxLen, (unsigned)I->first.size());
std::vector<const Record*> &V = I->second.DiagsInGroup;
- if (V.empty()) continue;
+ if (!V.empty()) {
+ OS << "static const short DiagArray" << I->second.IDNo << "[] = { ";
+ for (unsigned i = 0, e = V.size(); i != e; ++i)
+ OS << "diag::" << V[i]->getName() << ", ";
+ OS << "-1 };\n";
+ }
- OS << "static const short DiagArray" << IDNo++
- << "[] = { ";
- for (unsigned i = 0, e = V.size(); i != e; ++i)
- OS << "diag::" << V[i]->getName() << ", ";
- OS << "-1 };\n";
+ const std::vector<std::string> &SubGroups = I->second.SubGroups;
+ if (!SubGroups.empty()) {
+ OS << "static const char DiagSubGroup" << I->second.IDNo << "[] = { ";
+ for (unsigned i = 0, e = SubGroups.size(); i != e; ++i) {
+ std::map<std::string, GroupInfo>::iterator RI =
+ DiagsInGroup.find(SubGroups[i]);
+ assert(RI != DiagsInGroup.end() && "Referenced without existing?");
+ OS << RI->second.IDNo << ", ";
+ }
+ OS << "-1 };\n";
+ }
}
OS << "#endif // GET_DIAG_ARRAYS\n\n";
// Emit the table now.
OS << "\n#ifdef GET_DIAG_TABLE\n";
- IDNo = 0;
for (std::map<std::string, GroupInfo>::iterator
I = DiagsInGroup.begin(), E = DiagsInGroup.end(); I != E; ++I) {
std::string S = I->first;
@@ -128,10 +144,13 @@ void ClangDiagGroupsEmitter::run(std::ostream &OS) {
if (I->second.DiagsInGroup.empty())
OS << "0, ";
else
- OS << "DiagArray" << IDNo++ << ", ";
+ OS << "DiagArray" << I->second.IDNo << ", ";
- // FIXME: Subgroups.
- OS << 0;
+ // Subgroups.
+ if (I->second.SubGroups.empty())
+ OS << 0;
+ else
+ OS << "DiagSubGroup" << I->second.IDNo;
OS << " },\n";
}
OS << "#endif // GET_DIAG_TABLE\n\n";