[cfe-commits] r129093 - /cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp

Daniel Dunbar daniel at zuster.org
Thu Apr 7 11:44:15 PDT 2011


Author: ddunbar
Date: Thu Apr  7 13:44:15 2011
New Revision: 129093

URL: http://llvm.org/viewvc/llvm-project?rev=129093&view=rev
Log:
Fronted/CC_LOG_DIAGNOSTICS: Tweak output form to be plist chunks, and don't
output missing data.

Modified:
    cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp

Modified: cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp?rev=129093&r1=129092&r2=129093&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp Thu Apr  7 13:44:15 2011
@@ -52,23 +52,37 @@
   llvm::SmallString<512> Msg;
   llvm::raw_svector_ostream OS(Msg);
 
-  OS << "{\n";
+  OS << "<dict>\n";
   // FIXME: Output main translation unit file name.
   // FIXME: Include the invocation, if dwarf-debug-flags is available.
-  OS << "  \"diagnostics\" : [\n";
+  OS << "  <key>diagnostics</key>\n";
+  OS << "  <array>\n";
   for (unsigned i = 0, e = Entries.size(); i != e; ++i) {
     DiagEntry &DE = Entries[i];
 
-    OS << "    {\n";
-    OS << "      \"filename\" : \"" << DE.Filename << "\",\n";
-    OS << "      \"line\" : " << DE.Line << ",\n";
-    OS << "      \"column\" : " << DE.Column << ",\n";
-    OS << "      \"message\" : \"" << DE.Message << "\",\n";
-    OS << "      \"level\" : \"" << getLevelName(DE.DiagnosticLevel) << "\"\n";
-    OS << "    }" << ((i + 1 != e) ? "," : "") << '\n';
+    OS << "    <dict>\n";
+    OS << "      <key>level</key>\n"
+       << "      <string>" << getLevelName(DE.DiagnosticLevel) << "</string>\n";
+    if (!DE.Filename.empty()) {
+      OS << "      <key>filename</key>\n"
+         << "      <string>" << DE.Filename << "</string>\n";
+    }
+    if (DE.Line != 0) {
+      OS << "      <key>line</key>\n"
+         << "      <integer>" << DE.Line << "</integer>\n";
+    }
+    if (DE.Column != 0) {
+      OS << "      <key>column</key>\n"
+         << "      <integer>" << DE.Column << "</integer>\n";
+    }
+    if (!DE.Message.empty()) {
+      OS << "      <key>message</key>\n"
+         << "      <string>" << DE.Message << "</string>\n";
+    }
+    OS << "    </dict>\n";
   }
-  OS << "  ]\n";
-  OS << "},\n";
+  OS << "  </array>\n";
+  OS << "</dict>\n";
 
   this->OS << OS.str();
 }





More information about the cfe-commits mailing list