summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-01-22 16:04:52 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-01-22 16:04:52 +0000
commit2edc3a6b8df2962f4bcc769fd2606e4f6c36fb06 (patch)
tree4ad876aa8eec3475f0eeb6dc88b45cc2c85b6187 /include
parent929b0fb893f2c794a450975d802c0b39752effc0 (diff)
downloadllvm-2edc3a6b8df2962f4bcc769fd2606e4f6c36fb06.tar.gz
llvm-2edc3a6b8df2962f4bcc769fd2606e4f6c36fb06.tar.bz2
llvm-2edc3a6b8df2962f4bcc769fd2606e4f6c36fb06.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199813 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Object/Binary.h5
-rw-r--r--include/llvm/Object/ObjectFile.h5
2 files changed, 8 insertions, 2 deletions
diff --git a/include/llvm/Object/Binary.h b/include/llvm/Object/Binary.h
index 6a73e0a5b1..7742f83cd0 100644
--- a/include/llvm/Object/Binary.h
+++ b/include/llvm/Object/Binary.h
@@ -16,6 +16,7 @@
#include "llvm/Object/Error.h"
#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/FileSystem.h"
namespace llvm {
@@ -115,7 +116,9 @@ public:
/// @param Source The data to create the Binary from. Ownership is transferred
/// to the Binary if successful. If an error is returned,
/// Source is destroyed by createBinary before returning.
-ErrorOr<Binary *> createBinary(MemoryBuffer *Source);
+ErrorOr<Binary *> createBinary(MemoryBuffer *Source,
+ sys::fs::file_magic Type =
+ sys::fs::file_magic::unknown);
ErrorOr<Binary *> createBinary(StringRef Path);
}
diff --git a/include/llvm/Object/ObjectFile.h b/include/llvm/Object/ObjectFile.h
index 4aa1e06676..77833cbf94 100644
--- a/include/llvm/Object/ObjectFile.h
+++ b/include/llvm/Object/ObjectFile.h
@@ -18,6 +18,7 @@
#include "llvm/Object/Binary.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include <cstring>
#include <vector>
@@ -377,7 +378,9 @@ public:
/// return true.
/// @brief Create ObjectFile from path.
static ErrorOr<ObjectFile *> createObjectFile(StringRef ObjectPath);
- static ErrorOr<ObjectFile *> createObjectFile(MemoryBuffer *Object);
+ static ErrorOr<ObjectFile *>
+ createObjectFile(MemoryBuffer *Object,
+ sys::fs::file_magic Type = sys::fs::file_magic::unknown);
static inline bool classof(const Binary *v) {
return v->isObject();