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

Ted Kremenek kremenek at apple.com
Wed Mar 18 14:36:49 PDT 2009


Author: kremenek
Date: Wed Mar 18 16:36:46 2009
New Revision: 67244

URL: http://llvm.org/viewvc/llvm-project?rev=67244&view=rev
Log:
tblgen -gen-clang-diags-options: Output OptionTable entries in lexicographic
order.

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=67244&r1=67243&r2=67244&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp Wed Mar 18 16:36:46 2009
@@ -14,6 +14,7 @@
 #include "ClangDiagnosticsEmitter.h"
 #include "Record.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Streams.h"
 #include "llvm/ADT/VectorExtras.h"
 #include "llvm/ADT/DenseSet.h"
@@ -123,8 +124,24 @@
 // Warning Group Tables generation.
 //===----------------------------------------------------------------------===//
 
+static const std::string &getOptName(const Record *R) {
+  const RecordVal *V = findRecordVal(*R, "Name");
+  assert(V && "Options must have a 'Name' value.");
+  const StringInit* SV = dynamic_cast<const StringInit*>(V->getValue());
+  assert(SV && "'Name' entry must be a string.");
+  return SV->getValue();
+}  
+
+namespace {
+struct VISIBILITY_HIDDEN CompareOptName {  
+  bool operator()(const Record* A, const Record* B) {
+    return getOptName(A) < getOptName(B);    
+  }
+};
+}
+
 typedef std::set<const Record*> DiagnosticSet;
-typedef std::map<const Record*, DiagnosticSet> OptionMap;
+typedef std::map<const Record*, DiagnosticSet, CompareOptName> OptionMap;
 typedef llvm::DenseSet<const ListInit*> VisitedLists;
 
 static void BuildGroup(DiagnosticSet& DS, VisitedLists &Visited, const Init* X);
@@ -206,17 +223,12 @@
   OS << "\nstatic const WarningOption OptionTable[] = {";
   bool first = true;
   for (OptionMap::iterator I = OM.begin(), E = OM.end(); I!=E; ++I) {
-    const RecordVal *V = findRecordVal(*I->first, "Name");
-    assert(V && "Options must have a 'Name' value.");
-    const StringInit* SV = dynamic_cast<const StringInit*>(V->getValue());
-    assert(SV && "'Name' entry must be a string.");
-    
     if (first)
       first = false;
     else
       OS << ',';
     
-    OS << "\n  {\"" << SV->getValue()
+    OS << "\n  {\"" << getOptName(I->first)
        << "\", DIAGS(" << I->first->getName() << ")}";
   }
   OS << "\n};\n";





More information about the llvm-commits mailing list