Index: include/llvm/ADT/SmallVector.h =================================================================== --- include/llvm/ADT/SmallVector.h +++ include/llvm/ADT/SmallVector.h @@ -388,7 +388,8 @@ void swap(SmallVectorImpl &RHS); /// Add the specified range to the end of the SmallVector. - template + template ::pointer> void append(in_iter in_start, in_iter in_end) { size_type NumInputs = std::distance(in_start, in_end); // Grow allocated space if needed. @@ -426,7 +427,9 @@ std::uninitialized_fill(this->begin(), this->end(), Elt); } - template void assign(in_iter in_start, in_iter in_end) { + template ::pointer> + void assign(in_iter in_start, in_iter in_end) { clear(); append(in_start, in_end); } @@ -579,7 +582,8 @@ return I; } - template + template ::pointer> iterator insert(iterator I, ItTy From, ItTy To) { // Convert iterator to elt# to avoid invalidating iterator when we reserve() size_t InsertElt = I - this->begin(); @@ -860,7 +864,8 @@ this->assign(Size, Value); } - template + template ::pointer> SmallVector(ItTy S, ItTy E) : SmallVectorImpl(N) { this->append(S, E); } Index: unittests/ADT/SmallVectorTest.cpp =================================================================== --- unittests/ADT/SmallVectorTest.cpp +++ unittests/ADT/SmallVectorTest.cpp @@ -415,6 +415,15 @@ this->assertValuesInOrder(this->theVector, 3u, 1, 77, 77); } +// Append test +TYPED_TEST(SmallVectorTest, AppendNonIterTest) { + SCOPED_TRACE("AppendRepeatedTest"); + + this->theVector.push_back(Constructable(1)); + this->theVector.append(2, 7); + this->assertValuesInOrder(this->theVector, 3u, 1, 7, 7); +} + // Assign test TYPED_TEST(SmallVectorTest, AssignTest) { SCOPED_TRACE("AssignTest"); @@ -434,6 +443,15 @@ this->assertValuesInOrder(this->theVector, 3u, 1, 2, 3); } +// Assign test +TYPED_TEST(SmallVectorTest, AssignNonIterTest) { + SCOPED_TRACE("AssignTest"); + + this->theVector.push_back(Constructable(1)); + this->theVector.assign(2, 7); + this->assertValuesInOrder(this->theVector, 2u, 7, 7); +} + // Move-assign test TYPED_TEST(SmallVectorTest, MoveAssignTest) { SCOPED_TRACE("MoveAssignTest"); @@ -532,6 +550,16 @@ this->assertValuesInOrder(this->theVector, 6u, 1, 16, 16, 2, 3, 4); } +TYPED_TEST(SmallVectorTest, InsertRepeatedNonIterTest) { + SCOPED_TRACE("InsertRepeatedTest"); + + this->makeSequence(this->theVector, 1, 4); + Constructable::reset(); + auto I = + this->theVector.insert(this->theVector.begin() + 1, 2, 7); + EXPECT_EQ(this->theVector.begin() + 1, I); + this->assertValuesInOrder(this->theVector, 6u, 1, 7, 7, 2, 3, 4); +} TYPED_TEST(SmallVectorTest, InsertRepeatedAtEndTest) { SCOPED_TRACE("InsertRepeatedTest");