diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc index 674cb5528b..3581344946 100644 --- a/src/google/protobuf/extension_set.cc +++ b/src/google/protobuf/extension_set.cc @@ -180,14 +180,6 @@ void ExtensionSet::RegisterMessageExtension(const MessageLite* extendee, // =================================================================== // Constructors and basic methods. -ExtensionSet::ExtensionSet(Arena* arena) - : arena_(arena), - flat_capacity_(0), - flat_size_(0), - map_{flat_capacity_ == 0 - ? nullptr - : Arena::CreateArray(arena_, flat_capacity_)} {} - ExtensionSet::~ExtensionSet() { // Deletes all allocated extensions. if (arena_ == nullptr) { diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h index bfd75a5c61..52b22c798e 100644 --- a/src/google/protobuf/extension_set.h +++ b/src/google/protobuf/extension_set.h @@ -49,6 +49,7 @@ #include "absl/base/call_once.h" #include "absl/container/btree_map.h" #include "absl/log/absl_check.h" +#include "google/protobuf/internal_visibility.h" #include "google/protobuf/port.h" #include "google/protobuf/port.h" #include "google/protobuf/io/coded_stream.h" @@ -194,10 +195,18 @@ class PROTOBUF_EXPORT GeneratedExtensionFinder { // off to the ExtensionSet for parsing. Etc. class PROTOBUF_EXPORT ExtensionSet { public: - constexpr ExtensionSet(); - explicit ExtensionSet(Arena* arena); + constexpr ExtensionSet() : ExtensionSet(nullptr) {} + ExtensionSet(const ExtensionSet& rhs) = delete; + + // Arena enabled constructors: for internal use only. + ExtensionSet(internal::InternalVisibility, Arena* arena) + : ExtensionSet(arena) {} + + // TODO(b/290091828): make constructor private, and migrate `ArenaInitialized` + // to `InternalVisibility` overloaded constructor(s). + explicit constexpr ExtensionSet(Arena* arena); ExtensionSet(ArenaInitialized, Arena* arena) : ExtensionSet(arena) {} - ExtensionSet(const ExtensionSet&) = delete; + ExtensionSet& operator=(const ExtensionSet&) = delete; ~ExtensionSet(); @@ -932,8 +941,8 @@ class PROTOBUF_EXPORT ExtensionSet { static void DeleteFlatMap(const KeyValue* flat, uint16_t flat_capacity); }; -constexpr ExtensionSet::ExtensionSet() - : arena_(nullptr), flat_capacity_(0), flat_size_(0), map_{nullptr} {} +constexpr ExtensionSet::ExtensionSet(Arena* arena) + : arena_(arena), flat_capacity_(0), flat_size_(0), map_{nullptr} {} // These are just for convenience... inline void ExtensionSet::SetString(int number, FieldType type,