summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/AllocatorTest.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-04-16 10:48:27 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-04-16 10:48:27 +0000
commit0e31ed9058570d2e115c8bcd86c9b50612c94d13 (patch)
tree8b25712bf833b4c8cc879c4eebfa06adbdff7c1b /llvm/unittests/Support/AllocatorTest.cpp
parent11c0c067c2604ddcb4b9f90b505b88d0fb400fe7 (diff)
downloadbcm5719-llvm-0e31ed9058570d2e115c8bcd86c9b50612c94d13.tar.gz
bcm5719-llvm-0e31ed9058570d2e115c8bcd86c9b50612c94d13.zip
[Allocator] Make BumpPtrAllocator movable and move assignable.
llvm-svn: 206372
Diffstat (limited to 'llvm/unittests/Support/AllocatorTest.cpp')
-rw-r--r--llvm/unittests/Support/AllocatorTest.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/unittests/Support/AllocatorTest.cpp b/llvm/unittests/Support/AllocatorTest.cpp
index 8c2ddadf7fa..0fc84c7613f 100644
--- a/llvm/unittests/Support/AllocatorTest.cpp
+++ b/llvm/unittests/Support/AllocatorTest.cpp
@@ -29,6 +29,21 @@ TEST(AllocatorTest, Basics) {
EXPECT_EQ(2, b[9]);
EXPECT_EQ(3, *c);
EXPECT_EQ(1U, Alloc.GetNumSlabs());
+
+ BumpPtrAllocator Alloc2 = std::move(Alloc);
+ EXPECT_EQ(0U, Alloc.GetNumSlabs());
+ EXPECT_EQ(1U, Alloc2.GetNumSlabs());
+
+ // Make sure the old pointers still work. These are especially interesting
+ // under ASan or Valgrind.
+ EXPECT_EQ(1, *a);
+ EXPECT_EQ(2, b[0]);
+ EXPECT_EQ(2, b[9]);
+ EXPECT_EQ(3, *c);
+
+ Alloc = std::move(Alloc2);
+ EXPECT_EQ(0U, Alloc2.GetNumSlabs());
+ EXPECT_EQ(1U, Alloc.GetNumSlabs());
}
// Allocate enough bytes to create three slabs.
OpenPOWER on IntegriCloud