diff options
author | Reid Kleckner <rnk@google.com> | 2017-08-04 01:39:23 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2017-08-04 01:39:23 +0000 |
commit | 02aeadcf3d431f35941c628643e919c5aa2169a1 (patch) | |
tree | 97e54bc66abbceab7bb2195eb22dff5ea3353977 /llvm/lib/Support/raw_ostream.cpp | |
parent | 696e3847dd5723d94335adf65435dc1de229a3b7 (diff) | |
download | bcm5719-llvm-02aeadcf3d431f35941c628643e919c5aa2169a1.tar.gz bcm5719-llvm-02aeadcf3d431f35941c628643e919c5aa2169a1.zip |
[Support] Update comments about stdout, raw_fd_ostream, and outs()
The full story is in the comments:
// Do not attempt to close stdout or stderr. We used to try to maintain the
// property that tools that support writing file to stdout should not also
// write informational output to stdout, but in practice we were never able to
// maintain this invariant. Many features have been added to LLVM and clang
// (-fdump-record-layouts, optimization remarks, etc) that print to stdout, so
// users must simply be aware that mixed output and remarks is a possibility.
NFC, I am just updating comments to reflect reality.
llvm-svn: 310016
Diffstat (limited to 'llvm/lib/Support/raw_ostream.cpp')
-rw-r--r-- | llvm/lib/Support/raw_ostream.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp index dd58eccee95..6a0f08690e7 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -513,11 +513,13 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered) ShouldClose = false; return; } - // We do not want to close STDOUT as there may have been several uses of it - // such as the case: llc %s -o=- -pass-remarks-output=- -filetype=asm - // which cause multiple closes of STDOUT_FILENO and/or use-after-close of it. - // Using dup() in getFD doesn't work as we end up with original STDOUT_FILENO - // open anyhow. + + // Do not attempt to close stdout or stderr. We used to try to maintain the + // property that tools that support writing file to stdout should not also + // write informational output to stdout, but in practice we were never able to + // maintain this invariant. Many features have been added to LLVM and clang + // (-fdump-record-layouts, optimization remarks, etc) that print to stdout, so + // users must simply be aware that mixed output and remarks is a possibility. if (FD <= STDERR_FILENO) ShouldClose = false; @@ -722,10 +724,7 @@ bool raw_fd_ostream::has_colors() const { /// outs() - This returns a reference to a raw_ostream for standard output. /// Use it like: outs() << "foo" << "bar"; raw_ostream &llvm::outs() { - // Set buffer settings to model stdout behavior. Delete the file descriptor - // when the program exits, forcing error detection. This means that if you - // ever call outs(), you can't open another raw_fd_ostream on stdout, as we'll - // close stdout twice and print an error the second time. + // Set buffer settings to model stdout behavior. std::error_code EC; static raw_fd_ostream S("-", EC, sys::fs::F_None); assert(!EC); |