[PATCH] D64887: [llvm-bcanalyzer] Fixed error 'Expected<T> must be checked before access or destruction'

Denis Bakhvalov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 17 14:41:56 PDT 2019


dendibakh created this revision.
dendibakh added a reviewer: thegameg.
Herald added subscribers: llvm-commits, dkrupp, donat.nagy, Szelethus, dexonsmith, a.sidorin, baloghadamsoftware, hiraditya, mehdi_amini.
Herald added a project: LLVM.

After rL365286 <https://reviews.llvm.org/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:


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64887

Files:
  llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp


Index: llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
===================================================================
--- llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
+++ llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
@@ -539,8 +539,11 @@
 
 Error BitcodeAnalyzer::analyze(Optional<BCDumpOptions> O,
                                Optional<StringRef> CheckHash) {
-  if (Expected<CurStreamTypeType> H = analyzeHeader(O, Stream))
-    CurStreamType = *H;
+  Expected<CurStreamTypeType> MaybeType = analyzeHeader(O, Stream);
+  if (!MaybeType)
+    return MaybeType.takeError();
+  else
+    CurStreamType = *MaybeType;
 
   Stream.setBlockInfo(&BlockInfo);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64887.210425.patch
Type: text/x-patch
Size: 656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190717/4687d240/attachment.bin>


More information about the llvm-commits mailing list