clang-format: Don't allow -i when reading from stdin.
authorDaniel Jasper <djasper@google.com>
Wed, 6 May 2015 11:56:54 +0000 (11:56 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 6 May 2015 11:56:54 +0000 (11:56 +0000)
llvm-svn: 236592

clang/tools/clang-format/ClangFormat.cpp

index f611f70..fe7d678 100644 (file)
@@ -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)