Breaking change: Remove deprecated clear APIs on repeated fields

PiperOrigin-RevId: 589920681
pull/14994/head
Mike Kruskal 12 months ago committed by Copybara-Service
parent cf2d6965dc
commit 229906f309
  1. 14
      src/google/protobuf/arena_unittest.cc
  2. 4
      src/google/protobuf/port_def.inc
  3. 1
      src/google/protobuf/port_undef.inc
  4. 13
      src/google/protobuf/repeated_field_unittest.cc
  5. 32
      src/google/protobuf/repeated_ptr_field.h

@ -953,20 +953,6 @@ TEST(ArenaTest, AddAllocatedWithReflection) {
}
TEST(ArenaTest, RepeatedPtrFieldAddClearedTest) {
#ifndef PROTOBUF_FUTURE_REMOVE_CLEARED_API
{
PROTOBUF_IGNORE_DEPRECATION_START
RepeatedPtrField<TestAllTypes> 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<TestAllTypes> repeated_field;
EXPECT_TRUE(repeated_field.empty());

@ -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

@ -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

@ -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
}

@ -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<Element>::ClearedCount() const {
return RepeatedPtrFieldBase::ClearedCount();
}
#ifndef PROTOBUF_FUTURE_REMOVE_CLEARED_API
template <typename Element>
inline void RepeatedPtrField<Element>::AddCleared(Element* value) {
return RepeatedPtrFieldBase::AddCleared<TypeHandler>(value);
}
template <typename Element>
inline Element* RepeatedPtrField<Element>::ReleaseCleared() {
return RepeatedPtrFieldBase::ReleaseCleared<TypeHandler>();
}
#endif // !PROTOBUF_FUTURE_REMOVE_CLEARED_API
template <typename Element>
inline void RepeatedPtrField<Element>::Reserve(int new_size) {
return RepeatedPtrFieldBase::Reserve(new_size);

Loading…
Cancel
Save