From ed48e53d604a4264c1907b9bf4b14a82edf0eb60 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 27 Apr 2015 22:48:51 +0000 Subject: [PATCH] Use MemoryBufferRef instead of MemoryBuffer&. NFC. This just reduces the noise from another patch. llvm-svn: 235933 --- lld/include/lld/ReaderWriter/MachOLinkingContext.h | 3 +-- lld/lib/ReaderWriter/ELF/DynamicFile.cpp | 2 +- lld/lib/ReaderWriter/ELF/DynamicFile.h | 2 +- lld/lib/ReaderWriter/ELF/ELFFile.cpp | 2 +- lld/lib/ReaderWriter/ELF/ELFFile.h | 2 +- lld/lib/ReaderWriter/ELF/ELFReader.h | 2 +- lld/lib/ReaderWriter/ELF/FileCommon.h | 2 +- lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp | 5 ++--- lld/lib/ReaderWriter/MachO/MachONormalizedFile.h | 4 ++-- lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp | 7 +++---- 10 files changed, 14 insertions(+), 17 deletions(-) diff --git a/lld/include/lld/ReaderWriter/MachOLinkingContext.h b/lld/include/lld/ReaderWriter/MachOLinkingContext.h index 0be07c6..911755d 100644 --- a/lld/include/lld/ReaderWriter/MachOLinkingContext.h +++ b/lld/include/lld/ReaderWriter/MachOLinkingContext.h @@ -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; diff --git a/lld/lib/ReaderWriter/ELF/DynamicFile.cpp b/lld/lib/ReaderWriter/ELF/DynamicFile.cpp index 4a6ee83..32a45a1 100644 --- a/lld/lib/ReaderWriter/ELF/DynamicFile.cpp +++ b/lld/lib/ReaderWriter/ELF/DynamicFile.cpp @@ -24,7 +24,7 @@ DynamicFile::DynamicFile(std::unique_ptr mb, _ctx(ctx), _useShlibUndefines(ctx.useShlibUndefines()) {} template -std::error_code DynamicFile::isCompatible(const MemoryBuffer &mb, +std::error_code DynamicFile::isCompatible(MemoryBufferRef mb, ELFLinkingContext &ctx) { return elf::isCompatible(mb, ctx); } diff --git a/lld/lib/ReaderWriter/ELF/DynamicFile.h b/lld/lib/ReaderWriter/ELF/DynamicFile.h index ffb4326..a155900 100644 --- a/lld/lib/ReaderWriter/ELF/DynamicFile.h +++ b/lld/lib/ReaderWriter/ELF/DynamicFile.h @@ -23,7 +23,7 @@ template class DynamicFile : public SharedLibraryFile { public: DynamicFile(std::unique_ptr 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, diff --git a/lld/lib/ReaderWriter/ELF/ELFFile.cpp b/lld/lib/ReaderWriter/ELF/ELFFile.cpp index 57c2503..14442a7 100644 --- a/lld/lib/ReaderWriter/ELF/ELFFile.cpp +++ b/lld/lib/ReaderWriter/ELF/ELFFile.cpp @@ -28,7 +28,7 @@ ELFFile::ELFFile(std::unique_ptr mb, ELFLinkingContext &ctx) _useWrap(ctx.wrapCalls().size()), _ctx(ctx) {} template -std::error_code ELFFile::isCompatible(const MemoryBuffer &mb, +std::error_code ELFFile::isCompatible(MemoryBufferRef mb, ELFLinkingContext &ctx) { return elf::isCompatible(mb, ctx); } diff --git a/lld/lib/ReaderWriter/ELF/ELFFile.h b/lld/lib/ReaderWriter/ELF/ELFFile.h index a5589d4..f519450 100644 --- a/lld/lib/ReaderWriter/ELF/ELFFile.h +++ b/lld/lib/ReaderWriter/ELF/ELFFile.h @@ -90,7 +90,7 @@ public: ELFFile(StringRef name, ELFLinkingContext &ctx); ELFFile(std::unique_ptr 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) { diff --git a/lld/lib/ReaderWriter/ELF/ELFReader.h b/lld/lib/ReaderWriter/ELF/ELFReader.h index 995876d..60af6df 100644 --- a/lld/lib/ReaderWriter/ELF/ELFReader.h +++ b/lld/lib/ReaderWriter/ELF/ELFReader.h @@ -31,7 +31,7 @@ public: ErrorOr> loadFile(std::unique_ptr 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 ret = llvm::make_unique(std::move(mb), _ctx); return std::move(ret); diff --git a/lld/lib/ReaderWriter/ELF/FileCommon.h b/lld/lib/ReaderWriter/ELF/FileCommon.h index 16d7836..4ae31e3 100644 --- a/lld/lib/ReaderWriter/ELF/FileCommon.h +++ b/lld/lib/ReaderWriter/ELF/FileCommon.h @@ -21,7 +21,7 @@ template std::error_code checkCompatibility(unsigned char size, unsigned char endian); template -std::error_code isCompatible(const MemoryBuffer &mb, ELFLinkingContext &ctx) { +std::error_code isCompatible(MemoryBufferRef mb, ELFLinkingContext &ctx) { typedef llvm::object::Elf_Ehdr_Impl Elf_Ehdr; if (uintptr_t(mb.getBufferStart()) & 1) diff --git a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp index c071f80..114a1b8 100644 --- a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp +++ b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp @@ -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); } diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFile.h b/lld/lib/ReaderWriter/MachO/MachONormalizedFile.h index 134c28d..f423d81 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFile.h +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFile.h @@ -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> diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp index 2dc9a12..1013d3d 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp @@ -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(start); @@ -212,7 +211,7 @@ readBinary(std::unique_ptr &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(start); -- 2.7.4