diff --git a/llvm/include/llvm/Object/Binary.h b/llvm/include/llvm/Object/Binary.h index ce870e25acafe..083a8cc0cfeb6 100644 --- a/llvm/include/llvm/Object/Binary.h +++ b/llvm/include/llvm/Object/Binary.h @@ -189,7 +189,7 @@ DEFINE_ISA_CONVERSION_FUNCTIONS(Binary, LLVMBinaryRef) /// Create a Binary from Source, autodetecting the file type. /// /// @param Source The data to create the Binary from. -Expected> createBinary(MemoryBufferRef Source, +Expected> createBinary(const MemoryBufferRef &Source, LLVMContext *Context = nullptr, bool InitContent = true); diff --git a/llvm/include/llvm/Object/COFFModuleDefinition.h b/llvm/include/llvm/Object/COFFModuleDefinition.h index a4ed9978dcc0a..3ccfee8f9142b 100644 --- a/llvm/include/llvm/Object/COFFModuleDefinition.h +++ b/llvm/include/llvm/Object/COFFModuleDefinition.h @@ -40,7 +40,7 @@ struct COFFModuleDefinition { }; Expected -parseCOFFModuleDefinition(MemoryBufferRef MB, COFF::MachineTypes Machine, +parseCOFFModuleDefinition(const MemoryBufferRef &MB, COFF::MachineTypes Machine, bool MingwDef = false, bool AddUnderscores = true); } // End namespace object. diff --git a/llvm/include/llvm/Object/DXContainer.h b/llvm/include/llvm/Object/DXContainer.h index 19c83ba6c6e85..78acffda38e04 100644 --- a/llvm/include/llvm/Object/DXContainer.h +++ b/llvm/include/llvm/Object/DXContainer.h @@ -370,7 +370,7 @@ class DXContainer { PartIterator end() const { return PartIterator(*this, PartOffsets.end()); } StringRef getData() const { return Data.getBuffer(); } - static Expected create(MemoryBufferRef Object); + static Expected create(const MemoryBufferRef &Object); const dxbc::Header &getHeader() const { return Header; } diff --git a/llvm/include/llvm/Object/ObjectFile.h b/llvm/include/llvm/Object/ObjectFile.h index 20c0ef5ccfcea..79e1074a2ae4f 100644 --- a/llvm/include/llvm/Object/ObjectFile.h +++ b/llvm/include/llvm/Object/ObjectFile.h @@ -382,7 +382,7 @@ class ObjectFile : public SymbolicFile { } static Expected> - createCOFFObjectFile(MemoryBufferRef Object); + createCOFFObjectFile(const MemoryBufferRef &Object); static Expected> createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType); @@ -396,7 +396,7 @@ class ObjectFile : public SymbolicFile { size_t MachOFilesetEntryOffset = 0); static Expected> - createGOFFObjectFile(MemoryBufferRef Object); + createGOFFObjectFile(const MemoryBufferRef &Object); static Expected> createWasmObjectFile(MemoryBufferRef Object); diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.cpp b/llvm/lib/ObjCopy/ELF/ELFObject.cpp index 45c7ea49b5d93..7b9b4206a87e6 100644 --- a/llvm/lib/ObjCopy/ELF/ELFObject.cpp +++ b/llvm/lib/ObjCopy/ELF/ELFObject.cpp @@ -711,7 +711,7 @@ void SymbolTableSection::assignIndices() { } } -void SymbolTableSection::addSymbol(Twine Name, uint8_t Bind, uint8_t Type, +void SymbolTableSection::addSymbol(const Twine &Name, uint8_t Bind, uint8_t Type, SectionBase *DefinedIn, uint64_t Value, uint8_t Visibility, uint16_t Shndx, uint64_t SymbolSize) { @@ -1680,7 +1680,7 @@ static Error initRelocations(RelocationSection *Relocs, T RelRange) { } Expected SectionTableRef::getSection(uint32_t Index, - Twine ErrMsg) { + const Twine &ErrMsg) { if (Index == SHN_UNDEF || Index > Sections.size()) return createStringError(errc::invalid_argument, ErrMsg); return Sections[Index - 1].get(); diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.h b/llvm/lib/ObjCopy/ELF/ELFObject.h index d8f79a4b1a3cc..6506bfbc80eaf 100644 --- a/llvm/lib/ObjCopy/ELF/ELFObject.h +++ b/llvm/lib/ObjCopy/ELF/ELFObject.h @@ -61,7 +61,7 @@ class SectionTableRef { iterator end() const { return iterator(Sections.data() + Sections.size()); } size_t size() const { return Sections.size(); } - Expected getSection(uint32_t Index, Twine ErrMsg); + Expected getSection(uint32_t Index, const Twine &ErrMsg); template Expected getSectionOfType(uint32_t Index, Twine IndexErrMsg, @@ -825,7 +825,7 @@ class SymbolTableSection : public SectionBase { public: SymbolTableSection() { Type = OriginalType = ELF::SHT_SYMTAB; } - void addSymbol(Twine Name, uint8_t Bind, uint8_t Type, SectionBase *DefinedIn, + void addSymbol(const Twine &Name, uint8_t Bind, uint8_t Type, SectionBase *DefinedIn, uint64_t Value, uint8_t Visibility, uint16_t Shndx, uint64_t SymbolSize); void prepareForLayout(); diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp index 92f31c909efd4..2f40e638f8b41 100644 --- a/llvm/lib/Object/Archive.cpp +++ b/llvm/lib/Object/Archive.cpp @@ -40,7 +40,7 @@ using namespace llvm::support::endian; void Archive::anchor() {} -static Error malformedError(Twine Msg) { +static Error malformedError(const Twine &Msg) { std::string StringMsg = "truncated or malformed archive (" + Msg.str() + ")"; return make_error(std::move(StringMsg), object_error::parse_failed); @@ -177,7 +177,7 @@ Expected ArchiveMemberHeader::getRawName() const { } Expected -getArchiveMemberDecField(Twine FieldName, const StringRef RawField, +getArchiveMemberDecField(const Twine &FieldName, const StringRef RawField, const Archive *Parent, const AbstractArchiveMemberHeader *MemHeader) { uint64_t Value; @@ -195,7 +195,7 @@ getArchiveMemberDecField(Twine FieldName, const StringRef RawField, } Expected -getArchiveMemberOctField(Twine FieldName, const StringRef RawField, +getArchiveMemberOctField(const Twine &FieldName, const StringRef RawField, const Archive *Parent, const AbstractArchiveMemberHeader *MemHeader) { uint64_t Value; diff --git a/llvm/lib/Object/ArchiveWriter.cpp b/llvm/lib/Object/ArchiveWriter.cpp index c61ba868efe60..46932ef6d1f48 100644 --- a/llvm/lib/Object/ArchiveWriter.cpp +++ b/llvm/lib/Object/ArchiveWriter.cpp @@ -482,7 +482,7 @@ static uint64_t computeHeadersSize(object::Archive::Kind Kind, } static Expected> -getSymbolicFile(MemoryBufferRef Buf, LLVMContext &Context, +getSymbolicFile(const MemoryBufferRef &Buf, LLVMContext &Context, object::Archive::Kind Kind, function_ref Warn) { const file_magic Type = identify_magic(Buf.getBuffer()); // Don't attempt to read non-symbolic file types. diff --git a/llvm/lib/Object/Binary.cpp b/llvm/lib/Object/Binary.cpp index 2dfae8ab5d3c6..4b5934cac9903 100644 --- a/llvm/lib/Object/Binary.cpp +++ b/llvm/lib/Object/Binary.cpp @@ -42,7 +42,7 @@ StringRef Binary::getFileName() const { return Data.getBufferIdentifier(); } MemoryBufferRef Binary::getMemoryBufferRef() const { return Data; } -Expected> object::createBinary(MemoryBufferRef Buffer, +Expected> object::createBinary(const MemoryBufferRef &Buffer, LLVMContext *Context, bool InitContent) { file_magic Type = identify_magic(Buffer.getBuffer()); diff --git a/llvm/lib/Object/COFFModuleDefinition.cpp b/llvm/lib/Object/COFFModuleDefinition.cpp index 82c18539658e8..1c0fa14d43791 100644 --- a/llvm/lib/Object/COFFModuleDefinition.cpp +++ b/llvm/lib/Object/COFFModuleDefinition.cpp @@ -362,7 +362,7 @@ class Parser { bool AddUnderscores; }; -Expected parseCOFFModuleDefinition(MemoryBufferRef MB, +Expected parseCOFFModuleDefinition(const MemoryBufferRef &MB, MachineTypes Machine, bool MingwDef, bool AddUnderscores) { diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index 242c123665f76..cf25f393dcb32 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -43,7 +43,7 @@ using support::ulittle64_t; using support::little16_t; // Returns false if size is greater than the buffer size. And sets ec. -static bool checkSize(MemoryBufferRef M, std::error_code &EC, uint64_t Size) { +static bool checkSize(const MemoryBufferRef &M, std::error_code &EC, uint64_t Size) { if (M.getBufferSize() < Size) { EC = object_error::unexpected_eof; return false; @@ -353,7 +353,7 @@ bool COFFObjectFile::isSectionVirtual(DataRefImpl Ref) const { } static uint32_t getNumberOfRelocations(const coff_section *Sec, - MemoryBufferRef M, const uint8_t *base) { + const MemoryBufferRef &M, const uint8_t *base) { // The field for the number of relocations in COFF section table is only // 16-bit wide. If a section has more than 65535 relocations, 0xFFFF is set to // NumberOfRelocations field, and the actual relocation count is stored in the @@ -373,7 +373,7 @@ static uint32_t getNumberOfRelocations(const coff_section *Sec, } static const coff_relocation * -getFirstReloc(const coff_section *Sec, MemoryBufferRef M, const uint8_t *Base) { +getFirstReloc(const coff_section *Sec, const MemoryBufferRef &M, const uint8_t *Base) { uint64_t NumRelocs = getNumberOfRelocations(Sec, M, Base); if (!NumRelocs) return nullptr; @@ -1893,7 +1893,7 @@ Error ImportedSymbolRef::getOrdinal(uint16_t &Result) const { } Expected> -ObjectFile::createCOFFObjectFile(MemoryBufferRef Object) { +ObjectFile::createCOFFObjectFile(const MemoryBufferRef &Object) { return COFFObjectFile::create(Object); } diff --git a/llvm/lib/Object/DXContainer.cpp b/llvm/lib/Object/DXContainer.cpp index 3b1a6203a1f8f..f26c0133e24a1 100644 --- a/llvm/lib/Object/DXContainer.cpp +++ b/llvm/lib/Object/DXContainer.cpp @@ -208,7 +208,7 @@ Error DXContainer::parsePartOffsets() { return Error::success(); } -Expected DXContainer::create(MemoryBufferRef Object) { +Expected DXContainer::create(const MemoryBufferRef &Object) { DXContainer Container(Object); if (Error Err = Container.parseHeader()) return std::move(Err); diff --git a/llvm/lib/Object/GOFFObjectFile.cpp b/llvm/lib/Object/GOFFObjectFile.cpp index db1e7e704f62e..b9072fddc5a52 100644 --- a/llvm/lib/Object/GOFFObjectFile.cpp +++ b/llvm/lib/Object/GOFFObjectFile.cpp @@ -25,7 +25,7 @@ using namespace llvm::object; using namespace llvm; Expected> -ObjectFile::createGOFFObjectFile(MemoryBufferRef Object) { +ObjectFile::createGOFFObjectFile(const MemoryBufferRef &Object) { Error Err = Error::success(); std::unique_ptr Ret(new GOFFObjectFile(Object, Err)); if (Err)