diff --git a/libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp --- a/libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp @@ -76,15 +76,15 @@ void duplicate_keys_test() { typedef std::map, test_allocator > > Map; { - LIBCPP_ASSERT(test_alloc_base::alloc_count == 0); + LIBCPP_ASSERT(alloc_stats.alloc_count == 0); Map s = {{1, 0}, {2, 0}, {3, 0}}; - LIBCPP_ASSERT(test_alloc_base::alloc_count == 3); + LIBCPP_ASSERT(alloc_stats.alloc_count == 3); s = {{4, 0}, {4, 0}, {4, 0}, {4, 0}}; - LIBCPP_ASSERT(test_alloc_base::alloc_count == 1); + LIBCPP_ASSERT(alloc_stats.alloc_count == 1); assert(s.size() == 1); assert(s.begin()->first == 4); } - LIBCPP_ASSERT(test_alloc_base::alloc_count == 0); + LIBCPP_ASSERT(alloc_stats.alloc_count == 0); } int main(int, char**) diff --git a/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp --- a/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp +++ b/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp @@ -57,15 +57,15 @@ void duplicate_keys_test() { typedef std::set, test_allocator > Set; { - LIBCPP_ASSERT(test_alloc_base::alloc_count == 0); + LIBCPP_ASSERT(alloc_stats.alloc_count == 0); Set s = {1, 2, 3}; - LIBCPP_ASSERT(test_alloc_base::alloc_count == 3); + LIBCPP_ASSERT(alloc_stats.alloc_count == 3); s = {4, 4, 4, 4, 4}; - LIBCPP_ASSERT(test_alloc_base::alloc_count == 1); + LIBCPP_ASSERT(alloc_stats.alloc_count == 1); assert(s.size() == 1); assert(*s.begin() == 4); } - LIBCPP_ASSERT(test_alloc_base::alloc_count == 0); + LIBCPP_ASSERT(alloc_stats.alloc_count == 0); } int main(int, char**) { diff --git a/libcxx/test/std/containers/container.requirements/container.requirements.general/allocator_move.pass.cpp b/libcxx/test/std/containers/container.requirements/container.requirements.general/allocator_move.pass.cpp --- a/libcxx/test/std/containers/container.requirements/container.requirements.general/allocator_move.pass.cpp +++ b/libcxx/test/std/containers/container.requirements/container.requirements.general/allocator_move.pass.cpp @@ -28,26 +28,26 @@ template void test(int expected_num_allocs = 1) { { - test_alloc_base::clear(); + alloc_stats.clear(); using AllocT = typename C::allocator_type; C v(AllocT(42, 101)); - assert(test_alloc_base::count == expected_num_allocs); + assert(alloc_stats.count == expected_num_allocs); - const int num_stored_allocs = test_alloc_base::count; + const int num_stored_allocs = alloc_stats.count; { const AllocT& a = v.get_allocator(); - assert(test_alloc_base::count == 1 + num_stored_allocs); + assert(alloc_stats.count == 1 + num_stored_allocs); assert(a.get_data() == 42); assert(a.get_id() == 101); } - assert(test_alloc_base::count == num_stored_allocs); - test_alloc_base::clear_ctor_counters(); + assert(alloc_stats.count == num_stored_allocs); + alloc_stats.clear_ctor_counters(); C v2 = std::move(v); - assert(test_alloc_base::count == num_stored_allocs * 2); - assert(test_alloc_base::copied == 0); - assert(test_alloc_base::moved == num_stored_allocs); + assert(alloc_stats.count == num_stored_allocs * 2); + assert(alloc_stats.copied == 0); + assert(alloc_stats.moved == num_stored_allocs); { const AllocT& a = v.get_allocator(); assert(a.get_id() == test_alloc_base::moved_value); diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp --- a/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp +++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp @@ -90,7 +90,7 @@ C vec; C vec2(vec); - C::allocator_type::throw_after = 1; + alloc_stats.throw_after = 1; try { vec.push_back(instance); assert(false); diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp --- a/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp +++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp @@ -90,7 +90,7 @@ C vec; C vec2(vec); - C::allocator_type::throw_after = 1; + alloc_stats.throw_after = 1; try { vec.push_front(instance); assert(false); diff --git a/libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp @@ -60,24 +60,24 @@ assert(l2.get_allocator() == lo.get_allocator()); } { - test_alloc_base::clear(); + alloc_stats.clear(); using Vect = std::vector >; using AllocT = Vect::allocator_type; Vect v(test_allocator(42, 101)); - assert(test_alloc_base::count == 1); + assert(alloc_stats.count == 1); { const AllocT& a = v.get_allocator(); - assert(test_alloc_base::count == 2); + assert(alloc_stats.count == 2); assert(a.get_data() == 42); assert(a.get_id() == 101); } - assert(test_alloc_base::count == 1); - test_alloc_base::clear_ctor_counters(); + assert(alloc_stats.count == 1); + alloc_stats.clear_ctor_counters(); Vect v2 = std::move(v); - assert(test_alloc_base::count == 2); - assert(test_alloc_base::copied == 0); - assert(test_alloc_base::moved == 1); + assert(alloc_stats.count == 2); + assert(alloc_stats.copied == 0); + assert(alloc_stats.moved == 1); { const AllocT& a = v.get_allocator(); assert(a.get_id() == test_alloc_base::moved_value); diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp @@ -100,24 +100,24 @@ assert(is_contiguous_container_asan_correct(c2)); } { - test_alloc_base::clear(); + alloc_stats.clear(); using Vect = std::vector >; Vect v(test_allocator(42, 101)); - assert(test_alloc_base::count == 1); - assert(test_alloc_base::copied == 1); - assert(test_alloc_base::moved == 0); + assert(alloc_stats.count == 1); + assert(alloc_stats.copied == 1); + assert(alloc_stats.moved == 0); { const test_allocator& a = v.get_allocator(); assert(a.get_data() == 42); assert(a.get_id() == 101); } - assert(test_alloc_base::count == 1); - test_alloc_base::clear_ctor_counters(); + assert(alloc_stats.count == 1); + alloc_stats.clear_ctor_counters(); Vect v2 = std::move(v); - assert(test_alloc_base::count == 2); - assert(test_alloc_base::copied == 0); - assert(test_alloc_base::moved == 1); + assert(alloc_stats.count == 2); + assert(alloc_stats.copied == 0); + assert(alloc_stats.moved == 1); { const test_allocator& a = v.get_allocator(); assert(a.get_id() == test_alloc_base::moved_value); diff --git a/libcxx/test/std/re/re.results/re.results.const/move.pass.cpp b/libcxx/test/std/re/re.results/re.results.const/move.pass.cpp --- a/libcxx/test/std/re/re.results/re.results.const/move.pass.cpp +++ b/libcxx/test/std/re/re.results/re.results.const/move.pass.cpp @@ -41,9 +41,9 @@ test(std::allocator >()); test (test_allocator >(3)); - assert(test_alloc_base::moved == 1); + assert(alloc_stats.moved == 1); test(test_allocator >(3)); - assert(test_alloc_base::moved == 2); + assert(alloc_stats.moved == 2); return 0; } diff --git a/libcxx/test/std/strings/basic.string/string.capacity/capacity.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/capacity.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/capacity.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/capacity.pass.cpp @@ -22,7 +22,7 @@ void test(S s) { - S::allocator_type::throw_after = 0; + alloc_stats.throw_after = 0; #ifndef TEST_HAS_NO_EXCEPTIONS try #endif @@ -37,7 +37,7 @@ assert(false); } #endif - S::allocator_type::throw_after = INT_MAX; + alloc_stats.throw_after = INT_MAX; } int main(int, char**) diff --git a/libcxx/test/std/strings/basic.string/string.cons/move_alloc.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/move_alloc.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.cons/move_alloc.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/move_alloc.pass.cpp @@ -49,7 +49,7 @@ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7)); } - int alloc_count = test_alloc_base::alloc_count; + int alloc_count = alloc_stats.alloc_count; { typedef test_allocator A; typedef std::basic_string, A> S; @@ -61,7 +61,7 @@ S s1 ( "Twas brillig, and the slivy toves did gyre and gymbal in the wabe" ); S s2 (std::move(s1), A(1)); } - assert ( test_alloc_base::alloc_count == alloc_count ); + assert ( alloc_stats.alloc_count == alloc_count ); { typedef min_allocator A; typedef std::basic_string, A> S; diff --git a/libcxx/test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp b/libcxx/test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp --- a/libcxx/test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp +++ b/libcxx/test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp @@ -25,31 +25,31 @@ int main(int, char**) { - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { std::promise p(std::allocator_arg, test_allocator(42)); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { std::promise p(std::allocator_arg, test_allocator(42)); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { std::promise p(std::allocator_arg, test_allocator(42)); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); // Test with a minimal allocator { std::promise p(std::allocator_arg, bare_allocator()); diff --git a/libcxx/test/std/thread/futures/futures.promise/move_assign.pass.cpp b/libcxx/test/std/thread/futures/futures.promise/move_assign.pass.cpp --- a/libcxx/test/std/thread/futures/futures.promise/move_assign.pass.cpp +++ b/libcxx/test/std/thread/futures/futures.promise/move_assign.pass.cpp @@ -23,15 +23,15 @@ int main(int, char**) { - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::alloc_count == 2); + assert(alloc_stats.alloc_count == 2); p = std::move(p0); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); #ifndef TEST_HAS_NO_EXCEPTIONS try @@ -44,17 +44,17 @@ assert(e.code() == make_error_code(std::future_errc::no_state)); } #endif - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::alloc_count == 2); + assert(alloc_stats.alloc_count == 2); p = std::move(p0); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); #ifndef TEST_HAS_NO_EXCEPTIONS try @@ -67,17 +67,17 @@ assert(e.code() == make_error_code(std::future_errc::no_state)); } #endif - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::alloc_count == 2); + assert(alloc_stats.alloc_count == 2); p = std::move(p0); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); #ifndef TEST_HAS_NO_EXCEPTIONS try @@ -90,9 +90,9 @@ assert(e.code() == make_error_code(std::future_errc::no_state)); } #endif - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); return 0; } diff --git a/libcxx/test/std/thread/futures/futures.promise/move_ctor.pass.cpp b/libcxx/test/std/thread/futures/futures.promise/move_ctor.pass.cpp --- a/libcxx/test/std/thread/futures/futures.promise/move_ctor.pass.cpp +++ b/libcxx/test/std/thread/futures/futures.promise/move_ctor.pass.cpp @@ -23,13 +23,13 @@ int main(int, char**) { - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::move(p0)); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); #ifndef TEST_HAS_NO_EXCEPTIONS try @@ -41,16 +41,16 @@ { assert(e.code() == make_error_code(std::future_errc::no_state)); } - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); #endif } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::move(p0)); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); #ifndef TEST_HAS_NO_EXCEPTIONS try @@ -62,16 +62,16 @@ { assert(e.code() == make_error_code(std::future_errc::no_state)); } - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); #endif } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::move(p0)); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); #ifndef TEST_HAS_NO_EXCEPTIONS try @@ -83,10 +83,10 @@ { assert(e.code() == make_error_code(std::future_errc::no_state)); } - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); #endif } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); return 0; } diff --git a/libcxx/test/std/thread/futures/futures.promise/swap.pass.cpp b/libcxx/test/std/thread/futures/futures.promise/swap.pass.cpp --- a/libcxx/test/std/thread/futures/futures.promise/swap.pass.cpp +++ b/libcxx/test/std/thread/futures/futures.promise/swap.pass.cpp @@ -25,63 +25,63 @@ int main(int, char**) { - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::alloc_count == 2); + assert(alloc_stats.alloc_count == 2); p.swap(p0); - assert(test_alloc_base::alloc_count == 2); + assert(alloc_stats.alloc_count == 2); std::future f = p.get_future(); - assert(test_alloc_base::alloc_count == 2); + assert(alloc_stats.alloc_count == 2); assert(f.valid()); f = p0.get_future(); assert(f.valid()); - assert(test_alloc_base::alloc_count == 2); + assert(alloc_stats.alloc_count == 2); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::alloc_count == 2); + assert(alloc_stats.alloc_count == 2); swap(p, p0); - assert(test_alloc_base::alloc_count == 2); + assert(alloc_stats.alloc_count == 2); std::future f = p.get_future(); - assert(test_alloc_base::alloc_count == 2); + assert(alloc_stats.alloc_count == 2); assert(f.valid()); f = p0.get_future(); assert(f.valid()); - assert(test_alloc_base::alloc_count == 2); + assert(alloc_stats.alloc_count == 2); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p; - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); p.swap(p0); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); f = p0.get_future(); assert(f.valid()); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p; - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); swap(p, p0); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); f = p0.get_future(); assert(f.valid()); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); return 0; } diff --git a/libcxx/test/std/thread/futures/futures.shared_future/dtor.pass.cpp b/libcxx/test/std/thread/futures/futures.shared_future/dtor.pass.cpp --- a/libcxx/test/std/thread/futures/futures.shared_future/dtor.pass.cpp +++ b/libcxx/test/std/thread/futures/futures.shared_future/dtor.pass.cpp @@ -24,49 +24,49 @@ int main(int, char**) { - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { typedef int T; std::shared_future f; { std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { typedef int& T; std::shared_future f; { std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { typedef void T; std::shared_future f; { std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); return 0; } diff --git a/libcxx/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp b/libcxx/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp --- a/libcxx/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp +++ b/libcxx/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp @@ -50,7 +50,7 @@ { std::packaged_task p(std::allocator_arg, test_allocator(), A(5)); - assert(test_alloc_base::alloc_count > 0); + assert(alloc_stats.alloc_count > 0); assert(p.valid()); std::future f = p.get_future(); p(3, 'a'); @@ -58,14 +58,14 @@ assert(A::n_copies == 0); assert(A::n_moves > 0); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); A::n_copies = 0; A::n_moves = 0; { A a(5); std::packaged_task p(std::allocator_arg, test_allocator(), a); - assert(test_alloc_base::alloc_count > 0); + assert(alloc_stats.alloc_count > 0); assert(p.valid()); std::future f = p.get_future(); p(3, 'a'); @@ -73,31 +73,31 @@ assert(A::n_copies > 0); assert(A::n_moves >= 0); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); A::n_copies = 0; A::n_moves = 0; { A a(5); std::packaged_task p(std::allocator_arg, test_allocator(), &func); - assert(test_alloc_base::alloc_count > 0); + assert(alloc_stats.alloc_count > 0); assert(p.valid()); std::future f = p.get_future(); p(4); assert(f.get() == 4); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); A::n_copies = 0; A::n_moves = 0; { A a(5); std::packaged_task p(std::allocator_arg, test_allocator(), func); - assert(test_alloc_base::alloc_count > 0); + assert(alloc_stats.alloc_count > 0); assert(p.valid()); std::future f = p.get_future(); p(4); assert(f.get() == 4); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); A::n_copies = 0; A::n_moves = 0; { diff --git a/libcxx/test/std/thread/futures/futures.unique_future/dtor.pass.cpp b/libcxx/test/std/thread/futures/futures.unique_future/dtor.pass.cpp --- a/libcxx/test/std/thread/futures/futures.unique_future/dtor.pass.cpp +++ b/libcxx/test/std/thread/futures/futures.unique_future/dtor.pass.cpp @@ -24,49 +24,49 @@ int main(int, char**) { - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { typedef int T; std::future f; { std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { typedef int& T; std::future f; { std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { typedef void T; std::future f; { std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); f = p.get_future(); - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); return 0; } 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 --- 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 @@ -69,7 +69,7 @@ std::function f2(std::allocator_arg, alloc, target); // The allocator may not fit in the small object buffer, if we allocated // check it was done via the allocator. - assert(globalMemCounter.checkOutstandingNewEq(test_alloc_base::alloc_count)); + assert(globalMemCounter.checkOutstandingNewEq(alloc_stats.alloc_count)); assert(f2.template target()); assert(*f2.template target() == target); assert(f2.template target() == 0); @@ -86,7 +86,7 @@ TargetType target = &MemFunClass::foo; assert(globalMemCounter.checkOutstandingNewEq(0)); std::function f2(std::allocator_arg, alloc, target); - assert(globalMemCounter.checkOutstandingNewEq(test_alloc_base::alloc_count)); + assert(globalMemCounter.checkOutstandingNewEq(alloc_stats.alloc_count)); assert(f2.template target()); assert(*f2.template target() == target); assert(f2.template target() == 0); diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp @@ -42,14 +42,14 @@ assert(d); assert(d->state() == 3); #endif - assert(test_allocator::count == 1); - assert(test_allocator::alloc_count == 1); + assert(alloc_stats.count == 1); + assert(alloc_stats.alloc_count == 1); } assert(A::count == 0); assert(test_deleter::count == 0); assert(test_deleter::dealloc_count == 1); - assert(test_allocator::count == 0); - assert(test_allocator::alloc_count == 0); + assert(alloc_stats.count == 0); + assert(alloc_stats.alloc_count == 0); test_deleter::dealloc_count = 0; // Test an allocator with a minimal interface { diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp @@ -32,7 +32,7 @@ { try { - test_allocator::throw_after = 0; + alloc_stats.throw_after = 0; std::shared_ptr p(nullptr, test_deleter(3), test_allocator(5)); assert(false); } @@ -41,8 +41,8 @@ assert(A::count == 0); assert(test_deleter::count == 0); assert(test_deleter::dealloc_count == 1); - assert(test_allocator::count == 0); - assert(test_allocator::alloc_count == 0); + assert(alloc_stats.count == 0); + assert(alloc_stats.alloc_count == 0); } return 0; diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp @@ -75,14 +75,14 @@ assert(d); assert(d->state() == 3); #endif - assert(test_allocator::count == 1); - assert(test_allocator::alloc_count == 1); + assert(alloc_stats.count == 1); + assert(alloc_stats.alloc_count == 1); } assert(A::count == 0); assert(test_deleter::count == 0); assert(test_deleter::dealloc_count == 1); - assert(test_allocator::count == 0); - assert(test_allocator::alloc_count == 0); + assert(alloc_stats.count == 0); + assert(alloc_stats.alloc_count == 0); test_deleter::dealloc_count = 0; // Test an allocator with a minimal interface { diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp @@ -33,17 +33,17 @@ A* ptr = new A; try { - test_allocator::throw_after = 0; + alloc_stats.throw_after = 0; std::shared_ptr p(ptr, test_deleter(3), test_allocator(5)); assert(false); } catch (std::bad_alloc&) { - assert(A::count == 0); - assert(test_deleter::count == 0); + assert(alloc_stats.count == 0); + assert(alloc_stats.count == 0); assert(test_deleter::dealloc_count == 1); - assert(test_allocator::count == 0); - assert(test_allocator::alloc_count == 0); + assert(alloc_stats.count == 0); + assert(alloc_stats.alloc_count == 0); } return 0; diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp @@ -151,13 +151,13 @@ int i = 67; char c = 'e'; std::shared_ptr p = std::allocate_shared(test_allocator(54), i, c); - assert(test_allocator::alloc_count == 1); + assert(alloc_stats.alloc_count == 1); assert(A::count == 1); assert(p->get_int() == 67); assert(p->get_char() == 'e'); } assert(A::count == 0); - assert(test_allocator::alloc_count == 0); + assert(alloc_stats.alloc_count == 0); { int i = 67; char c = 'e'; diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp @@ -58,14 +58,14 @@ assert(d); assert(d->state() == 3); #endif - assert(test_allocator::count == 1); - assert(test_allocator::alloc_count == 1); + assert(alloc_stats.count == 1); + assert(alloc_stats.alloc_count == 1); } assert(A::count == 0); assert(test_deleter::count == 0); assert(test_deleter::dealloc_count == 1); - assert(test_allocator::count == 0); - assert(test_allocator::alloc_count == 0); + assert(alloc_stats.count == 0); + assert(alloc_stats.alloc_count == 0); { std::shared_ptr p; A* ptr = new A; @@ -81,14 +81,14 @@ assert(d); assert(d->state() == 3); #endif - assert(test_allocator::count == 1); - assert(test_allocator::alloc_count == 1); + assert(alloc_stats.count == 1); + assert(alloc_stats.alloc_count == 1); } assert(A::count == 0); assert(test_deleter::count == 0); assert(test_deleter::dealloc_count == 2); - assert(test_allocator::count == 0); - assert(test_allocator::alloc_count == 0); + assert(alloc_stats.count == 0); + assert(alloc_stats.alloc_count == 0); return 0; } diff --git a/libcxx/test/support/test_allocator.h b/libcxx/test/support/test_allocator.h --- a/libcxx/test/support/test_allocator.h +++ b/libcxx/test/support/test_allocator.h @@ -27,23 +27,17 @@ return AT::max_size(a); } -class test_alloc_base +struct test_allocator_statistics { -protected: - static int time_to_throw; -public: - static int throw_after; - static int count; - static int alloc_count; - static int copied; - static int moved; - static int converted; - - const static int destructed_value = -1; - const static int default_value = 0; - const static int moved_value = INT_MAX; - - static void clear() { + int time_to_throw = 0; + int throw_after = INT_MAX; + int count = 0; + int alloc_count = 0; + int copied = 0; + int moved = 0; + int converted = 0; + + TEST_CONSTEXPR_CXX14 void clear() { assert(count == 0 && "clearing leaking allocator data?"); count = 0; time_to_throw = 0; @@ -52,20 +46,27 @@ clear_ctor_counters(); } - static void clear_ctor_counters() { + TEST_CONSTEXPR_CXX14 void clear_ctor_counters() { copied = 0; moved = 0; converted = 0; } }; -int test_alloc_base::count = 0; -int test_alloc_base::time_to_throw = 0; -int test_alloc_base::alloc_count = 0; -int test_alloc_base::throw_after = INT_MAX; -int test_alloc_base::copied = 0; -int test_alloc_base::moved = 0; -int test_alloc_base::converted = 0; +test_allocator_statistics alloc_stats; + +class test_alloc_base +{ +public: + TEST_CONSTEXPR test_alloc_base(test_allocator_statistics* stats) : stats_(stats) {} + + const static int destructed_value = -1; + const static int default_value = 0; + const static int moved_value = INT_MAX; + +protected: + test_allocator_statistics* stats_; +}; template class test_allocator @@ -86,21 +87,24 @@ template struct rebind {typedef test_allocator other;}; - test_allocator() TEST_NOEXCEPT : data_(0), id_(0) {++count;} - explicit test_allocator(int i, int id = 0) TEST_NOEXCEPT : data_(i), id_(id) - {++count;} - test_allocator(const test_allocator& a) TEST_NOEXCEPT : data_(a.data_), + TEST_CONSTEXPR_CXX14 test_allocator(test_allocator_statistics* stats = &alloc_stats) TEST_NOEXCEPT + : test_alloc_base(stats), data_(0), id_(0) + {++stats_->count;} + TEST_CONSTEXPR_CXX14 explicit test_allocator(int i, int id = 0, test_allocator_statistics* stats = &alloc_stats) TEST_NOEXCEPT + : test_alloc_base(stats), data_(i), id_(id) + {++stats_->count;} + TEST_CONSTEXPR_CXX14 test_allocator(const test_allocator& a) TEST_NOEXCEPT : test_alloc_base(a.stats_), data_(a.data_), id_(a.id_) { - ++count; - ++copied; + ++stats_->count; + ++stats_->copied; assert(a.data_ != destructed_value && a.id_ != destructed_value && "copying from destroyed allocator"); } #if TEST_STD_VER >= 11 - test_allocator(test_allocator&& a) TEST_NOEXCEPT : data_(a.data_), + TEST_CONSTEXPR_CXX14 test_allocator(test_allocator&& a) TEST_NOEXCEPT : test_alloc_base(a.stats_), data_(a.data_), id_(a.id_) { - ++count; - ++moved; + ++stats_->count; + ++stats_->moved; assert(a.data_ != destructed_value && a.id_ != destructed_value && "moving from destroyed allocator"); a.data_ = moved_value; @@ -108,53 +112,53 @@ } #endif template - test_allocator(const test_allocator& a) TEST_NOEXCEPT : data_(a.data_), - id_(a.id_) { - ++count; - ++converted; + TEST_CONSTEXPR_CXX14 test_allocator(const test_allocator& a) TEST_NOEXCEPT + : test_alloc_base(a.stats_), data_(a.data_), id_(a.id_) { + ++stats_->count; + ++stats_->converted; } - ~test_allocator() TEST_NOEXCEPT { + TEST_CONSTEXPR_CXX20 ~test_allocator() TEST_NOEXCEPT { assert(data_ >= 0); assert(id_ >= 0); - --count; + --stats_->count; data_ = destructed_value; id_ = destructed_value; } - pointer address(reference x) const {return &x;} - const_pointer address(const_reference x) const {return &x;} - pointer allocate(size_type n, const void* = 0) + TEST_CONSTEXPR pointer address(reference x) const {return &x;} + TEST_CONSTEXPR const_pointer address(const_reference x) const {return &x;} + TEST_CONSTEXPR_CXX14 pointer allocate(size_type n, const void* = 0) { assert(data_ >= 0); - if (time_to_throw >= throw_after) { + if (stats_->time_to_throw >= stats_->throw_after) { #ifndef TEST_HAS_NO_EXCEPTIONS throw std::bad_alloc(); #else std::terminate(); #endif } - ++time_to_throw; - ++alloc_count; + ++stats_->time_to_throw; + ++stats_->alloc_count; return (pointer)::operator new(n * sizeof(T)); } - void deallocate(pointer p, size_type) - {assert(data_ >= 0); --alloc_count; ::operator delete((void*)p);} - size_type max_size() const TEST_NOEXCEPT + TEST_CONSTEXPR_CXX14 void deallocate(pointer p, size_type) + {assert(data_ >= 0); --stats_->alloc_count; ::operator delete((void*)p);} + TEST_CONSTEXPR size_type max_size() const TEST_NOEXCEPT {return UINT_MAX / sizeof(T);} #if TEST_STD_VER < 11 void construct(pointer p, const T& val) {::new(static_cast(p)) T(val);} #else - template void construct(pointer p, U&& val) + template TEST_CONSTEXPR_CXX14 void construct(pointer p, U&& val) {::new(static_cast(p)) T(std::forward(val));} #endif - void destroy(pointer p) + TEST_CONSTEXPR_CXX14 void destroy(pointer p) {p->~T();} - friend bool operator==(const test_allocator& x, const test_allocator& y) + TEST_CONSTEXPR friend bool operator==(const test_allocator& x, const test_allocator& y) {return x.data_ == y.data_;} - friend bool operator!=(const test_allocator& x, const test_allocator& y) + TEST_CONSTEXPR friend bool operator!=(const test_allocator& x, const test_allocator& y) {return !(x == y);} - int get_data() const { return data_; } - int get_id() const { return id_; } + TEST_CONSTEXPR int get_data() const { return data_; } + TEST_CONSTEXPR int get_id() const { return id_; } }; template @@ -177,30 +181,32 @@ template struct rebind {typedef non_default_test_allocator other;}; // non_default_test_allocator() TEST_NOEXCEPT : data_(0) {++count;} - explicit non_default_test_allocator(int i) TEST_NOEXCEPT : data_(i) {++count;} + explicit non_default_test_allocator(int i, test_allocator_statistics* stats = &alloc_stats) TEST_NOEXCEPT + : test_alloc_base(stats), data_(i) + {++stats_->count;} non_default_test_allocator(const non_default_test_allocator& a) TEST_NOEXCEPT - : data_(a.data_) {++count;} + : test_alloc_base(a.stats_), data_(a.data_) {++stats_->count;} template non_default_test_allocator(const non_default_test_allocator& a) TEST_NOEXCEPT - : data_(a.data_) {++count;} - ~non_default_test_allocator() TEST_NOEXCEPT {assert(data_ >= 0); --count; data_ = -1;} + : test_alloc_base(a.stats_), data_(a.data_) {++stats_->count;} + ~non_default_test_allocator() TEST_NOEXCEPT {assert(data_ >= 0); --stats_->count; data_ = -1;} pointer address(reference x) const {return &x;} const_pointer address(const_reference x) const {return &x;} pointer allocate(size_type n, const void* = 0) { assert(data_ >= 0); - if (time_to_throw >= throw_after) { + if (stats_->time_to_throw >= stats_->throw_after) { #ifndef TEST_HAS_NO_EXCEPTIONS throw std::bad_alloc(); #else std::terminate(); #endif } - ++time_to_throw; - ++alloc_count; + ++stats_->time_to_throw; + ++stats_->alloc_count; return (pointer)::operator new (n * sizeof(T)); } void deallocate(pointer p, size_type) - {assert(data_ >= 0); --alloc_count; ::operator delete((void*)p); } + {assert(data_ >= 0); --stats_->alloc_count; ::operator delete((void*)p); } size_type max_size() const TEST_NOEXCEPT {return UINT_MAX / sizeof(T);} #if TEST_STD_VER < 11 @@ -236,12 +242,12 @@ template struct rebind {typedef test_allocator other;}; - test_allocator() TEST_NOEXCEPT : data_(0), id_(0) {} - explicit test_allocator(int i, int id = 0) TEST_NOEXCEPT : data_(i), id_(id) {} + test_allocator(test_allocator_statistics* stats = &alloc_stats) TEST_NOEXCEPT : test_alloc_base(stats), data_(0), id_(0) {} + explicit test_allocator(int i, int id = 0, test_allocator_statistics* stats = &alloc_stats) TEST_NOEXCEPT : test_alloc_base(stats), data_(i), id_(id) {} test_allocator(const test_allocator& a) TEST_NOEXCEPT - : data_(a.data_), id_(a.id_) {} + : test_alloc_base(a.stats_), data_(a.data_), id_(a.id_) {} template test_allocator(const test_allocator& a) TEST_NOEXCEPT - : data_(a.data_), id_(a.id_) {} + : test_alloc_base(a.stats_), data_(a.data_), id_(a.id_) {} ~test_allocator() TEST_NOEXCEPT {data_ = -1; id_ = -1; } int get_id() const { return id_; }