[PATCH] D113226: Support: Change FileOutputBuffer to return FileError

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 4 16:15:54 PDT 2021


dexonsmith created this revision.
dexonsmith added reviewers: dblaikie, lhames.
Herald added subscribers: ormris, hiraditya, arichardson, sbc100, emaste.
Herald added a reviewer: MaskRay.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
dexonsmith requested review of this revision.
Herald added a subscriber: aheejin.
Herald added a project: LLVM.

Update FileOutputBuffer to always return a `FileError`, now that it will
pass through the error code from the wrapped error. Also update the
callers not to redundantly include the filename in messages.

One awkward question is whether sys::fs::TempFile should return
FileError. If TempFile starts doing so and it reports the temporary file
path, then FileOutputBuffer should stop adding one... but it probably
wants to avoid leaking the temporary name and report the intended output
file instead. Maybe createFileError() should avoid double-wrapping a
FileError, instead replacing the named file in that error?

Another awkward question is whether all the callers were updated to
avoid redundantly reporting the filename. No tests failed, even before I
audited the callers. Maybe this is fine?

Note: this is an example of using https://reviews.llvm.org/D113225.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113226

Files:
  lld/COFF/Writer.cpp
  lld/ELF/Writer.cpp
  lld/MachO/Writer.cpp
  lld/wasm/Writer.cpp
  llvm/include/llvm/Support/FileOutputBuffer.h
  llvm/lib/InterfaceStub/ELFObjHandler.cpp
  llvm/lib/Support/FileOutputBuffer.cpp
  llvm/tools/llvm-cvtres/llvm-cvtres.cpp
  llvm/tools/llvm-lipo/llvm-lipo.cpp
  llvm/tools/llvm-mt/llvm-mt.cpp
  llvm/unittests/Support/FileOutputBufferTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113226.384901.patch
Type: text/x-patch
Size: 8803 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211104/6dd9eff2/attachment.bin>


More information about the llvm-commits mailing list