Reset more globalMemCounters.
authorDan Albert <danalbert@google.com>
Tue, 7 Apr 2020 23:29:13 +0000 (16:29 -0700)
committerDan Albert <danalbert@google.com>
Tue, 7 Apr 2020 23:40:22 +0000 (16:40 -0700)
Reviewers: EricWF, #libc

Reviewed By: EricWF, #libc

Subscribers: broadwaylamb, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D77681

libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/construct.cxx2a.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp

index 56acbbf..d3a7dad 100644 (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;
index f21f8d4..2e67ab1 100644 (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);
index 33f2962..3ffc137 100644 (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
index 5e9e06f..4650013 100644 (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)