llvm.org GIT mirror llvm / 6d66a1c
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217049 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 5 years ago
7 changed file(s) with 15 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
2727 class raw_ostream;
2828
2929 /// Read the header of the specified bitcode buffer and prepare for lazy
30 /// deserialization of function bodies. If successful, this takes ownership
31 /// of 'buffer. On error, this *does not* take ownership of Buffer.
32 ErrorOr getLazyBitcodeModule(std::unique_ptr &Buffer,
30 /// deserialization of function bodies. If successful, this moves Buffer. On
31 /// error, this *does not* move Buffer.
32 ErrorOr getLazyBitcodeModule(std::unique_ptr &&Buffer,
3333 LLVMContext &Context);
3434
3535 /// getStreamedBitcodeModule - Read the header of the specified stream
5353 std::unique_ptr Owner(unwrap(MemBuf));
5454
5555 ErrorOr ModuleOrErr =
56 getLazyBitcodeModule(Owner, *unwrap(ContextRef));
56 getLazyBitcodeModule(std::move(Owner), *unwrap(ContextRef));
5757 Owner.release();
5858
5959 if (std::error_code EC = ModuleOrErr.getError()) {
35193519 /// \param[in] WillMaterializeAll Set to \c true if the caller promises to
35203520 /// materialize everything -- in particular, if this isn't truly lazy.
35213521 static ErrorOr
3522 getLazyBitcodeModuleImpl(std::unique_ptr &Buffer,
3522 getLazyBitcodeModuleImpl(std::unique_ptr &&Buffer,
35233523 LLVMContext &Context, bool WillMaterializeAll) {
35243524 Module *M = new Module(Buffer->getBufferIdentifier(), Context);
35253525 BitcodeReader *R = new BitcodeReader(Buffer.get(), Context);
35443544 }
35453545
35463546 ErrorOr
3547 llvm::getLazyBitcodeModule(std::unique_ptr &Buffer,
3547 llvm::getLazyBitcodeModule(std::unique_ptr &&Buffer,
35483548 LLVMContext &Context) {
3549 return getLazyBitcodeModuleImpl(Buffer, Context, false);
3549 return getLazyBitcodeModuleImpl(std::move(Buffer), Context, false);
35503550 }
35513551
35523552 Module *llvm::getStreamedBitcodeModule(const std::string &name,
35683568 ErrorOr llvm::parseBitcodeFile(MemoryBufferRef Buffer,
35693569 LLVMContext &Context) {
35703570 std::unique_ptr Buf = MemoryBuffer::getMemBuffer(Buffer, false);
3571 ErrorOr ModuleOrErr = getLazyBitcodeModuleImpl(Buf, Context, true);
3571 ErrorOr ModuleOrErr =
3572 getLazyBitcodeModuleImpl(std::move(Buf), Context, true);
35723573 if (!ModuleOrErr)
35733574 return ModuleOrErr;
35743575 Module *M = ModuleOrErr.get();
3434 if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
3535 (const unsigned char *)Buffer->getBufferEnd())) {
3636 std::string ErrMsg;
37 ErrorOr ModuleOrErr = getLazyBitcodeModule(Buffer, Context);
37 ErrorOr ModuleOrErr =
38 getLazyBitcodeModule(std::move(Buffer), Context);
3839 if (std::error_code EC = ModuleOrErr.getError()) {
3940 Err = SMDiagnostic(Buffer->getBufferIdentifier(), SourceMgr::DK_Error,
4041 EC.message());
269269
270270 std::unique_ptr Buff(MemoryBuffer::getMemBuffer(Object, false));
271271
272 ErrorOr MOrErr = getLazyBitcodeModule(Buff, Context);
272 ErrorOr MOrErr = getLazyBitcodeModule(std::move(Buff), Context);
273273 if (std::error_code EC = MOrErr.getError())
274274 return EC;
275275
551551 if (release_input_file(F.handle) != LDPS_OK)
552552 message(LDPL_FATAL, "Failed to release file information");
553553
554 ErrorOr MOrErr = getLazyBitcodeModule(Buffer, Context);
554 ErrorOr MOrErr = getLazyBitcodeModule(std::move(Buffer), Context);
555555
556556 if (std::error_code EC = MOrErr.getError())
557557 message(LDPL_FATAL, "Could not read bitcode from file : %s",
5252 writeModuleToBuffer(parseAssembly(Assembly), Mem);
5353 std::unique_ptr Buffer =
5454 MemoryBuffer::getMemBuffer(Mem.str(), "test", false);
55 ErrorOr ModuleOrErr = getLazyBitcodeModule(Buffer, Context);
55 ErrorOr ModuleOrErr =
56 getLazyBitcodeModule(std::move(Buffer), Context);
5657 return std::unique_ptr(ModuleOrErr.get());
5758 }
5859