[llvm-objdump][MachO] Correctly handle the llvm::Error when -dsym has errors
In an assert build, the Error gets destroyed and we get "Program aborted
due to an unhandled Error:".
In release, we get an empty message.
llvm-svn: 350848
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index 142ad8f..4198ff0 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -6977,8 +6977,9 @@
Expected<std::unique_ptr<MachOObjectFile>> DbgObjCheck =
ObjectFile::createMachOObjectFile(BufOrErr.get()->getMemBufferRef());
- if (DbgObjCheck.takeError())
- report_error(MachOOF->getFileName(), DbgObjCheck.takeError());
+ if (Error E = DbgObjCheck.takeError())
+ report_error(MachOOF->getFileName(), std::move(E));
+
DbgObj = DbgObjCheck.get().release();
// We need to keep the file alive, because we're replacing DbgObj with it.
DSYMBuf = std::move(BufOrErr.get());