kljohann / clang-format.el

Format code using clang-format
4 stars 0 forks source link

Fails with clang-format 3.3 #1

Closed ccdunder closed 9 years ago

ccdunder commented 10 years ago

Changing the call-process-region call to #1 below fixes it. Now it's just a matter of doing this automatically when either (a) clang-format -version matches #2 below or (b) clang-format -help doesn't include the arguments "-cursor" & "-assume-filename" (see #3 below). Thoughts on which approach is better?

1:

(call-process-region
               (point-min) (point-max) clang-format-executable
               'delete keep-stderr nil

               "-style" style
               "-offset" (number-to-string (1- start))
               "-length" (number-to-string (- end start))
               (buffer-file-name))

2:

$ clang-format -version
LLVM (http://llvm.org/):
  LLVM version 3.3
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: core-avx-i

3:

$ clang-format -help
OVERVIEW: A tool to format C/C++/Obj-C code.

If no arguments are specified, it formats the code from standard input
and writes the result to the standard output.
If <file>s are given, it reformats the files. If -i is specified 
together with <file>s, the files are edited in-place. Otherwise, the 
result is written to the standard output.

USAGE: clang-format [options] [<file> ...]

OPTIONS:
  -fatal-assembler-warnings - Consider warnings as error
  -help                     - Display available options (-help-hidden for more)
  -i                        - Inplace edit <file>s, if specified.
  -length=<uint>            - Format a range of this length. When it's not specified, end of file is used. Can only be used with one input file.
  -offset=<uint>            - Format a range starting at this file offset. Can only be used with one input file.
  -output-replacements-xml  - Output replacements as XML.
  -stats                    - Enable statistics output from program (available with Asserts)
  -style=<string>           - Coding style, currently supports: LLVM, Google, Chromium, Mozilla.
  -version                  - Display the version of this program
kljohann commented 10 years ago

Ah, thanks for catching this. As I do not have version 3.3 on this machine, can you check if the check-version branch fixes this for you? If I recall correctly, 3.3 did not have a json-line in its output.

kljohann commented 9 years ago

Closing this as further development should happen upstream.