Add missing newlines at EOF (for clang++).
[oota-llvm.git] / utils / TableGen / ClangDiagnosticsEmitter.cpp
index 4d7f92968c25812fcfe4e217f1fd1f5aff920c8b..6f1080eb5eb20426df3f5a5ec9dc35bb838c608c 100644 (file)
@@ -15,7 +15,6 @@
 #include "Record.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Compiler.h"
-#include "llvm/Support/Streams.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/VectorExtras.h"
@@ -27,7 +26,7 @@ using namespace llvm;
 // Warning Tables (.inc file) generation.
 //===----------------------------------------------------------------------===//
 
-void ClangDiagsDefsEmitter::run(std::ostream &OS) {
+void ClangDiagsDefsEmitter::run(raw_ostream &OS) {
   // Write the #if guard
   if (!Component.empty()) {
     std::string ComponentName = UppercaseString(Component);
@@ -50,10 +49,25 @@ void ClangDiagsDefsEmitter::run(std::ostream &OS) {
     OS << "DIAG(" << R.getName() << ", ";
     OS << R.getValueAsDef("Class")->getName();
     OS << ", diag::" << R.getValueAsDef("DefaultMapping")->getName();
+    
+    // Description string.
     OS << ", \"";
-    std::string S = R.getValueAsString("Text");
-    EscapeString(S);
-    OS << S << "\")\n";
+    OS.write_escaped(R.getValueAsString("Text")) << '"';
+    
+    // Warning associated with the diagnostic.
+    if (DefInit *DI = dynamic_cast<DefInit*>(R.getValueInit("Group"))) {
+      OS << ", \"";
+      OS.write_escaped(DI->getDef()->getValueAsString("GroupName")) << '"';
+    } else {
+      OS << ", 0";
+    }
+
+    // SFINAE bit
+    if (R.getValueAsBit("SFINAE"))
+      OS << ", true";
+    else
+      OS << ", false";
+    OS << ")\n";
   }
 }
 
@@ -67,7 +81,7 @@ struct GroupInfo {
   unsigned IDNo;
 };
 
-void ClangDiagGroupsEmitter::run(std::ostream &OS) {
+void ClangDiagGroupsEmitter::run(raw_ostream &OS) {
   // Invert the 1-[0/1] mapping of diags to group into a one to many mapping of
   // groups to diags in the group.
   std::map<std::string, GroupInfo> DiagsInGroup;
@@ -134,11 +148,10 @@ void ClangDiagGroupsEmitter::run(std::ostream &OS) {
   OS << "\n#ifdef GET_DIAG_TABLE\n";
   for (std::map<std::string, GroupInfo>::iterator
        I = DiagsInGroup.begin(), E = DiagsInGroup.end(); I != E; ++I) {
-    std::string S = I->first;
-    EscapeString(S);
     // Group option string.
-    OS << "  { \"" << S << "\","
-      << std::string(MaxLen-I->first.size()+1, ' ');
+    OS << "  { \"";
+    OS.write_escaped(I->first) << "\","
+                               << std::string(MaxLen-I->first.size()+1, ' ');
     
     // Diagnostics in the group.
     if (I->second.DiagsInGroup.empty())