summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/AST/ASTVector.h4
-rw-r--r--clang/unittests/AST/ASTVectorTest.cpp24
-rw-r--r--clang/unittests/AST/CMakeLists.txt1
3 files changed, 27 insertions, 2 deletions
diff --git a/clang/include/clang/AST/ASTVector.h b/clang/include/clang/AST/ASTVector.h
index 669e50dbeb8..0d4b3c4bb7e 100644
--- a/clang/include/clang/AST/ASTVector.h
+++ b/clang/include/clang/AST/ASTVector.h
@@ -216,11 +216,11 @@ public:
iterator insert(ASTContext &C, iterator I, const T &Elt) {
if (I == this->end()) { // Important special case for empty vector.
- push_back(Elt);
+ push_back(Elt, C);
return this->end()-1;
}
- if (this->EndX < this->CapacityX) {
+ if (this->End < this->Capacity) {
Retry:
new (this->end()) T(this->back());
this->setEnd(this->end()+1);
diff --git a/clang/unittests/AST/ASTVectorTest.cpp b/clang/unittests/AST/ASTVectorTest.cpp
new file mode 100644
index 00000000000..a92e86b3cd8
--- /dev/null
+++ b/clang/unittests/AST/ASTVectorTest.cpp
@@ -0,0 +1,24 @@
+//===- unittests/AST/DeclTest.cpp --- Declaration tests -------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Unit tests for the ASTVector container.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/Compiler.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTVector.h"
+
+using namespace clang;
+
+LLVM_ATTRIBUTE_UNUSED void CompileTest() {
+ ASTContext *C = 0;
+ ASTVector<int> V;
+ V.insert(*C, V.begin(), 0);
+}
diff --git a/clang/unittests/AST/CMakeLists.txt b/clang/unittests/AST/CMakeLists.txt
index c414ae3b237..70f86d3c730 100644
--- a/clang/unittests/AST/CMakeLists.txt
+++ b/clang/unittests/AST/CMakeLists.txt
@@ -1,6 +1,7 @@
add_clang_unittest(ASTTests
ASTContextParentMapTest.cpp
ASTTypeTraitsTest.cpp
+ ASTVectorTest.cpp
CommentLexer.cpp
CommentParser.cpp
DeclPrinterTest.cpp
OpenPOWER on IntegriCloud