summaryrefslogtreecommitdiff
path: root/lib/LTO/LTOModule.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-06-16 22:27:55 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-06-16 22:27:55 +0000
commit20a6785cd235990cc8cb3e2e402b7f8caca609ec (patch)
tree9bff776d8214ca8703b344cc123cc4daf92afe81 /lib/LTO/LTOModule.cpp
parent3bcfd461f61a6cd5b4088c3be7f5d227973cb108 (diff)
Return a unique_ptr from getLazyBitcodeModule and parseBitcodeFile. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239858 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/LTO/LTOModule.cpp')
-rw-r--r--lib/LTO/LTOModule.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/LTO/LTOModule.cpp b/lib/LTO/LTOModule.cpp
index 0794d3c9ea4..bbb3b6df30c 100644
--- a/lib/LTO/LTOModule.cpp
+++ b/lib/LTO/LTOModule.cpp
@@ -147,9 +147,10 @@ LTOModule *LTOModule::createInContext(const void *mem, size_t length,
return makeLTOModule(Buffer, options, errMsg, Context);
}
-static Module *parseBitcodeFileImpl(MemoryBufferRef Buffer,
- LLVMContext &Context, bool ShouldBeLazy,
- std::string &ErrMsg) {
+static std::unique_ptr<Module> parseBitcodeFileImpl(MemoryBufferRef Buffer,
+ LLVMContext &Context,
+ bool ShouldBeLazy,
+ std::string &ErrMsg) {
// Find the buffer.
ErrorOr<MemoryBufferRef> MBOrErr =
@@ -168,22 +169,22 @@ static Module *parseBitcodeFileImpl(MemoryBufferRef Buffer,
if (!ShouldBeLazy) {
// Parse the full file.
- ErrorOr<Module *> M =
+ ErrorOr<std::unique_ptr<Module>> M =
parseBitcodeFile(*MBOrErr, Context, DiagnosticHandler);
if (!M)
return nullptr;
- return *M;
+ return std::move(*M);
}
// Parse lazily.
std::unique_ptr<MemoryBuffer> LightweightBuf =
MemoryBuffer::getMemBuffer(*MBOrErr, false);
- ErrorOr<Module *> M = getLazyBitcodeModule(std::move(LightweightBuf), Context,
- DiagnosticHandler,
- true/*ShouldLazyLoadMetadata*/);
+ ErrorOr<std::unique_ptr<Module>> M =
+ getLazyBitcodeModule(std::move(LightweightBuf), Context,
+ DiagnosticHandler, true /*ShouldLazyLoadMetadata*/);
if (!M)
return nullptr;
- return *M;
+ return std::move(*M);
}
LTOModule *LTOModule::makeLTOModule(MemoryBufferRef Buffer,
@@ -197,9 +198,9 @@ LTOModule *LTOModule::makeLTOModule(MemoryBufferRef Buffer,
// If we own a context, we know this is being used only for symbol
// extraction, not linking. Be lazy in that case.
- std::unique_ptr<Module> M(parseBitcodeFileImpl(
+ std::unique_ptr<Module> M = parseBitcodeFileImpl(
Buffer, *Context,
- /* ShouldBeLazy */ static_cast<bool>(OwnedContext), errMsg));
+ /* ShouldBeLazy */ static_cast<bool>(OwnedContext), errMsg);
if (!M)
return nullptr;