Skip to content

Commit

Permalink
Make outs() close its file when its stream is destructed, so that
Browse files Browse the repository at this point in the history
pending output errors are detected.

llvm-svn: 111643
  • Loading branch information
Dan Gohman committed Aug 20, 2010
1 parent 443f2d6 commit e9a4691
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions llvm/lib/Support/raw_ostream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,14 +540,16 @@ bool raw_fd_ostream::is_displayed() const {
}

//===----------------------------------------------------------------------===//
// raw_stdout/err_ostream
// outs(), errs(), nulls()
//===----------------------------------------------------------------------===//

/// 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.
static raw_fd_ostream S(STDOUT_FILENO, false);
// Delete the file descriptor when the program exists, forcing error
// detection. If you don't want this behavior, don't use outs().
static raw_fd_ostream S(STDOUT_FILENO, true);
return S;
}

Expand Down

0 comments on commit e9a4691

Please sign in to comment.