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

Chris Lattner sabre at nondot.org
Wed Apr 15 20:16:16 PDT 2009


Author: lattner
Date: Wed Apr 15 22:16:12 2009
New Revision: 69257

URL: http://llvm.org/viewvc/llvm-project?rev=69257&view=rev
Log:
encode subgroups into the clang .inc file.  -Wall now works!

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=69257&r1=69256&r2=69257&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp Wed Apr 15 22:16:12 2009
@@ -64,6 +64,7 @@
 struct GroupInfo {
   std::vector<const Record*> DiagsInGroup;
   std::vector<std::string> SubGroups;
+  unsigned IDNo;
 };
 
 void ClangDiagGroupsEmitter::run(std::ostream &OS) {
@@ -93,29 +94,44 @@
       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 @@
     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";





More information about the llvm-commits mailing list