aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Object/Binary.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/Object/Binary.h')
-rw-r--r--include/llvm/Object/Binary.h27
1 files changed, 19 insertions, 8 deletions
diff --git a/include/llvm/Object/Binary.h b/include/llvm/Object/Binary.h
index a3f5625..b10e40a 100644
--- a/include/llvm/Object/Binary.h
+++ b/include/llvm/Object/Binary.h
@@ -14,11 +14,13 @@
#ifndef LLVM_OBJECT_BINARY_H
#define LLVM_OBJECT_BINARY_H
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/Object/Error.h"
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/FileSystem.h"
namespace llvm {
+class LLVMContext;
class MemoryBuffer;
class StringRef;
@@ -30,15 +32,18 @@ private:
Binary(const Binary &other) LLVM_DELETED_FUNCTION;
unsigned int TypeID;
+ bool BufferOwned;
protected:
MemoryBuffer *Data;
- Binary(unsigned int Type, MemoryBuffer *Source);
+ Binary(unsigned int Type, MemoryBuffer *Source, bool BufferOwned = true);
enum {
ID_Archive,
ID_MachOUniversalBinary,
+ ID_IR, // LLVM IR
+
// Object and children.
ID_StartObjects,
ID_COFF,
@@ -84,6 +89,10 @@ public:
return TypeID > ID_StartObjects && TypeID < ID_EndObjects;
}
+ bool isSymbolic() const {
+ return isIR() || isObject();
+ }
+
bool isArchive() const {
return TypeID == ID_Archive;
}
@@ -104,6 +113,10 @@ public:
return TypeID == ID_COFF;
}
+ bool isIR() const {
+ return TypeID == ID_IR;
+ }
+
bool isLittleEndian() const {
return !(TypeID == ID_ELF32B || TypeID == ID_ELF64B ||
TypeID == ID_MachO32B || TypeID == ID_MachO64B);
@@ -113,13 +126,11 @@ public:
/// @brief Create a Binary from Source, autodetecting the file type.
///
/// @param Source The data to create the Binary from. Ownership is transferred
-/// to Result if successful. If an error is returned, Source is destroyed
-/// by createBinary before returning.
-/// @param Result A pointer to the resulting Binary if no error occured.
-error_code createBinary(MemoryBuffer *Source, OwningPtr<Binary> &Result);
-
-error_code createBinary(StringRef Path, OwningPtr<Binary> &Result);
+/// to the Binary if successful. If an error is returned,
+/// Source is destroyed by createBinary before returning.
+ErrorOr<Binary *> createBinary(MemoryBuffer *Source, LLVMContext *Context = 0);
+ErrorOr<Binary *> createBinary(StringRef Path);
}
}