diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-01-21 16:53:26 -0800 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-01-22 16:17:58 -0800 |
commit | ba5628f2c2a9de049b80b3e276f7e05f481c49e7 (patch) | |
tree | 08b15d5d5693966db67ab856238f80b6a5cd68b2 /llvm/unittests/ADT/SmallVectorTest.cpp | |
parent | 47e95e87a3e4f738635ff965616d4e2d96bf838a (diff) | |
download | llvm-ba5628f2c2a9de049b80b3e276f7e05f481c49e7.zip llvm-ba5628f2c2a9de049b80b3e276f7e05f481c49e7.tar.gz llvm-ba5628f2c2a9de049b80b3e276f7e05f481c49e7.tar.bz2 |
ADT: Use 'using' to inherit assign and append in SmallString
Rather than reimplement, use a `using` declaration to bring in
`SmallVectorImpl<char>`'s assign and append implementations in
`SmallString`.
The `SmallString` versions were missing reference invalidation
assertions from `SmallVector`. This patch also fixes a bug in
`llvm::FileCollector::addFileImpl`, which was a copy/paste from
`clang::ModuleDependencyCollector::copyToRoot`, both caught by the
no-longer-skipped assertions.
As a drive-by, this also sinks the `const SmallVectorImpl&` versions of
these methods down into `SmallVectorImpl`, since I imagine they'd be
useful elsewhere.
Differential Revision: https://reviews.llvm.org/D95202
Diffstat (limited to 'llvm/unittests/ADT/SmallVectorTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/SmallVectorTest.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp index b2cccc1..a533bb8 100644 --- a/llvm/unittests/ADT/SmallVectorTest.cpp +++ b/llvm/unittests/ADT/SmallVectorTest.cpp @@ -485,6 +485,15 @@ TYPED_TEST(SmallVectorTest, AppendRepeatedNonForwardIterator) { this->assertValuesInOrder(this->theVector, 3u, 1, 7, 7); } +TYPED_TEST(SmallVectorTest, AppendSmallVector) { + SCOPED_TRACE("AppendSmallVector"); + + SmallVector<Constructable, 3> otherVector = {7, 7}; + this->theVector.push_back(Constructable(1)); + this->theVector.append(otherVector); + this->assertValuesInOrder(this->theVector, 3u, 1, 7, 7); +} + // Assign test TYPED_TEST(SmallVectorTest, AssignTest) { SCOPED_TRACE("AssignTest"); @@ -513,6 +522,15 @@ TYPED_TEST(SmallVectorTest, AssignNonIterTest) { this->assertValuesInOrder(this->theVector, 2u, 7, 7); } +TYPED_TEST(SmallVectorTest, AssignSmallVector) { + SCOPED_TRACE("AssignSmallVector"); + + SmallVector<Constructable, 3> otherVector = {7, 7}; + this->theVector.push_back(Constructable(1)); + this->theVector.assign(otherVector); + this->assertValuesInOrder(this->theVector, 2u, 7, 7); +} + // Move-assign test TYPED_TEST(SmallVectorTest, MoveAssignTest) { SCOPED_TRACE("MoveAssignTest"); |