From 70b5fa948d920ccca86d143057497132f63a44f3 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 26 Mar 2018 15:15:40 -0700 Subject: Changes imported from Abseil "staging" branch: - f2c4c517f14afa7a3fac6b35588381462f02dec3 Rollback release of algorithm benchmark. by Alex Strelnikov - ec8a9569ac36d58a4fff2f9fc851e5a9474d274a Change AllocInspector to ConstructorTracker by Jon Cohen - 6f94f3d65a29b11c692948d23c0fc530f015cd53 Update WORKSPACE for C++ microbenchmarks and release algo... by Alex Strelnikov - 79187dd7cec821e47cdd751db71bb23be2b8cef7 Define copy assignment operator for ThrowingAllocator. by Xiaoyi Zhang - 8bf5e1048dd7788f4bce60376f5c3992f8525d88 Fix incorrect format string used in str_cat_test.cc code,... by Jorg Brown - 19c51194e6638f05cbb364c6684f14dc7ed1a323 Fix symbolize_test under sanitizers. by Derek Mauro - d68119cfb845a9d460fc3fd4aae1d2ea7d79ee21 Internal change. by Derek Mauro - 4ca54d336c7a18050c95c6c1a859f2a0530e1cde Internal change. by Shaindel Schwartz GitOrigin-RevId: f2c4c517f14afa7a3fac6b35588381462f02dec3 Change-Id: If61a65d65f03b26d6776710040780ddd1c52c4de --- absl/base/internal/exception_safety_testing.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'absl/base/internal/exception_safety_testing.h') diff --git a/absl/base/internal/exception_safety_testing.h b/absl/base/internal/exception_safety_testing.h index adee848b..a0cd33b4 100644 --- a/absl/base/internal/exception_safety_testing.h +++ b/absl/base/internal/exception_safety_testing.h @@ -37,7 +37,7 @@ namespace absl { struct InternalAbslNamespaceFinder {}; -struct AllocInspector; +struct ConstructorTracker; // A configuration enum for Throwing*. Operations whose flags are set will // throw, everything else won't. This isn't meant to be exhaustive, more flags @@ -125,7 +125,7 @@ class TrackedObject { } } - friend struct ::absl::AllocInspector; + friend struct ::absl::ConstructorTracker; }; template @@ -594,6 +594,8 @@ class ThrowingAllocator : private exceptions_internal::TrackedObject { const ThrowingAllocator& other) noexcept : TrackedObject(ABSL_PRETTY_FUNCTION), dummy_(other.State()) {} + // According to C++11 standard [17.6.3.5], Table 28, the move/copy ctors of + // allocator shall not exit via an exception, thus they are marked noexcept. ThrowingAllocator(const ThrowingAllocator& other) noexcept : TrackedObject(ABSL_PRETTY_FUNCTION), dummy_(other.State()) {} @@ -607,6 +609,11 @@ class ThrowingAllocator : private exceptions_internal::TrackedObject { ~ThrowingAllocator() noexcept = default; + ThrowingAllocator& operator=(const ThrowingAllocator& other) noexcept { + dummy_ = other.State(); + return *this; + } + template ThrowingAllocator& operator=( const ThrowingAllocator& other) noexcept { @@ -704,11 +711,11 @@ int ThrowingAllocator::next_id_ = 0; // Inspects the constructions and destructions of anything inheriting from // TrackedObject. Place this as a member variable in a test fixture to ensure // that every ThrowingValue was constructed and destroyed correctly. This also -// allows us to safely "leak" TrackedObjects, as AllocInspector will destroy +// allows us to safely "leak" TrackedObjects, as ConstructorTracker will destroy // everything left over in its destructor. -struct AllocInspector { - AllocInspector() = default; - ~AllocInspector() { +struct ConstructorTracker { + ConstructorTracker() = default; + ~ConstructorTracker() { auto& allocs = exceptions_internal::TrackedObject::GetAllocs(); for (const auto& kv : allocs) { ADD_FAILURE() << "Object at address " << static_cast(kv.first) @@ -720,7 +727,7 @@ struct AllocInspector { // Tests for resource leaks by attempting to construct a T using args repeatedly // until successful, using the countdown method. Side effects can then be -// tested for resource leaks. If an AllocInspector is present in the test +// tested for resource leaks. If a ConstructorTracker is present in the test // fixture, then this will also test that memory resources are not leaked as // long as T allocates TrackedObjects. template -- cgit v1.2.3