Skip to content

Commit

Permalink
Breaking change: Remove deprecated clear APIs on repeated fields
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 589920681
  • Loading branch information
mkruskal-google authored and copybara-github committed Dec 11, 2023
1 parent cf2d696 commit 229906f
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 64 deletions.
14 changes: 0 additions & 14 deletions src/google/protobuf/arena_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 0 additions & 4 deletions src/google/protobuf/port_def.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/google/protobuf/port_undef.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 0 additions & 13 deletions src/google/protobuf/repeated_field_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
32 changes: 0 additions & 32 deletions src/google/protobuf/repeated_ptr_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 229906f

Please sign in to comment.