summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/AllocatorTest.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2015-05-18 16:54:17 +0000
committerHans Wennborg <hans@hanshq.net>2015-05-18 16:54:17 +0000
commitda5ddff74af0d5693771b027aa179d8983a0d6b4 (patch)
tree4cec0c04cfdd33d420403e8f4bdfeb8a850ecdb6 /llvm/unittests/Support/AllocatorTest.cpp
parent715b27f0588747f38ef4932ce1e54dc42c5962e4 (diff)
downloadbcm5719-llvm-da5ddff74af0d5693771b027aa179d8983a0d6b4.tar.gz
bcm5719-llvm-da5ddff74af0d5693771b027aa179d8983a0d6b4.zip
Fix llvm::BumpPtrAllocatorImpl::Reset()
BumpPtrAllocator's Reset wouldn't clear CustomSizedSlabs if Slabs.size() == 0. Patch by Kal <b17c0de@gmail.com>! llvm-svn: 237588
Diffstat (limited to 'llvm/unittests/Support/AllocatorTest.cpp')
-rw-r--r--llvm/unittests/Support/AllocatorTest.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/unittests/Support/AllocatorTest.cpp b/llvm/unittests/Support/AllocatorTest.cpp
index 7f15776d6f0..38c7fcba8af 100644
--- a/llvm/unittests/Support/AllocatorTest.cpp
+++ b/llvm/unittests/Support/AllocatorTest.cpp
@@ -61,6 +61,13 @@ TEST(AllocatorTest, ThreeSlabs) {
// again.
TEST(AllocatorTest, TestReset) {
BumpPtrAllocator Alloc;
+
+ // Allocate something larger than the SizeThreshold=4096.
+ (void)Alloc.Allocate(5000, 1);
+ Alloc.Reset();
+ // Calling Reset should free all CustomSizedSlabs.
+ EXPECT_EQ(0u, Alloc.GetNumSlabs());
+
Alloc.Allocate(3000, 1);
EXPECT_EQ(1U, Alloc.GetNumSlabs());
Alloc.Allocate(3000, 1);
OpenPOWER on IntegriCloud