Reset more globalMemCounters.

Reviewers: EricWF, #libc

Reviewed By: EricWF, #libc

Subscribers: broadwaylamb, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D77681
This commit is contained in:
Dan Albert 2020-04-07 16:29:13 -07:00
parent 6fa0d0ae11
commit 0b43db5202
5 changed files with 31 additions and 25 deletions

View File

@ -62,7 +62,8 @@ public:
int main(int, char**)
{
{
globalMemCounter.reset();
{
std::allocator<A> a;
assert(globalMemCounter.checkOutstandingNewEq(0));
assert(A_constructed == 0);
@ -110,7 +111,7 @@ int main(int, char**)
DoNotOptimize(ap);
assert(globalMemCounter.checkOutstandingNewEq(0));
assert(A_constructed == 0);
}
}
#if TEST_STD_VER >= 11
{
std::allocator<move_only> a;

View File

@ -110,10 +110,11 @@ void test_for_alloc(Alloc& alloc) {
int main(int, char**)
{
{
bare_allocator<DummyClass> bare_alloc;
test_for_alloc(bare_alloc);
}
globalMemCounter.reset();
{
bare_allocator<DummyClass> bare_alloc;
test_for_alloc(bare_alloc);
}
{
non_default_test_allocator<DummyClass> non_default_alloc(42);
test_for_alloc(non_default_alloc);

View File

@ -114,6 +114,7 @@ void test_for_alloc(Alloc& alloc)
int main(int, char**)
{
globalMemCounter.reset();
{
bare_allocator<DummyClass> alloc;
test_for_alloc(alloc);

View File

@ -56,21 +56,23 @@ int g(int) { return 0; }
int main(int, char**)
{
assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2(std::allocator_arg, bare_allocator<A>(), std::move(f));
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f2.target<A>());
assert(f2.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
assert(f.target<int(*)(int)>() == 0);
}
globalMemCounter.reset();
assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f.target<A>());
assert(f.target<int (*)(int)>() == 0);
std::function<int(int)> f2(std::allocator_arg, bare_allocator<A>(),
std::move(f));
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f2.target<A>());
assert(f2.target<int (*)(int)>() == 0);
assert(f.target<A>() == 0);
assert(f.target<int (*)(int)>() == 0);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
{
// Test that moving a function constructed from a reference wrapper

View File

@ -46,9 +46,10 @@ int A::count = 0;
int main(int, char**)
{
{
std::auto_ptr<A> ptr(new A);
A* raw_ptr = ptr.get();
globalMemCounter.reset();
{
std::auto_ptr<A> ptr(new A);
A* raw_ptr = ptr.get();
#if TEST_STD_VER >= 11
std::shared_ptr<B> p(std::move(ptr));
#else
@ -59,7 +60,7 @@ int main(int, char**)
assert(p.use_count() == 1);
assert(p.get() == raw_ptr);
assert(ptr.get() == 0);
}
}
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
#if !defined(TEST_HAS_NO_EXCEPTIONS) && !defined(DISABLE_NEW_COUNT)