[llvm-commits] [llvm] r158457 - /llvm/trunk/include/llvm/ADT/FlatArrayMap.h
Stepan Dyatkovskiy
stpworld at narod.ru
Thu Jun 14 09:59:43 PDT 2012
Author: dyatkovskiy
Date: Thu Jun 14 11:59:43 2012
New Revision: 158457
URL: http://llvm.org/viewvc/llvm-project?rev=158457&view=rev
Log:
SmallMap, FlatArrayMap::copyFrom
Replaced memcpy with std::copy, since the first one may work improperly with non POD data.
Modified:
llvm/trunk/include/llvm/ADT/FlatArrayMap.h
Modified: llvm/trunk/include/llvm/ADT/FlatArrayMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/FlatArrayMap.h?rev=158457&r1=158456&r2=158457&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/FlatArrayMap.h (original)
+++ llvm/trunk/include/llvm/ADT/FlatArrayMap.h Thu Jun 14 11:59:43 2012
@@ -96,11 +96,13 @@
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;
}
More information about the llvm-commits
mailing list