From 3eab4819f25afad53060e8d5bb97c7eab46bb586 Mon Sep 17 00:00:00 2001 From: Denis Bakhvalov Date: Wed, 17 Jul 2019 23:28:39 +0000 Subject: [llvm-bcanalyzer] Fixed error 'Expected must be checked before access or destruction' After rL365286 I had failing test: LLVM :: tools/gold/X86/v1.12/thinlto_emit_linked_objects.ll It was failing with the output: $ llvm-bcanalyzer --dump llvm/test/tools/gold/X86/v1.12/Output/thinlto_emit_linked_objects.ll.tmp3.o.thinlto.bc Expected must be checked before access or destruction. Unchecked Expected contained error: Unexpected end of file reading 0 of 0 bytesStack dump: Change-Id: I07e03262074ea5e0aae7a8d787d5487c87f914a2 llvm-svn: 366387 --- llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp b/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp index 8794050..9c30d56 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp @@ -539,8 +539,11 @@ BitcodeAnalyzer::BitcodeAnalyzer(StringRef Buffer, Error BitcodeAnalyzer::analyze(Optional O, Optional CheckHash) { - if (Expected H = analyzeHeader(O, Stream)) - CurStreamType = *H; + Expected MaybeType = analyzeHeader(O, Stream); + if (!MaybeType) + return MaybeType.takeError(); + else + CurStreamType = *MaybeType; Stream.setBlockInfo(&BlockInfo); -- cgit v1.1