Make emacs show when clang-format encountered a syntax error.

Propagate the 'incomplete-format' state back through clang-format's command
line interace and adapt the emacs integration to show a better result.

llvm-svn: 236854
diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp
index fe7d678..ae2180c 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -225,14 +225,17 @@
 
   FormatStyle FormatStyle = getStyle(
       Style, (FileName == "-") ? AssumeFilename : FileName, FallbackStyle);
-  tooling::Replacements Replaces = reformat(FormatStyle, Sources, ID, Ranges);
+  bool IncompleteFormat = false;
+  tooling::Replacements Replaces = reformat(FormatStyle, Sources, ID, Ranges, &IncompleteFormat);
   if (OutputXML) {
-    llvm::outs()
-        << "<?xml version='1.0'?>\n<replacements xml:space='preserve'>\n";
+    llvm::outs() << "<?xml version='1.0'?>\n<replacements "
+                    "xml:space='preserve' incomplete_format='"
+                 << (IncompleteFormat ? "true" : "false") << "'>\n";
     if (Cursor.getNumOccurrences() != 0)
       llvm::outs() << "<cursor>"
                    << tooling::shiftedCodePosition(Replaces, Cursor)
                    << "</cursor>\n";
+
     for (tooling::Replacements::const_iterator I = Replaces.begin(),
                                                E = Replaces.end();
          I != E; ++I) {
@@ -252,9 +255,12 @@
       else if (Rewrite.overwriteChangedFiles())
         return true;
     } else {
+      outs() << "{";
       if (Cursor.getNumOccurrences() != 0)
-        outs() << "{ \"Cursor\": "
-               << tooling::shiftedCodePosition(Replaces, Cursor) << " }\n";
+        outs() << " \"Cursor\": "
+               << tooling::shiftedCodePosition(Replaces, Cursor) << ",";
+      outs() << " \"IncompleteFormat\": "
+             << (IncompleteFormat ? "true" : "false") << " }\n";
       Rewrite.getEditBuffer(ID).write(outs());
     }
   }