]> granicus.if.org Git - clang/commitdiff
Revert "Revert "PR16540: ASTVector::insert(Context, Iter, Element) doesn't compile""
authorDavid Blaikie <dblaikie@gmail.com>
Sat, 13 Jul 2013 19:23:35 +0000 (19:23 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Sat, 13 Jul 2013 19:23:35 +0000 (19:23 +0000)
This reverts commit b18b043a5a37f76803d89467e46bcac286c0ecae.

Reapply with fix for the configure+make build (missing include of
ASTContext.h).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186257 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ASTVector.h
unittests/AST/ASTVectorTest.cpp [new file with mode: 0644]
unittests/AST/CMakeLists.txt

index 669e50dbeb8791029ba476a4142c87c259b47327..0d4b3c4bb7e49d10d01955e290bccfb258965e92 100644 (file)
@@ -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/unittests/AST/ASTVectorTest.cpp b/unittests/AST/ASTVectorTest.cpp
new file mode 100644 (file)
index 0000000..a92e86b
--- /dev/null
@@ -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);
+}
index c414ae3b237fabd703ff5dc3cb3d1cb5631b1168..70f86d3c73010191c8af45ec198cd1aba933f85e 100644 (file)
@@ -1,6 +1,7 @@
 add_clang_unittest(ASTTests
   ASTContextParentMapTest.cpp
   ASTTypeTraitsTest.cpp
+  ASTVectorTest.cpp
   CommentLexer.cpp
   CommentParser.cpp
   DeclPrinterTest.cpp