diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-01-15 01:08:23 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-01-15 01:08:23 +0000 |
commit | 8f31e213e425a3cab12b37941b5102533fc8ddbe (patch) | |
tree | e9afe480a039ae71d0008222c11367067a1d35eb /llvm/lib/IRReader | |
parent | bae1bcb6bf47c6227aaae4758ff91c52f8fc4e9b (diff) | |
download | llvm-8f31e213e425a3cab12b37941b5102533fc8ddbe.zip llvm-8f31e213e425a3cab12b37941b5102533fc8ddbe.tar.gz llvm-8f31e213e425a3cab12b37941b5102533fc8ddbe.tar.bz2 |
Make parseBitcodeFile return an ErrorOr<Module *>.
llvm-svn: 199279
Diffstat (limited to 'llvm/lib/IRReader')
-rw-r--r-- | llvm/lib/IRReader/IRReader.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/IRReader/IRReader.cpp b/llvm/lib/IRReader/IRReader.cpp index 7356fd0..70801c4 100644 --- a/llvm/lib/IRReader/IRReader.cpp +++ b/llvm/lib/IRReader/IRReader.cpp @@ -69,12 +69,14 @@ Module *llvm::ParseIR(MemoryBuffer *Buffer, SMDiagnostic &Err, TimePassesIsEnabled); if (isBitcode((const unsigned char *)Buffer->getBufferStart(), (const unsigned char *)Buffer->getBufferEnd())) { - std::string ErrMsg; - Module *M = ParseBitcodeFile(Buffer, Context, &ErrMsg); - if (M == 0) + ErrorOr<Module *> ModuleOrErr = parseBitcodeFile(Buffer, Context); + Module *M = 0; + if (error_code EC = ModuleOrErr.getError()) Err = SMDiagnostic(Buffer->getBufferIdentifier(), SourceMgr::DK_Error, - ErrMsg); - // ParseBitcodeFile does not take ownership of the Buffer. + EC.message()); + else + M = ModuleOrErr.get(); + // parseBitcodeFile does not take ownership of the Buffer. delete Buffer; return M; } |