This is an archive of the discontinued LLVM Phabricator instance.

FileOutputBuffer: Treat "-" as the stdout.
ClosedPublic

Authored by ruiu on Jan 18 2019, 2:27 PM.

Details

Summary

I was honestly a bit surprised that we didn't do this before. This
patch is to handle "-" as the stdout so that if you pass -o - to
lld, for example, then it write an output to stdout instead of file -.

I thought that we might want to handle this at a higher level than
FileOutputBuffer, because if we land this patch, we can no longer
create a file whose name is - (there's a workaround though; you can
pass ./- instead of -). However, because raw_fd_ostream already
handle - as a special name, I think it's okay and actually more
consistent to handle - as a special name in FileOutputBuffer as well.

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu created this revision.Jan 18 2019, 2:27 PM
ruiu updated this revision to Diff 182634.Jan 18 2019, 4:25 PM
  • simplify

This looks good to me.

I added a local hack for CHERI lld to just replace - with /device/stdout and never got around to replacing it with a sensible solution. This is much better since it will also work on Windows.

thakis accepted this revision.Jan 22 2019, 7:32 AM
This revision is now accepted and ready to land.Jan 22 2019, 7:32 AM
This revision was automatically updated to reflect the committed changes.