summaryrefslogtreecommitdiff
path: root/lib/Support
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-08-17 03:53:23 +0000
committerChris Lattner <sabre@nondot.org>2008-08-17 03:53:23 +0000
commitc52b128e1a9b1f16403dcbabf46ffc8ee1f7082e (patch)
tree8dd16f6fd217e60d2f8cf81e213340cd8a342ec9 /lib/Support
parentd497df5cf5d977522814acef72b8b65f1774408e (diff)
downloadllvm-c52b128e1a9b1f16403dcbabf46ffc8ee1f7082e.tar.gz
llvm-c52b128e1a9b1f16403dcbabf46ffc8ee1f7082e.tar.bz2
llvm-c52b128e1a9b1f16403dcbabf46ffc8ee1f7082e.tar.xz
opening "-" automatically yields stdout.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54863 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/raw_ostream.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
index e47bccde6c..a4dc797f01 100644
--- a/lib/Support/raw_ostream.cpp
+++ b/lib/Support/raw_ostream.cpp
@@ -34,6 +34,13 @@ void raw_ostream::handle() {}
/// information about the error is put into ErrorInfo, and the stream should
/// be immediately destroyed.
raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo) {
+ // Handle "-" as stdout.
+ if (Filename[0] == '-' && Filename[1] == 0) {
+ FD = STDOUT_FILENO;
+ ShouldClose = false;
+ return;
+ }
+
FD = open(Filename, O_WRONLY|O_CREAT|O_TRUNC, 0644);
if (FD < 0) {
ErrorInfo = "Error opening output file '" + std::string(Filename) + "'";