llvm-project/llvm/lib
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
..
Analysis [AA] Enhance the new AliasAnalysis infrastructure with an optional 2015-10-21 12:15:19 +00:00
AsmParser AsmParser: Remove implicit ilist iterator conversions, NFC 2015-10-20 01:12:49 +00:00
Bitcode Pass FunctionInfoIndex by reference to WriteFunctionSummaryToFile (NFC) 2015-10-19 19:06:06 +00:00
CodeGen Masked Load/Store optimization for scalar code 2015-10-21 11:50:54 +00:00
DebugInfo [llvm-symbolizer] Make --relative-address work with DWARF contexts 2015-10-09 00:15:01 +00:00
ExecutionEngine This removes the eating of the error in Archive::Child::getSize() when the characters 2015-10-21 16:59:24 +00:00
Fuzzer Make a bunch of static arrays const. 2015-10-18 05:15:34 +00:00
IR Make a bunch of static arrays const. 2015-10-18 05:15:34 +00:00
IRReader Return a unique_ptr from getLazyBitcodeModule and parseBitcodeFile. NFC. 2015-06-16 22:27:55 +00:00
LTO Reapply "LTO: Disable extra verify runs in release builds" 2015-09-15 23:05:59 +00:00
LibDriver [Option] Use an ArrayRef to store the Option Infos in OptTable. NFC 2015-10-21 16:30:42 +00:00
LineEditor Use ADDITIONAL_HEADER_DIRS in all LLVM CMake projects. 2015-02-11 03:28:02 +00:00
Linker Linker: Remove implicit ilist iterator conversion, NFC 2015-10-19 22:23:36 +00:00
MC Use std::begin/end and std::is_sorted to simplify some code. NFC 2015-10-17 16:37:11 +00:00
Object This removes the eating of the error in Archive::Child::getSize() when the characters 2015-10-21 16:59:24 +00:00
Option [Option] Use an ArrayRef to store the Option Infos in OptTable. NFC 2015-10-21 16:30:42 +00:00
Passes [PM] Port SROA to the new pass manager. 2015-09-12 09:09:14 +00:00
ProfileData Tolerate negative offset when matching sample profile. 2015-10-21 01:22:27 +00:00
Support Use array_lengthof. NFC 2015-10-18 05:15:38 +00:00
TableGen TableGen: Support folding casts from bits to int 2015-07-31 01:12:06 +00:00
Target [mips][mips16] Re-work the inline assembly stubs to work with IAS. NFC. 2015-10-21 12:44:14 +00:00
Transforms Tolerate negative offset when matching sample profile. 2015-10-21 01:22:27 +00:00
CMakeLists.txt LibDriver, llvm-lib: introduce. 2015-06-09 21:50:22 +00:00
LLVMBuild.txt Wrap some long lines in LLVMBuild files. NFC 2015-06-12 18:44:57 +00:00
Makefile LibDriver, llvm-lib: introduce. 2015-06-09 21:50:22 +00:00