Bitcode: Change module reader functions to return an llvm::Expected.
Differential Revision: https://reviews.llvm.org/D26562
llvm-svn: 286752
diff --git a/llvm/lib/LTO/LTOModule.cpp b/llvm/lib/LTO/LTOModule.cpp
index ef1c93a..876b43d 100644
--- a/llvm/lib/LTO/LTOModule.cpp
+++ b/llvm/lib/LTO/LTOModule.cpp
@@ -184,18 +184,14 @@
if (!ShouldBeLazy) {
// Parse the full file.
- ErrorOr<std::unique_ptr<Module>> M = parseBitcodeFile(*MBOrErr, Context);
- if (std::error_code EC = M.getError())
- return EC;
- return std::move(*M);
+ return expectedToErrorOrAndEmitErrors(Context,
+ parseBitcodeFile(*MBOrErr, Context));
}
// Parse lazily.
- ErrorOr<std::unique_ptr<Module>> M =
- getLazyBitcodeModule(*MBOrErr, Context, true /*ShouldLazyLoadMetadata*/);
- if (std::error_code EC = M.getError())
- return EC;
- return std::move(*M);
+ return expectedToErrorOrAndEmitErrors(
+ Context,
+ getLazyBitcodeModule(*MBOrErr, Context, true /*ShouldLazyLoadMetadata*/));
}
ErrorOr<std::unique_ptr<LTOModule>>