1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

Pass a && to getLazyBitcodeModule.

This forces callers to use std::move when calling it. It is somewhat odd to have
code with std::move that doesn't always move, but it is also odd to have code
without std::move that sometimes moves.

llvm-svn: 217049
This commit is contained in:
Rafael Espindola 2014-09-03 17:31:46 +00:00
parent c2ca095c4d
commit cbfc7723a8
7 changed files with 15 additions and 12 deletions

View File

@ -28,9 +28,9 @@ namespace llvm {
class raw_ostream;
/// Read the header of the specified bitcode buffer and prepare for lazy
/// deserialization of function bodies. If successful, this takes ownership
/// of 'buffer. On error, this *does not* take ownership of Buffer.
ErrorOr<Module *> getLazyBitcodeModule(std::unique_ptr<MemoryBuffer> &Buffer,
/// deserialization of function bodies. If successful, this moves Buffer. On
/// error, this *does not* move Buffer.
ErrorOr<Module *> getLazyBitcodeModule(std::unique_ptr<MemoryBuffer> &&Buffer,
LLVMContext &Context);
/// getStreamedBitcodeModule - Read the header of the specified stream

View File

@ -54,7 +54,7 @@ LLVMBool LLVMGetBitcodeModuleInContext(LLVMContextRef ContextRef,
std::unique_ptr<MemoryBuffer> Owner(unwrap(MemBuf));
ErrorOr<Module *> ModuleOrErr =
getLazyBitcodeModule(Owner, *unwrap(ContextRef));
getLazyBitcodeModule(std::move(Owner), *unwrap(ContextRef));
Owner.release();
if (std::error_code EC = ModuleOrErr.getError()) {

View File

@ -3520,7 +3520,7 @@ const std::error_category &llvm::BitcodeErrorCategory() {
/// \param[in] WillMaterializeAll Set to \c true if the caller promises to
/// materialize everything -- in particular, if this isn't truly lazy.
static ErrorOr<Module *>
getLazyBitcodeModuleImpl(std::unique_ptr<MemoryBuffer> &Buffer,
getLazyBitcodeModuleImpl(std::unique_ptr<MemoryBuffer> &&Buffer,
LLVMContext &Context, bool WillMaterializeAll) {
Module *M = new Module(Buffer->getBufferIdentifier(), Context);
BitcodeReader *R = new BitcodeReader(Buffer.get(), Context);
@ -3545,9 +3545,9 @@ getLazyBitcodeModuleImpl(std::unique_ptr<MemoryBuffer> &Buffer,
}
ErrorOr<Module *>
llvm::getLazyBitcodeModule(std::unique_ptr<MemoryBuffer> &Buffer,
llvm::getLazyBitcodeModule(std::unique_ptr<MemoryBuffer> &&Buffer,
LLVMContext &Context) {
return getLazyBitcodeModuleImpl(Buffer, Context, false);
return getLazyBitcodeModuleImpl(std::move(Buffer), Context, false);
}
Module *llvm::getStreamedBitcodeModule(const std::string &name,
@ -3569,7 +3569,8 @@ Module *llvm::getStreamedBitcodeModule(const std::string &name,
ErrorOr<Module *> llvm::parseBitcodeFile(MemoryBufferRef Buffer,
LLVMContext &Context) {
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Buffer, false);
ErrorOr<Module *> ModuleOrErr = getLazyBitcodeModuleImpl(Buf, Context, true);
ErrorOr<Module *> ModuleOrErr =
getLazyBitcodeModuleImpl(std::move(Buf), Context, true);
if (!ModuleOrErr)
return ModuleOrErr;
Module *M = ModuleOrErr.get();

View File

@ -35,7 +35,8 @@ getLazyIRModule(std::unique_ptr<MemoryBuffer> Buffer, SMDiagnostic &Err,
if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
(const unsigned char *)Buffer->getBufferEnd())) {
std::string ErrMsg;
ErrorOr<Module *> ModuleOrErr = getLazyBitcodeModule(Buffer, Context);
ErrorOr<Module *> ModuleOrErr =
getLazyBitcodeModule(std::move(Buffer), Context);
if (std::error_code EC = ModuleOrErr.getError()) {
Err = SMDiagnostic(Buffer->getBufferIdentifier(), SourceMgr::DK_Error,
EC.message());

View File

@ -270,7 +270,7 @@ llvm::object::IRObjectFile::createIRObjectFile(MemoryBufferRef Object,
std::unique_ptr<MemoryBuffer> Buff(MemoryBuffer::getMemBuffer(Object, false));
ErrorOr<Module *> MOrErr = getLazyBitcodeModule(Buff, Context);
ErrorOr<Module *> MOrErr = getLazyBitcodeModule(std::move(Buff), Context);
if (std::error_code EC = MOrErr.getError())
return EC;

View File

@ -552,7 +552,7 @@ getModuleForFile(LLVMContext &Context, claimed_file &F, raw_fd_ostream *ApiFile,
if (release_input_file(F.handle) != LDPS_OK)
message(LDPL_FATAL, "Failed to release file information");
ErrorOr<Module *> MOrErr = getLazyBitcodeModule(Buffer, Context);
ErrorOr<Module *> MOrErr = getLazyBitcodeModule(std::move(Buffer), Context);
if (std::error_code EC = MOrErr.getError())
message(LDPL_FATAL, "Could not read bitcode from file : %s",

View File

@ -53,7 +53,8 @@ static std::unique_ptr<Module> getLazyModuleFromAssembly(LLVMContext &Context,
writeModuleToBuffer(parseAssembly(Assembly), Mem);
std::unique_ptr<MemoryBuffer> Buffer =
MemoryBuffer::getMemBuffer(Mem.str(), "test", false);
ErrorOr<Module *> ModuleOrErr = getLazyBitcodeModule(Buffer, Context);
ErrorOr<Module *> ModuleOrErr =
getLazyBitcodeModule(std::move(Buffer), Context);
return std::unique_ptr<Module>(ModuleOrErr.get());
}