Skip to content

Commit 768db14

Browse files
ClaytonKnittelmkruskal-google
authored andcommitted
Add a macro to make RepeatedField(Arena*) constructor private in a future release.
PiperOrigin-RevId: 816029788
1 parent 543a17f commit 768db14

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/google/protobuf/port_def.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),
169169
// Owner: cknittel@, mkruskal@
170170
#define PROTOBUF_FUTURE_REMOVE_MAP_FIELD_ARENA_CONSTRUCTOR 1
171171

172+
// Removes the public RepeatedField(Arena*) constructor.
173+
// Owner: cknittel@, mkruskal@
174+
#define PROTOBUF_FUTURE_REMOVE_REPEATED_FIELD_ARENA_CONSTRUCTOR 1
175+
172176
#else
173177

174178
#define PROTOBUF_FUTURE_ADD_NODISCARD

src/google/protobuf/repeated_field.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ namespace protobuf {
5858

5959
class Message;
6060
class UnknownField; // For the allowlist
61+
class UnknownFieldSet;
62+
class DynamicMessage;
6163

6264
namespace internal {
6365

@@ -290,8 +292,10 @@ class ABSL_ATTRIBUTE_WARN_UNUSED RepeatedField final
290292
constexpr RepeatedField();
291293
RepeatedField(const RepeatedField& rhs) : RepeatedField(nullptr, rhs) {}
292294

295+
#ifndef PROTOBUF_FUTURE_REMOVE_REPEATED_FIELD_ARENA_CONSTRUCTOR
293296
// TODO: make this constructor private
294297
explicit RepeatedField(Arena* arena);
298+
#endif
295299

296300
template <typename Iter,
297301
typename = typename std::enable_if<std::is_constructible<
@@ -486,12 +490,22 @@ class ABSL_ATTRIBUTE_WARN_UNUSED RepeatedField final
486490

487491
friend class Arena;
488492

493+
#ifdef PROTOBUF_FUTURE_REMOVE_REPEATED_FIELD_ARENA_CONSTRUCTOR
494+
// For access to private arena constructor.
495+
friend class UnknownFieldSet;
496+
friend class DynamicMessage;
497+
#endif
498+
489499
static constexpr int kSooCapacityElements =
490500
internal::SooCapacityElements<Element>();
491501

492502
static constexpr int kInitialSize = 0;
493503
static PROTOBUF_CONSTEXPR const size_t kHeapRepHeaderSize = sizeof(HeapRep);
494504

505+
#ifdef PROTOBUF_FUTURE_REMOVE_REPEATED_FIELD_ARENA_CONSTRUCTOR
506+
explicit RepeatedField(Arena* arena);
507+
#endif
508+
495509
RepeatedField(Arena* arena, const RepeatedField& rhs);
496510
RepeatedField(Arena* arena, RepeatedField&& rhs);
497511

0 commit comments

Comments
 (0)