diff options
author | Daniel Jasper <djasper@google.com> | 2013-01-30 09:52:38 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-01-30 09:52:38 +0000 |
commit | 5a871a0706547cb60f47d8a8dddcc1f3a26bdbbc (patch) | |
tree | 32d1ee693a644c214f3428bf06e7c644b03bdab6 /clang-format | |
parent | dc034c1e6d8a7c0623567c3426b5f1743c9e8f25 (diff) |
Don't touch unchanged file for in-place edit.
This fixes llvm.org/PR15087.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@173919 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-format')
-rw-r--r-- | clang-format/ClangFormat.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang-format/ClangFormat.cpp b/clang-format/ClangFormat.cpp index 23043a3b..da032d5c 100644 --- a/clang-format/ClangFormat.cpp +++ b/clang-format/ClangFormat.cpp @@ -97,6 +97,9 @@ static void format() { Rewriter Rewrite(Sources, LangOptions()); tooling::applyAllReplacements(Replaces, Rewrite); if (Inplace) { + if (Replaces.size() == 0) + return; // Nothing changed, don't touch the file. + std::string ErrorInfo; llvm::raw_fd_ostream FileStream(FileName.c_str(), ErrorInfo, llvm::raw_fd_ostream::F_Binary); |