Update LLVM from stable upstream (#1653)

Replace CheckedMalloc with upstream safe_malloc.
This commit is contained in:
Peter Johnson
2019-04-27 20:33:08 -07:00
committed by GitHub
parent 3cf4f38f5d
commit 2de3bf7f58
59 changed files with 4839 additions and 841 deletions

View File

@@ -15,7 +15,6 @@
#include "wpi/StringExtras.h"
#include "wpi/Compiler.h"
#include "wpi/MathExtras.h"
#include "wpi/memory.h"
#include <cassert>
using namespace wpi;
@@ -59,7 +58,7 @@ void StringMapImpl::init(unsigned InitSize) {
NumTombstones = 0;
TheTable = static_cast<StringMapEntryBase **>(
CheckedCalloc(NewNumBuckets+1,
safe_calloc(NewNumBuckets+1,
sizeof(StringMapEntryBase **) + sizeof(unsigned)));
// Set the member only if TheTable was successfully allocated
@@ -129,7 +128,6 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) {
}
}
/// FindKey - Look up the bucket that contains the specified key. If it exists
/// in the map, return the bucket number of the key. Otherwise return -1.
/// This does not modify the map.
@@ -219,7 +217,7 @@ unsigned StringMapImpl::RehashTable(unsigned BucketNo) {
// Allocate one extra bucket which will always be non-empty. This allows the
// iterators to stop at end.
auto NewTableArray = static_cast<StringMapEntryBase **>(
CheckedCalloc(NewSize+1, sizeof(StringMapEntryBase *) + sizeof(unsigned)));
safe_calloc(NewSize+1, sizeof(StringMapEntryBase *) + sizeof(unsigned)));
unsigned *NewHashArray = (unsigned *)(NewTableArray + NewSize + 1);
NewTableArray[NewSize] = (StringMapEntryBase*)2;