Use MemoryBufferRef instead of MemoryBuffer&. NFC.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 27 Apr 2015 22:48:51 +0000 (22:48 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 27 Apr 2015 22:48:51 +0000 (22:48 +0000)
This just reduces the noise from another patch.

llvm-svn: 235933

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

index 0be07c6..911755d 100644 (file)
@@ -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;
index 4a6ee83..32a45a1 100644 (file)
@@ -24,7 +24,7 @@ DynamicFile<ELFT>::DynamicFile(std::unique_ptr<MemoryBuffer> mb,
       _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);
 }
index ffb4326..a155900 100644 (file)
@@ -23,7 +23,7 @@ template <class ELFT> class DynamicFile : public SharedLibraryFile {
 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,
index 57c2503..14442a7 100644 (file)
@@ -28,7 +28,7 @@ ELFFile<ELFT>::ELFFile(std::unique_ptr<MemoryBuffer> mb, ELFLinkingContext &ctx)
       _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);
 }
index a5589d4..f519450 100644 (file)
@@ -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) {
index 995876d..60af6df 100644 (file)
@@ -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);
index 16d7836..4ae31e3 100644 (file)
@@ -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)
index c071f80..114a1b8 100644 (file)
@@ -133,8 +133,7 @@ bool MachOLinkingContext::isThinObjectFile(StringRef path, Arch &arch) {
   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(StringRef path) {
   // 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);
 }
index 134c28d..f423d81 100644 (file)
@@ -264,8 +264,8 @@ bool isThinObjectFile(StringRef path, MachOLinkingContext::Arch &arch);
 /// 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>>
index 2dc9a12..1013d3d 100644 (file)
@@ -170,9 +170,8 @@ bool isThinObjectFile(StringRef path, MachOLinkingContext::Arch &arch) {
   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> &mb,
 
   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);