[PATCH] D19838: [LLVM-AR] Fixed bug where temporary file would be left behind every time an archive was updated

Cameron via llvm-commits llvm-commits at lists.llvm.org
Wed May 4 09:17:29 PDT 2016


cameron314 updated the summary for this revision.
cameron314 added a reviewer: rafael.
cameron314 removed rL LLVM as the repository for this revision.
cameron314 updated this revision to Diff 56161.
cameron314 added a comment.

All right, I've changed the patch according to your suggestion. The buffer is no longer linked to the `Archive` object, and is passed separately. (Note this leaves the Archive object in an unusable state after the buffer is removed from under it, but that llvm-ar doesn't use it after that point.)

Long term, it might be a good idea to introduce another flag to `MemoryBuffer::getFile` to always force it to copy the file into memory instead of mapping it. This would be less efficient most of the time, but would fix this sort of bug which is otherwise very annoying to handle if there's any abstraction at all in the code that consumes the buffer before overwriting the file. It seems there's a lot of read-modify-update file access idioms across the various tools that are prone to this problem.


http://reviews.llvm.org/D19838

Files:
  include/llvm/Object/ArchiveWriter.h
  lib/Object/ArchiveWriter.cpp
  tools/llvm-ar/llvm-ar.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19838.56161.patch
Type: text/x-patch
Size: 4070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160504/c87edd1b/attachment.bin>


More information about the llvm-commits mailing list