aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Object/Binary.h
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-04-23 16:57:46 -0700
committerStephen Hines <srhines@google.com>2014-04-24 15:53:16 -0700
commit36b56886974eae4f9c5ebc96befd3e7bfe5de338 (patch)
treee6cfb69fbbd937f450eeb83bfb83b9da3b01275a /include/llvm/Object/Binary.h
parent69a8640022b04415ae9fac62f8ab090601d8f889 (diff)
downloadexternal_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.zip
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.gz
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.bz2
Update to LLVM 3.5a.
Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
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);
}
}