[libcxx-commits] [libcxx] 0b43db5 - Reset more globalMemCounters.

Dan Albert via libcxx-commits libcxx-commits at lists.llvm.org
Tue Apr 7 16:40:33 PDT 2020


Author: Dan Albert
Date: 2020-04-07T16:40:22-07:00
New Revision: 0b43db5202eef38d736e22042f7b5038454f44fd

URL: https://github.com/llvm/llvm-project/commit/0b43db5202eef38d736e22042f7b5038454f44fd
DIFF: https://github.com/llvm/llvm-project/commit/0b43db5202eef38d736e22042f7b5038454f44fd.diff

LOG: Reset more globalMemCounters.

Reviewers: EricWF, #libc

Reviewed By: EricWF, #libc

Subscribers: broadwaylamb, libcxx-commits

Tags: #libc

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

Added: 
    

Modified: 
    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

Removed: 
    


################################################################################
diff  --git a/libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/construct.cxx2a.pass.cpp b/libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/construct.cxx2a.pass.cpp
index 56acbbf184af..d3a7dadbbe11 100644
--- a/libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/construct.cxx2a.pass.cpp
+++ b/libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/construct.cxx2a.pass.cpp
@@ -62,7 +62,8 @@ class move_only
 
 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;

diff  --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
index f21f8d4cc67b..2e67ab143551 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
@@ -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);

diff  --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
index 138f3d9d8dcf..8c4a207a7d6f 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
@@ -114,6 +114,7 @@ void test_for_alloc(Alloc& alloc)
 
 int main(int, char**)
 {
+  globalMemCounter.reset();
   {
     bare_allocator<DummyClass> alloc;
     test_for_alloc(alloc);

diff  --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
index 33f29627c1ce..3ffc137b9ad2 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
@@ -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

diff  --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
index 5e9e06f7d790..4650013b3bd1 100644
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
+++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
@@ -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)


        


More information about the libcxx-commits mailing list