class Binary {
private:
- Binary() LLVM_DELETED_FUNCTION;
- Binary(const Binary &other) LLVM_DELETED_FUNCTION;
+ Binary() = delete;
+ Binary(const Binary &other) = delete;
unsigned int TypeID;
enum {
ID_Archive,
ID_MachOUniversalBinary,
+ ID_COFFImportFile,
ID_IR, // LLVM IR
// Object and children.
return TypeID == ID_COFF;
}
+ bool isCOFFImportFile() const {
+ return TypeID == ID_COFFImportFile;
+ }
+
bool isIR() const {
return TypeID == ID_IR;
}
OwningBinary();
OwningBinary(std::unique_ptr<T> Bin, std::unique_ptr<MemoryBuffer> Buf);
OwningBinary(OwningBinary<T>&& Other);
+ OwningBinary<T> &operator=(OwningBinary<T> &&Other);
- std::unique_ptr<T> &getBinary();
- std::unique_ptr<MemoryBuffer> &getBuffer();
+ std::pair<std::unique_ptr<T>, std::unique_ptr<MemoryBuffer>> takeBinary();
+
+ T* getBinary();
+ const T* getBinary() const;
};
template <typename T>
OwningBinary<T>::OwningBinary(OwningBinary &&Other)
: Bin(std::move(Other.Bin)), Buf(std::move(Other.Buf)) {}
-template <typename T> std::unique_ptr<T> &OwningBinary<T>::getBinary() {
- return Bin;
+template <typename T>
+OwningBinary<T> &OwningBinary<T>::operator=(OwningBinary &&Other) {
+ Bin = std::move(Other.Bin);
+ Buf = std::move(Other.Buf);
+ return *this;
}
template <typename T>
-std::unique_ptr<MemoryBuffer> &OwningBinary<T>::getBuffer() {
- return Buf;
+std::pair<std::unique_ptr<T>, std::unique_ptr<MemoryBuffer>>
+OwningBinary<T>::takeBinary() {
+ return std::make_pair(std::move(Bin), std::move(Buf));
+}
+
+template <typename T> T* OwningBinary<T>::getBinary() {
+ return Bin.get();
+}
+
+template <typename T> const T* OwningBinary<T>::getBinary() const {
+ return Bin.get();
}
ErrorOr<OwningBinary<Binary>> createBinary(StringRef Path);