r286752 - Bitcode: Change module reader functions to return an llvm::Expected.
Peter Collingbourne via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 12 23:00:18 PST 2016
Author: pcc
Date: Sun Nov 13 01:00:17 2016
New Revision: 286752
URL: http://llvm.org/viewvc/llvm-project?rev=286752&view=rev
Log:
Bitcode: Change module reader functions to return an llvm::Expected.
Differential Revision: https://reviews.llvm.org/D26562
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=286752&r1=286751&r2=286752&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Sun Nov 13 01:00:17 2016
@@ -3012,7 +3012,8 @@ void CGOpenMPRuntime::loadOffloadInfoMet
return;
llvm::LLVMContext C;
- auto ME = llvm::parseBitcodeFile(Buf.get()->getMemBufferRef(), C);
+ auto ME = expectedToErrorOrAndEmitErrors(
+ C, llvm::parseBitcodeFile(Buf.get()->getMemBufferRef(), C));
if (ME.getError())
return;
Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=286752&r1=286751&r2=286752&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Sun Nov 13 01:00:17 2016
@@ -771,11 +771,13 @@ CodeGenAction::CreateASTConsumer(Compile
return nullptr;
}
- ErrorOr<std::unique_ptr<llvm::Module>> ModuleOrErr =
+ Expected<std::unique_ptr<llvm::Module>> ModuleOrErr =
getOwningLazyBitcodeModule(std::move(*BCBuf), *VMContext);
- if (std::error_code EC = ModuleOrErr.getError()) {
- CI.getDiagnostics().Report(diag::err_cannot_open_file) << LinkBCFile
- << EC.message();
+ if (!ModuleOrErr) {
+ handleAllErrors(ModuleOrErr.takeError(), [&](ErrorInfoBase &EIB) {
+ CI.getDiagnostics().Report(diag::err_cannot_open_file)
+ << LinkBCFile << EIB.message();
+ });
LinkModules.clear();
return nullptr;
}
More information about the cfe-commits
mailing list