From 126a64517e056508704c9abe7015a81e0d4835a2 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Tue, 10 Oct 2023 14:24:35 -0700 Subject: [PATCH] Automated rollback of commit 40bed71a88ad4051989c9d14ff0ddae799b2d1e6. PiperOrigin-RevId: 572366502 --- src/google/protobuf/arena.h | 31 +- src/google/protobuf/arena_unittest.cc | 14 +- .../cpp/field_generators/message_field.cc | 6 +- src/google/protobuf/compiler/cpp/message.cc | 12 +- src/google/protobuf/compiler/plugin.pb.h | 54 ++- src/google/protobuf/cpp_features.pb.h | 12 +- src/google/protobuf/descriptor.pb.h | 444 +++++++++--------- src/google/protobuf/extension_set.cc | 5 +- .../protobuf/generated_message_reflection.cc | 22 +- .../generated_message_tctable_lite.cc | 4 +- src/google/protobuf/generated_message_util.cc | 2 +- src/google/protobuf/message.cc | 4 +- src/google/protobuf/message_lite.h | 7 + src/google/protobuf/proto3_arena_unittest.cc | 12 + src/google/protobuf/reflection_ops.cc | 10 +- src/google/protobuf/repeated_field.h | 30 +- src/google/protobuf/repeated_ptr_field.cc | 6 +- src/google/protobuf/repeated_ptr_field.h | 69 +-- 18 files changed, 425 insertions(+), 319 deletions(-) diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 0ca9c15429..10ce61b3c8 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -261,7 +261,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { // again. template PROTOBUF_ALWAYS_INLINE static void Destroy(T* obj) { - if (InternalGetArena(obj) == nullptr) delete obj; + if (InternalGetOwningArena(obj) == nullptr) delete obj; } // Allocates memory with the specific size and alignment. @@ -392,6 +392,21 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { struct Rank1 {}; struct Rank0 : Rank1 {}; + static Arena* GetOwningArena(const T* p) { + return GetOwningArena(Rank0{}, p); + } + + template + static auto GetOwningArena(Rank0, const U* p) + -> EnableIfArenaGetOwningArena())> { + return p->GetOwningArena(); + } + + template + static Arena* GetOwningArena(Rank1, const U*) { + return nullptr; + } + static void InternalSwap(T* a, T* b) { a->InternalSwap(b); } static Arena* GetArena(T* p) { return GetArena(Rank0{}, p); } @@ -443,6 +458,20 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { friend class TestUtil::ReflectionTester; }; + // Provides access to protected GetOwningArena to generated messages. For + // internal use only. + template + static Arena* InternalGetOwningArena(const T* p) { + return InternalHelper::GetOwningArena(p); + } + + // Wraps InternalGetArena() and will be removed soon. + // For internal use only. + template + static Arena* InternalGetArenaForAllocation(T* p) { + return InternalHelper::GetArena(p); + } + // Provides access to protected GetArena to generated messages. // For internal use only. template diff --git a/src/google/protobuf/arena_unittest.cc b/src/google/protobuf/arena_unittest.cc index 21041129fb..f56ced3229 100644 --- a/src/google/protobuf/arena_unittest.cc +++ b/src/google/protobuf/arena_unittest.cc @@ -561,6 +561,16 @@ TEST(ArenaTest, UnsafeArenaSwap) { TestUtil::ExpectAllFieldsSet(*message2); } +TEST(ArenaTest, GetOwningArena) { + Arena arena; + auto* m1 = Arena::CreateMessage(&arena); + EXPECT_EQ(Arena::InternalGetOwningArena(m1), &arena); + EXPECT_EQ(&arena, Arena::InternalGetOwningArena( + m1->mutable_repeated_foreign_message())); + EXPECT_EQ(&arena, + Arena::InternalGetOwningArena(m1->mutable_repeated_int32())); +} + TEST(ArenaTest, SwapBetweenArenasUsingReflection) { Arena arena1; TestAllTypes* arena1_message = Arena::CreateMessage(&arena1); @@ -713,7 +723,7 @@ TEST(ArenaTest, SetAllocatedAcrossArenasWithReflection) { #if GTEST_HAS_DEATH_TEST EXPECT_DEBUG_DEATH( r->SetAllocatedMessage(arena1_message, arena2_submessage, msg_field), - "GetArena"); + "GetOwningArena"); #endif EXPECT_NE(arena2_submessage, arena1_message->mutable_optional_nested_message()); @@ -726,7 +736,7 @@ TEST(ArenaTest, SetAllocatedAcrossArenasWithReflection) { #if GTEST_HAS_DEATH_TEST EXPECT_DEBUG_DEATH( r->SetAllocatedMessage(heap_message, arena1_submessage, msg_field), - "GetArena"); + "GetOwningArena"); #endif EXPECT_NE(arena1_submessage, heap_message->mutable_optional_nested_message()); delete heap_message; diff --git a/src/google/protobuf/compiler/cpp/field_generators/message_field.cc b/src/google/protobuf/compiler/cpp/field_generators/message_field.cc index 945fc22cfb..9da586c609 100644 --- a/src/google/protobuf/compiler/cpp/field_generators/message_field.cc +++ b/src/google/protobuf/compiler/cpp/field_generators/message_field.cc @@ -287,7 +287,8 @@ void SingularMessage::GenerateInlineAccessorDefinitions(io::Printer* p) const { //~ When $Submsg$ is a cross-file type, have to read the arena //~ through the virtual method, because the type isn't defined in //~ this file, only forward-declated. - $pb$::Arena* submessage_arena = $base_cast$(value)->GetArena(); + $pb$::Arena* submessage_arena = + $pb$::Arena::InternalGetOwningArena($base_cast$(value)); if (message_arena != submessage_arena) { value = $pbi$::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -574,7 +575,8 @@ void OneofMessage::GenerateNonInlineAccessorDefinitions(io::Printer* p) const { $pb$::Arena* message_arena = GetArena(); clear_$oneof_name$(); if ($name$) { - $pb$::Arena* submessage_arena = $foreign_cast$($name$)->GetArena(); + $pb$::Arena* submessage_arena = + $pb$::Arena::InternalGetOwningArena($foreign_cast$($name$)); if (message_arena != submessage_arena) { $name$ = $pbi$::GetOwnedMessage(message_arena, $name$, submessage_arena); } diff --git a/src/google/protobuf/compiler/cpp/message.cc b/src/google/protobuf/compiler/cpp/message.cc index 08fd28f69b..95ae770824 100644 --- a/src/google/protobuf/compiler/cpp/message.cc +++ b/src/google/protobuf/compiler/cpp/message.cc @@ -1297,9 +1297,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) { "}\n" "inline $classname$& operator=($classname$&& from) noexcept {\n" " if (this == &from) return *this;\n" - " if (GetArena() == from.GetArena()\n" + " if (GetOwningArena() == from.GetOwningArena()\n" "#ifdef PROTOBUF_FORCE_COPY_IN_MOVE\n" - " && GetArena() != nullptr\n" + " && GetOwningArena() != nullptr\n" "#endif // !PROTOBUF_FORCE_COPY_IN_MOVE\n" " ) {\n" " InternalSwap(&from);\n" @@ -1459,10 +1459,10 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) { "inline void Swap($classname$* other) {\n" " if (other == this) return;\n" "#ifdef PROTOBUF_FORCE_COPY_IN_SWAP\n" - " if (GetArena() != nullptr &&\n" - " GetArena() == other->GetArena()) {\n " + " if (GetOwningArena() != nullptr &&\n" + " GetOwningArena() == other->GetOwningArena()) {\n " "#else // PROTOBUF_FORCE_COPY_IN_SWAP\n" - " if (GetArena() == other->GetArena()) {\n" + " if (GetOwningArena() == other->GetOwningArena()) {\n" "#endif // !PROTOBUF_FORCE_COPY_IN_SWAP\n" " InternalSwap(other);\n" " } else {\n" @@ -1471,7 +1471,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) { "}\n" "void UnsafeArenaSwap($classname$* other) {\n" " if (other == this) return;\n" - " $DCHK$(GetArena() == other->GetArena());\n" + " $DCHK$(GetOwningArena() == other->GetOwningArena());\n" " InternalSwap(other);\n" "}\n"); diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 3936fe2abe..6cf992148b 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -142,9 +142,9 @@ class PROTOC_EXPORT Version final : } inline Version& operator=(Version&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -188,10 +188,10 @@ class PROTOC_EXPORT Version final : inline void Swap(Version* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -200,7 +200,7 @@ class PROTOC_EXPORT Version final : } void UnsafeArenaSwap(Version* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -364,9 +364,9 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : } inline CodeGeneratorResponse_File& operator=(CodeGeneratorResponse_File&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -410,10 +410,10 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : inline void Swap(CodeGeneratorResponse_File* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -422,7 +422,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : } void UnsafeArenaSwap(CodeGeneratorResponse_File* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -602,9 +602,9 @@ class PROTOC_EXPORT CodeGeneratorResponse final : } inline CodeGeneratorResponse& operator=(CodeGeneratorResponse&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -648,10 +648,10 @@ class PROTOC_EXPORT CodeGeneratorResponse final : inline void Swap(CodeGeneratorResponse* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -660,7 +660,7 @@ class PROTOC_EXPORT CodeGeneratorResponse final : } void UnsafeArenaSwap(CodeGeneratorResponse* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -841,9 +841,9 @@ class PROTOC_EXPORT CodeGeneratorRequest final : } inline CodeGeneratorRequest& operator=(CodeGeneratorRequest&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -887,10 +887,10 @@ class PROTOC_EXPORT CodeGeneratorRequest final : inline void Swap(CodeGeneratorRequest* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -899,7 +899,7 @@ class PROTOC_EXPORT CodeGeneratorRequest final : } void UnsafeArenaSwap(CodeGeneratorRequest* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -1610,7 +1610,8 @@ inline void CodeGeneratorRequest::set_allocated_compiler_version(::google::proto } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::compiler::Version*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::compiler::Version*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -1918,7 +1919,8 @@ inline void CodeGeneratorResponse_File::set_allocated_generated_code_info(::goog } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::MessageLite*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::MessageLite*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } diff --git a/src/google/protobuf/cpp_features.pb.h b/src/google/protobuf/cpp_features.pb.h index 8169b4fb86..55e7a01659 100644 --- a/src/google/protobuf/cpp_features.pb.h +++ b/src/google/protobuf/cpp_features.pb.h @@ -94,9 +94,9 @@ class PROTOBUF_EXPORT CppFeatures final : } inline CppFeatures& operator=(CppFeatures&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -140,10 +140,10 @@ class PROTOBUF_EXPORT CppFeatures final : inline void Swap(CppFeatures* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -152,7 +152,7 @@ class PROTOBUF_EXPORT CppFeatures final : } void UnsafeArenaSwap(CppFeatures* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index afce859e4d..9beb322fe8 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -723,9 +723,9 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final : } inline UninterpretedOption_NamePart& operator=(UninterpretedOption_NamePart&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -769,10 +769,10 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final : inline void Swap(UninterpretedOption_NamePart* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -781,7 +781,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final : } void UnsafeArenaSwap(UninterpretedOption_NamePart* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -919,9 +919,9 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final : } inline SourceCodeInfo_Location& operator=(SourceCodeInfo_Location&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -965,10 +965,10 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final : inline void Swap(SourceCodeInfo_Location* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -977,7 +977,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final : } void UnsafeArenaSwap(SourceCodeInfo_Location* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -1193,9 +1193,9 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : } inline GeneratedCodeInfo_Annotation& operator=(GeneratedCodeInfo_Annotation&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -1239,10 +1239,10 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : inline void Swap(GeneratedCodeInfo_Annotation* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -1251,7 +1251,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : } void UnsafeArenaSwap(GeneratedCodeInfo_Annotation* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -1457,9 +1457,9 @@ class PROTOBUF_EXPORT FieldOptions_EditionDefault final : } inline FieldOptions_EditionDefault& operator=(FieldOptions_EditionDefault&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -1503,10 +1503,10 @@ class PROTOBUF_EXPORT FieldOptions_EditionDefault final : inline void Swap(FieldOptions_EditionDefault* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -1515,7 +1515,7 @@ class PROTOBUF_EXPORT FieldOptions_EditionDefault final : } void UnsafeArenaSwap(FieldOptions_EditionDefault* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -1653,9 +1653,9 @@ class PROTOBUF_EXPORT FeatureSet final : } inline FeatureSet& operator=(FeatureSet&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -1699,10 +1699,10 @@ class PROTOBUF_EXPORT FeatureSet final : inline void Swap(FeatureSet* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -1711,7 +1711,7 @@ class PROTOBUF_EXPORT FeatureSet final : } void UnsafeArenaSwap(FeatureSet* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -2201,9 +2201,9 @@ class PROTOBUF_EXPORT ExtensionRangeOptions_Declaration final : } inline ExtensionRangeOptions_Declaration& operator=(ExtensionRangeOptions_Declaration&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -2247,10 +2247,10 @@ class PROTOBUF_EXPORT ExtensionRangeOptions_Declaration final : inline void Swap(ExtensionRangeOptions_Declaration* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -2259,7 +2259,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions_Declaration final : } void UnsafeArenaSwap(ExtensionRangeOptions_Declaration* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -2442,9 +2442,9 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : } inline EnumDescriptorProto_EnumReservedRange& operator=(EnumDescriptorProto_EnumReservedRange&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -2488,10 +2488,10 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : inline void Swap(EnumDescriptorProto_EnumReservedRange* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -2500,7 +2500,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : } void UnsafeArenaSwap(EnumDescriptorProto_EnumReservedRange* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -2632,9 +2632,9 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : } inline DescriptorProto_ReservedRange& operator=(DescriptorProto_ReservedRange&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -2678,10 +2678,10 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : inline void Swap(DescriptorProto_ReservedRange* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -2690,7 +2690,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : } void UnsafeArenaSwap(DescriptorProto_ReservedRange* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -2822,9 +2822,9 @@ class PROTOBUF_EXPORT UninterpretedOption final : } inline UninterpretedOption& operator=(UninterpretedOption&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -2868,10 +2868,10 @@ class PROTOBUF_EXPORT UninterpretedOption final : inline void Swap(UninterpretedOption* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -2880,7 +2880,7 @@ class PROTOBUF_EXPORT UninterpretedOption final : } void UnsafeArenaSwap(UninterpretedOption* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -3104,9 +3104,9 @@ class PROTOBUF_EXPORT SourceCodeInfo final : } inline SourceCodeInfo& operator=(SourceCodeInfo&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -3150,10 +3150,10 @@ class PROTOBUF_EXPORT SourceCodeInfo final : inline void Swap(SourceCodeInfo* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -3162,7 +3162,7 @@ class PROTOBUF_EXPORT SourceCodeInfo final : } void UnsafeArenaSwap(SourceCodeInfo* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -3289,9 +3289,9 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : } inline GeneratedCodeInfo& operator=(GeneratedCodeInfo&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -3335,10 +3335,10 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : inline void Swap(GeneratedCodeInfo* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -3347,7 +3347,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : } void UnsafeArenaSwap(GeneratedCodeInfo* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -3474,9 +3474,9 @@ class PROTOBUF_EXPORT FeatureSetDefaults_FeatureSetEditionDefault final : } inline FeatureSetDefaults_FeatureSetEditionDefault& operator=(FeatureSetDefaults_FeatureSetEditionDefault&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -3520,10 +3520,10 @@ class PROTOBUF_EXPORT FeatureSetDefaults_FeatureSetEditionDefault final : inline void Swap(FeatureSetDefaults_FeatureSetEditionDefault* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -3532,7 +3532,7 @@ class PROTOBUF_EXPORT FeatureSetDefaults_FeatureSetEditionDefault final : } void UnsafeArenaSwap(FeatureSetDefaults_FeatureSetEditionDefault* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -3668,9 +3668,9 @@ class PROTOBUF_EXPORT ServiceOptions final : } inline ServiceOptions& operator=(ServiceOptions&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -3714,10 +3714,10 @@ class PROTOBUF_EXPORT ServiceOptions final : inline void Swap(ServiceOptions* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -3726,7 +3726,7 @@ class PROTOBUF_EXPORT ServiceOptions final : } void UnsafeArenaSwap(ServiceOptions* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -4061,9 +4061,9 @@ class PROTOBUF_EXPORT OneofOptions final : } inline OneofOptions& operator=(OneofOptions&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -4107,10 +4107,10 @@ class PROTOBUF_EXPORT OneofOptions final : inline void Swap(OneofOptions* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -4119,7 +4119,7 @@ class PROTOBUF_EXPORT OneofOptions final : } void UnsafeArenaSwap(OneofOptions* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -4441,9 +4441,9 @@ class PROTOBUF_EXPORT MethodOptions final : } inline MethodOptions& operator=(MethodOptions&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -4487,10 +4487,10 @@ class PROTOBUF_EXPORT MethodOptions final : inline void Swap(MethodOptions* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -4499,7 +4499,7 @@ class PROTOBUF_EXPORT MethodOptions final : } void UnsafeArenaSwap(MethodOptions* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -4868,9 +4868,9 @@ class PROTOBUF_EXPORT MessageOptions final : } inline MessageOptions& operator=(MessageOptions&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -4914,10 +4914,10 @@ class PROTOBUF_EXPORT MessageOptions final : inline void Swap(MessageOptions* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -4926,7 +4926,7 @@ class PROTOBUF_EXPORT MessageOptions final : } void UnsafeArenaSwap(MessageOptions* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -5313,9 +5313,9 @@ class PROTOBUF_EXPORT FileOptions final : } inline FileOptions& operator=(FileOptions&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -5359,10 +5359,10 @@ class PROTOBUF_EXPORT FileOptions final : inline void Swap(FileOptions* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -5371,7 +5371,7 @@ class PROTOBUF_EXPORT FileOptions final : } void UnsafeArenaSwap(FileOptions* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -6034,9 +6034,9 @@ class PROTOBUF_EXPORT FieldOptions final : } inline FieldOptions& operator=(FieldOptions&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -6080,10 +6080,10 @@ class PROTOBUF_EXPORT FieldOptions final : inline void Swap(FieldOptions* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -6092,7 +6092,7 @@ class PROTOBUF_EXPORT FieldOptions final : } void UnsafeArenaSwap(FieldOptions* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -6665,9 +6665,9 @@ class PROTOBUF_EXPORT FeatureSetDefaults final : } inline FeatureSetDefaults& operator=(FeatureSetDefaults&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -6711,10 +6711,10 @@ class PROTOBUF_EXPORT FeatureSetDefaults final : inline void Swap(FeatureSetDefaults* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -6723,7 +6723,7 @@ class PROTOBUF_EXPORT FeatureSetDefaults final : } void UnsafeArenaSwap(FeatureSetDefaults* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -6877,9 +6877,9 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : } inline ExtensionRangeOptions& operator=(ExtensionRangeOptions&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -6923,10 +6923,10 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : inline void Swap(ExtensionRangeOptions* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -6935,7 +6935,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : } void UnsafeArenaSwap(ExtensionRangeOptions* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -7312,9 +7312,9 @@ class PROTOBUF_EXPORT EnumValueOptions final : } inline EnumValueOptions& operator=(EnumValueOptions&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -7358,10 +7358,10 @@ class PROTOBUF_EXPORT EnumValueOptions final : inline void Swap(EnumValueOptions* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -7370,7 +7370,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : } void UnsafeArenaSwap(EnumValueOptions* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -7718,9 +7718,9 @@ class PROTOBUF_EXPORT EnumOptions final : } inline EnumOptions& operator=(EnumOptions&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -7764,10 +7764,10 @@ class PROTOBUF_EXPORT EnumOptions final : inline void Swap(EnumOptions* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -7776,7 +7776,7 @@ class PROTOBUF_EXPORT EnumOptions final : } void UnsafeArenaSwap(EnumOptions* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -8137,9 +8137,9 @@ class PROTOBUF_EXPORT OneofDescriptorProto final : } inline OneofDescriptorProto& operator=(OneofDescriptorProto&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -8183,10 +8183,10 @@ class PROTOBUF_EXPORT OneofDescriptorProto final : inline void Swap(OneofDescriptorProto* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -8195,7 +8195,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto final : } void UnsafeArenaSwap(OneofDescriptorProto* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -8337,9 +8337,9 @@ class PROTOBUF_EXPORT MethodDescriptorProto final : } inline MethodDescriptorProto& operator=(MethodDescriptorProto&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -8383,10 +8383,10 @@ class PROTOBUF_EXPORT MethodDescriptorProto final : inline void Swap(MethodDescriptorProto* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -8395,7 +8395,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto final : } void UnsafeArenaSwap(MethodDescriptorProto* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -8601,9 +8601,9 @@ class PROTOBUF_EXPORT FieldDescriptorProto final : } inline FieldDescriptorProto& operator=(FieldDescriptorProto&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -8647,10 +8647,10 @@ class PROTOBUF_EXPORT FieldDescriptorProto final : inline void Swap(FieldDescriptorProto* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -8659,7 +8659,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto final : } void UnsafeArenaSwap(FieldDescriptorProto* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -8999,9 +8999,9 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final : } inline EnumValueDescriptorProto& operator=(EnumValueDescriptorProto&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -9045,10 +9045,10 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final : inline void Swap(EnumValueDescriptorProto* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -9057,7 +9057,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final : } void UnsafeArenaSwap(EnumValueDescriptorProto* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -9212,9 +9212,9 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : } inline DescriptorProto_ExtensionRange& operator=(DescriptorProto_ExtensionRange&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -9258,10 +9258,10 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : inline void Swap(DescriptorProto_ExtensionRange* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -9270,7 +9270,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : } void UnsafeArenaSwap(DescriptorProto_ExtensionRange* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -9419,9 +9419,9 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final : } inline ServiceDescriptorProto& operator=(ServiceDescriptorProto&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -9465,10 +9465,10 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final : inline void Swap(ServiceDescriptorProto* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -9477,7 +9477,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final : } void UnsafeArenaSwap(ServiceDescriptorProto* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -9639,9 +9639,9 @@ class PROTOBUF_EXPORT EnumDescriptorProto final : } inline EnumDescriptorProto& operator=(EnumDescriptorProto&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -9685,10 +9685,10 @@ class PROTOBUF_EXPORT EnumDescriptorProto final : inline void Swap(EnumDescriptorProto* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -9697,7 +9697,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto final : } void UnsafeArenaSwap(EnumDescriptorProto* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -9911,9 +9911,9 @@ class PROTOBUF_EXPORT DescriptorProto final : } inline DescriptorProto& operator=(DescriptorProto&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -9957,10 +9957,10 @@ class PROTOBUF_EXPORT DescriptorProto final : inline void Swap(DescriptorProto* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -9969,7 +9969,7 @@ class PROTOBUF_EXPORT DescriptorProto final : } void UnsafeArenaSwap(DescriptorProto* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -10284,9 +10284,9 @@ class PROTOBUF_EXPORT FileDescriptorProto final : } inline FileDescriptorProto& operator=(FileDescriptorProto&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -10330,10 +10330,10 @@ class PROTOBUF_EXPORT FileDescriptorProto final : inline void Swap(FileDescriptorProto* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -10342,7 +10342,7 @@ class PROTOBUF_EXPORT FileDescriptorProto final : } void UnsafeArenaSwap(FileDescriptorProto* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -10702,9 +10702,9 @@ class PROTOBUF_EXPORT FileDescriptorSet final : } inline FileDescriptorSet& operator=(FileDescriptorSet&& from) noexcept { if (this == &from) return *this; - if (GetArena() == from.GetArena() + if (GetOwningArena() == from.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetArena() != nullptr + && GetOwningArena() != nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { InternalSwap(&from); @@ -10748,10 +10748,10 @@ class PROTOBUF_EXPORT FileDescriptorSet final : inline void Swap(FileDescriptorSet* other) { if (other == this) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && - GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { @@ -10760,7 +10760,7 @@ class PROTOBUF_EXPORT FileDescriptorSet final : } void UnsafeArenaSwap(FileDescriptorSet* other) { if (other == this) return; - ABSL_DCHECK(GetArena() == other->GetArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -11545,7 +11545,8 @@ inline void FileDescriptorProto::set_allocated_options(::google::protobuf::FileO } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::FileOptions*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::FileOptions*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -11641,7 +11642,8 @@ inline void FileDescriptorProto::set_allocated_source_code_info(::google::protob } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::SourceCodeInfo*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::SourceCodeInfo*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -11897,7 +11899,8 @@ inline void DescriptorProto_ExtensionRange::set_allocated_options(::google::prot } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::ExtensionRangeOptions*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::ExtensionRangeOptions*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -12422,7 +12425,8 @@ inline void DescriptorProto::set_allocated_options(::google::protobuf::MessageOp } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::MessageOptions*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::MessageOptions*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -13000,7 +13004,8 @@ inline void ExtensionRangeOptions::set_allocated_features(::google::protobuf::Fe } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::FeatureSet*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::FeatureSet*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -13598,7 +13603,8 @@ inline void FieldDescriptorProto::set_allocated_options(::google::protobuf::Fiel } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::FieldOptions*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::FieldOptions*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -13797,7 +13803,8 @@ inline void OneofDescriptorProto::set_allocated_options(::google::protobuf::Oneo } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::OneofOptions*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::OneofOptions*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -14077,7 +14084,8 @@ inline void EnumDescriptorProto::set_allocated_options(::google::protobuf::EnumO } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::EnumOptions*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::EnumOptions*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -14426,7 +14434,8 @@ inline void EnumValueDescriptorProto::set_allocated_options(::google::protobuf:: } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::EnumValueOptions*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::EnumValueOptions*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -14646,7 +14655,8 @@ inline void ServiceDescriptorProto::set_allocated_options(::google::protobuf::Se } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::ServiceOptions*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::ServiceOptions*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -14959,7 +14969,8 @@ inline void MethodDescriptorProto::set_allocated_options(::google::protobuf::Met } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::MethodOptions*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::MethodOptions*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -16106,7 +16117,8 @@ inline void FileOptions::set_allocated_features(::google::protobuf::FeatureSet* } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::FeatureSet*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::FeatureSet*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -16395,7 +16407,8 @@ inline void MessageOptions::set_allocated_features(::google::protobuf::FeatureSe } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::FeatureSet*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::FeatureSet*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -16998,7 +17011,8 @@ inline void FieldOptions::set_allocated_features(::google::protobuf::FeatureSet* } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::FeatureSet*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::FeatureSet*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -17147,7 +17161,8 @@ inline void OneofOptions::set_allocated_features(::google::protobuf::FeatureSet* } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::FeatureSet*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::FeatureSet*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -17380,7 +17395,8 @@ inline void EnumOptions::set_allocated_features(::google::protobuf::FeatureSet* } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::FeatureSet*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::FeatureSet*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -17557,7 +17573,8 @@ inline void EnumValueOptions::set_allocated_features(::google::protobuf::Feature } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::FeatureSet*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::FeatureSet*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -17734,7 +17751,8 @@ inline void ServiceOptions::set_allocated_features(::google::protobuf::FeatureSe } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::FeatureSet*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::FeatureSet*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -17968,7 +17986,8 @@ inline void MethodOptions::set_allocated_features(::google::protobuf::FeatureSet } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::FeatureSet*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::FeatureSet*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } @@ -18777,7 +18796,8 @@ inline void FeatureSetDefaults_FeatureSetEditionDefault::set_allocated_features( } if (value != nullptr) { - ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::FeatureSet*>(value)->GetArena(); + ::google::protobuf::Arena* submessage_arena = + ::google::protobuf::Arena::InternalGetOwningArena(reinterpret_cast<::google::protobuf::FeatureSet*>(value)); if (message_arena != submessage_arena) { value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); } diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc index 4b54d7a3b6..622c86ae15 100644 --- a/src/google/protobuf/extension_set.cc +++ b/src/google/protobuf/extension_set.cc @@ -626,8 +626,9 @@ void ExtensionSet::SetAllocatedMessage(int number, FieldType type, ClearExtension(number); return; } - ABSL_DCHECK(message->GetArena() == nullptr || message->GetArena() == arena_); - Arena* message_arena = message->GetArena(); + ABSL_DCHECK(message->GetOwningArena() == nullptr || + message->GetOwningArena() == arena_); + Arena* message_arena = message->GetOwningArena(); Extension* extension; if (MaybeNewExtension(number, descriptor, &extension)) { extension->type = type; diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index 452fd5240d..1e9be1ee22 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc @@ -1064,16 +1064,16 @@ void Reflection::Swap(Message* message1, Message* message2) const { // Check that both messages are in the same arena (or both on the heap). We // need to copy all data if not, due to ownership semantics. #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (message1->GetArena() == nullptr || - message1->GetArena() != message2->GetArena()) { + if (message1->GetOwningArena() == nullptr || + message1->GetOwningArena() != message2->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (message1->GetArena() != message2->GetArena()) { + if (message1->GetOwningArena() != message2->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP // One of the two is guaranteed to have an arena. Switch things around // to guarantee that message1 has an arena. - Arena* arena = message1->GetArena(); + Arena* arena = message1->GetOwningArena(); if (arena == nullptr) { - arena = message2->GetArena(); + arena = message2->GetOwningArena(); std::swap(message1, message2); // Swapping names for pointers! } @@ -1203,7 +1203,7 @@ bool Reflection::HasField(const Message& message, } void Reflection::UnsafeArenaSwap(Message* lhs, Message* rhs) const { - ABSL_DCHECK_EQ(lhs->GetArena(), rhs->GetArena()); + ABSL_DCHECK_EQ(lhs->GetOwningArena(), rhs->GetOwningArena()); InternalSwap(lhs, rhs); } @@ -2311,15 +2311,17 @@ void Reflection::UnsafeArenaSetAllocatedMessage( void Reflection::SetAllocatedMessage(Message* message, Message* sub_message, const FieldDescriptor* field) const { - ABSL_DCHECK(sub_message == nullptr || sub_message->GetArena() == nullptr || - sub_message->GetArena() == message->GetArena()); + 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->GetArena() != message->GetArena()) { - if (sub_message->GetArena() == nullptr && message->GetArena() != nullptr) { + sub_message->GetOwningArena() != message->GetArena()) { + if (sub_message->GetOwningArena() == 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. diff --git a/src/google/protobuf/generated_message_tctable_lite.cc b/src/google/protobuf/generated_message_tctable_lite.cc index 531d0556a7..77f66b0557 100644 --- a/src/google/protobuf/generated_message_tctable_lite.cc +++ b/src/google/protobuf/generated_message_tctable_lite.cc @@ -1557,7 +1557,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedString( } }; - auto* arena = field.GetArena(); + auto* arena = field.GetOwningArena(); SerialArena* serial_arena; if (PROTOBUF_PREDICT_TRUE(arena != nullptr && arena->impl_.GetSerialArenaFast(&serial_arena) && @@ -2260,7 +2260,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpRepeatedString( const char* ptr2 = ptr; uint32_t next_tag; - auto* arena = field.GetArena(); + auto* arena = field.GetOwningArena(); SerialArena* serial_arena; if (PROTOBUF_PREDICT_TRUE( arena != nullptr && diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc index 4893ca80b9..b9fb77ef8f 100644 --- a/src/google/protobuf/generated_message_util.cc +++ b/src/google/protobuf/generated_message_util.cc @@ -368,7 +368,7 @@ void GenericSwap(MessageLite* m1, MessageLite* m2) { MessageLite* GetOwnedMessageInternal(Arena* message_arena, MessageLite* submessage, Arena* submessage_arena) { - ABSL_DCHECK(submessage->GetArena() == submessage_arena); + ABSL_DCHECK(Arena::InternalGetOwningArena(submessage) == submessage_arena); ABSL_DCHECK(message_arena != submessage_arena); ABSL_DCHECK_EQ(submessage_arena, nullptr); if (message_arena != nullptr && submessage_arena == nullptr) { diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index b4b1a40c51..6f04c4c911 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -414,8 +414,8 @@ template <> PROTOBUF_NOINLINE #endif Arena* - GenericTypeHandler::GetArena(Message* value) { - return value->GetArena(); + GenericTypeHandler::GetOwningArena(Message* value) { + return value->GetOwningArena(); } template void InternalMetadata::DoClear(); diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index 3fe93857b8..de8bd19aa0 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -514,6 +514,13 @@ class PROTOBUF_EXPORT MessageLite { inline explicit MessageLite(Arena* arena) : _internal_metadata_(arena) {} + // Returns the arena, if any, that directly owns this message and its internal + // memory (Arena::Own is different in that the arena doesn't directly own the + // internal memory). This method is used in proto's implementation for + // swapping, moving and setting allocated, for deciding whether the ownership + // of this message or its internal memory could be changed. + Arena* GetOwningArena() 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` diff --git a/src/google/protobuf/proto3_arena_unittest.cc b/src/google/protobuf/proto3_arena_unittest.cc index 5079c2d6f5..519c176d5e 100644 --- a/src/google/protobuf/proto3_arena_unittest.cc +++ b/src/google/protobuf/proto3_arena_unittest.cc @@ -28,6 +28,18 @@ using proto3_arena_unittest::TestAllTypes; namespace google { namespace protobuf { +namespace internal { + +class Proto3ArenaTestHelper { + public: + template + static Arena* GetOwningArena(const T& msg) { + return msg.GetOwningArena(); + } +}; + +} // namespace internal + namespace { // We selectively set/check a few representative fields rather than all fields // as this test is only expected to cover the basics of arena support. diff --git a/src/google/protobuf/reflection_ops.cc b/src/google/protobuf/reflection_ops.cc index 03b0d38b69..d1153b81d1 100644 --- a/src/google/protobuf/reflection_ops.cc +++ b/src/google/protobuf/reflection_ops.cc @@ -415,14 +415,16 @@ void ReflectionOps::FindInitializationErrors(const Message& message, void GenericSwap(Message* lhs, Message* rhs) { #ifndef PROTOBUF_FORCE_COPY_IN_SWAP - ABSL_DCHECK(lhs->GetArena() != rhs->GetArena()); - ABSL_DCHECK(lhs->GetArena() != nullptr || rhs->GetArena() != nullptr); + ABSL_DCHECK(Arena::InternalGetOwningArena(lhs) != + Arena::InternalGetOwningArena(rhs)); + ABSL_DCHECK(Arena::InternalGetOwningArena(lhs) != nullptr || + Arena::InternalGetOwningArena(rhs) != nullptr); #endif // !PROTOBUF_FORCE_COPY_IN_SWAP // At least one of these must have an arena, so make `rhs` point to it. - Arena* arena = rhs->GetArena(); + Arena* arena = Arena::InternalGetOwningArena(rhs); if (arena == nullptr) { std::swap(lhs, rhs); - arena = rhs->GetArena(); + arena = Arena::InternalGetOwningArena(rhs); } // Improve efficiency by placing the temporary on an arena so that messages diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index e922b0b1f8..4b15be2630 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -293,10 +293,7 @@ class RepeatedField final // Gets the Arena on which this RepeatedField stores its elements. // Note: this can be inaccurate for split default fields so we make this // function non-const. - inline Arena* GetArena() { - return (total_size_ == 0) ? static_cast(arena_or_elements_) - : rep()->arena; - } + inline Arena* GetArena() { return GetOwningArena(); } // For internal use only. // @@ -330,6 +327,12 @@ class RepeatedField final RepeatedField(Arena* arena, const RepeatedField& rhs); + // Gets the Arena on which this RepeatedField stores its elements. + inline Arena* GetOwningArena() const { + return (total_size_ == 0) ? static_cast(arena_or_elements_) + : rep()->arena; + } + // Swaps entire contents with "other". Should be called only if the caller can // guarantee that both repeated fields are on the same arena or are on the // heap. Swapping between different arenas is disallowed and caught by a @@ -497,7 +500,7 @@ RepeatedField::~RepeatedField() { #ifndef NDEBUG // Try to trigger segfault / asan failure in non-opt builds if arena_ // lifetime has ended before the destructor. - auto arena = GetArena(); + auto arena = GetOwningArena(); if (arena) (void)arena->SpaceAllocated(); #endif if (total_size_ > 0) { @@ -522,7 +525,7 @@ inline RepeatedField::RepeatedField(RepeatedField&& other) noexcept // We don't just call Swap(&other) here because it would perform 3 copies if // other is on an arena. This field can't be on an arena because arena // construction always uses the Arena* accepting constructor. - if (other.GetArena()) { + if (other.GetOwningArena()) { CopyFrom(other); } else { InternalSwap(&other); @@ -536,9 +539,9 @@ inline RepeatedField& RepeatedField::operator=( // We don't just call Swap(&other) here because it would perform 3 copies if // the two fields are on different arenas. if (this != &other) { - if (GetArena() != other.GetArena() + if (GetOwningArena() != other.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - || GetArena() == nullptr + || GetOwningArena() == nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { CopyFrom(other); @@ -831,13 +834,14 @@ template void RepeatedField::Swap(RepeatedField* other) { if (this == other) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { - RepeatedField temp(other->GetArena()); + RepeatedField temp(other->GetOwningArena()); temp.MergeFrom(*this); CopyFrom(*other); other->UnsafeArenaSwap(&temp); @@ -847,7 +851,7 @@ void RepeatedField::Swap(RepeatedField* other) { template void RepeatedField::UnsafeArenaSwap(RepeatedField* other) { if (this == other) return; - ABSL_DCHECK_EQ(GetArena(), other->GetArena()); + ABSL_DCHECK_EQ(GetOwningArena(), other->GetOwningArena()); InternalSwap(other); } @@ -936,7 +940,7 @@ PROTOBUF_NOINLINE void RepeatedField::GrowNoAnnotate(int current_size, int new_size) { ABSL_DCHECK_GT(new_size, total_size_); Rep* new_rep; - Arena* arena = GetArena(); + Arena* arena = GetOwningArena(); new_size = internal::CalculateReserveSize( total_size_, new_size); diff --git a/src/google/protobuf/repeated_ptr_field.cc b/src/google/protobuf/repeated_ptr_field.cc index 0351104d13..c4889a61dc 100644 --- a/src/google/protobuf/repeated_ptr_field.cc +++ b/src/google/protobuf/repeated_ptr_field.cc @@ -34,7 +34,7 @@ void** RepeatedPtrFieldBase::InternalExtend(int extend_amount) { ABSL_DCHECK(extend_amount > 0); constexpr size_t ptr_size = sizeof(rep()->elements[0]); int new_capacity = total_size_ + extend_amount; - Arena* arena = GetArena(); + Arena* arena = GetOwningArena(); new_capacity = internal::CalculateReserveSize( total_size_, new_capacity); ABSL_CHECK_LE( @@ -207,7 +207,7 @@ void RepeatedPtrFieldBase::MergeFromConcreteMessage( dst += recycled; src += recycled; } - Arena* arena = GetArena(); + Arena* arena = GetOwningArena(); for (; src < end; ++src, ++dst) { *dst = copy_fn(arena, **src); } @@ -230,7 +230,7 @@ void RepeatedPtrFieldBase::MergeFrom( dst += recycled; src += recycled; } - Arena* arena = GetArena(); + Arena* arena = GetOwningArena(); for (; src < end; ++src, ++dst) { *dst = (*src)->New(arena); (*dst)->CheckTypeAndMergeFrom(**src); diff --git a/src/google/protobuf/repeated_ptr_field.h b/src/google/protobuf/repeated_ptr_field.h index baff229e3f..51c8065685 100644 --- a/src/google/protobuf/repeated_ptr_field.h +++ b/src/google/protobuf/repeated_ptr_field.h @@ -386,9 +386,10 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { template PROTOBUF_NDEBUG_INLINE void Swap(RepeatedPtrFieldBase* other) { #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && GetArena() == other->GetArena()) + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) + if (GetOwningArena() == other->GetOwningArena()) #endif // !PROTOBUF_FORCE_COPY_IN_SWAP { InternalSwap(other); @@ -494,9 +495,10 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { template void AddCleared(Value* value) { - ABSL_DCHECK(GetArena() == nullptr) << "AddCleared() can only be used on a " - "RepeatedPtrField not on an arena."; - ABSL_DCHECK(TypeHandler::GetArena(value) == nullptr) + ABSL_DCHECK(GetOwningArena() == nullptr) + << "AddCleared() can only be used on a " + "RepeatedPtrField not on an arena."; + ABSL_DCHECK(TypeHandler::GetOwningArena(value) == nullptr) << "AddCleared() can only accept values not on an arena."; MaybeExtend(); if (using_sso()) { @@ -508,7 +510,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { template PROTOBUF_NODISCARD Value* ReleaseCleared() { - ABSL_DCHECK(GetArena() == nullptr) + ABSL_DCHECK(GetOwningArena() == nullptr) << "ReleaseCleared() can only be used on a RepeatedPtrField not on " << "an arena."; ABSL_DCHECK(tagged_rep_or_elem_ != nullptr); @@ -525,8 +527,8 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { // AddAllocated version that implements arena-safe copying behavior. template void AddAllocatedInternal(Value* value, std::true_type) { - Arena* element_arena = TypeHandler::GetArena(value); - Arena* arena = GetArena(); + Arena* element_arena = TypeHandler::GetOwningArena(value); + Arena* arena = GetOwningArena(); if (arena == element_arena && allocated_size() < total_size_) { // Fast path: underlying arena representation (tagged pointer) is equal to // our arena pointer, and we can add to array without resizing it (at @@ -592,7 +594,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { // First, release an element. Value* result = UnsafeArenaReleaseLast(); // Now perform a copy if we're on an arena. - Arena* arena = GetArena(); + Arena* arena = GetOwningArena(); #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* new_result = copy(result); @@ -609,7 +611,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { // this is the same as UnsafeArenaReleaseLast(). Note that we // ABSL_DCHECK-fail if we're on an arena, since the user really should // implement the copy operation in this case. - ABSL_DCHECK(GetArena() == nullptr) + ABSL_DCHECK(GetOwningArena() == nullptr) << "ReleaseLast() called on a RepeatedPtrField that is on an arena, " << "with a type that does not implement MergeFrom. This is unsafe; " << "please implement MergeFrom for your type."; @@ -619,15 +621,16 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { template PROTOBUF_NOINLINE void SwapFallback(RepeatedPtrFieldBase* other) { #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - ABSL_DCHECK(GetArena() == nullptr || other->GetArena() != GetArena()); + ABSL_DCHECK(GetOwningArena() == nullptr || + other->GetOwningArena() != GetOwningArena()); #else // PROTOBUF_FORCE_COPY_IN_SWAP - ABSL_DCHECK(other->GetArena() != GetArena()); + ABSL_DCHECK(other->GetOwningArena() != GetOwningArena()); #endif // !PROTOBUF_FORCE_COPY_IN_SWAP // Copy semantics in this case. We try to improve efficiency by placing the // temporary on |other|'s arena so that messages are copied twice rather // than three times. - RepeatedPtrFieldBase temp(other->GetArena()); + RepeatedPtrFieldBase temp(other->GetOwningArena()); if (!this->empty()) { temp.MergeFrom(*this); } @@ -637,7 +640,9 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { } // Gets the Arena on which this RepeatedPtrField stores its elements. - inline Arena* GetArena() const { return arena_; } + inline Arena* GetArena() const { return GetOwningArena(); } + + inline Arena* GetOwningArena() const { return arena_; } private: using InternalArenaConstructable_ = void; @@ -880,8 +885,8 @@ class GenericTypeHandler { delete value; #endif } - static inline Arena* GetArena(GenericType* value) { - return Arena::InternalGetArena(value); + static inline Arena* GetOwningArena(GenericType* value) { + return Arena::InternalGetOwningArena(value); } static inline void Clear(GenericType* value) { value->Clear(); } @@ -903,8 +908,9 @@ inline MessageLite* GenericTypeHandler::NewFromPrototype( return NewFromPrototypeHelper(prototype, arena); } template <> -inline Arena* GenericTypeHandler::GetArena(MessageLite* value) { - return value->GetArena(); +inline Arena* GenericTypeHandler::GetOwningArena( + MessageLite* value) { + return value->GetOwningArena(); } template @@ -931,7 +937,8 @@ template <> PROTOBUF_EXPORT Message* GenericTypeHandler::NewFromPrototype( const Message* prototype, Arena* arena); template <> -PROTOBUF_EXPORT Arena* GenericTypeHandler::GetArena(Message* value); +PROTOBUF_EXPORT Arena* GenericTypeHandler::GetOwningArena( + Message* value); class StringTypeHandler { public: @@ -948,7 +955,7 @@ class StringTypeHandler { Arena* arena) { return New(arena); } - static inline Arena* GetArena(std::string*) { return nullptr; } + static inline Arena* GetOwningArena(std::string*) { return nullptr; } static inline void Delete(std::string* value, Arena* arena) { if (arena == nullptr) { delete value; @@ -1300,6 +1307,9 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { RepeatedPtrField(Arena* arena, const RepeatedPtrField& rhs); + // Internal version of GetArena(). + inline Arena* GetOwningArena() const; + // Implementations for ExtractSubrange(). The copying behavior must be // included only if the type supports the necessary operations (e.g., // MergeFrom()), so we must resolve this at compile time. ExtractSubrange() @@ -1384,7 +1394,7 @@ inline RepeatedPtrField::RepeatedPtrField( // We don't just call Swap(&other) here because it would perform 3 copies if // other is on an arena. This field can't be on an arena because arena // construction always uses the Arena* accepting constructor. - if (other.GetArena()) { + if (other.GetOwningArena()) { CopyFrom(other); } else { InternalSwap(&other); @@ -1398,9 +1408,9 @@ inline RepeatedPtrField& RepeatedPtrField::operator=( // We don't just call Swap(&other) here because it would perform 3 copies if // the two fields are on different arenas. if (this != &other) { - if (GetArena() != other.GetArena() + if (GetOwningArena() != other.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - || GetArena() == nullptr + || GetOwningArena() == nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { CopyFrom(other); @@ -1482,7 +1492,7 @@ inline void RepeatedPtrField::DeleteSubrange(int start, int num) { ABSL_DCHECK_GE(num, 0); ABSL_DCHECK_LE(start + num, size()); void** subrange = raw_mutable_data() + start; - Arena* arena = GetArena(); + Arena* arena = GetOwningArena(); for (int i = 0; i < num; ++i) { using H = CommonHandler; H::Delete(static_cast(subrange[i]), arena); @@ -1513,7 +1523,7 @@ inline void RepeatedPtrField::ExtractSubrangeInternal( << "Releasing elements without transferring ownership is an unsafe " "operation. Use UnsafeArenaExtractSubrange."; if (elements != nullptr) { - Arena* arena = GetArena(); + Arena* arena = GetOwningArena(); auto* extracted = data() + start; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE // Always copy. @@ -1549,7 +1559,7 @@ inline void RepeatedPtrField::ExtractSubrangeInternal( // ExtractSubrange() must return heap-allocated objects by contract, and we // cannot fulfill this contract if we are an on arena, we must ABSL_DCHECK() // that we are not on an arena. - ABSL_DCHECK(GetArena() == nullptr) + ABSL_DCHECK(GetOwningArena() == nullptr) << "ExtractSubrange() when arena is non-nullptr is only supported when " << "the Element type supplies a MergeFrom() operation to make copies."; UnsafeArenaExtractSubrange(start, num, elements); @@ -1634,7 +1644,7 @@ template inline void RepeatedPtrField::UnsafeArenaSwap( RepeatedPtrField* other) { if (this == other) return; - ABSL_DCHECK_EQ(GetArena(), other->GetArena()); + ABSL_DCHECK_EQ(GetOwningArena(), other->GetOwningArena()); RepeatedPtrFieldBase::InternalSwap(other); } @@ -1655,6 +1665,11 @@ inline Arena* RepeatedPtrField::GetArena() const { } #endif // !PROTOBUF_FUTURE_REMOVE_CONST_REPEATEDFIELD_GETARENA_API +template +inline Arena* RepeatedPtrField::GetOwningArena() const { + return RepeatedPtrFieldBase::GetOwningArena(); +} + template inline size_t RepeatedPtrField::SpaceUsedExcludingSelfLong() const { // `google::protobuf::Message` has a virtual method `SpaceUsedLong`, hence we can