aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Object/Archive.cpp
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-12-04 19:51:48 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-12-04 19:51:48 +0000
commita21bbdfad461e957fa42ac9d6860ddc9de2da3e9 (patch)
tree8d32ff2094b47e15a8def30d62fd7dee6e009de3 /lib/Object/Archive.cpp
parent6b8c6a5088c221af2b25065b8b6b8b0fec8a116f (diff)
parent876d6995443e99d13696f3941c3a789a4daa7c7a (diff)
downloadexternal_llvm-a21bbdfad461e957fa42ac9d6860ddc9de2da3e9.zip
external_llvm-a21bbdfad461e957fa42ac9d6860ddc9de2da3e9.tar.gz
external_llvm-a21bbdfad461e957fa42ac9d6860ddc9de2da3e9.tar.bz2
am 876d6995: Merge "Update aosp/master LLVM for rebase to r222494."
* commit '876d6995443e99d13696f3941c3a789a4daa7c7a': Update aosp/master LLVM for rebase to r222494.
Diffstat (limited to 'lib/Object/Archive.cpp')
-rw-r--r--lib/Object/Archive.cpp40
1 files changed, 15 insertions, 25 deletions
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<StringRef> Archive::Child::getName() const {
return name;
}
-ErrorOr<std::unique_ptr<MemoryBuffer>>
-Archive::Child::getMemoryBuffer(bool FullPath) const {
+ErrorOr<MemoryBufferRef> Archive::Child::getMemoryBufferRef() const {
ErrorOr<StringRef> NameOrErr = getName();
if (std::error_code EC = NameOrErr.getError())
return EC;
StringRef Name = NameOrErr.get();
- SmallString<128> Path;
- std::unique_ptr<MemoryBuffer> Ret(MemoryBuffer::getMemBuffer(
- getBuffer(),
- FullPath
- ? (Twine(Parent->getFileName()) + "(" + Name + ")").toStringRef(Path)
- : Name,
- false));
- return std::move(Ret);
+ return MemoryBufferRef(getBuffer(), Name);
}
ErrorOr<std::unique_ptr<Binary>>
Archive::Child::getAsBinary(LLVMContext *Context) const {
- std::unique_ptr<Binary> ret;
- ErrorOr<std::unique_ptr<MemoryBuffer>> BuffOrErr = getMemoryBuffer();
+ ErrorOr<MemoryBufferRef> BuffOrErr = getMemoryBufferRef();
if (std::error_code EC = BuffOrErr.getError())
return EC;
- std::unique_ptr<MemoryBuffer> Buff(BuffOrErr.get().release());
- return createBinary(Buff, Context);
+ return createBinary(BuffOrErr.get(), Context);
}
-ErrorOr<Archive *> Archive::create(std::unique_ptr<MemoryBuffer> Source) {
+ErrorOr<std::unique_ptr<Archive>> Archive::create(MemoryBufferRef Source) {
std::error_code EC;
- std::unique_ptr<Archive> Ret(new Archive(std::move(Source), EC));
+ std::unique_ptr<Archive> Ret(new Archive(Source, EC));
if (EC)
return EC;
- return Ret.release();
+ return std::move(Ret);
}
-Archive::Archive(std::unique_ptr<MemoryBuffer> 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<MemoryBuffer> 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<MemoryBuffer> 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;
}