Skip to content

Commit 3eab481

Browse files
[llvm-bcanalyzer] Fixed error 'Expected<T> 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<T> must be checked before access or destruction. Unchecked Expected<T> contained error: Unexpected end of file reading 0 of 0 bytesStack dump: Change-Id: I07e03262074ea5e0aae7a8d787d5487c87f914a2 llvm-svn: 366387
1 parent 7bb5fc0 commit 3eab481

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,11 @@ BitcodeAnalyzer::BitcodeAnalyzer(StringRef Buffer,
539539

540540
Error BitcodeAnalyzer::analyze(Optional<BCDumpOptions> O,
541541
Optional<StringRef> CheckHash) {
542-
if (Expected<CurStreamTypeType> H = analyzeHeader(O, Stream))
543-
CurStreamType = *H;
542+
Expected<CurStreamTypeType> MaybeType = analyzeHeader(O, Stream);
543+
if (!MaybeType)
544+
return MaybeType.takeError();
545+
else
546+
CurStreamType = *MaybeType;
544547

545548
Stream.setBlockInfo(&BlockInfo);
546549

0 commit comments

Comments
 (0)