From 37ed9c199ca639565f6ce88105f9e39e898d82d0 Mon Sep 17 00:00:00 2001 From: Stephen Hines Date: Mon, 1 Dec 2014 14:51:49 -0800 Subject: Update aosp/master LLVM for rebase to r222494. Change-Id: Ic787f5e0124df789bd26f3f24680f45e678eef2d --- lib/Object/Archive.cpp | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'lib/Object/Archive.cpp') diff --git a/lib/Object/Archive.cpp b/lib/Object/Archive.cpp index 6d09bdb..d169dbe 100644 --- a/lib/Object/Archive.cpp +++ b/lib/Object/Archive.cpp @@ -109,7 +109,7 @@ Archive::Child Archive::Child::getNext() const { const char *NextLoc = Data.data() + SpaceToSkip; // Check to see if this is past the end of the archive. - if (NextLoc >= Parent->Data->getBufferEnd()) + if (NextLoc >= Parent->Data.getBufferEnd()) return Child(Parent, nullptr); return Child(Parent, NextLoc); @@ -159,46 +159,36 @@ ErrorOr Archive::Child::getName() const { return name; } -ErrorOr> -Archive::Child::getMemoryBuffer(bool FullPath) const { +ErrorOr Archive::Child::getMemoryBufferRef() const { ErrorOr NameOrErr = getName(); if (std::error_code EC = NameOrErr.getError()) return EC; StringRef Name = NameOrErr.get(); - SmallString<128> Path; - std::unique_ptr Ret(MemoryBuffer::getMemBuffer( - getBuffer(), - FullPath - ? (Twine(Parent->getFileName()) + "(" + Name + ")").toStringRef(Path) - : Name, - false)); - return std::move(Ret); + return MemoryBufferRef(getBuffer(), Name); } ErrorOr> Archive::Child::getAsBinary(LLVMContext *Context) const { - std::unique_ptr ret; - ErrorOr> BuffOrErr = getMemoryBuffer(); + ErrorOr BuffOrErr = getMemoryBufferRef(); if (std::error_code EC = BuffOrErr.getError()) return EC; - std::unique_ptr Buff(BuffOrErr.get().release()); - return createBinary(Buff, Context); + return createBinary(BuffOrErr.get(), Context); } -ErrorOr Archive::create(std::unique_ptr Source) { +ErrorOr> Archive::create(MemoryBufferRef Source) { std::error_code EC; - std::unique_ptr Ret(new Archive(std::move(Source), EC)); + std::unique_ptr Ret(new Archive(Source, EC)); if (EC) return EC; - return Ret.release(); + return std::move(Ret); } -Archive::Archive(std::unique_ptr Source, std::error_code &ec) - : Binary(Binary::ID_Archive, std::move(Source)), SymbolTable(child_end()) { +Archive::Archive(MemoryBufferRef Source, std::error_code &ec) + : Binary(Binary::ID_Archive, Source), SymbolTable(child_end()) { // Check for sufficient magic. - if (Data->getBufferSize() < 8 || - StringRef(Data->getBufferStart(), 8) != Magic) { + if (Data.getBufferSize() < 8 || + StringRef(Data.getBufferStart(), 8) != Magic) { ec = object_error::invalid_file_type; return; } @@ -250,7 +240,7 @@ Archive::Archive(std::unique_ptr Source, std::error_code &ec) if (ec) return; Name = NameOrErr.get(); - if (Name == "__.SYMDEF SORTED") { + if (Name == "__.SYMDEF SORTED" || Name == "__.SYMDEF") { SymbolTable = i; ++i; } @@ -312,13 +302,13 @@ Archive::Archive(std::unique_ptr Source, std::error_code &ec) } Archive::child_iterator Archive::child_begin(bool SkipInternal) const { - if (Data->getBufferSize() == 8) // empty archive. + if (Data.getBufferSize() == 8) // empty archive. return child_end(); if (SkipInternal) return FirstRegular; - const char *Loc = Data->getBufferStart() + strlen(Magic); + const char *Loc = Data.getBufferStart() + strlen(Magic); Child c(this, Loc); return c; } -- cgit v1.1