summaryrefslogtreecommitdiff
path: root/tools/clang-format/ClangFormat.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-07-03 12:22:18 +0000
committerDaniel Jasper <djasper@google.com>2013-07-03 12:22:18 +0000
commitc1baef687bd2e53aa5ac54b825d66eda86c9e408 (patch)
treedf40eba101fe9a7a701a12405ed60f1fa742c15d /tools/clang-format/ClangFormat.cpp
parent6df7a2db6d74d41c4150b2c46b9a9e4e2db6c1dc (diff)
downloadclang-c1baef687bd2e53aa5ac54b825d66eda86c9e408.tar.gz
clang-c1baef687bd2e53aa5ac54b825d66eda86c9e408.tar.bz2
clang-c1baef687bd2e53aa5ac54b825d66eda86c9e408.tar.xz
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
Diffstat (limited to 'tools/clang-format/ClangFormat.cpp')
-rw-r--r--tools/clang-format/ClangFormat.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/clang-format/ClangFormat.cpp b/tools/clang-format/ClangFormat.cpp
index 33b7be9f1e..2aa43259ed 100644
--- a/tools/clang-format/ClangFormat.cpp
+++ b/tools/clang-format/ClangFormat.cpp
@@ -162,6 +162,8 @@ static bool format(std::string FileName) {
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);