diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-01-22 16:04:52 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-01-22 16:04:52 +0000 |
commit | ec46f3182b684b41ae4348b013f50740cf1cd2b1 (patch) | |
tree | 9ce8ca097dd89f8b3d734b10b4deaa1d3934bf5a /llvm/lib/Object/ObjectFile.cpp | |
parent | 7a7c192e3e896dc5160bdee536ece542fc3c3fc3 (diff) | |
download | bcm5719-llvm-ec46f3182b684b41ae4348b013f50740cf1cd2b1.tar.gz bcm5719-llvm-ec46f3182b684b41ae4348b013f50740cf1cd2b1.zip |
Pass the computed magic to createBinary and createObjectFile if available.
identify_magic is not free, so we should avoid calling it twice. The argument
also makes it cheap for createBinary to just forward to createObjectFile.
llvm-svn: 199813
Diffstat (limited to 'llvm/lib/Object/ObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/ObjectFile.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Object/ObjectFile.cpp b/llvm/lib/Object/ObjectFile.cpp index fd2b024687c..6b14e78ff3d 100644 --- a/llvm/lib/Object/ObjectFile.cpp +++ b/llvm/lib/Object/ObjectFile.cpp @@ -37,9 +37,11 @@ section_iterator ObjectFile::getRelocatedSection(DataRefImpl Sec) const { return section_iterator(SectionRef(Sec, this)); } -ErrorOr<ObjectFile *> ObjectFile::createObjectFile(MemoryBuffer *Object) { +ErrorOr<ObjectFile *> ObjectFile::createObjectFile(MemoryBuffer *Object, + sys::fs::file_magic Type) { OwningPtr<MemoryBuffer> ScopedObj(Object); - sys::fs::file_magic Type = sys::fs::identify_magic(Object->getBuffer()); + if (Type == sys::fs::file_magic::unknown) + Type = sys::fs::identify_magic(Object->getBuffer()); switch (Type) { case sys::fs::file_magic::unknown: |