llvm-project/llvm/lib/Object
Kevin Enderby e3bf4fd546 This removes the eating of the error in Archive::Child::getSize() when the characters
in the size field in the archive header for the member is not a number.  To do this we
have all of the needed methods return ErrorOr to push them up until we get out of lib.
Then the tools and can handle the error in whatever way is appropriate for that tool.

So the solution is to plumb all the ErrorOr stuff through everything that touches archives.
This include its iterators as one can create an Archive object but the first or any other
Child object may fail to be created due to a bad size field in its header.

Thanks to Lang Hames on the changes making child_iterator contain an
ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add
operator overloading for * and -> .

We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash”
and using report_fatal_error() to move the error checking will cause the program to
stop, neither of which are really correct in library code. There are still some uses of
these that should be cleaned up in this library code for other than the size field.

Also corrected the code where the size gets us to the “at the end of the archive”
which is OK but past the end of the archive will return object_error::parse_failed now.

The test cases use archives with text files so one can see the non-digit character,
in this case a ‘%’, in the size field.

llvm-svn: 250906
2015-10-21 16:59:24 +00:00
..
Archive.cpp This removes the eating of the error in Archive::Child::getSize() when the characters 2015-10-21 16:59:24 +00:00
ArchiveWriter.cpp This removes the eating of the error in Archive::Child::getSize() when the characters 2015-10-21 16:59:24 +00:00
Binary.cpp Object: Handle Mach-O kext bundle files 2015-02-25 22:59:20 +00:00
CMakeLists.txt Support for function summary index bitcode sections and files. 2015-10-04 14:33:43 +00:00
COFFObjectFile.cpp Address review comments, remove error case and return 0 instead as required by tests 2015-10-09 00:15:08 +00:00
COFFYAML.cpp [COFF] Add IMAGE_SCN_TYPE_NOLOAD to SectionCharacteristics 2015-07-30 16:47:56 +00:00
ELF.cpp Remove duplication of relocation names in lib/Object/ELF.cpp 2014-11-21 20:16:07 +00:00
ELFObjectFile.cpp [Object, ELF] Don't assert on invalid magic in createELFObjectFile. 2015-06-04 23:14:43 +00:00
ELFYAML.cpp ELFYAML: Enable parsing of EM_AMDGPU 2015-07-31 01:15:15 +00:00
Error.cpp Add dynamic_table iterators back to ELF.h. 2015-08-07 15:25:20 +00:00
FunctionIndexObjectFile.cpp Support for function summary index bitcode sections and files. 2015-10-04 14:33:43 +00:00
IRObjectFile.cpp Simplify the Mangler interface now that DataLayout is mandatory. 2015-06-23 13:59:29 +00:00
LLVMBuild.txt Object/LLVMBuild.txt: Sort required_libraries by alphabetical order. 2014-07-14 02:52:08 +00:00
MachOObjectFile.cpp Fix a bug in llvm-objdump’s printing of Objective-C meta data 2015-10-08 22:50:55 +00:00
MachOUniversal.cpp Use early return NFC. 2015-08-03 00:10:33 +00:00
Makefile
Object.cpp Convert getSymbolSection to return an ErrorOr. 2015-08-07 23:27:14 +00:00
ObjectFile.cpp Convert getSymbolSection to return an ErrorOr. 2015-08-07 23:27:14 +00:00
RecordStreamer.cpp Move alignment from MCSectionData to MCSection. 2015-05-21 19:20:38 +00:00
RecordStreamer.h Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC) 2015-06-23 09:49:53 +00:00
SymbolSize.cpp [SymbolSize] Skip sorting by index, just assign by index. 2015-06-29 16:05:00 +00:00
SymbolicFile.cpp Re-apply r246276 - Object: Teach llvm-ar to create symbol table for COFF short import files 2015-08-28 07:40:30 +00:00