Skip to content

Commit 6d4a502

Browse files
committed
[ADT] Avoid ambiguity by using std::memcpy instead of memcpy (NFC).
1 parent d4516c7 commit 6d4a502

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

llvm/include/llvm/ADT/Hashing.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,15 @@ namespace detail {
136136

137137
inline uint64_t fetch64(const char *p) {
138138
uint64_t result;
139-
memcpy(&result, p, sizeof(result));
139+
std::memcpy(&result, p, sizeof(result));
140140
if (sys::IsBigEndianHost)
141141
sys::swapByteOrder(result);
142142
return result;
143143
}
144144

145145
inline uint32_t fetch32(const char *p) {
146146
uint32_t result;
147-
memcpy(&result, p, sizeof(result));
147+
std::memcpy(&result, p, sizeof(result));
148148
if (sys::IsBigEndianHost)
149149
sys::swapByteOrder(result);
150150
return result;
@@ -379,7 +379,7 @@ bool store_and_advance(char *&buffer_ptr, char *buffer_end, const T& value,
379379
if (buffer_ptr + store_size > buffer_end)
380380
return false;
381381
const char *value_data = reinterpret_cast<const char *>(&value);
382-
memcpy(buffer_ptr, value_data + offset, store_size);
382+
std::memcpy(buffer_ptr, value_data + offset, store_size);
383383
buffer_ptr += store_size;
384384
return true;
385385
}
@@ -513,7 +513,7 @@ struct hash_combine_recursive_helper {
513513
// with the variadic combine because that formation can have varying
514514
// argument types.
515515
size_t partial_store_size = buffer_end - buffer_ptr;
516-
memcpy(buffer_ptr, &data, partial_store_size);
516+
std::memcpy(buffer_ptr, &data, partial_store_size);
517517

518518
// If the store fails, our buffer is full and ready to hash. We have to
519519
// either initialize the hash state (on the first full buffer) or mix

llvm/include/llvm/ADT/SmallVector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ class SmallVectorTemplateBase<T, true> : public SmallVectorTemplateCommon<T> {
518518
// use memcpy here. Note that I and E are iterators and thus might be
519519
// invalid for memcpy if they are equal.
520520
if (I != E)
521-
memcpy(reinterpret_cast<void *>(Dest), I, (E - I) * sizeof(T));
521+
std::memcpy(reinterpret_cast<void *>(Dest), I, (E - I) * sizeof(T));
522522
}
523523

524524
/// Double the size of the allocated memory, guaranteeing space for at
@@ -561,7 +561,7 @@ class SmallVectorTemplateBase<T, true> : public SmallVectorTemplateCommon<T> {
561561
public:
562562
void push_back(ValueParamT Elt) {
563563
const T *EltPtr = reserveForParamAndGetAddress(Elt);
564-
memcpy(reinterpret_cast<void *>(this->end()), EltPtr, sizeof(T));
564+
std::memcpy(reinterpret_cast<void *>(this->end()), EltPtr, sizeof(T));
565565
this->set_size(this->size() + 1);
566566
}
567567

0 commit comments

Comments
 (0)