Skip to content

Commit

Permalink
Roll back: Add more debug capacity validation checks on moves.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 708329082
Change-Id: Ic4561c6f4786711166de3f4b53fe55b539366f1f
  • Loading branch information
ezbr authored and copybara-github committed Dec 20, 2024
1 parent 50292b7 commit f7bdb7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 5 additions & 6 deletions absl/container/internal/raw_hash_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -2823,10 +2823,9 @@ class raw_hash_set {
// `that` must be left valid. If Hash is std::function<Key>, moving it
// would create a nullptr functor that cannot be called.
// Note: we avoid using exchange for better generated code.
settings_((that.AssertNotDebugCapacity(),
PolicyTraits::transfer_uses_memcpy() || !that.is_full_soo()
? std::move(that.common())
: CommonFields{full_soo_tag_t{}}),
settings_(PolicyTraits::transfer_uses_memcpy() || !that.is_full_soo()
? std::move(that.common())
: CommonFields{full_soo_tag_t{}},
that.hash_ref(), that.eq_ref(), that.alloc_ref()) {
if (!PolicyTraits::transfer_uses_memcpy() && that.is_full_soo()) {
transfer(soo_slot(), that.soo_slot());
Expand All @@ -2838,7 +2837,6 @@ class raw_hash_set {
raw_hash_set(raw_hash_set&& that, const allocator_type& a)
: settings_(CommonFields::CreateDefault<SooEnabled()>(), that.hash_ref(),
that.eq_ref(), a) {
that.AssertNotDebugCapacity();
if (a == that.alloc_ref()) {
swap_common(that);
annotate_for_bug_detection_on_move(that);
Expand All @@ -2865,7 +2863,8 @@ class raw_hash_set {
absl::allocator_traits<allocator_type>::is_always_equal::value &&
std::is_nothrow_move_assignable<hasher>::value &&
std::is_nothrow_move_assignable<key_equal>::value) {
that.AssertNotDebugCapacity();
// TODO(sbenza): We should only use the operations from the noexcept clause
// to make sure we actually adhere to that contract.
// NOLINTNEXTLINE: not returning *this for performance.
return move_assign(
std::move(that),
Expand Down
2 changes: 0 additions & 2 deletions absl/container/internal/raw_hash_set_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3715,8 +3715,6 @@ TEST(Table, MovedFromCallsFail) {
EXPECT_DEATH_IF_SUPPORTED(t1.end(), "moved-from");
// NOLINTNEXTLINE(bugprone-use-after-move)
EXPECT_DEATH_IF_SUPPORTED(t1.size(), "moved-from");
// NOLINTNEXTLINE(bugprone-use-after-move)
EXPECT_DEATH_IF_SUPPORTED(IntTable{std::move(t1)}, "moved-from");
}
{
ABSL_ATTRIBUTE_UNUSED IntTable t1;
Expand Down

0 comments on commit f7bdb7a

Please sign in to comment.