From 229906f3091742e05e51445a66164025b0244409 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Mon, 11 Dec 2023 13:04:12 -0800 Subject: [PATCH] Breaking change: Remove deprecated clear APIs on repeated fields PiperOrigin-RevId: 589920681 --- src/google/protobuf/arena_unittest.cc | 14 -------- src/google/protobuf/port_def.inc | 4 --- src/google/protobuf/port_undef.inc | 1 - .../protobuf/repeated_field_unittest.cc | 13 -------- src/google/protobuf/repeated_ptr_field.h | 32 ------------------- 5 files changed, 64 deletions(-) diff --git a/src/google/protobuf/arena_unittest.cc b/src/google/protobuf/arena_unittest.cc index f1337b1c1f..d1afa07d8f 100644 --- a/src/google/protobuf/arena_unittest.cc +++ b/src/google/protobuf/arena_unittest.cc @@ -953,20 +953,6 @@ TEST(ArenaTest, AddAllocatedWithReflection) { } TEST(ArenaTest, RepeatedPtrFieldAddClearedTest) { -#ifndef PROTOBUF_FUTURE_REMOVE_CLEARED_API - { - PROTOBUF_IGNORE_DEPRECATION_START - RepeatedPtrField repeated_field; - EXPECT_TRUE(repeated_field.empty()); - EXPECT_EQ(0, repeated_field.size()); - // Ownership is passed to repeated_field. - TestAllTypes* cleared = new TestAllTypes(); - repeated_field.AddCleared(cleared); - EXPECT_TRUE(repeated_field.empty()); - EXPECT_EQ(0, repeated_field.size()); - PROTOBUF_IGNORE_DEPRECATION_STOP - } -#endif // !PROTOBUF_FUTURE_REMOVE_CLEARED_API { RepeatedPtrField repeated_field; EXPECT_TRUE(repeated_field.empty()); diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 9fdb3ff5c8..c0307c0b75 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -159,10 +159,6 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3), #ifdef PROTOBUF_FUTURE_BREAKING_CHANGES -// Used to remove the manipulation of cleared elements in RepeatedPtrField. -// Owner: mkruskal@ -#define PROTOBUF_FUTURE_REMOVE_CLEARED_API 1 - // Used for descriptor proto extension declarations. // Owner: shaod@, gberg@ #define PROTOBUF_FUTURE_DESCRIPTOR_EXTENSION_DECL 1 diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc index b64343632a..a107fb325f 100644 --- a/src/google/protobuf/port_undef.inc +++ b/src/google/protobuf/port_undef.inc @@ -84,7 +84,6 @@ #ifdef PROTOBUF_FUTURE_BREAKING_CHANGES #undef PROTOBUF_FUTURE_BREAKING_CHANGES -#undef PROTOBUF_FUTURE_REMOVE_CLEARED_API #undef PROTOBUF_FUTURE_DESCRIPTOR_EXTENSION_DECL #endif diff --git a/src/google/protobuf/repeated_field_unittest.cc b/src/google/protobuf/repeated_field_unittest.cc index fb9c85bdb4..d99aae6f52 100644 --- a/src/google/protobuf/repeated_field_unittest.cc +++ b/src/google/protobuf/repeated_field_unittest.cc @@ -1675,19 +1675,6 @@ TEST(RepeatedPtrField, ClearedElements) { field.Clear(); EXPECT_EQ(field.ClearedCount(), 2); -#ifndef PROTOBUF_FUTURE_REMOVE_CLEARED_API - EXPECT_EQ(field.ReleaseCleared(), original); // Take ownership again. - EXPECT_EQ(field.ClearedCount(), 1); - EXPECT_NE(field.Add(), original); - EXPECT_EQ(field.ClearedCount(), 0); - EXPECT_NE(field.Add(), original); - EXPECT_EQ(field.ClearedCount(), 0); - - field.AddCleared(original); // Give ownership back, but as a cleared object. - EXPECT_EQ(field.ClearedCount(), 1); - EXPECT_EQ(field.Add(), original); - EXPECT_EQ(field.ClearedCount(), 0); -#endif // !PROTOBUF_FUTURE_REMOVE_CLEARED_API PROTOBUF_IGNORE_DEPRECATION_STOP } diff --git a/src/google/protobuf/repeated_ptr_field.h b/src/google/protobuf/repeated_ptr_field.h index 9c15b3762a..f48d41de76 100644 --- a/src/google/protobuf/repeated_ptr_field.h +++ b/src/google/protobuf/repeated_ptr_field.h @@ -1174,26 +1174,6 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { ABSL_DEPRECATED("This will be removed in a future release") int ClearedCount() const; -#ifndef PROTOBUF_FUTURE_REMOVE_CLEARED_API - // Adds an element to the pool of cleared objects, passing ownership to - // the RepeatedPtrField. The element must be cleared prior to calling - // this method. - // - // This method cannot be called when either the repeated field or |value| is - // on an arena; both cases will trigger a ABSL_DCHECK-failure. - ABSL_DEPRECATED("This will be removed in a future release") - void AddCleared(Element* value); - // Removes and returns a single element from the cleared pool, passing - // ownership to the caller. The element is guaranteed to be cleared. - // Requires: ClearedCount() > 0 - // - // This method cannot be called when the repeated field is on an arena; doing - // so will trigger a ABSL_DCHECK-failure. - PROTOBUF_NODISCARD - ABSL_DEPRECATED("This will be removed in a future release") - pointer ReleaseCleared(); -#endif // !PROTOBUF_FUTURE_REMOVE_CLEARED_API - // Removes the element referenced by position. // // Returns an iterator to the element immediately following the removed @@ -1593,18 +1573,6 @@ inline int RepeatedPtrField::ClearedCount() const { return RepeatedPtrFieldBase::ClearedCount(); } -#ifndef PROTOBUF_FUTURE_REMOVE_CLEARED_API -template -inline void RepeatedPtrField::AddCleared(Element* value) { - return RepeatedPtrFieldBase::AddCleared(value); -} - -template -inline Element* RepeatedPtrField::ReleaseCleared() { - return RepeatedPtrFieldBase::ReleaseCleared(); -} -#endif // !PROTOBUF_FUTURE_REMOVE_CLEARED_API - template inline void RepeatedPtrField::Reserve(int new_size) { return RepeatedPtrFieldBase::Reserve(new_size);