summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/raw_ostream.cpp
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
commitd5bc0683fd33f768d3b6e6886306a82c24e2c8a6 (patch)
treedc9e83c0661a8203ebe16ffb3fbd91a4966a7ffc /llvm/lib/Support/raw_ostream.cpp
parent87aab6c7710dd6d4406b6a05b21047d46ffba485 (diff)
downloadbcm5719-llvm-d5bc0683fd33f768d3b6e6886306a82c24e2c8a6.tar.gz
bcm5719-llvm-d5bc0683fd33f768d3b6e6886306a82c24e2c8a6.zip
opening "-" automatically yields stdout.
llvm-svn: 54863
Diffstat (limited to 'llvm/lib/Support/raw_ostream.cpp')
-rw-r--r--llvm/lib/Support/raw_ostream.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index e47bccde6cb..a4dc797f01c 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/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) + "'";
OpenPOWER on IntegriCloud