summaryrefslogtreecommitdiffstats
path: root/tools/clang-format/ClangFormat.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-05-06 11:56:54 +0000
committerDaniel Jasper <djasper@google.com>2015-05-06 11:56:54 +0000
commit92e78b69dfb77849617ab60500745983c3254573 (patch)
treead6ddd0167d4245c2c5667bbaa53b6e67426140a /tools/clang-format/ClangFormat.cpp
parent13e7452f302ea1d047d33963397c9206420813b7 (diff)
clang-format: Don't allow -i when reading from stdin.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236592 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/clang-format/ClangFormat.cpp')
-rw-r--r--tools/clang-format/ClangFormat.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/clang-format/ClangFormat.cpp b/tools/clang-format/ClangFormat.cpp
index f611f70246..fe7d678852 100644
--- a/tools/clang-format/ClangFormat.cpp
+++ b/tools/clang-format/ClangFormat.cpp
@@ -247,7 +247,9 @@ static bool format(StringRef FileName) {
Rewriter Rewrite(Sources, LangOptions());
tooling::applyAllReplacements(Replaces, Rewrite);
if (Inplace) {
- if (Rewrite.overwriteChangedFiles())
+ if (FileName == "-")
+ llvm::errs() << "error: cannot use -i when reading from stdin.\n";
+ else if (Rewrite.overwriteChangedFiles())
return true;
} else {
if (Cursor.getNumOccurrences() != 0)