diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:36:24 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:36:24 +0000 | 
| commit | 36c5ade2f4674b544039d78db4c466756cf142b0 (patch) | |
| tree | 3d3ed1e1987dbe6444294b1b4e249814b97b97a5 /include/clang/Analysis | |
| parent | 51ece4aae5857052d224ce52277924c74685714e (diff) | |
Notes
Diffstat (limited to 'include/clang/Analysis')
| -rw-r--r-- | include/clang/Analysis/Support/BumpVector.h | 17 | 
1 files changed, 9 insertions, 8 deletions
diff --git a/include/clang/Analysis/Support/BumpVector.h b/include/clang/Analysis/Support/BumpVector.h index 841adf64557d..3abe32d79cce 100644 --- a/include/clang/Analysis/Support/BumpVector.h +++ b/include/clang/Analysis/Support/BumpVector.h @@ -223,14 +223,15 @@ void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) {    T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity);    // Copy the elements over. -  if (std::is_class<T>::value) { -    std::uninitialized_copy(Begin, End, NewElts); -    // Destroy the original elements. -    destroy_range(Begin, End); -  } -  else { -    // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove). -    memcpy(NewElts, Begin, CurSize * sizeof(T)); +  if (Begin != End) { +    if (std::is_class<T>::value) { +      std::uninitialized_copy(Begin, End, NewElts); +      // Destroy the original elements. +      destroy_range(Begin, End); +    } else { +      // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove). +      memcpy(NewElts, Begin, CurSize * sizeof(T)); +    }    }    // For now, leak 'Begin'.  We can add it back to a freelist in  | 
