Skip to content

Commit ef890c3

Browse files
ClaytonKnittelcopybara-github
authored andcommitted
Breaking change: Make the arena-enabled constructors of RepeatedField, RepeatedPtrField, and Map private.
If you would like to construct one of these fields with arena storage, you must construct them on an arena. For example: ```cc RepeatedPtrField<MyMessage> rpf(arena); ``` should be changed to: ```cc auto* rpf = Arena::Create<RepeatedPtrField<MyMessage>>(arena); ``` PiperOrigin-RevId: 820040847
1 parent 3cc5e07 commit ef890c3

File tree

5 files changed

+0
-43
lines changed

5 files changed

+0
-43
lines changed

src/google/protobuf/map.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,22 +1181,12 @@ class Map : private internal::KeyMapBase<internal::KeyForBase<Key>> {
11811181
CopyFromImpl(arena(), other);
11821182
}
11831183
#else
1184-
// If PROTOBUF_FUTURE_REMOVE_MAP_FIELD_ARENA_CONSTRUCTOR is defined, make the
1185-
// arena-enabled constructor private.
1186-
#ifdef PROTOBUF_FUTURE_REMOVE_MAP_FIELD_ARENA_CONSTRUCTOR
11871184

11881185
private:
1189-
#endif
11901186
explicit Map(Arena* arena) : Base(arena, GetTypeInfo()) {
11911187
StaticValidityCheck();
11921188
}
11931189

1194-
// If PROTOBUF_FUTURE_REMOVE_MAP_FIELD_ARENA_CONSTRUCTOR was not defined, we
1195-
// need to add the private tag here.
1196-
#ifndef PROTOBUF_FUTURE_REMOVE_MAP_FIELD_ARENA_CONSTRUCTOR
1197-
1198-
private:
1199-
#endif
12001190
Map(Arena* arena, const Map& other) : Map(arena) {
12011191
StaticValidityCheck();
12021192
CopyFromImpl(arena, other);

src/google/protobuf/port_def.inc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,6 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),
161161
// Owner: cknittel@, mkruskal@
162162
#define PROTOBUF_FUTURE_NO_RECURSIVE_MESSAGE_COPY 1
163163

164-
// Removes the public RepeatedPtrField(Arena*) constructor.
165-
// Owner: cknittel@, mkruskal@
166-
#define PROTOBUF_FUTURE_REMOVE_REPEATED_PTR_FIELD_ARENA_CONSTRUCTOR 1
167-
168-
// Removes the public Map(Arena*) constructor.
169-
// Owner: cknittel@, mkruskal@
170-
#define PROTOBUF_FUTURE_REMOVE_MAP_FIELD_ARENA_CONSTRUCTOR 1
171-
172-
// Removes the public RepeatedField(Arena*) constructor.
173-
// Owner: cknittel@, mkruskal@
174-
#define PROTOBUF_FUTURE_REMOVE_REPEATED_FIELD_ARENA_CONSTRUCTOR 1
175-
176164
#else
177165

178166
#define PROTOBUF_FUTURE_ADD_NODISCARD

src/google/protobuf/port_undef.inc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@
7777
#undef PROTOBUF_FUTURE_REMOVE_CREATEMESSAGE
7878
#undef PROTOBUF_FUTURE_ADD_NODISCARD
7979
#undef PROTOBUF_FUTURE_NO_RECURSIVE_MESSAGE_COPY
80-
#undef PROTOBUF_FUTURE_REMOVE_REPEATED_PTR_FIELD_ARENA_CONSTRUCTOR
81-
#undef PROTOBUF_FUTURE_REMOVE_MAP_FIELD_ARENA_CONSTRUCTOR
8280
#endif
8381

8482
#include "google/protobuf/os_macros_restore.inc"

src/google/protobuf/repeated_field.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,6 @@ class ABSL_ATTRIBUTE_WARN_UNUSED PROTOBUF_DECLSPEC_EMPTY_BASES
403403
RepeatedField(const RepeatedField& rhs) : RepeatedField(nullptr, rhs) {}
404404
#endif
405405

406-
#ifndef PROTOBUF_INTERNAL_REMOVE_ARENA_PTRS_REPEATED_FIELD
407-
#ifndef PROTOBUF_FUTURE_REMOVE_REPEATED_FIELD_ARENA_CONSTRUCTOR
408-
// TODO: make this constructor private
409-
explicit RepeatedField(Arena* arena);
410-
#endif
411-
#endif
412-
413406
template <typename Iter,
414407
typename = typename std::enable_if<std::is_constructible<
415408
Element, decltype(*std::declval<Iter>())>::value>::type>
@@ -630,10 +623,8 @@ class ABSL_ATTRIBUTE_WARN_UNUSED PROTOBUF_DECLSPEC_EMPTY_BASES
630623

631624
friend class internal::FieldWithArena<RepeatedField<Element>>;
632625

633-
#ifdef PROTOBUF_FUTURE_REMOVE_REPEATED_FIELD_ARENA_CONSTRUCTOR
634626
// For access to private arena constructor.
635627
friend class UnknownFieldSet;
636-
#endif
637628

638629
static constexpr int kSooCapacityElements =
639630
internal::SooCapacityElements<Element>();
@@ -647,9 +638,7 @@ class ABSL_ATTRIBUTE_WARN_UNUSED PROTOBUF_DECLSPEC_EMPTY_BASES
647638
const RepeatedField& rhs);
648639
RepeatedField(internal::InternalMetadataOffset offset, RepeatedField&& rhs);
649640
#else
650-
#ifdef PROTOBUF_FUTURE_REMOVE_REPEATED_FIELD_ARENA_CONSTRUCTOR
651641
explicit RepeatedField(Arena* arena);
652-
#endif
653642

654643
RepeatedField(Arena* arena, const RepeatedField& rhs);
655644
RepeatedField(Arena* arena, RepeatedField&& rhs);

src/google/protobuf/repeated_ptr_field.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,12 +1149,6 @@ class ABSL_ATTRIBUTE_WARN_UNUSED RepeatedPtrField final
11491149
RepeatedPtrField(internal::InternalVisibility, Arena* arena,
11501150
RepeatedPtrField&& rhs)
11511151
: RepeatedPtrField(arena, std::move(rhs)) {}
1152-
1153-
#ifndef PROTOBUF_FUTURE_REMOVE_REPEATED_PTR_FIELD_ARENA_CONSTRUCTOR
1154-
// TODO: make constructor private
1155-
[[deprecated("Use Arena::Create<RepeatedPtrField<...>>(Arena*) instead")]]
1156-
explicit RepeatedPtrField(Arena* arena);
1157-
#endif
11581152
#endif // !PROTOBUF_INTERNAL_REMOVE_ARENA_PTRS_REPEATED_PTR_FIELD
11591153

11601154
template <typename Iter,
@@ -1504,9 +1498,7 @@ class ABSL_ATTRIBUTE_WARN_UNUSED RepeatedPtrField final
15041498
RepeatedPtrField(Arena* arena, const RepeatedPtrField& rhs);
15051499
RepeatedPtrField(Arena* arena, RepeatedPtrField&& rhs);
15061500

1507-
#ifdef PROTOBUF_FUTURE_REMOVE_REPEATED_PTR_FIELD_ARENA_CONSTRUCTOR
15081501
explicit RepeatedPtrField(Arena* arena);
1509-
#endif
15101502
#endif // !PROTOBUF_INTERNAL_REMOVE_ARENA_PTRS_REPEATED_PTR_FIELD
15111503

15121504

0 commit comments

Comments
 (0)