[PATCH] D84858: [llvm-libtool-darwin] Refactor ArchiveWriter
Sameer Arora via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 29 08:48:46 PDT 2020
sameerarora101 added inline comments.
================
Comment at: llvm/lib/Object/ArchiveWriter.cpp:673-674
+
+ ErrorOr<std::unique_ptr<MemoryBuffer>> Ret =
+ MemoryBuffer::getOpenFile(Temp->FD, ArcName, -1);
+ if (std::error_code EC = Ret.getError())
----------------
My current approach involves factoring out the common code of writing the archive to a temporary FD. Now, in case of `writeArchive`, I simply write the temporary file to disk by invoking `Temp->keep(ArcName)`. However, for `writeArchiveBuffer`, I read the archive again in a `MemoryBuffer` using
```
ErrorOr<std::unique_ptr<MemoryBuffer>> Ret =
MemoryBuffer::getOpenFile(Temp->FD, ArcName, -1);
```
This memory buffer is then put in `ReturnBuffer` (which is the buffer allocated by the caller to receive the archive buffer).
Please let me know if there is a better approach to get the archive in a buffer than this current roundtrip method(writing to a FD and then reading back into a MemBuf). Thanks!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84858/new/
https://reviews.llvm.org/D84858
More information about the llvm-commits
mailing list