summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clang-format/ClangFormat.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-format/ClangFormat.cpp b/clang-tools-extra/clang-format/ClangFormat.cpp
index 23043a3bf90..da032d5cd6d 100644
--- a/clang-tools-extra/clang-format/ClangFormat.cpp
+++ b/clang-tools-extra/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);
OpenPOWER on IntegriCloud