Prevent error message when formatting an empty file.
This fixes llvm.org/PR16514.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185531 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/clang-format/ClangFormat.cpp b/tools/clang-format/ClangFormat.cpp
index 33b7be9..2aa4325 100644
--- a/tools/clang-format/ClangFormat.cpp
+++ b/tools/clang-format/ClangFormat.cpp
@@ -162,6 +162,8 @@
llvm::errs() << ec.message() << "\n";
return true;
}
+ if (Code->getBufferSize() == 0)
+ return true; // Empty files are formatted correctly.
FileID ID = createInMemoryFile(FileName, Code.get(), Sources, Files);
if (Offsets.empty())
Offsets.push_back(0);