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

Tobias Grosser tobias at grosser.es
Fri May 8 14:34:09 PDT 2015


Author: grosser
Date: Fri May  8 16:34:09 2015
New Revision: 236908

URL: http://llvm.org/viewvc/llvm-project?rev=236908&view=rev
Log:
Revert "Make emacs show when clang-format encountered a syntax error."

This reverts commit 236854, which caused clang-format to always print
'{ "IncompleteFormat": false }' at the top of an incompletely formatted file.
This output causes problems e.g. in Polly's automatic formatting checks. Daniel
tried to fix this in 236867, but this fix had to be reverted due to buildbot
failures. I revert this change as well for now as it is Friday night and
unlikely to be fixed immediately.

Removed:
    cfe/trunk/test/Format/incomplete.cpp
Modified:
    cfe/trunk/test/Format/cursor.cpp
    cfe/trunk/tools/clang-format/ClangFormat.cpp
    cfe/trunk/tools/clang-format/clang-format.el

Modified: cfe/trunk/test/Format/cursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/cursor.cpp?rev=236908&r1=236907&r2=236908&view=diff
==============================================================================
--- cfe/trunk/test/Format/cursor.cpp (original)
+++ cfe/trunk/test/Format/cursor.cpp Fri May  8 16:34:09 2015
@@ -1,6 +1,6 @@
 // RUN: grep -Ev "// *[A-Z-]+:" %s > %t2.cpp
 // RUN: clang-format -style=LLVM %t2.cpp -cursor=6 > %t.cpp
 // RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s
-// CHECK: {{^\{ "Cursor": 4, }}
+// CHECK: {{^\{ "Cursor": 4 \}$}}
 // CHECK: {{^int\ \i;$}}
  int    i;

Removed: cfe/trunk/test/Format/incomplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/incomplete.cpp?rev=236907&view=auto
==============================================================================
--- cfe/trunk/test/Format/incomplete.cpp (original)
+++ cfe/trunk/test/Format/incomplete.cpp (removed)
@@ -1,8 +0,0 @@
-// RUN: grep -Ev "// *[A-Z-]+:" %s > %t2.cpp
-// RUN: clang-format -style=LLVM %t2.cpp > %t.cpp
-// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s
-// CHECK: {{^\{ "IncompleteFormat": true }}
-// CHECK: {{^int\ \i;$}}
- int    i;
-// CHECK: {{^f  \( g  \(;$}}
-f  ( g  (;

Modified: cfe/trunk/tools/clang-format/ClangFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/ClangFormat.cpp?rev=236908&r1=236907&r2=236908&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/ClangFormat.cpp (original)
+++ cfe/trunk/tools/clang-format/ClangFormat.cpp Fri May  8 16:34:09 2015
@@ -225,17 +225,14 @@ static bool format(StringRef FileName) {
 
   FormatStyle FormatStyle = getStyle(
       Style, (FileName == "-") ? AssumeFilename : FileName, FallbackStyle);
-  bool IncompleteFormat = false;
-  tooling::Replacements Replaces = reformat(FormatStyle, Sources, ID, Ranges, &IncompleteFormat);
+  tooling::Replacements Replaces = reformat(FormatStyle, Sources, ID, Ranges);
   if (OutputXML) {
-    llvm::outs() << "<?xml version='1.0'?>\n<replacements "
-                    "xml:space='preserve' incomplete_format='"
-                 << (IncompleteFormat ? "true" : "false") << "'>\n";
+    llvm::outs()
+        << "<?xml version='1.0'?>\n<replacements xml:space='preserve'>\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) {
@@ -255,12 +252,9 @@ static bool format(StringRef FileName) {
       else if (Rewrite.overwriteChangedFiles())
         return true;
     } else {
-      outs() << "{";
       if (Cursor.getNumOccurrences() != 0)
-        outs() << " \"Cursor\": "
-               << tooling::shiftedCodePosition(Replaces, Cursor) << ",";
-      outs() << " \"IncompleteFormat\": "
-             << (IncompleteFormat ? "true" : "false") << " }\n";
+        outs() << "{ \"Cursor\": "
+               << tooling::shiftedCodePosition(Replaces, Cursor) << " }\n";
       Rewrite.getEditBuffer(ID).write(outs());
     }
   }

Modified: cfe/trunk/tools/clang-format/clang-format.el
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.el?rev=236908&r1=236907&r2=236908&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/clang-format.el (original)
+++ cfe/trunk/tools/clang-format/clang-format.el Fri May  8 16:34:09 2015
@@ -61,7 +61,6 @@ of the buffer."
   (unless (and (listp xml-node) (eq (xml-node-name xml-node) 'replacements))
     (error "Expected <replacements> node"))
   (let ((nodes (xml-node-children xml-node))
-        (incomplete-format (xml-get-attribute xml-node 'incomplete_format))
         replacements
         cursor)
     (dolist (node nodes)
@@ -90,7 +89,7 @@ of the buffer."
                                    (and (= (car a) (car b))
                                         (> (cadr a) (cadr b)))))))
 
-    (list replacements cursor (string= incomplete-format "true"))))
+    (cons replacements cursor)))
 
 (defun clang-format--replace (offset length &optional text)
   (let ((start (byte-to-position (1+ offset)))
@@ -143,24 +142,20 @@ is no active region.  If no style is giv
            ((stringp status)
             (error "(clang-format killed by signal %s%s)" status stderr))
            ((not (equal 0 status))
-            (error "(clang-format failed with code %d%s)" status stderr)))
+            (error "(clang-format failed with code %d%s)" status stderr))
+           (t (message "(clang-format succeeded%s)" stderr)))
 
           (with-current-buffer temp-buffer
             (setq operations (clang-format--extract (car (xml-parse-region)))))
 
-          (let ((replacements (nth 0 operations))
-                (cursor (nth 1 operations))
-                (incomplete-format (nth 2 operations)))
+          (let ((replacements (car operations))
+                (cursor (cdr operations)))
             (save-excursion
               (mapc (lambda (rpl)
                       (apply #'clang-format--replace rpl))
                     replacements))
             (when cursor
-              (goto-char (byte-to-position (1+ cursor))))
-            (message "%s" incomplete-format)
-            (if incomplete-format
-                (message "(clang-format: incomplete (syntax errors)%s)" stderr)
-              (message "(clang-format: success%s)" stderr))))
+              (goto-char (byte-to-position (1+ cursor))))))
       (delete-file temp-file)
       (when (buffer-name temp-buffer) (kill-buffer temp-buffer)))))
 





More information about the cfe-commits mailing list