[PATCH] D81078: [Support] Use outs() in ToolOutputFile

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 03:48:19 PDT 2020


labath created this revision.
labath added reviewers: dblaikie, JDevlieghere, MaskRay, jhenderson.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

If the output filename was specified as "-", the ToolOutputFile class
would create a brand new raw_ostream object referring to the stdout.
This patch changes it to reuse the llvm::outs() singleton.

At the moment, this change should be "NFC", but it does enable other
enhancements, like the automatic stdout/stderr synchronization as
discussed on D80803 <https://reviews.llvm.org/D80803>.

I've checked the history, and I did not find any indication that this
class *has* to use a brand new stream object instead of outs() --
indeed, it is special-casing "-" in a number of places already, so this
change fits the pattern pretty well. I suspect the main reason for the
current state of affairs is that the class was originally introduced
(r111595, in 2010) as a raw_fd_ostream subclass, which made any other
solution impossible.

Another potential benefit of this patch is that it makes it possible to
move the raw_ostream class out of the business of special-casing "-" for
stdout handling. That state of affairs does not seem appropriate because
"-" is a valid filename (albeit hard to access with a lot of command
line tools) on most systems. Handling "-" in ToolOutputFile seems more
appropriate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81078

Files:
  llvm/include/llvm/Support/ToolOutputFile.h
  llvm/include/llvm/Support/raw_ostream.h
  llvm/lib/Support/ToolOutputFile.cpp
  llvm/lib/Support/raw_ostream.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81078.268122.patch
Type: text/x-patch
Size: 4630 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200603/1d1edec7/attachment.bin>


More information about the llvm-commits mailing list