Pass a unique_ptr<MemoryBuffer> to the constructors in the Binary hierarchy.

Once the objects are constructed, they own the buffer. Passing a unique_ptr
makes that clear.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211595 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-06-24 13:56:32 +00:00
parent d3aaad2d26
commit 0d50598d71
21 changed files with 104 additions and 88 deletions

View File

@ -17,14 +17,15 @@
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
#include "llvm/Object/IRObjectFile.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
using namespace object;
IRObjectFile::IRObjectFile(MemoryBuffer *Object, std::error_code &EC,
LLVMContext &Context)
: SymbolicFile(Binary::ID_IR, Object) {
ErrorOr<Module *> MOrErr = getLazyBitcodeModule(Object, Context);
IRObjectFile::IRObjectFile(std::unique_ptr<MemoryBuffer> Object,
std::error_code &EC, LLVMContext &Context)
: SymbolicFile(Binary::ID_IR, std::move(Object)) {
ErrorOr<Module *> MOrErr = getLazyBitcodeModule(Data.get(), Context);
if ((EC = MOrErr.getError()))
return;
@ -153,11 +154,11 @@ basic_symbol_iterator IRObjectFile::symbol_end_impl() const {
return basic_symbol_iterator(BasicSymbolRef(Ret, this));
}
ErrorOr<SymbolicFile *>
llvm::object::SymbolicFile::createIRObjectFile(MemoryBuffer *Object,
LLVMContext &Context) {
ErrorOr<SymbolicFile *> llvm::object::SymbolicFile::createIRObjectFile(
std::unique_ptr<MemoryBuffer> Object, LLVMContext &Context) {
std::error_code EC;
std::unique_ptr<IRObjectFile> Ret(new IRObjectFile(Object, EC, Context));
std::unique_ptr<IRObjectFile> Ret(
new IRObjectFile(std::move(Object), EC, Context));
if (EC)
return EC;
return Ret.release();