llvm-project/llvm/test
Kevin Enderby 3fcdf6ae2a Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message
Produce the first specific error message for a malformed Mach-O file describing
the problem instead of the generic message for object_error::parse_failed of
"Invalid data was encountered while parsing the file”.  Many more good error
messages will follow after this first one.

This is built on Lang Hames’ great work of adding the ’Error' class for
structured error handling and threading Error through MachOObjectFile
construction.  And making createMachOObjectFile return Expected<...> .

So to to get the error to the llvm-obdump tool, I changed the stack of
these methods to also return Expected<...> :

  object::ObjectFile::createObjectFile()
  object::SymbolicFile::createSymbolicFile()
  object::createBinary()

Then finally in ParseInputMachO() in MachODump.cpp the error can
be reported and the specific error message can be printed in llvm-objdump
and can be seen in the existing test case for the existing malformed binary
but with the updated error message.

Converting these interfaces to Expected<> from ErrorOr<> does involve
touching a number of places. To contain the changes for now use of
errorToErrorCode() and errorOrToExpected() are used where the callers
are yet to be converted.

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(ObjOrErr.takeError()) so the buggy code will not crash
since needed to deal with the Error.

Note there is one fix also needed to lld/COFF/InputFiles.cpp that goes along
with this that I will commit right after this.  So expect lld not to built
after this commit and before the next one.

llvm-svn: 265606
2016-04-06 22:14:09 +00:00
..
Analysis AMDGPU: Add a shader calling convention 2016-04-06 19:40:20 +00:00
Assembler AsmParser: Don't crash on unresolved !tbaa 2016-04-06 02:06:40 +00:00
Bindings [OCaml] Reinstate data_layout 2016-04-01 07:54:24 +00:00
Bitcode Bitcode: Try to emit metadata in function blocks 2016-04-02 15:22:57 +00:00
BugPoint
CodeGen [PPC] Use VSX/FP Facility integer load when an integer load's only users are conversion to FP 2016-04-06 20:12:29 +00:00
DebugInfo Add missing emissionKind flags to the DICompileUnits of several old testcases. 2016-04-01 22:18:43 +00:00
Examples
ExecutionEngine Disable the new Orc lazy JIT tests on Windows, they do not pass 2016-02-10 18:46:42 +00:00
Feature [NVVM] Remove noduplicate attribute from synchronizing intrinsics. 2016-03-22 22:08:01 +00:00
FileCheck Reapply r262092: [FileCheck] Abort if -NOT is combined with another suffix. 2016-02-29 22:13:03 +00:00
Instrumentation [DebugInfo] Fix tests so that each subprogram belongs to a CU. 2016-04-05 23:37:08 +00:00
Integer
JitListener testcase gardening: update the emissionKind enum to the new syntax. (NFC) 2016-04-01 00:16:49 +00:00
LTO [LoopVectorize] Don't unconditionally print vectorization diagnostics 2016-04-01 00:34:39 +00:00
LibDriver
Linker testcase gardening: update the emissionKind enum to the new syntax. (NFC) 2016-04-01 00:16:49 +00:00
MC [AMDGPU] AsmParser: disable DPP for unsupported instructions. New dpp tests. Fix v_nop_dpp. 2016-04-06 13:29:59 +00:00
Object Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message 2016-04-06 22:14:09 +00:00
Other [CG] Add a new pass manager printer pass for the old call graph and 2016-03-10 11:24:11 +00:00
SymbolRewriter
TableGen [GlobalISel][Target] Add an opcode for unconditional branch. 2016-03-11 17:27:38 +00:00
ThinLTO/X86 ThinLTO: special handling for LinkOnce functions 2016-04-01 21:53:50 +00:00
Transforms [LoopUnroll] Fix the way we update DT after complete unrolling. 2016-04-06 21:47:12 +00:00
Unit [lit] Hack lit to allow a test suite to request that it is run "early". 2016-03-12 03:03:31 +00:00
Verifier [IRVerifier] Don't crash on invalid DIFile inside DISubprogram. 2016-04-06 18:46:39 +00:00
YAMLParser
tools Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message 2016-04-06 22:14:09 +00:00
.clang-format
CMakeLists.txt [CMake] Add convenience target llvm-test-depends to build test dependencies. 2016-03-02 00:27:14 +00:00
TestRunner.sh
lit.cfg test: Always treat .mir files as tests even outside of CodeGen/MIR 2016-04-04 21:23:44 +00:00
lit.site.cfg.in