From bb6d2dc9da8ba0c4b9adc25925a83823328adf67 Mon Sep 17 00:00:00 2001 From: Stepan Dyatkovskiy Date: Thu, 14 Jun 2012 16:59:43 +0000 Subject: [PATCH] SmallMap, FlatArrayMap::copyFrom Replaced memcpy with std::copy, since the first one may work improperly with non POD data. llvm-svn: 158457 --- include/llvm/ADT/FlatArrayMap.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/llvm/ADT/FlatArrayMap.h b/include/llvm/ADT/FlatArrayMap.h index b414cde7a16..2d60ef88373 100644 --- a/include/llvm/ADT/FlatArrayMap.h +++ b/include/llvm/ADT/FlatArrayMap.h @@ -96,11 +96,13 @@ namespace llvm { void copyFrom(const self &RHS) { - memcpy(Array, RHS.Array, sizeof(value_type) * (MaxArraySize + 1)); + std::copy(RHS.Array, RHS.Array + MaxArraySize + 1, Array); NumElements = RHS.NumElements; } void init () { + // Even if Array contains non POD, use memset for last element, + // since it is used as end() iterator only. memset(Array + MaxArraySize, 0, sizeof(value_type)); NumElements = 0; }