diff options
Diffstat (limited to 'contrib/llvm/lib/IRReader/IRReader.cpp')
-rw-r--r-- | contrib/llvm/lib/IRReader/IRReader.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/contrib/llvm/lib/IRReader/IRReader.cpp b/contrib/llvm/lib/IRReader/IRReader.cpp index 9b243fc..ba587ce 100644 --- a/contrib/llvm/lib/IRReader/IRReader.cpp +++ b/contrib/llvm/lib/IRReader/IRReader.cpp @@ -11,7 +11,7 @@ #include "llvm-c/Core.h" #include "llvm-c/IRReader.h" #include "llvm/AsmParser/Parser.h" -#include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/Bitcode/BitcodeReader.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/Support/MemoryBuffer.h" @@ -26,19 +26,23 @@ namespace llvm { extern bool TimePassesIsEnabled; } -static const char *const TimeIRParsingGroupName = "LLVM IR Parsing"; -static const char *const TimeIRParsingName = "Parse IR"; +static const char *const TimeIRParsingGroupName = "irparse"; +static const char *const TimeIRParsingGroupDescription = "LLVM IR Parsing"; +static const char *const TimeIRParsingName = "parse"; +static const char *const TimeIRParsingDescription = "Parse IR"; static std::unique_ptr<Module> getLazyIRModule(std::unique_ptr<MemoryBuffer> Buffer, SMDiagnostic &Err, LLVMContext &Context, bool ShouldLazyLoadMetadata) { if (isBitcode((const unsigned char *)Buffer->getBufferStart(), (const unsigned char *)Buffer->getBufferEnd())) { - ErrorOr<std::unique_ptr<Module>> ModuleOrErr = getLazyBitcodeModule( + Expected<std::unique_ptr<Module>> ModuleOrErr = getOwningLazyBitcodeModule( std::move(Buffer), Context, ShouldLazyLoadMetadata); - if (std::error_code EC = ModuleOrErr.getError()) { - Err = SMDiagnostic(Buffer->getBufferIdentifier(), SourceMgr::DK_Error, - EC.message()); + if (Error E = ModuleOrErr.takeError()) { + handleAllErrors(std::move(E), [&](ErrorInfoBase &EIB) { + Err = SMDiagnostic(Buffer->getBufferIdentifier(), SourceMgr::DK_Error, + EIB.message()); + }); return nullptr; } return std::move(ModuleOrErr.get()); @@ -65,15 +69,18 @@ std::unique_ptr<Module> llvm::getLazyIRFileModule(StringRef Filename, std::unique_ptr<Module> llvm::parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err, LLVMContext &Context) { - NamedRegionTimer T(TimeIRParsingName, TimeIRParsingGroupName, + NamedRegionTimer T(TimeIRParsingName, TimeIRParsingDescription, + TimeIRParsingGroupName, TimeIRParsingGroupDescription, TimePassesIsEnabled); if (isBitcode((const unsigned char *)Buffer.getBufferStart(), (const unsigned char *)Buffer.getBufferEnd())) { - ErrorOr<std::unique_ptr<Module>> ModuleOrErr = + Expected<std::unique_ptr<Module>> ModuleOrErr = parseBitcodeFile(Buffer, Context); - if (std::error_code EC = ModuleOrErr.getError()) { - Err = SMDiagnostic(Buffer.getBufferIdentifier(), SourceMgr::DK_Error, - EC.message()); + if (Error E = ModuleOrErr.takeError()) { + handleAllErrors(std::move(E), [&](ErrorInfoBase &EIB) { + Err = SMDiagnostic(Buffer.getBufferIdentifier(), SourceMgr::DK_Error, + EIB.message()); + }); return nullptr; } return std::move(ModuleOrErr.get()); |