1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00
llvm-mirror/lib/Object
Serge Pavlov 5202bf068f Report fatal error in the case of out of memory
This is the second part of recommit of r325224. The previous part was
committed in r325426, which deals with C++ memory allocation. Solution
for C memory allocation involved functions `llvm::malloc` and similar.
This was a fragile solution because it caused ambiguity errors in some
cases. In this commit the new functions have names like `llvm::safe_malloc`.

The relevant part of original comment is below, updated for new function
names.

Analysis of fails in the case of out of memory errors can be tricky on
Windows. Such error emerges at the point where memory allocation function
fails, but manifests itself when null pointer is used. These two points
may be distant from each other. Besides, next runs may not exhibit
allocation error.

In some cases memory is allocated by a call to some of C allocation
functions, malloc, calloc and realloc. They are used for interoperability
with C code, when allocated object has variable size and when it is
necessary to avoid call of constructors. In many calls the result is not
checked for null pointer. To simplify checks, new functions are defined
in the namespace 'llvm': `safe_malloc`, `safe_calloc` and `safe_realloc`.
They behave as corresponding standard functions but produce fatal error if
allocation fails. This change replaces the standard functions like 'malloc'
in the cases when the result of the allocation function is not checked
for null pointer.

Finally, there are plain C code, that uses malloc and similar functions. If
the result is not checked, assert statement is added.

Differential Revision: https://reviews.llvm.org/D43010

llvm-svn: 325551
2018-02-20 05:41:26 +00:00
..
Archive.cpp Make 32-bit member offset in Archive::Symbol::getMember 64-bit 2017-10-27 21:47:38 +00:00
ArchiveWriter.cpp Add flag to ArchiveWriter to test GNU64 format more efficiently 2017-12-01 00:54:28 +00:00
Binary.cpp Move Object format code to lib/BinaryFormat. 2017-06-07 03:48:56 +00:00
CMakeLists.txt Bitcode: Write the irsymtab to disk. 2017-06-27 23:50:11 +00:00
COFFImportFile.cpp [COFF] Keep the underscore on exported decorated stdcall functions in MSVC mode 2018-01-20 11:44:32 +00:00
COFFModuleDefinition.cpp [COFF] Ignore semicolons in module definition identifiers 2017-12-06 19:18:24 +00:00
COFFObjectFile.cpp Fix many -Wsign-compare and -Wtautological-constant-compare warnings. 2017-12-14 22:07:03 +00:00
Decompressor.cpp Revert "[Decompression] Fail gracefully when out of memory" 2017-09-05 22:04:00 +00:00
ELF.cpp CodeGen: support an extension to pass linker options on ELF 2018-01-30 16:29:29 +00:00
ELFObjectFile.cpp [RISCV] Add ELFObjectFileBase::getRISCVFeatures let llvm-objdump could get RISCV target feature 2018-02-02 06:01:02 +00:00
Error.cpp Revert "[ADT] Make Twine's copy constructor private." 2017-10-11 23:54:34 +00:00
IRObjectFile.cpp Remove redundant includes from lib/Object. 2017-12-13 21:30:55 +00:00
IRSymtab.cpp Object: Improve COFF irsymtab comdat representation. 2017-11-21 22:06:20 +00:00
LLVMBuild.txt Move Object format code to lib/BinaryFormat. 2017-06-07 03:48:56 +00:00
MachOObjectFile.cpp Do not look up symbol names when n_strx == 0 2018-01-03 23:28:32 +00:00
MachOUniversal.cpp Fix a bugs with using some Mach-O command line flags like "-arch armv7m". 2016-12-16 22:54:02 +00:00
ModuleSymbolTable.cpp Don't pass the code model to MC 2017-08-02 20:32:26 +00:00
Object.cpp Report fatal error in the case of out of memory 2018-02-20 05:41:26 +00:00
ObjectFile.cpp Convert two uses of ErrorOr to Expected. 2017-10-10 20:00:07 +00:00
RecordStreamer.cpp [Object] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-04-24 23:21:38 +00:00
RecordStreamer.h [Object] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-04-24 23:21:38 +00:00
SymbolicFile.cpp Convert the last uses of ErrorOr in include/llvm/Object. 2017-10-11 18:07:18 +00:00
SymbolSize.cpp Fix llvm-symbolizer to correctly sort a symbol array and calculate symbol sizes 2016-11-15 21:07:03 +00:00
WasmObjectFile.cpp [WebAssebmly] Report undefined symbols correctly in objdump 2018-02-09 20:21:50 +00:00
WindowsResource.cpp [Support] Add WritableMemoryBuffer::getNewMemBuffer 2018-01-09 17:26:06 +00:00