Thread Expected<...> up from libObject’s getType() for symbols to allow llvm-objdump...
authorKevin Enderby <enderby@apple.com>
Mon, 2 May 2016 20:28:12 +0000 (20:28 +0000)
committerKevin Enderby <enderby@apple.com>
Mon, 2 May 2016 20:28:12 +0000 (20:28 +0000)
commit7bd8d994978d6404a79b28e04a802d070c45ba16
treeb827e6424c503f1ec157ad5dd700b9a0fee9bc06
parent34c549ea02081e48946750adbc928ae57ff67bd9
Thread Expected<...> up from libObject’s getType() for symbols to allow llvm-objdump to produce a good error message.

Produce another specific error message for a malformed Mach-O file when a symbol’s
section index is more than the number of sections.  The existing test case in test/Object/macho-invalid.test
for macho-invalid-section-index-getSectionRawName now reports the error with the message indicating
that a symbol at a specific index has a bad section index and that bad section index value.

Again converting interfaces to Expected<> from ErrorOr<> does involve
touching a number of places. Where the existing code reported the error with a
string message or an error code it was converted to do the same.

Also there some were bugs in the existing code that did not deal with the
old ErrorOr<> return values.  So now with Expected<> since they must be
checked and the error handled, I added a TODO and a comment:
"// TODO: Actually report errors helpfully" and a call something like
consumeError(NameOrErr.takeError()) so the buggy code will not crash
since needed to deal with the Error.

llvm-svn: 268298
26 files changed:
llvm/include/llvm/Object/COFF.h
llvm/include/llvm/Object/ELFObjectFile.h
llvm/include/llvm/Object/MachO.h
llvm/include/llvm/Object/ObjectFile.h
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
llvm/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp
llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h
llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
llvm/lib/Object/COFFObjectFile.cpp
llvm/lib/Object/MachOObjectFile.cpp
llvm/lib/Object/Object.cpp
llvm/lib/Object/ObjectFile.cpp
llvm/test/Object/macho-invalid.test
llvm/tools/dsymutil/MachODebugMapParser.cpp
llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp
llvm/tools/llvm-nm/llvm-nm.cpp
llvm/tools/llvm-objdump/COFFDump.cpp
llvm/tools/llvm-objdump/MachODump.cpp
llvm/tools/llvm-objdump/llvm-objdump.cpp
llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
llvm/tools/llvm-readobj/MachODumper.cpp
llvm/tools/llvm-readobj/Win64EHDumper.cpp
llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp