summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/MacroArgs.cpp
diff options
context:
space:
mode:
authorSerge Pavlov <sepavloff@gmail.com>2018-02-21 02:02:39 +0000
committerSerge Pavlov <sepavloff@gmail.com>2018-02-21 02:02:39 +0000
commit52525730a163c56f82a43584faa8acb8fd45e1da (patch)
treebd0bbd8442cdba5a7fd40b2555bfa0a7ac1e02ff /clang/lib/Lex/MacroArgs.cpp
parent56492f9177e57b383d54366f93d77595ee80fd78 (diff)
downloadbcm5719-llvm-52525730a163c56f82a43584faa8acb8fd45e1da.tar.gz
bcm5719-llvm-52525730a163c56f82a43584faa8acb8fd45e1da.zip
Clean up use of C allocation functions
If the value returned by `malloc`, `calloc` or `realloc` is not checked for null pointer, this change replaces them for `safe_malloc`, `safe_calloc` or `safe_realloc`, which are defined in the namespace `llvm`. These function report fatal error on out of memory. In the plain C files, assertion statements are added to ensure that memory is successfully allocated. The aim of this change is to get better diagnostics of OOM on Windows. Differential Revision: https://reviews.llvm.org/D43017 llvm-svn: 325661
Diffstat (limited to 'clang/lib/Lex/MacroArgs.cpp')
-rw-r--r--clang/lib/Lex/MacroArgs.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Lex/MacroArgs.cpp b/clang/lib/Lex/MacroArgs.cpp
index 5c0f0623c3e..df3f8a4877a 100644
--- a/clang/lib/Lex/MacroArgs.cpp
+++ b/clang/lib/Lex/MacroArgs.cpp
@@ -49,7 +49,8 @@ MacroArgs *MacroArgs::create(const MacroInfo *MI,
if (!ResultEnt) {
// Allocate memory for a MacroArgs object with the lexer tokens at the end,
// and construct the MacroArgs object.
- Result = new (std::malloc(totalSizeToAlloc<Token>(UnexpArgTokens.size())))
+ Result = new (
+ llvm::safe_malloc(totalSizeToAlloc<Token>(UnexpArgTokens.size())))
MacroArgs(UnexpArgTokens.size(), VarargsElided, MI->getNumParams());
} else {
Result = *ResultEnt;
OpenPOWER on IntegriCloud