]> granicus.if.org Git - clang/commitdiff
clang-format.py: Make formatting unnamed buffers work again (broke in r190691).
authorNico Weber <nicolasweber@gmx.de>
Fri, 25 Oct 2013 20:06:20 +0000 (20:06 +0000)
committerNico Weber <nicolasweber@gmx.de>
Fri, 25 Oct 2013 20:06:20 +0000 (20:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193433 91177308-0d34-0410-b5e6-96231b3b80d8

tools/clang-format/clang-format.py

index c333e4dd142a1a744a4f1937b5e66481bffa9c7a..f5a57569db07bef15d9097c83b9c9adc17f6b245 100644 (file)
@@ -48,9 +48,10 @@ if sys.platform.startswith('win32'):
   startupinfo.wShowWindow = subprocess.SW_HIDE
 
 # Call formatter.
-p = subprocess.Popen([binary, '-lines', lines, '-style', style,
-                      '-cursor', str(cursor),
-                      '-assume-filename', vim.current.buffer.name],
+command = [binary, '-lines', lines, '-style', style, '-cursor', str(cursor)]
+if vim.current.buffer.name:
+  command.extend(['-assume-filename', vim.current.buffer.name])
+p = subprocess.Popen(command,
                      stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                      stdin=subprocess.PIPE, startupinfo=startupinfo)
 stdout, stderr = p.communicate(input=text)