[lld] r235933 - Use MemoryBufferRef instead of MemoryBuffer&. NFC.

Rafael Espindola rafael.espindola at gmail.com
Mon Apr 27 15:48:52 PDT 2015


Author: rafael
Date: Mon Apr 27 17:48:51 2015
New Revision: 235933

URL: http://llvm.org/viewvc/llvm-project?rev=235933&view=rev
Log:
Use MemoryBufferRef instead of MemoryBuffer&. NFC.

This just reduces the noise from another patch.

Modified:
    lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h
    lld/trunk/lib/ReaderWriter/ELF/DynamicFile.cpp
    lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h
    lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp
    lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
    lld/trunk/lib/ReaderWriter/ELF/ELFReader.h
    lld/trunk/lib/ReaderWriter/ELF/FileCommon.h
    lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFile.h
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp

Modified: lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h?rev=235933&r1=235932&r2=235933&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h Mon Apr 27 17:48:51 2015
@@ -271,8 +271,7 @@ public:
 
   /// If the memoryBuffer is a fat file with a slice for the current arch,
   /// this method will return the offset and size of that slice.
-  bool sliceFromFatFile(const MemoryBuffer &mb, uint32_t &offset,
-                        uint32_t &size);
+  bool sliceFromFatFile(MemoryBufferRef mb, uint32_t &offset, uint32_t &size);
 
   /// Returns if a command line option specified dylib is an upward link.
   bool isUpwardDylib(StringRef installName) const;

Modified: lld/trunk/lib/ReaderWriter/ELF/DynamicFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DynamicFile.cpp?rev=235933&r1=235932&r2=235933&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/DynamicFile.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/DynamicFile.cpp Mon Apr 27 17:48:51 2015
@@ -24,7 +24,7 @@ DynamicFile<ELFT>::DynamicFile(std::uniq
       _ctx(ctx), _useShlibUndefines(ctx.useShlibUndefines()) {}
 
 template <typename ELFT>
-std::error_code DynamicFile<ELFT>::isCompatible(const MemoryBuffer &mb,
+std::error_code DynamicFile<ELFT>::isCompatible(MemoryBufferRef mb,
                                                 ELFLinkingContext &ctx) {
   return elf::isCompatible<ELFT>(mb, ctx);
 }

Modified: lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h?rev=235933&r1=235932&r2=235933&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h Mon Apr 27 17:48:51 2015
@@ -23,7 +23,7 @@ template <class ELFT> class DynamicFile
 public:
   DynamicFile(std::unique_ptr<MemoryBuffer> mb, ELFLinkingContext &ctx);
 
-  static std::error_code isCompatible(const MemoryBuffer &mb,
+  static std::error_code isCompatible(MemoryBufferRef mb,
                                       ELFLinkingContext &ctx);
 
   const SharedLibraryAtom *exports(StringRef name,

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp?rev=235933&r1=235932&r2=235933&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp Mon Apr 27 17:48:51 2015
@@ -28,7 +28,7 @@ ELFFile<ELFT>::ELFFile(std::unique_ptr<M
       _useWrap(ctx.wrapCalls().size()), _ctx(ctx) {}
 
 template <typename ELFT>
-std::error_code ELFFile<ELFT>::isCompatible(const MemoryBuffer &mb,
+std::error_code ELFFile<ELFT>::isCompatible(MemoryBufferRef mb,
                                             ELFLinkingContext &ctx) {
   return elf::isCompatible<ELFT>(mb, ctx);
 }

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.h?rev=235933&r1=235932&r2=235933&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.h Mon Apr 27 17:48:51 2015
@@ -90,7 +90,7 @@ public:
   ELFFile(StringRef name, ELFLinkingContext &ctx);
   ELFFile(std::unique_ptr<MemoryBuffer> mb, ELFLinkingContext &ctx);
 
-  static std::error_code isCompatible(const MemoryBuffer &mb,
+  static std::error_code isCompatible(MemoryBufferRef mb,
                                       ELFLinkingContext &ctx);
 
   static bool canParse(file_magic magic) {

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFReader.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFReader.h?rev=235933&r1=235932&r2=235933&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFReader.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFReader.h Mon Apr 27 17:48:51 2015
@@ -31,7 +31,7 @@ public:
   ErrorOr<std::unique_ptr<File>>
   loadFile(std::unique_ptr<MemoryBuffer> mb,
            const class Registry &) const override {
-    if (std::error_code ec = FileT::isCompatible(*mb, _ctx))
+    if (std::error_code ec = FileT::isCompatible(mb->getMemBufferRef(), _ctx))
       return ec;
     std::unique_ptr<File> ret = llvm::make_unique<FileT>(std::move(mb), _ctx);
     return std::move(ret);

Modified: lld/trunk/lib/ReaderWriter/ELF/FileCommon.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/FileCommon.h?rev=235933&r1=235932&r2=235933&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/FileCommon.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/FileCommon.h Mon Apr 27 17:48:51 2015
@@ -21,7 +21,7 @@ template <class ELFT>
 std::error_code checkCompatibility(unsigned char size, unsigned char endian);
 
 template <typename ELFT>
-std::error_code isCompatible(const MemoryBuffer &mb, ELFLinkingContext &ctx) {
+std::error_code isCompatible(MemoryBufferRef mb, ELFLinkingContext &ctx) {
   typedef llvm::object::Elf_Ehdr_Impl<ELFT> Elf_Ehdr;
 
   if (uintptr_t(mb.getBufferStart()) & 1)

Modified: lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=235933&r1=235932&r2=235933&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp Mon Apr 27 17:48:51 2015
@@ -133,8 +133,7 @@ bool MachOLinkingContext::isThinObjectFi
   return mach_o::normalized::isThinObjectFile(path, arch);
 }
 
-bool MachOLinkingContext::sliceFromFatFile(const MemoryBuffer &mb,
-                                           uint32_t &offset,
+bool MachOLinkingContext::sliceFromFatFile(MemoryBufferRef mb, uint32_t &offset,
                                            uint32_t &size) {
   return mach_o::normalized::sliceFromFatFile(mb, _arch, offset, size);
 }
@@ -613,7 +612,7 @@ MachOLinkingContext::getMemoryBuffer(Str
   // and switch buffer to point to just that required slice.
   uint32_t offset;
   uint32_t size;
-  if (sliceFromFatFile(*mb, offset, size))
+  if (sliceFromFatFile(mb->getMemBufferRef(), offset, size))
     return MemoryBuffer::getFileSlice(path, size, offset);
   return std::move(mb);
 }

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFile.h?rev=235933&r1=235932&r2=235933&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFile.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFile.h Mon Apr 27 17:48:51 2015
@@ -264,8 +264,8 @@ bool isThinObjectFile(StringRef path, Ma
 /// If the buffer is a fat file with the request arch, then this function
 /// returns true with 'offset' and 'size' set to location of the arch slice
 /// within the buffer.  Otherwise returns false;
-bool sliceFromFatFile(const MemoryBuffer &mb, MachOLinkingContext::Arch arch,
-                       uint32_t &offset, uint32_t &size);
+bool sliceFromFatFile(MemoryBufferRef mb, MachOLinkingContext::Arch arch,
+                      uint32_t &offset, uint32_t &size);
 
 /// Reads a mach-o file and produces an in-memory normalized view.
 ErrorOr<std::unique_ptr<NormalizedFile>>

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp?rev=235933&r1=235932&r2=235933&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp Mon Apr 27 17:48:51 2015
@@ -170,9 +170,8 @@ bool isThinObjectFile(StringRef path, Ma
   return true;
 }
 
-
-bool sliceFromFatFile(const MemoryBuffer &mb, MachOLinkingContext::Arch arch,
-                                             uint32_t &offset, uint32_t &size) {
+bool sliceFromFatFile(MemoryBufferRef mb, MachOLinkingContext::Arch arch,
+                      uint32_t &offset, uint32_t &size) {
   const char *start = mb.getBufferStart();
   const llvm::MachO::fat_header *fh =
       reinterpret_cast<const llvm::MachO::fat_header *>(start);
@@ -212,7 +211,7 @@ readBinary(std::unique_ptr<MemoryBuffer>
 
   uint32_t sliceOffset;
   uint32_t sliceSize;
-  if (sliceFromFatFile(*mb, arch, sliceOffset, sliceSize)) {
+  if (sliceFromFatFile(mb->getMemBufferRef(), arch, sliceOffset, sliceSize)) {
     start = &start[sliceOffset];
     objSize = sliceSize;
     mh = reinterpret_cast<const mach_header *>(start);





More information about the llvm-commits mailing list