GetArena() instead of GetArenaForAllocation().

PiperOrigin-RevId: 570142494
pull/14266/head
Protobuf Team Bot 1 year ago committed by Copybara-Service
parent 1f720d9d8a
commit ebb1b0550a
  1. 2
      python/google/protobuf/pyext/message.cc
  2. 35
      src/google/protobuf/arena.h
  3. 14
      src/google/protobuf/compiler/cpp/field_generators/cord_field.cc
  4. 4
      src/google/protobuf/compiler/cpp/field_generators/enum_field.cc
  5. 27
      src/google/protobuf/compiler/cpp/field_generators/message_field.cc
  6. 2
      src/google/protobuf/compiler/cpp/field_generators/primitive_field.cc
  7. 20
      src/google/protobuf/compiler/cpp/field_generators/string_field.cc
  8. 8
      src/google/protobuf/compiler/cpp/message.cc
  9. 24
      src/google/protobuf/compiler/plugin.pb.cc
  10. 92
      src/google/protobuf/compiler/plugin.pb.h
  11. 2
      src/google/protobuf/cpp_features.pb.cc
  12. 124
      src/google/protobuf/descriptor.pb.cc
  13. 632
      src/google/protobuf/descriptor.pb.h
  14. 31
      src/google/protobuf/dynamic_message.cc
  15. 72
      src/google/protobuf/generated_message_reflection.cc
  16. 2
      src/google/protobuf/generated_message_tctable_impl.h
  17. 18
      src/google/protobuf/generated_message_tctable_lite.cc
  18. 6
      src/google/protobuf/map_entry.h
  19. 4
      src/google/protobuf/message_lite.h

@ -899,7 +899,7 @@ int DeleteRepeatedField(
}
}
Arena* arena = Arena::InternalGetArenaForAllocation(message);
Arena* arena = message->GetArena();
ABSL_DCHECK_EQ(arena, nullptr)
<< "python protobuf is expected to be allocated from heap";
// Remove items, starting from the end.

@ -389,8 +389,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
// mutually exclusive fashion, we use implicit conversions to base classes
// to force an explicit ranking for our preferences. The lowest ranked
// version that compiles will be accepted.
struct Rank2 {};
struct Rank1 : Rank2 {};
struct Rank1 {};
struct Rank0 : Rank1 {};
static Arena* GetOwningArena(const T* p) {
@ -410,31 +409,16 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
static void InternalSwap(T* a, T* b) { a->InternalSwap(b); }
static Arena* GetArenaForAllocation(T* p) {
return GetArenaForAllocation(Rank0{}, p);
}
static Arena* GetArena(T* p) {
// Rather than replicate probing for `GetArena` with fallback to nullptr,
// we borrow the implementation of `GetArenaForAllocation` but skip
// `Rank0` which probes for `GetArenaForAllocation`.
return GetArenaForAllocation(Rank1{}, p);
}
template <typename U>
static auto GetArenaForAllocation(Rank0, U* p)
-> EnableIfArena<decltype(p->GetArenaForAllocation())> {
return p->GetArenaForAllocation();
}
static Arena* GetArena(T* p) { return GetArena(Rank0{}, p); }
template <typename U>
static auto GetArenaForAllocation(Rank1, U* p)
static auto GetArena(Rank0, U* p)
-> EnableIfArena<decltype(p->GetArena())> {
return p->GetArena();
}
template <typename U>
static Arena* GetArenaForAllocation(Rank2, U*) {
static Arena* GetArena(Rank1, U*) {
return nullptr;
}
@ -481,11 +465,18 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
return InternalHelper<T>::GetOwningArena(p);
}
// Provides access to protected GetArenaForAllocation to generated messages.
// Wraps InternalGetArena() and will be removed soon.
// For internal use only.
template <typename T>
static Arena* InternalGetArenaForAllocation(T* p) {
return InternalHelper<T>::GetArenaForAllocation(p);
return InternalHelper<T>::GetArena(p);
}
// Provides access to protected GetArena to generated messages.
// For internal use only.
template <typename T>
static Arena* InternalGetArena(T* p) {
return InternalHelper<T>::GetArena(p);
}
// Helper typetraits that indicates support for arenas in a type T at compile

@ -366,8 +366,8 @@ void CordOneofFieldGenerator::GenerateInlineAccessorDefinitions(
clear_$oneof_name$();
set_has_$name$();
$field$ = new ::absl::Cord;
if (GetArenaForAllocation() != nullptr) {
GetArenaForAllocation()->Own($field$);
if (GetArena() != nullptr) {
GetArena()->Own($field$);
}
}
*$field$ = value;
@ -386,8 +386,8 @@ void CordOneofFieldGenerator::GenerateInlineAccessorDefinitions(
clear_$oneof_name$();
set_has_$name$();
$field$ = new ::absl::Cord;
if (GetArenaForAllocation() != nullptr) {
GetArenaForAllocation()->Own($field$);
if (GetArena() != nullptr) {
GetArena()->Own($field$);
}
}
*$field$ = value;
@ -401,8 +401,8 @@ void CordOneofFieldGenerator::GenerateInlineAccessorDefinitions(
clear_$oneof_name$();
set_has_$name$();
$field$ = new ::absl::Cord;
if (GetArenaForAllocation() != nullptr) {
GetArenaForAllocation()->Own($field$);
if (GetArena() != nullptr) {
GetArena()->Own($field$);
}
}
return $field$;
@ -425,7 +425,7 @@ void CordOneofFieldGenerator::GenerateNonInlineAccessorDefinitions(
void CordOneofFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
format(
"if (GetArenaForAllocation() == nullptr) {\n"
"if (GetArena() == nullptr) {\n"
" delete $field$;\n"
"}\n");
}

@ -450,8 +450,8 @@ void RepeatedEnum::GenerateInlineAccessorDefinitions(io::Printer* p) const {
$TsanDetectConcurrentRead$;
$PrepareSplitMessageForWrite$;
if ($field_$.IsDefault()) {
$field_$.Set($pb$::Arena::CreateMessage<$pb$::RepeatedField<int>>(
GetArenaForAllocation()));
$field_$.Set(
$pb$::Arena::CreateMessage<$pb$::RepeatedField<int>>(GetArena()));
}
return $field_$.Get();
}

@ -212,7 +212,7 @@ void SingularMessage::GenerateInlineAccessorDefinitions(io::Printer* p) const {
$PrepareSplitMessageForWrite$;
//~ If we're not on an arena, free whatever we were holding before.
//~ (If we are on arena, we can just forget the earlier pointer.)
if (GetArenaForAllocation() == nullptr) {
if (GetArena() == nullptr) {
delete reinterpret_cast<$pb$::MessageLite*>($field_$);
}
$field_$ = reinterpret_cast<$MemberType$*>(value);
@ -232,11 +232,11 @@ void SingularMessage::GenerateInlineAccessorDefinitions(io::Printer* p) const {
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
auto* old = reinterpret_cast<$pb$::MessageLite*>(released);
released = $pbi$::DuplicateIfNonNull(released);
if (GetArenaForAllocation() == nullptr) {
if (GetArena() == nullptr) {
delete old;
}
#else // PROTOBUF_FORCE_COPY_IN_RELEASE
if (GetArenaForAllocation() != nullptr) {
if (GetArena() != nullptr) {
released = $pbi$::DuplicateIfNonNull(released);
}
#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE
@ -259,7 +259,7 @@ void SingularMessage::GenerateInlineAccessorDefinitions(io::Printer* p) const {
$StrongRef$;
$set_hasbit$;
if ($field_$ == nullptr) {
auto* p = CreateMaybeMessage<$Submsg$>(GetArenaForAllocation());
auto* p = CreateMaybeMessage<$Submsg$>(GetArena());
$field_$ = reinterpret_cast<$MemberType$*>(p);
}
return $cast_field_$;
@ -276,7 +276,7 @@ void SingularMessage::GenerateInlineAccessorDefinitions(io::Printer* p) const {
//~ We handle the most common case inline, and delegate less common
//~ cases to the slow fallback function.
inline void $Msg$::set_allocated_$name$($Submsg$* value) {
$pb$::Arena* message_arena = GetArenaForAllocation();
$pb$::Arena* message_arena = GetArena();
$TsanDetectConcurrentMutation$;
$PrepareSplitMessageForWrite$;
if (message_arena == nullptr) {
@ -378,7 +378,7 @@ void SingularMessage::GenerateInternalAccessorDefinitions(
$update_hasbit$;
if ($is_already_set$) {
$clear_oneof$;
msg->$field_$ = $kDefaultPtr$->New(msg->GetArenaForAllocation());
msg->$field_$ = $kDefaultPtr$->New(msg->GetArena());
}
return msg->$field_$;
}
@ -390,7 +390,7 @@ void SingularMessage::GenerateClearingCode(io::Printer* p) const {
// If we don't have has-bits, message presence is indicated only by ptr !=
// nullptr. Thus on clear, we need to delete the object.
p->Emit(
"if (GetArenaForAllocation() == nullptr && $field_$ != nullptr) {\n"
"if (GetArena() == nullptr && $field_$ != nullptr) {\n"
" delete $field_$;\n"
"}\n"
"$field_$ = nullptr;\n");
@ -404,7 +404,7 @@ void SingularMessage::GenerateMessageClearingCode(io::Printer* p) const {
// If we don't have has-bits, message presence is indicated only by ptr !=
// nullptr. Thus on clear, we need to delete the object.
p->Emit(
"if (GetArenaForAllocation() == nullptr && $field_$ != nullptr) {\n"
"if (GetArena() == nullptr && $field_$ != nullptr) {\n"
" delete $field_$;\n"
"}\n"
"$field_$ = nullptr;\n");
@ -572,7 +572,7 @@ class OneofMessage : public SingularMessage {
void OneofMessage::GenerateNonInlineAccessorDefinitions(io::Printer* p) const {
p->Emit(R"cc(
void $Msg$::set_allocated_$name$($Submsg$* $name$) {
$pb$::Arena* message_arena = GetArenaForAllocation();
$pb$::Arena* message_arena = GetArena();
clear_$oneof_name$();
if ($name$) {
$pb$::Arena* submessage_arena =
@ -602,7 +602,7 @@ void OneofMessage::GenerateInlineAccessorDefinitions(io::Printer* p) const {
if ($has_field$) {
clear_has_$oneof_name$();
auto* temp = $cast_field_$;
if (GetArenaForAllocation() != nullptr) {
if (GetArena() != nullptr) {
temp = $pbi$::DuplicateIfNonNull(temp);
}
$field_$ = nullptr;
@ -660,8 +660,7 @@ void OneofMessage::GenerateInlineAccessorDefinitions(io::Printer* p) const {
if ($not_has_field$) {
clear_$oneof_name$();
set_has_$name$();
$field_$ =
$weak_cast$(CreateMaybeMessage<$Submsg$>(GetArenaForAllocation()));
$field_$ = $weak_cast$(CreateMaybeMessage<$Submsg$>(GetArena()));
}
return $cast_field_$;
}
@ -678,7 +677,7 @@ void OneofMessage::GenerateInlineAccessorDefinitions(io::Printer* p) const {
void OneofMessage::GenerateClearingCode(io::Printer* p) const {
p->Emit(R"cc(
if (GetArenaForAllocation() == nullptr) {
if (GetArena() == nullptr) {
delete $field_$;
})cc");
}
@ -858,7 +857,7 @@ void RepeatedMessage::GenerateInlineAccessorDefinitions(io::Printer* p) const {
if ($field_$.IsDefault()) {
$field_$.Set(
CreateMaybeMessage<$pb$::$Weak$RepeatedPtrField<$Submsg$>>(
GetArenaForAllocation()));
GetArena()));
}
return $field_$.Get();
}

@ -520,7 +520,7 @@ void RepeatedPrimitive::GenerateInlineAccessorDefinitions(
$PrepareSplitMessageForWrite$;
if ($field_$.IsDefault()) {
$field_$.Set($pb$::Arena::CreateMessage<$pb$::RepeatedField<$Type$>>(
GetArenaForAllocation()));
GetArena()));
}
return $field_$.Get();
}

@ -291,11 +291,11 @@ void UpdateHasbitSet(io::Printer* p, bool is_oneof) {
void ArgsForSetter(io::Printer* p, bool inlined) {
if (!inlined) {
p->Emit("GetArenaForAllocation()");
p->Emit("GetArena()");
return;
}
p->Emit(
"GetArenaForAllocation(), _internal_$name$_donated(), "
"GetArena(), _internal_$name$_donated(), "
"&$donating_states_word$, $mask_for_undonate$, this");
}
@ -325,7 +325,7 @@ void SingularString::ReleaseImpl(io::Printer* p) const {
}
$clear_hasbit$;
return $field_$.Release(GetArenaForAllocation(), _internal_$name$_donated());
return $field_$.Release(GetArena(), _internal_$name$_donated());
)cc");
return;
}
@ -361,7 +361,7 @@ void SingularString::SetAllocatedImpl(io::Printer* p) const {
}
if (value != nullptr) {
set_has_$name$();
$field_$.InitAllocated(value, GetArenaForAllocation());
$field_$.InitAllocated(value, GetArena());
}
)cc");
return;
@ -512,7 +512,7 @@ void SingularString::GenerateClearingCode(io::Printer* p) const {
ABSL_DCHECK(!is_inlined());
p->Emit(R"cc(
$field_$.ClearToDefault($lazy_var$, GetArenaForAllocation());
$field_$.ClearToDefault($lazy_var$, GetArena());
)cc");
}
@ -551,7 +551,7 @@ void SingularString::GenerateMessageClearingCode(io::Printer* p) const {
// Clear to a non-empty default is more involved, as we try to use the
// Arena if one is present and may need to reallocate the string.
p->Emit(R"cc(
$field_$.ClearToDefault($lazy_var$, GetArenaForAllocation());
$field_$.ClearToDefault($lazy_var$, GetArena());
)cc");
return;
}
@ -599,7 +599,7 @@ void SingularString::GenerateConstructorCode(io::Printer* p) const {
if (IsString(field_, *opts_) && EmptyDefault()) {
p->Emit(R"cc(
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
$field_$.Set("", GetArenaForAllocation());
$field_$.Set("", GetArena());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
)cc");
}
@ -626,10 +626,10 @@ void SingularString::GenerateCopyConstructorCode(io::Printer* p) const {
{"set_args",
[&] {
if (!is_inlined()) {
p->Emit("_this->GetArenaForAllocation()");
p->Emit("_this->GetArena()");
} else {
p->Emit(
"_this->GetArenaForAllocation(), "
"_this->GetArena(), "
"_this->_internal_$name$_donated(), "
"&_this->$donating_states_word$, $mask_for_undonate$, _this");
}
@ -972,7 +972,7 @@ void RepeatedString::GenerateInlineAccessorDefinitions(io::Printer* p) const {
if ($field_$.IsDefault()) {
$field_$.Set(
$pb$::Arena::CreateMessage<$pb$::RepeatedPtrField<std::string>>(
GetArenaForAllocation()));
GetArena()));
}
return $field_$.Get();
}

@ -2099,7 +2099,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* p) {
"void $classname$::PrepareSplitMessageForWrite() {\n"
" if (PROTOBUF_PREDICT_TRUE(IsSplitMessageDefault())) {\n"
" void* chunk = $pbi$::CreateSplitMessageGeneric("
"GetArenaForAllocation(), &$1$, sizeof(Impl_::Split), this, &$2$);\n"
"GetArena(), &$1$, sizeof(Impl_::Split), this, &$2$);\n"
" $split$ = reinterpret_cast<Impl_::Split*>(chunk);\n"
" }\n"
"}\n",
@ -2749,7 +2749,7 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* p) {
},
R"cc(
inline void $classname$::SharedDtor() {
$DCHK$(GetArenaForAllocation() == nullptr);
$DCHK$(GetArena() == nullptr);
$extensions_dtor$;
$field_dtors$;
$split_field_dtors$;
@ -3854,8 +3854,8 @@ void MessageGenerator::GenerateSwap(io::Printer* p) {
if (HasNonSplitOptionalString(descriptor_, options_)) {
p->Emit(R"cc(
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
)cc");
}
format("_internal_metadata_.InternalSwap(&other->_internal_metadata_);\n");

@ -374,7 +374,7 @@ Version::~Version() {
SharedDtor();
}
inline void Version::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.suffix_.Destroy();
_impl_.~Impl_();
}
@ -592,8 +592,8 @@ PROTOBUF_NOINLINE bool Version::IsInitialized() const {
}
void Version::InternalSwap(Version* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
::_pbi::ArenaStringPtr::InternalSwap(&_impl_.suffix_, &other->_impl_.suffix_, arena);
@ -687,7 +687,7 @@ CodeGeneratorRequest::~CodeGeneratorRequest() {
SharedDtor();
}
inline void CodeGeneratorRequest::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.parameter_.Destroy();
if (this != internal_default_instance()) delete _impl_.compiler_version_;
_impl_.~Impl_();
@ -940,8 +940,8 @@ PROTOBUF_NOINLINE bool CodeGeneratorRequest::IsInitialized() const {
}
void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.file_to_generate_.InternalSwap(&other->_impl_.file_to_generate_);
@ -1034,7 +1034,7 @@ CodeGeneratorResponse_File::~CodeGeneratorResponse_File() {
SharedDtor();
}
inline void CodeGeneratorResponse_File::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.name_.Destroy();
_impl_.insertion_point_.Destroy();
_impl_.content_.Destroy();
@ -1267,8 +1267,8 @@ PROTOBUF_NOINLINE bool CodeGeneratorResponse_File::IsInitialized() const {
}
void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, &other->_impl_.name_, arena);
@ -1340,7 +1340,7 @@ CodeGeneratorResponse::~CodeGeneratorResponse() {
SharedDtor();
}
inline void CodeGeneratorResponse::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.error_.Destroy();
_impl_.~Impl_();
}
@ -1534,8 +1534,8 @@ PROTOBUF_NOINLINE bool CodeGeneratorResponse::IsInitialized() const {
}
void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.file_.InternalSwap(&other->_impl_.file_);

@ -1210,7 +1210,7 @@ inline PROTOBUF_ALWAYS_INLINE void Version::set_suffix(Arg_&& arg,
Args_... args) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000001u;
_impl_.suffix_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
_impl_.suffix_.Set(static_cast<Arg_&&>(arg), args..., GetArena());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix)
}
inline std::string* Version::mutable_suffix() ABSL_ATTRIBUTE_LIFETIME_BOUND {
@ -1225,12 +1225,12 @@ inline const std::string& Version::_internal_suffix() const {
inline void Version::_internal_set_suffix(const std::string& value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000001u;
_impl_.suffix_.Set(value, GetArenaForAllocation());
_impl_.suffix_.Set(value, GetArena());
}
inline std::string* Version::_internal_mutable_suffix() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000001u;
return _impl_.suffix_.Mutable( GetArenaForAllocation());
return _impl_.suffix_.Mutable( GetArena());
}
inline std::string* Version::release_suffix() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
@ -1241,7 +1241,7 @@ inline std::string* Version::release_suffix() {
_impl_._has_bits_[0] &= ~0x00000001u;
auto* released = _impl_.suffix_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.suffix_.Set("", GetArenaForAllocation());
_impl_.suffix_.Set("", GetArena());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return released;
}
@ -1252,10 +1252,10 @@ inline void Version::set_allocated_suffix(std::string* value) {
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
_impl_.suffix_.SetAllocated(value, GetArenaForAllocation());
_impl_.suffix_.SetAllocated(value, GetArena());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (_impl_.suffix_.IsDefault()) {
_impl_.suffix_.Set("", GetArenaForAllocation());
_impl_.suffix_.Set("", GetArena());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix)
@ -1386,7 +1386,7 @@ inline PROTOBUF_ALWAYS_INLINE void CodeGeneratorRequest::set_parameter(Arg_&& ar
Args_... args) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000001u;
_impl_.parameter_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
_impl_.parameter_.Set(static_cast<Arg_&&>(arg), args..., GetArena());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter)
}
inline std::string* CodeGeneratorRequest::mutable_parameter() ABSL_ATTRIBUTE_LIFETIME_BOUND {
@ -1401,12 +1401,12 @@ inline const std::string& CodeGeneratorRequest::_internal_parameter() const {
inline void CodeGeneratorRequest::_internal_set_parameter(const std::string& value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000001u;
_impl_.parameter_.Set(value, GetArenaForAllocation());
_impl_.parameter_.Set(value, GetArena());
}
inline std::string* CodeGeneratorRequest::_internal_mutable_parameter() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000001u;
return _impl_.parameter_.Mutable( GetArenaForAllocation());
return _impl_.parameter_.Mutable( GetArena());
}
inline std::string* CodeGeneratorRequest::release_parameter() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
@ -1417,7 +1417,7 @@ inline std::string* CodeGeneratorRequest::release_parameter() {
_impl_._has_bits_[0] &= ~0x00000001u;
auto* released = _impl_.parameter_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.parameter_.Set("", GetArenaForAllocation());
_impl_.parameter_.Set("", GetArena());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return released;
}
@ -1428,10 +1428,10 @@ inline void CodeGeneratorRequest::set_allocated_parameter(std::string* value) {
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
_impl_.parameter_.SetAllocated(value, GetArenaForAllocation());
_impl_.parameter_.SetAllocated(value, GetArena());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (_impl_.parameter_.IsDefault()) {
_impl_.parameter_.Set("", GetArenaForAllocation());
_impl_.parameter_.Set("", GetArena());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter)
@ -1549,7 +1549,7 @@ inline const ::google::protobuf::compiler::Version& CodeGeneratorRequest::compil
}
inline void CodeGeneratorRequest::unsafe_arena_set_allocated_compiler_version(::google::protobuf::compiler::Version* value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
if (GetArenaForAllocation() == nullptr) {
if (GetArena() == nullptr) {
delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.compiler_version_);
}
_impl_.compiler_version_ = reinterpret_cast<::google::protobuf::compiler::Version*>(value);
@ -1569,11 +1569,11 @@ inline ::google::protobuf::compiler::Version* CodeGeneratorRequest::release_comp
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
auto* old = reinterpret_cast<::google::protobuf::MessageLite*>(released);
released = ::google::protobuf::internal::DuplicateIfNonNull(released);
if (GetArenaForAllocation() == nullptr) {
if (GetArena() == nullptr) {
delete old;
}
#else // PROTOBUF_FORCE_COPY_IN_RELEASE
if (GetArenaForAllocation() != nullptr) {
if (GetArena() != nullptr) {
released = ::google::protobuf::internal::DuplicateIfNonNull(released);
}
#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE
@ -1592,7 +1592,7 @@ inline ::google::protobuf::compiler::Version* CodeGeneratorRequest::_internal_mu
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000002u;
if (_impl_.compiler_version_ == nullptr) {
auto* p = CreateMaybeMessage<::google::protobuf::compiler::Version>(GetArenaForAllocation());
auto* p = CreateMaybeMessage<::google::protobuf::compiler::Version>(GetArena());
_impl_.compiler_version_ = reinterpret_cast<::google::protobuf::compiler::Version*>(p);
}
return _impl_.compiler_version_;
@ -1603,7 +1603,7 @@ inline ::google::protobuf::compiler::Version* CodeGeneratorRequest::mutable_comp
return _msg;
}
inline void CodeGeneratorRequest::set_allocated_compiler_version(::google::protobuf::compiler::Version* value) {
::google::protobuf::Arena* message_arena = GetArenaForAllocation();
::google::protobuf::Arena* message_arena = GetArena();
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
if (message_arena == nullptr) {
delete reinterpret_cast<::google::protobuf::compiler::Version*>(_impl_.compiler_version_);
@ -1648,7 +1648,7 @@ inline PROTOBUF_ALWAYS_INLINE void CodeGeneratorResponse_File::set_name(Arg_&& a
Args_... args) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000001u;
_impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
_impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArena());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name)
}
inline std::string* CodeGeneratorResponse_File::mutable_name() ABSL_ATTRIBUTE_LIFETIME_BOUND {
@ -1663,12 +1663,12 @@ inline const std::string& CodeGeneratorResponse_File::_internal_name() const {
inline void CodeGeneratorResponse_File::_internal_set_name(const std::string& value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000001u;
_impl_.name_.Set(value, GetArenaForAllocation());
_impl_.name_.Set(value, GetArena());
}
inline std::string* CodeGeneratorResponse_File::_internal_mutable_name() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000001u;
return _impl_.name_.Mutable( GetArenaForAllocation());
return _impl_.name_.Mutable( GetArena());
}
inline std::string* CodeGeneratorResponse_File::release_name() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
@ -1679,7 +1679,7 @@ inline std::string* CodeGeneratorResponse_File::release_name() {
_impl_._has_bits_[0] &= ~0x00000001u;
auto* released = _impl_.name_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.name_.Set("", GetArenaForAllocation());
_impl_.name_.Set("", GetArena());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return released;
}
@ -1690,10 +1690,10 @@ inline void CodeGeneratorResponse_File::set_allocated_name(std::string* value) {
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
_impl_.name_.SetAllocated(value, GetArenaForAllocation());
_impl_.name_.SetAllocated(value, GetArena());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (_impl_.name_.IsDefault()) {
_impl_.name_.Set("", GetArenaForAllocation());
_impl_.name_.Set("", GetArena());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name)
@ -1719,7 +1719,7 @@ inline PROTOBUF_ALWAYS_INLINE void CodeGeneratorResponse_File::set_insertion_poi
Args_... args) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000002u;
_impl_.insertion_point_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
_impl_.insertion_point_.Set(static_cast<Arg_&&>(arg), args..., GetArena());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
}
inline std::string* CodeGeneratorResponse_File::mutable_insertion_point() ABSL_ATTRIBUTE_LIFETIME_BOUND {
@ -1734,12 +1734,12 @@ inline const std::string& CodeGeneratorResponse_File::_internal_insertion_point(
inline void CodeGeneratorResponse_File::_internal_set_insertion_point(const std::string& value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000002u;
_impl_.insertion_point_.Set(value, GetArenaForAllocation());
_impl_.insertion_point_.Set(value, GetArena());
}
inline std::string* CodeGeneratorResponse_File::_internal_mutable_insertion_point() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000002u;
return _impl_.insertion_point_.Mutable( GetArenaForAllocation());
return _impl_.insertion_point_.Mutable( GetArena());
}
inline std::string* CodeGeneratorResponse_File::release_insertion_point() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
@ -1750,7 +1750,7 @@ inline std::string* CodeGeneratorResponse_File::release_insertion_point() {
_impl_._has_bits_[0] &= ~0x00000002u;
auto* released = _impl_.insertion_point_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.insertion_point_.Set("", GetArenaForAllocation());
_impl_.insertion_point_.Set("", GetArena());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return released;
}
@ -1761,10 +1761,10 @@ inline void CodeGeneratorResponse_File::set_allocated_insertion_point(std::strin
} else {
_impl_._has_bits_[0] &= ~0x00000002u;
}
_impl_.insertion_point_.SetAllocated(value, GetArenaForAllocation());
_impl_.insertion_point_.SetAllocated(value, GetArena());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (_impl_.insertion_point_.IsDefault()) {
_impl_.insertion_point_.Set("", GetArenaForAllocation());
_impl_.insertion_point_.Set("", GetArena());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
@ -1790,7 +1790,7 @@ inline PROTOBUF_ALWAYS_INLINE void CodeGeneratorResponse_File::set_content(Arg_&
Args_... args) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000004u;
_impl_.content_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
_impl_.content_.Set(static_cast<Arg_&&>(arg), args..., GetArena());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content)
}
inline std::string* CodeGeneratorResponse_File::mutable_content() ABSL_ATTRIBUTE_LIFETIME_BOUND {
@ -1805,12 +1805,12 @@ inline const std::string& CodeGeneratorResponse_File::_internal_content() const
inline void CodeGeneratorResponse_File::_internal_set_content(const std::string& value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000004u;
_impl_.content_.Set(value, GetArenaForAllocation());
_impl_.content_.Set(value, GetArena());
}
inline std::string* CodeGeneratorResponse_File::_internal_mutable_content() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000004u;
return _impl_.content_.Mutable( GetArenaForAllocation());
return _impl_.content_.Mutable( GetArena());
}
inline std::string* CodeGeneratorResponse_File::release_content() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
@ -1821,7 +1821,7 @@ inline std::string* CodeGeneratorResponse_File::release_content() {
_impl_._has_bits_[0] &= ~0x00000004u;
auto* released = _impl_.content_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.content_.Set("", GetArenaForAllocation());
_impl_.content_.Set("", GetArena());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return released;
}
@ -1832,10 +1832,10 @@ inline void CodeGeneratorResponse_File::set_allocated_content(std::string* value
} else {
_impl_._has_bits_[0] &= ~0x00000004u;
}
_impl_.content_.SetAllocated(value, GetArenaForAllocation());
_impl_.content_.SetAllocated(value, GetArena());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (_impl_.content_.IsDefault()) {
_impl_.content_.Set("", GetArenaForAllocation());
_impl_.content_.Set("", GetArena());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)
@ -1858,7 +1858,7 @@ inline const ::google::protobuf::GeneratedCodeInfo& CodeGeneratorResponse_File::
}
inline void CodeGeneratorResponse_File::unsafe_arena_set_allocated_generated_code_info(::google::protobuf::GeneratedCodeInfo* value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
if (GetArenaForAllocation() == nullptr) {
if (GetArena() == nullptr) {
delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.generated_code_info_);
}
_impl_.generated_code_info_ = reinterpret_cast<::google::protobuf::GeneratedCodeInfo*>(value);
@ -1878,11 +1878,11 @@ inline ::google::protobuf::GeneratedCodeInfo* CodeGeneratorResponse_File::releas
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
auto* old = reinterpret_cast<::google::protobuf::MessageLite*>(released);
released = ::google::protobuf::internal::DuplicateIfNonNull(released);
if (GetArenaForAllocation() == nullptr) {
if (GetArena() == nullptr) {
delete old;
}
#else // PROTOBUF_FORCE_COPY_IN_RELEASE
if (GetArenaForAllocation() != nullptr) {
if (GetArena() != nullptr) {
released = ::google::protobuf::internal::DuplicateIfNonNull(released);
}
#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE
@ -1901,7 +1901,7 @@ inline ::google::protobuf::GeneratedCodeInfo* CodeGeneratorResponse_File::_inter
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000008u;
if (_impl_.generated_code_info_ == nullptr) {
auto* p = CreateMaybeMessage<::google::protobuf::GeneratedCodeInfo>(GetArenaForAllocation());
auto* p = CreateMaybeMessage<::google::protobuf::GeneratedCodeInfo>(GetArena());
_impl_.generated_code_info_ = reinterpret_cast<::google::protobuf::GeneratedCodeInfo*>(p);
}
return _impl_.generated_code_info_;
@ -1912,7 +1912,7 @@ inline ::google::protobuf::GeneratedCodeInfo* CodeGeneratorResponse_File::mutabl
return _msg;
}
inline void CodeGeneratorResponse_File::set_allocated_generated_code_info(::google::protobuf::GeneratedCodeInfo* value) {
::google::protobuf::Arena* message_arena = GetArenaForAllocation();
::google::protobuf::Arena* message_arena = GetArena();
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
if (message_arena == nullptr) {
delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.generated_code_info_);
@ -1957,7 +1957,7 @@ inline PROTOBUF_ALWAYS_INLINE void CodeGeneratorResponse::set_error(Arg_&& arg,
Args_... args) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000001u;
_impl_.error_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
_impl_.error_.Set(static_cast<Arg_&&>(arg), args..., GetArena());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error)
}
inline std::string* CodeGeneratorResponse::mutable_error() ABSL_ATTRIBUTE_LIFETIME_BOUND {
@ -1972,12 +1972,12 @@ inline const std::string& CodeGeneratorResponse::_internal_error() const {
inline void CodeGeneratorResponse::_internal_set_error(const std::string& value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000001u;
_impl_.error_.Set(value, GetArenaForAllocation());
_impl_.error_.Set(value, GetArena());
}
inline std::string* CodeGeneratorResponse::_internal_mutable_error() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_._has_bits_[0] |= 0x00000001u;
return _impl_.error_.Mutable( GetArenaForAllocation());
return _impl_.error_.Mutable( GetArena());
}
inline std::string* CodeGeneratorResponse::release_error() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
@ -1988,7 +1988,7 @@ inline std::string* CodeGeneratorResponse::release_error() {
_impl_._has_bits_[0] &= ~0x00000001u;
auto* released = _impl_.error_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.error_.Set("", GetArenaForAllocation());
_impl_.error_.Set("", GetArena());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return released;
}
@ -1999,10 +1999,10 @@ inline void CodeGeneratorResponse::set_allocated_error(std::string* value) {
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
_impl_.error_.SetAllocated(value, GetArenaForAllocation());
_impl_.error_.SetAllocated(value, GetArena());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (_impl_.error_.IsDefault()) {
_impl_.error_.Set("", GetArenaForAllocation());
_impl_.error_.Set("", GetArena());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error)

@ -151,7 +151,7 @@ CppFeatures::~CppFeatures() {
SharedDtor();
}
inline void CppFeatures::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.~Impl_();
}

@ -2387,7 +2387,7 @@ FileDescriptorSet::~FileDescriptorSet() {
SharedDtor();
}
inline void FileDescriptorSet::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.~Impl_();
}
@ -2633,7 +2633,7 @@ FileDescriptorProto::~FileDescriptorProto() {
SharedDtor();
}
inline void FileDescriptorProto::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.name_.Destroy();
_impl_.package_.Destroy();
_impl_.syntax_.Destroy();
@ -3103,8 +3103,8 @@ PROTOBUF_NOINLINE bool FileDescriptorProto::IsInitialized() const {
}
void FileDescriptorProto::InternalSwap(FileDescriptorProto* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.dependency_.InternalSwap(&other->_impl_.dependency_);
@ -3206,7 +3206,7 @@ DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() {
SharedDtor();
}
inline void DescriptorProto_ExtensionRange::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
if (this != internal_default_instance()) delete _impl_.options_;
_impl_.~Impl_();
}
@ -3464,7 +3464,7 @@ DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() {
SharedDtor();
}
inline void DescriptorProto_ReservedRange::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.~Impl_();
}
@ -3723,7 +3723,7 @@ DescriptorProto::~DescriptorProto() {
SharedDtor();
}
inline void DescriptorProto::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.name_.Destroy();
if (this != internal_default_instance()) delete _impl_.options_;
_impl_.~Impl_();
@ -4111,8 +4111,8 @@ PROTOBUF_NOINLINE bool DescriptorProto::IsInitialized() const {
}
void DescriptorProto::InternalSwap(DescriptorProto* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.field_.InternalSwap(&other->_impl_.field_);
@ -4210,7 +4210,7 @@ ExtensionRangeOptions_Declaration::~ExtensionRangeOptions_Declaration() {
SharedDtor();
}
inline void ExtensionRangeOptions_Declaration::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.full_name_.Destroy();
_impl_.type_.Destroy();
_impl_.~Impl_();
@ -4458,8 +4458,8 @@ PROTOBUF_NOINLINE bool ExtensionRangeOptions_Declaration::IsInitialized() const
}
void ExtensionRangeOptions_Declaration::InternalSwap(ExtensionRangeOptions_Declaration* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
::_pbi::ArenaStringPtr::InternalSwap(&_impl_.full_name_, &other->_impl_.full_name_, arena);
@ -4547,7 +4547,7 @@ ExtensionRangeOptions::~ExtensionRangeOptions() {
SharedDtor();
}
inline void ExtensionRangeOptions::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
if (this != internal_default_instance()) delete _impl_.features_;
_impl_.~Impl_();
}
@ -4916,7 +4916,7 @@ FieldDescriptorProto::~FieldDescriptorProto() {
SharedDtor();
}
inline void FieldDescriptorProto::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.name_.Destroy();
_impl_.extendee_.Destroy();
_impl_.type_name_.Destroy();
@ -5337,8 +5337,8 @@ PROTOBUF_NOINLINE bool FieldDescriptorProto::IsInitialized() const {
}
void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, &other->_impl_.name_, arena);
@ -5422,7 +5422,7 @@ OneofDescriptorProto::~OneofDescriptorProto() {
SharedDtor();
}
inline void OneofDescriptorProto::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.name_.Destroy();
if (this != internal_default_instance()) delete _impl_.options_;
_impl_.~Impl_();
@ -5601,8 +5601,8 @@ PROTOBUF_NOINLINE bool OneofDescriptorProto::IsInitialized() const {
}
void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, &other->_impl_.name_, arena);
@ -5659,7 +5659,7 @@ EnumDescriptorProto_EnumReservedRange::~EnumDescriptorProto_EnumReservedRange()
SharedDtor();
}
inline void EnumDescriptorProto_EnumReservedRange::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.~Impl_();
}
@ -5908,7 +5908,7 @@ EnumDescriptorProto::~EnumDescriptorProto() {
SharedDtor();
}
inline void EnumDescriptorProto::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.name_.Destroy();
if (this != internal_default_instance()) delete _impl_.options_;
_impl_.~Impl_();
@ -6163,8 +6163,8 @@ PROTOBUF_NOINLINE bool EnumDescriptorProto::IsInitialized() const {
}
void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.value_.InternalSwap(&other->_impl_.value_);
@ -6251,7 +6251,7 @@ EnumValueDescriptorProto::~EnumValueDescriptorProto() {
SharedDtor();
}
inline void EnumValueDescriptorProto::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.name_.Destroy();
if (this != internal_default_instance()) delete _impl_.options_;
_impl_.~Impl_();
@ -6455,8 +6455,8 @@ PROTOBUF_NOINLINE bool EnumValueDescriptorProto::IsInitialized() const {
}
void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, &other->_impl_.name_, arena);
@ -6538,7 +6538,7 @@ ServiceDescriptorProto::~ServiceDescriptorProto() {
SharedDtor();
}
inline void ServiceDescriptorProto::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.name_.Destroy();
if (this != internal_default_instance()) delete _impl_.options_;
_impl_.~Impl_();
@ -6744,8 +6744,8 @@ PROTOBUF_NOINLINE bool ServiceDescriptorProto::IsInitialized() const {
}
void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.method_.InternalSwap(&other->_impl_.method_);
@ -6849,7 +6849,7 @@ MethodDescriptorProto::~MethodDescriptorProto() {
SharedDtor();
}
inline void MethodDescriptorProto::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.name_.Destroy();
_impl_.input_type_.Destroy();
_impl_.output_type_.Destroy();
@ -7132,8 +7132,8 @@ PROTOBUF_NOINLINE bool MethodDescriptorProto::IsInitialized() const {
}
void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, &other->_impl_.name_, arena);
@ -7309,7 +7309,7 @@ FileOptions::~FileOptions() {
SharedDtor();
}
inline void FileOptions::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.java_package_.Destroy();
_impl_.java_outer_classname_.Destroy();
_impl_.go_package_.Destroy();
@ -8018,8 +8018,8 @@ PROTOBUF_NOINLINE bool FileOptions::IsInitialized() const {
void FileOptions::InternalSwap(FileOptions* PROTOBUF_RESTRICT other) {
using std::swap;
_impl_._extensions_.InternalSwap(&other->_impl_._extensions_);
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_);
@ -8136,7 +8136,7 @@ MessageOptions::~MessageOptions() {
SharedDtor();
}
inline void MessageOptions::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
if (this != internal_default_instance()) delete _impl_.features_;
_impl_.~Impl_();
}
@ -8502,7 +8502,7 @@ FieldOptions_EditionDefault::~FieldOptions_EditionDefault() {
SharedDtor();
}
inline void FieldOptions_EditionDefault::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.value_.Destroy();
_impl_.~Impl_();
}
@ -8671,8 +8671,8 @@ PROTOBUF_NOINLINE bool FieldOptions_EditionDefault::IsInitialized() const {
}
void FieldOptions_EditionDefault::InternalSwap(FieldOptions_EditionDefault* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
::_pbi::ArenaStringPtr::InternalSwap(&_impl_.value_, &other->_impl_.value_, arena);
@ -8790,7 +8790,7 @@ FieldOptions::~FieldOptions() {
SharedDtor();
}
inline void FieldOptions::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
if (this != internal_default_instance()) delete _impl_.features_;
_impl_.~Impl_();
}
@ -9318,7 +9318,7 @@ OneofOptions::~OneofOptions() {
SharedDtor();
}
inline void OneofOptions::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
if (this != internal_default_instance()) delete _impl_.features_;
_impl_.~Impl_();
}
@ -9596,7 +9596,7 @@ EnumOptions::~EnumOptions() {
SharedDtor();
}
inline void EnumOptions::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
if (this != internal_default_instance()) delete _impl_.features_;
_impl_.~Impl_();
}
@ -9947,7 +9947,7 @@ EnumValueOptions::~EnumValueOptions() {
SharedDtor();
}
inline void EnumValueOptions::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
if (this != internal_default_instance()) delete _impl_.features_;
_impl_.~Impl_();
}
@ -10271,7 +10271,7 @@ ServiceOptions::~ServiceOptions() {
SharedDtor();
}
inline void ServiceOptions::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
if (this != internal_default_instance()) delete _impl_.features_;
_impl_.~Impl_();
}
@ -10579,7 +10579,7 @@ MethodOptions::~MethodOptions() {
SharedDtor();
}
inline void MethodOptions::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
if (this != internal_default_instance()) delete _impl_.features_;
_impl_.~Impl_();
}
@ -10895,7 +10895,7 @@ UninterpretedOption_NamePart::~UninterpretedOption_NamePart() {
SharedDtor();
}
inline void UninterpretedOption_NamePart::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.name_part_.Destroy();
_impl_.~Impl_();
}
@ -11066,8 +11066,8 @@ PROTOBUF_NOINLINE bool UninterpretedOption_NamePart::IsInitialized() const {
}
void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_part_, &other->_impl_.name_part_, arena);
@ -11164,7 +11164,7 @@ UninterpretedOption::~UninterpretedOption() {
SharedDtor();
}
inline void UninterpretedOption::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.identifier_value_.Destroy();
_impl_.string_value_.Destroy();
_impl_.aggregate_value_.Destroy();
@ -11461,8 +11461,8 @@ PROTOBUF_NOINLINE bool UninterpretedOption::IsInitialized() const {
}
void UninterpretedOption::InternalSwap(UninterpretedOption* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.name_.InternalSwap(&other->_impl_.name_);
@ -11562,7 +11562,7 @@ FeatureSet::~FeatureSet() {
SharedDtor();
}
inline void FeatureSet::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.~Impl_();
}
@ -11915,7 +11915,7 @@ FeatureSetDefaults_FeatureSetEditionDefault::~FeatureSetDefaults_FeatureSetEditi
SharedDtor();
}
inline void FeatureSetDefaults_FeatureSetEditionDefault::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
if (this != internal_default_instance()) delete _impl_.features_;
_impl_.~Impl_();
}
@ -12169,7 +12169,7 @@ FeatureSetDefaults::~FeatureSetDefaults() {
SharedDtor();
}
inline void FeatureSetDefaults::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.~Impl_();
}
@ -12440,7 +12440,7 @@ SourceCodeInfo_Location::~SourceCodeInfo_Location() {
SharedDtor();
}
inline void SourceCodeInfo_Location::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.leading_comments_.Destroy();
_impl_.trailing_comments_.Destroy();
_impl_.~Impl_();
@ -12701,8 +12701,8 @@ PROTOBUF_NOINLINE bool SourceCodeInfo_Location::IsInitialized() const {
}
void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.path_.InternalSwap(&other->_impl_.path_);
@ -12761,7 +12761,7 @@ SourceCodeInfo::~SourceCodeInfo() {
SharedDtor();
}
inline void SourceCodeInfo::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.~Impl_();
}
@ -12976,7 +12976,7 @@ GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() {
SharedDtor();
}
inline void GeneratedCodeInfo_Annotation::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.source_file_.Destroy();
_impl_.~Impl_();
}
@ -13226,8 +13226,8 @@ PROTOBUF_NOINLINE bool GeneratedCodeInfo_Annotation::IsInitialized() const {
}
void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* PROTOBUF_RESTRICT other) {
using std::swap;
auto* arena = GetArenaForAllocation();
ABSL_DCHECK_EQ(arena, other->GetArenaForAllocation());
auto* arena = GetArena();
ABSL_DCHECK_EQ(arena, other->GetArena());
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.path_.InternalSwap(&other->_impl_.path_);
@ -13289,7 +13289,7 @@ GeneratedCodeInfo::~GeneratedCodeInfo() {
SharedDtor();
}
inline void GeneratedCodeInfo::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
ABSL_DCHECK(GetArena() == nullptr);
_impl_.~Impl_();
}

File diff suppressed because it is too large Load Diff

@ -354,7 +354,7 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
}
if (type_info_->extensions_offset != -1) {
new (MutableExtensionsRaw()) ExtensionSet(GetArenaForAllocation());
new (MutableExtensionsRaw()) ExtensionSet(GetArena());
}
for (int i = 0; i < descriptor->field_count(); i++) {
const FieldDescriptor* field = descriptor->field(i);
@ -363,13 +363,13 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
continue;
}
switch (field->cpp_type()) {
#define HANDLE_TYPE(CPPTYPE, TYPE) \
case FieldDescriptor::CPPTYPE_##CPPTYPE: \
if (!field->is_repeated()) { \
new (field_ptr) TYPE(field->default_value_##TYPE()); \
} else { \
new (field_ptr) RepeatedField<TYPE>(GetArenaForAllocation()); \
} \
#define HANDLE_TYPE(CPPTYPE, TYPE) \
case FieldDescriptor::CPPTYPE_##CPPTYPE: \
if (!field->is_repeated()) { \
new (field_ptr) TYPE(field->default_value_##TYPE()); \
} else { \
new (field_ptr) RepeatedField<TYPE>(GetArena()); \
} \
break;
HANDLE_TYPE(INT32, int32_t);
@ -385,7 +385,7 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
if (!field->is_repeated()) {
new (field_ptr) int{field->default_value_enum()->number()};
} else {
new (field_ptr) RepeatedField<int>(GetArenaForAllocation());
new (field_ptr) RepeatedField<int>(GetArena());
}
break;
@ -397,8 +397,7 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
ArenaStringPtr* asp = new (field_ptr) ArenaStringPtr();
asp->InitDefault();
} else {
new (field_ptr)
RepeatedPtrField<std::string>(GetArenaForAllocation());
new (field_ptr) RepeatedPtrField<std::string>(GetArena());
}
break;
}
@ -413,20 +412,20 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
// when the constructor is called inside GetPrototype(), in which
// case we have already locked the factory.
if (lock_factory) {
if (GetArenaForAllocation() != nullptr) {
if (GetArena() != nullptr) {
new (field_ptr) DynamicMapField(
type_info_->factory->GetPrototype(field->message_type()),
GetArenaForAllocation());
GetArena());
} else {
new (field_ptr) DynamicMapField(
type_info_->factory->GetPrototype(field->message_type()));
}
} else {
if (GetArenaForAllocation() != nullptr) {
if (GetArena() != nullptr) {
new (field_ptr)
DynamicMapField(type_info_->factory->GetPrototypeNoLock(
field->message_type()),
GetArenaForAllocation());
GetArena());
} else {
new (field_ptr)
DynamicMapField(type_info_->factory->GetPrototypeNoLock(
@ -434,7 +433,7 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
}
}
} else {
new (field_ptr) RepeatedPtrField<Message>(GetArenaForAllocation());
new (field_ptr) RepeatedPtrField<Message>(GetArena());
}
}
break;

@ -627,8 +627,8 @@ void SwapFieldHelper::SwapInlinedStrings(const Reflection* r, Message* lhs,
Message* rhs,
const FieldDescriptor* field) {
// Inlined string field.
Arena* lhs_arena = lhs->GetArenaForAllocation();
Arena* rhs_arena = rhs->GetArenaForAllocation();
Arena* lhs_arena = lhs->GetArena();
Arena* rhs_arena = rhs->GetArena();
auto* lhs_string = r->MutableRaw<InlinedStringField>(lhs, field);
auto* rhs_string = r->MutableRaw<InlinedStringField>(rhs, field);
uint32_t index = r->schema_.InlinedStringIndex(field);
@ -664,9 +664,8 @@ void SwapFieldHelper::SwapNonInlinedStrings(const Reflection* r, Message* lhs,
if (unsafe_shallow_swap) {
ArenaStringPtr::UnsafeShallowSwap(lhs_string, rhs_string);
} else {
SwapFieldHelper::SwapArenaStringPtr(
lhs_string, lhs->GetArenaForAllocation(), //
rhs_string, rhs->GetArenaForAllocation());
SwapFieldHelper::SwapArenaStringPtr(lhs_string, lhs->GetArena(), //
rhs_string, rhs->GetArena());
}
}
@ -749,8 +748,7 @@ void SwapFieldHelper::SwapMessageField(const Reflection* r, Message* lhs,
std::swap(*r->MutableRaw<Message*>(lhs, field),
*r->MutableRaw<Message*>(rhs, field));
} else {
SwapMessage(r, lhs, lhs->GetArenaForAllocation(), rhs,
rhs->GetArenaForAllocation(), field);
SwapMessage(r, lhs, lhs->GetArena(), rhs, rhs->GetArena(), field);
}
}
@ -1155,8 +1153,7 @@ void Reflection::SwapFieldsImpl(
if (field->options().ctype() == FieldOptions::STRING &&
IsInlined(field)) {
ABSL_DCHECK(!unsafe_shallow_swap ||
message1->GetArenaForAllocation() ==
message2->GetArenaForAllocation());
message1->GetArena() == message2->GetArena());
SwapInlinedStringDonated(message1, message2, field);
}
}
@ -1174,8 +1171,7 @@ void Reflection::SwapFields(
void Reflection::UnsafeShallowSwapFields(
Message* message1, Message* message2,
const std::vector<const FieldDescriptor*>& fields) const {
ABSL_DCHECK_EQ(message1->GetArenaForAllocation(),
message2->GetArenaForAllocation());
ABSL_DCHECK_EQ(message1->GetArena(), message2->GetArena());
SwapFieldsImpl<true>(message1, message2, fields);
}
@ -1183,7 +1179,7 @@ void Reflection::UnsafeShallowSwapFields(
void Reflection::UnsafeArenaSwapFields(
Message* lhs, Message* rhs,
const std::vector<const FieldDescriptor*>& fields) const {
ABSL_DCHECK_EQ(lhs->GetArenaForAllocation(), rhs->GetArenaForAllocation());
ABSL_DCHECK_EQ(lhs->GetArena(), rhs->GetArena());
UnsafeShallowSwapFields(lhs, rhs, fields);
}
@ -1400,7 +1396,7 @@ void Reflection::ClearField(Message* message,
if (schema_.HasBitIndex(field) == static_cast<uint32_t>(-1)) {
// Proto3 does not have has-bits and we need to set a message field
// to nullptr in order to indicate its un-presence.
if (message->GetArenaForAllocation() == nullptr) {
if (message->GetArena() == nullptr) {
delete *MutableRaw<Message*>(message, field);
}
*MutableRaw<Message*>(message, field) = nullptr;
@ -1520,7 +1516,7 @@ Message* Reflection::ReleaseLast(Message* message,
}
}
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
return MaybeForceCopy(message->GetArenaForAllocation(), released);
return MaybeForceCopy(message->GetArena(), released);
#else // PROTOBUF_FORCE_COPY_IN_RELEASE
return released;
#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE
@ -1878,7 +1874,7 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
if (!HasOneofField(*message, field)) {
ClearOneof(message, field->containing_oneof());
*MutableField<absl::Cord*>(message, field) =
Arena::Create<absl::Cord>(message->GetArenaForAllocation());
Arena::Create<absl::Cord>(message->GetArena());
}
*(*MutableField<absl::Cord*>(message, field)) = value;
break;
@ -1894,7 +1890,7 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
&MutableInlinedStringDonatedArray(message)[index / 32];
uint32_t mask = ~(static_cast<uint32_t>(1) << (index % 32));
MutableField<InlinedStringField>(message, field)
->Set(value, message->GetArenaForAllocation(),
->Set(value, message->GetArena(),
IsInlinedStringDonated(*message, field), states, mask,
message);
break;
@ -1909,7 +1905,7 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
MutableField<ArenaStringPtr>(message, field)->InitDefault();
}
MutableField<ArenaStringPtr>(message, field)
->Set(std::move(value), message->GetArenaForAllocation());
->Set(std::move(value), message->GetArena());
break;
}
}
@ -1930,7 +1926,7 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
if (!HasOneofField(*message, field)) {
ClearOneof(message, field->containing_oneof());
*MutableField<absl::Cord*>(message, field) =
Arena::Create<absl::Cord>(message->GetArenaForAllocation());
Arena::Create<absl::Cord>(message->GetArena());
}
*(*MutableField<absl::Cord*>(message, field)) = value;
} else {
@ -1954,12 +1950,12 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
uint32_t* states =
&MutableInlinedStringDonatedArray(message)[index / 32];
uint32_t mask = ~(static_cast<uint32_t>(1) << (index % 32));
str->Set(std::string(value), message->GetArenaForAllocation(),
str->Set(std::string(value), message->GetArena(),
IsInlinedStringDonated(*message, field), states, mask,
message);
} else {
auto* str = MutableField<ArenaStringPtr>(message, field);
str->Set(std::string(value), message->GetArenaForAllocation());
str->Set(std::string(value), message->GetArena());
}
break;
}
@ -2264,7 +2260,7 @@ Message* Reflection::MutableMessage(Message* message,
ClearOneof(message, field->containing_oneof());
result_holder = MutableField<Message*>(message, field);
const Message* default_message = GetDefaultMessageInstance(field);
*result_holder = default_message->New(message->GetArenaForAllocation());
*result_holder = default_message->New(message->GetArena());
}
} else {
SetBit(message, field);
@ -2272,7 +2268,7 @@ Message* Reflection::MutableMessage(Message* message,
if (*result_holder == nullptr) {
const Message* default_message = GetDefaultMessageInstance(field);
*result_holder = default_message->New(message->GetArenaForAllocation());
*result_holder = default_message->New(message->GetArena());
}
result = *result_holder;
return result;
@ -2306,7 +2302,7 @@ void Reflection::UnsafeArenaSetAllocatedMessage(
SetBit(message, field);
}
Message** sub_message_holder = MutableRaw<Message*>(message, field);
if (message->GetArenaForAllocation() == nullptr) {
if (message->GetArena() == nullptr) {
delete *sub_message_holder;
}
*sub_message_holder = sub_message;
@ -2315,21 +2311,21 @@ void Reflection::UnsafeArenaSetAllocatedMessage(
void Reflection::SetAllocatedMessage(Message* message, Message* sub_message,
const FieldDescriptor* field) const {
ABSL_DCHECK(
sub_message == nullptr || sub_message->GetOwningArena() == nullptr ||
sub_message->GetOwningArena() == message->GetArenaForAllocation());
ABSL_DCHECK(sub_message == nullptr ||
sub_message->GetOwningArena() == nullptr ||
sub_message->GetOwningArena() == message->GetArena());
// If message and sub-message are in different memory ownership domains
// (different arenas, or one is on heap and one is not), then we may need to
// do a copy.
if (sub_message != nullptr &&
sub_message->GetOwningArena() != message->GetArenaForAllocation()) {
sub_message->GetOwningArena() != message->GetArena()) {
if (sub_message->GetOwningArena() == nullptr &&
message->GetArenaForAllocation() != nullptr) {
message->GetArena() != nullptr) {
// Case 1: parent is on an arena and child is heap-allocated. We can add
// the child to the arena's Own() list to free on arena destruction, then
// set our pointer.
message->GetArenaForAllocation()->Own(sub_message);
message->GetArena()->Own(sub_message);
UnsafeArenaSetAllocatedMessage(message, sub_message, field);
} else {
// Case 2: all other cases. We need to make a copy. MutableMessage() will
@ -2378,9 +2374,9 @@ Message* Reflection::ReleaseMessage(Message* message,
MessageFactory* factory) const {
Message* released = UnsafeArenaReleaseMessage(message, field, factory);
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
released = MaybeForceCopy(message->GetArenaForAllocation(), released);
released = MaybeForceCopy(message->GetArena(), released);
#endif // PROTOBUF_FORCE_COPY_IN_RELEASE
if (message->GetArenaForAllocation() != nullptr && released != nullptr) {
if (message->GetArena() != nullptr && released != nullptr) {
Message* copy_from_arena = released->New();
copy_from_arena->CopyFrom(*released);
released = copy_from_arena;
@ -2459,7 +2455,7 @@ Message* Reflection::AddMessage(Message* message, const FieldDescriptor* field,
} else {
prototype = &repeated->Get<GenericTypeHandler<Message> >(0);
}
result = prototype->New(message->GetArenaForAllocation());
result = prototype->New(message->GetArena());
// We can guarantee here that repeated and result are either both heap
// allocated or arena owned. So it is safe to call the unsafe version
// of AddAllocated.
@ -2679,7 +2675,7 @@ void Reflection::PrepareSplitMessageForWrite(Message* message) const {
const void* default_split = GetSplitField(schema_.default_instance_);
if (*split == default_split) {
uint32_t size = schema_.SizeofSplit();
Arena* arena = message->GetArenaForAllocation();
Arena* arena = message->GetArena();
*split = (arena == nullptr) ? ::operator new(size)
: arena->AllocateAligned(size);
memcpy(*split, default_split, size);
@ -2717,7 +2713,7 @@ Type* Reflection::MutableRawNonOneof(Message* message,
if (SplitFieldHasExtraIndirection(field)) {
return AllocIfDefault(field,
*GetPointerAtOffset<Type*>(*split, field_offset),
message->GetArenaForAllocation());
message->GetArena());
}
return GetPointerAtOffset<Type>(*split, field_offset);
}
@ -2734,7 +2730,7 @@ Type* Reflection::MutableRaw(Message* message,
if (SplitFieldHasExtraIndirection(field)) {
return AllocIfDefault(field,
*GetPointerAtOffset<Type*>(*split, field_offset),
message->GetArenaForAllocation());
message->GetArena());
}
return GetPointerAtOffset<Type>(*split, field_offset);
}
@ -2815,8 +2811,8 @@ inline void ClearInlinedStringDonated(uint32_t index, uint32_t* array) {
void Reflection::SwapInlinedStringDonated(Message* lhs, Message* rhs,
const FieldDescriptor* field) const {
Arena* lhs_arena = lhs->GetArenaForAllocation();
Arena* rhs_arena = rhs->GetArenaForAllocation();
Arena* lhs_arena = lhs->GetArena();
Arena* rhs_arena = rhs->GetArena();
// If arenas differ, inined string fields are swapped by copying values.
// Donation status should not be swapped.
if (lhs_arena != rhs_arena) {
@ -2982,7 +2978,7 @@ void Reflection::ClearOneof(Message* message,
uint32_t oneof_case = GetOneofCase(*message, oneof_descriptor);
if (oneof_case > 0) {
const FieldDescriptor* field = descriptor_->FindFieldByNumber(oneof_case);
if (message->GetArenaForAllocation() == nullptr) {
if (message->GetArena() == nullptr) {
switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_STRING: {
switch (internal::cpp::EffectiveStringCType(field)) {

@ -598,7 +598,7 @@ class PROTOBUF_EXPORT TcParser final {
if (!is_split) return RefAt<T>(x, offset);
void*& ptr = RefAt<void*>(x, offset);
if (ptr == DefaultRawPtr()) {
ptr = Arena::CreateMessage<T>(msg->GetArenaForAllocation());
ptr = Arena::CreateMessage<T>(msg->GetArena());
}
return *static_cast<T*>(ptr);
}

@ -383,7 +383,7 @@ inline PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularParseMessageAuxImpl(
if (aux_is_table) {
const auto* inner_table = table->field_aux(data.aux_idx())->table;
if (field == nullptr) {
field = inner_table->default_instance->New(msg->GetArenaForAllocation());
field = inner_table->default_instance->New(msg->GetArena());
}
if (group_coding) {
return ctx->ParseGroup<TcParser>(field, ptr, FastDecodeTag(saved_tag),
@ -394,7 +394,7 @@ inline PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularParseMessageAuxImpl(
if (field == nullptr) {
const MessageLite* default_instance =
table->field_aux(data.aux_idx())->message_default();
field = default_instance->New(msg->GetArenaForAllocation());
field = default_instance->New(msg->GetArena());
}
if (group_coding) {
return ctx->ParseGroup(field, ptr, FastDecodeTag(saved_tag));
@ -1432,7 +1432,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularString(
ptr += sizeof(TagType);
hasbits |= (uint64_t{1} << data.hasbit_idx());
auto& field = RefAt<FieldType>(msg, data.offset());
auto arena = msg->GetArenaForAllocation();
auto arena = msg->GetArena();
if (arena) {
ptr =
ReadStringIntoArena(msg, ptr, ctx, data.aux_idx(), table, field, arena);
@ -1676,7 +1676,7 @@ bool TcParser::ChangeOneof(const TcParseTableBase* table,
case field_layout::kRepMessage:
case field_layout::kRepGroup: {
auto& field = RefAt<MessageLite*>(msg, current_entry->offset);
if (!msg->GetArenaForAllocation()) {
if (!msg->GetArena()) {
delete field;
}
break;
@ -1711,7 +1711,7 @@ void* TcParser::MaybeGetSplitBase(MessageLite* msg, const bool is_split,
if (split == default_split) {
// Allocate split instance when needed.
uint32_t size = GetSizeofSplit(table);
Arena* arena = msg->GetArenaForAllocation();
Arena* arena = msg->GetArena();
split = (arena == nullptr) ? ::operator new(size)
: arena->AllocateAligned(size);
memcpy(split, default_split, size);
@ -2184,7 +2184,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) {
case field_layout::kRepAString: {
auto& field = RefAt<ArenaStringPtr>(base, entry.offset);
if (need_init) field.InitDefault();
Arena* arena = msg->GetArenaForAllocation();
Arena* arena = msg->GetArena();
if (arena) {
ptr = ctx->ReadArenaString(ptr, &field, arena);
} else {
@ -2201,7 +2201,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) {
absl::Cord* field;
if (is_oneof) {
if (need_init) {
field = Arena::Create<absl::Cord>(msg->GetArenaForAllocation());
field = Arena::Create<absl::Cord>(msg->GetArena());
RefAt<absl::Cord*>(msg, entry.offset) = field;
} else {
field = RefAt<absl::Cord*>(msg, entry.offset);
@ -2366,7 +2366,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpMessage(PROTOBUF_TC_PARAM_DECL) {
if ((type_card & field_layout::kTvMask) == field_layout::kTvTable) {
auto* inner_table = table->field_aux(&entry)->table;
if (need_init || field == nullptr) {
field = inner_table->default_instance->New(msg->GetArenaForAllocation());
field = inner_table->default_instance->New(msg->GetArena());
}
if (is_group) {
return ctx->ParseGroup<TcParser>(field, ptr, decoded_tag, inner_table);
@ -2382,7 +2382,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpMessage(PROTOBUF_TC_PARAM_DECL) {
+field_layout::kTvWeakPtr);
def = table->field_aux(&entry)->message_default_weak();
}
field = def->New(msg->GetArenaForAllocation());
field = def->New(msg->GetArena());
}
if (is_group) {
return ctx->ParseGroup(field, ptr, decoded_tag);

@ -111,7 +111,7 @@ class MapEntry : public Message {
MapEntry& operator=(const MapEntry&) = delete;
~MapEntry() override {
if (GetArenaForAllocation() != nullptr) return;
if (GetArena() != nullptr) return;
Message::_internal_metadata_.template Delete<UnknownFieldSet>();
KeyTypeHandler::DeleteNoArena(key_);
ValueTypeHandler::DeleteNoArena(value_);
@ -130,11 +130,11 @@ class MapEntry : public Message {
}
inline auto* mutable_key() {
_has_bits_[0] |= 0x00000001u;
return KeyTypeHandler::EnsureMutable(&key_, GetArenaForAllocation());
return KeyTypeHandler::EnsureMutable(&key_, GetArena());
}
inline auto* mutable_value() {
_has_bits_[0] |= 0x00000002u;
return ValueTypeHandler::EnsureMutable(&value_, GetArenaForAllocation());
return ValueTypeHandler::EnsureMutable(&value_, GetArena());
}
// TODO: These methods currently differ in behavior from the ones

@ -521,10 +521,6 @@ class PROTOBUF_EXPORT MessageLite {
// of this message or its internal memory could be changed.
Arena* GetOwningArena() const { return _internal_metadata_.arena(); }
// Returns the arena, used for allocating internal objects(e.g., child
// messages, etc), or owning incoming objects (e.g., set allocated).
Arena* GetArenaForAllocation() const { return _internal_metadata_.arena(); }
struct ClassData {
// Note: The order of arguments in the functions is chosen so that it has
// the same ABI as the member function that calls them. Eg the `this`

Loading…
Cancel
Save