summaryrefslogtreecommitdiff
path: root/include/clang/AST/ASTVector.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/AST/ASTVector.h')
-rw-r--r--include/clang/AST/ASTVector.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/include/clang/AST/ASTVector.h b/include/clang/AST/ASTVector.h
index 6ec054582e263..79453bf10871a 100644
--- a/include/clang/AST/ASTVector.h
+++ b/include/clang/AST/ASTVector.h
@@ -384,14 +384,15 @@ void ASTVector<T>::grow(const ASTContext &C, size_t MinSize) {
T *NewElts = new (C, llvm::alignOf<T>()) 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));
+ }
}
// ASTContext never frees any memory.