clang-format: Fix vim-integration for empty files.

Discovered by Ahmed Charles in http://reviews.llvm.org/D3018.

git-svn-id: svn://svn.chromium.org/llvm-project/cfe/trunk/tools/clang-format@209417 0b72dbe1-c17f-4bc7-b9db-2b4152be0356
diff --git a/clang-format.py b/clang-format.py
index 46af068..16a1879 100644
--- a/clang-format.py
+++ b/clang-format.py
@@ -38,9 +38,14 @@
   text = '\n'.join(buf)
 
   # Determine range to format.
-  cursor = int(vim.eval('line2byte(line("."))+col(".")')) - 2
   lines = '%s:%s' % (vim.current.range.start + 1, vim.current.range.end + 1)
 
+  # Determine the cursor position.
+  cursor = int(vim.eval('line2byte(line("."))+col(".")')) - 2
+  if cursor < 0:
+    print 'Couldn\'t determine cursor position. Is your file empty?'
+    return
+
   # Avoid flashing an ugly, ugly cmd prompt on Windows when invoking clang-format.
   startupinfo = None
   if sys.platform.startswith('win32'):