[PATCH] D45909: [COFF] create MemoryBuffers without requiring NUL terminators

Bob Haarman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 24 16:20:55 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD330786: [COFF] create MemoryBuffers without requiring NUL terminators (authored by inglorion, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45909?vs=143409&id=143834#toc

Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D45909

Files:
  COFF/Driver.cpp


Index: COFF/Driver.cpp
===================================================================
--- COFF/Driver.cpp
+++ COFF/Driver.cpp
@@ -105,7 +105,9 @@
   auto Strategy = std::launch::deferred;
 #endif
   return std::async(Strategy, [=]() {
-    auto MBOrErr = MemoryBuffer::getFile(Path);
+    auto MBOrErr = MemoryBuffer::getFile(Path,
+                                         /*FileSize*/ -1,
+                                         /*RequiresNullTerminator*/ false);
     if (!MBOrErr)
       return MBErrPair{nullptr, MBOrErr.getError()};
     return MBErrPair{std::move(*MBOrErr), std::error_code()};
@@ -563,7 +565,8 @@
 
   // If the import library already exists, replace it only if the contents
   // have changed.
-  ErrorOr<std::unique_ptr<MemoryBuffer>> OldBuf = MemoryBuffer::getFile(Path);
+  ErrorOr<std::unique_ptr<MemoryBuffer>> OldBuf = MemoryBuffer::getFile(
+      Path, /*FileSize*/ -1, /*RequiresNullTerminator*/ false);
   if (!OldBuf) {
     HandleError(writeImportLibrary(LibName, Path, Exports, Config->Machine,
                                    false, Config->MinGW));
@@ -582,7 +585,8 @@
     return;
   }
 
-  std::unique_ptr<MemoryBuffer> NewBuf = check(MemoryBuffer::getFile(TmpName));
+  std::unique_ptr<MemoryBuffer> NewBuf = check(MemoryBuffer::getFile(
+      TmpName, /*FileSize*/ -1, /*RequiresNullTerminator*/ false));
   if ((*OldBuf)->getBuffer() != NewBuf->getBuffer()) {
     OldBuf->reset();
     HandleError(errorCodeToError(sys::fs::rename(TmpName, Path)));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45909.143834.patch
Type: text/x-patch
Size: 1508 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180424/69d303c8/attachment.bin>


More information about the llvm-commits mailing list