diff --git a/benchmarks/download_data.sh b/benchmarks/download_data.sh new file mode 100755 index 000000000..fa0729e9a --- /dev/null +++ b/benchmarks/download_data.sh @@ -0,0 +1,5 @@ +#! /bin/sh + +curl -O https://storage.googleapis.com/protobuf_opensource_benchmark_data/datasets.tar.gz +tar -zvxf datasets.tar.gz + diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index 8b21683db..931fdc128 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -32,9 +32,9 @@ namespace Google.Protobuf.Examples.AddressBook { "Eg4KBm51bWJlchgBIAEoCRIoCgR0eXBlGAIgASgOMhoudHV0b3JpYWwuUGVy", "c29uLlBob25lVHlwZSIrCglQaG9uZVR5cGUSCgoGTU9CSUxFEAASCAoESE9N", "RRABEggKBFdPUksQAiIvCgtBZGRyZXNzQm9vaxIgCgZwZW9wbGUYASADKAsy", - "EC50dXRvcmlhbC5QZXJzb25CWQobY29tLmV4YW1wbGUudHV0b3JpYWwucHJv", - "dG9zQhFBZGRyZXNzQm9va1Byb3Rvc1ABqgIkR29vZ2xlLlByb3RvYnVmLkV4", - "YW1wbGVzLkFkZHJlc3NCb29rYgZwcm90bzM=")); + "EC50dXRvcmlhbC5QZXJzb25CZgobY29tLmV4YW1wbGUudHV0b3JpYWwucHJv", + "dG9zQhFBZGRyZXNzQm9va1Byb3Rvc1ABWgsuLi90dXRvcmlhbKoCJEdvb2ds", + "ZS5Qcm90b2J1Zi5FeGFtcGxlcy5BZGRyZXNzQm9va2IGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { diff --git a/java/core/src/main/java/com/google/protobuf/Descriptors.java b/java/core/src/main/java/com/google/protobuf/Descriptors.java index 51597fa3d..e56a18ec9 100644 --- a/java/core/src/main/java/com/google/protobuf/Descriptors.java +++ b/java/core/src/main/java/com/google/protobuf/Descriptors.java @@ -724,12 +724,12 @@ public final class Descriptors { /** Determines if the given field number is an extension. */ public boolean isExtensionNumber(final int number) { - for (final DescriptorProto.ExtensionRange range : proto.getExtensionRangeList()) { - if (range.getStart() <= number && number < range.getEnd()) { - return true; - } + int index = Arrays.binarySearch(extensionRangeLowerBounds, number); + if (index < 0) { + index = ~index - 1; } - return false; + // extensionRangeLowerBounds[index] is the biggest value <= number + return index >= 0 && number < extensionRangeUpperBounds[index]; } /** Determines if the given field number is reserved. */ @@ -831,6 +831,9 @@ public final class Descriptors { private final OneofDescriptor[] oneofs; private final int realOneofCount; + private final int[] extensionRangeLowerBounds; + private final int[] extensionRangeUpperBounds; + // Used to create a placeholder when the type cannot be found. Descriptor(final String fullname) throws DescriptorValidationException { String name = fullname; @@ -859,6 +862,9 @@ public final class Descriptors { // Create a placeholder FileDescriptor to hold this message. this.file = new FileDescriptor(packageName, this); + + extensionRangeLowerBounds = new int[] {1}; + extensionRangeUpperBounds = new int[] {536870912}; } private Descriptor( @@ -922,6 +928,20 @@ public final class Descriptors { this.realOneofCount = this.oneofs.length - syntheticOneofCount; file.pool.addSymbol(this); + + // NOTE: The defined extension ranges are guaranteed to be disjoint. + extensionRangeLowerBounds = new int[proto.getExtensionRangeCount()]; + extensionRangeUpperBounds = new int[proto.getExtensionRangeCount()]; + int i = 0; + for (final DescriptorProto.ExtensionRange range : proto.getExtensionRangeList()) { + extensionRangeLowerBounds[i] = range.getStart(); + extensionRangeUpperBounds[i] = range.getEnd(); + i++; + } + // Since the ranges are disjoint, sorting these independently must still produce the correct + // order. + Arrays.sort(extensionRangeLowerBounds); + Arrays.sort(extensionRangeUpperBounds); } /** Look up and cross-link all field types, etc. */ diff --git a/java/core/src/test/java/com/google/protobuf/DescriptorsTest.java b/java/core/src/test/java/com/google/protobuf/DescriptorsTest.java index 74d42c670..b98b332d3 100644 --- a/java/core/src/test/java/com/google/protobuf/DescriptorsTest.java +++ b/java/core/src/test/java/com/google/protobuf/DescriptorsTest.java @@ -804,4 +804,8 @@ public class DescriptorsTest extends TestCase { .build(); assertEquals(8, msg.getExtension(NestedExtension.MyNestedExtension.default_).intValue()); } + + public void testDefaultDescriptorExtensionRange() throws Exception { + assertTrue(new Descriptor("default").isExtensionNumber(1)); + } } diff --git a/js/compatibility_tests/v3.1.0/binary/decoder_test.js b/js/compatibility_tests/v3.1.0/binary/decoder_test.js index 71a3725de..01100fd45 100644 --- a/js/compatibility_tests/v3.1.0/binary/decoder_test.js +++ b/js/compatibility_tests/v3.1.0/binary/decoder_test.js @@ -224,7 +224,6 @@ describe('binaryDecoderTest', function() { /** * Verifies that misuse of the decoder class triggers assertions. - * @suppress {checkTypes|visibility} */ it('testDecodeErrors', function() { // Reading a value past the end of the stream should trigger an assertion. diff --git a/python/google/protobuf/descriptor.py b/python/google/protobuf/descriptor.py index c8f7b4133..70fdae16f 100644 --- a/python/google/protobuf/descriptor.py +++ b/python/google/protobuf/descriptor.py @@ -912,7 +912,7 @@ class MethodDescriptor(DescriptorBase): self.containing_service = containing_service self.input_type = input_type self.output_type = output_type - + def CopyToProto(self, proto): """Copies this to a descriptor_pb2.MethodDescriptorProto. diff --git a/python/google/protobuf/internal/proto_builder_test.py b/python/google/protobuf/internal/proto_builder_test.py index 36dfbfded..3ee14e4e8 100755 --- a/python/google/protobuf/internal/proto_builder_test.py +++ b/python/google/protobuf/internal/proto_builder_test.py @@ -42,6 +42,7 @@ except ImportError: import unittest from google.protobuf import descriptor_pb2 +from google.protobuf import descriptor from google.protobuf import descriptor_pool from google.protobuf import proto_builder from google.protobuf import text_format @@ -91,6 +92,23 @@ class ProtoBuilderTest(unittest.TestCase): pool=pool) self.assertIs(proto_cls1.DESCRIPTOR, proto_cls2.DESCRIPTOR) + def testMakeLargeProtoClass(self): + """Test that large created protos don't use reserved field numbers.""" + num_fields = 123456 + fields = { + 'foo%d' % i: descriptor_pb2.FieldDescriptorProto.TYPE_INT64 + for i in range(num_fields) + } + proto_cls = proto_builder.MakeSimpleProtoClass( + fields, + full_name='net.proto2.python.public.proto_builder_test.LargeProtoTest') + + reserved_field_numbers = set( + range(descriptor.FieldDescriptor.FIRST_RESERVED_FIELD_NUMBER, + descriptor.FieldDescriptor.LAST_RESERVED_FIELD_NUMBER + 1)) + proto_field_numbers = set(proto_cls.DESCRIPTOR.fields_by_number) + self.assertFalse(reserved_field_numbers.intersection(proto_field_numbers)) + if __name__ == '__main__': unittest.main() diff --git a/python/google/protobuf/proto_builder.py b/python/google/protobuf/proto_builder.py index 736caed38..2b7dddcbd 100644 --- a/python/google/protobuf/proto_builder.py +++ b/python/google/protobuf/proto_builder.py @@ -31,13 +31,14 @@ """Dynamic Protobuf class creator.""" try: - from collections import OrderedDict + from collections import OrderedDict except ImportError: - from ordereddict import OrderedDict #PY26 + from ordereddict import OrderedDict #PY26 import hashlib import os from google.protobuf import descriptor_pb2 +from google.protobuf import descriptor from google.protobuf import message_factory @@ -124,6 +125,12 @@ def _MakeFileDescriptorProto(proto_file_name, full_name, field_items): for f_number, (f_name, f_type) in enumerate(field_items, 1): field_proto = desc_proto.field.add() field_proto.name = f_name + # # If the number falls in the reserved range, reassign it to the correct + # # number after the range. + if f_number >= descriptor.FieldDescriptor.FIRST_RESERVED_FIELD_NUMBER: + f_number += ( + descriptor.FieldDescriptor.LAST_RESERVED_FIELD_NUMBER - + descriptor.FieldDescriptor.FIRST_RESERVED_FIELD_NUMBER + 1) field_proto.number = f_number field_proto.label = descriptor_pb2.FieldDescriptorProto.LABEL_OPTIONAL field_proto.type = f_type diff --git a/python/google/protobuf/pyext/repeated_composite_container.cc b/python/google/protobuf/pyext/repeated_composite_container.cc index cbc0f9f8a..f3d6fc309 100644 --- a/python/google/protobuf/pyext/repeated_composite_container.cc +++ b/python/google/protobuf/pyext/repeated_composite_container.cc @@ -379,16 +379,19 @@ static void ReorderAttached(RepeatedCompositeContainer* self, const FieldDescriptor* descriptor = self->parent_field_descriptor; const Py_ssize_t length = Length(reinterpret_cast(self)); - // Since Python protobuf objects are never arena-allocated, adding and - // removing message pointers to the underlying array is just updating - // pointers. - for (Py_ssize_t i = 0; i < length; ++i) - reflection->ReleaseLast(message, descriptor); - + // We need to rearrange things to match python's sort order. Because there + // was already an O(n*log(n)) step in python and a bunch of reflection, we + // expect an O(n**2) step in C++ won't hurt too much. for (Py_ssize_t i = 0; i < length; ++i) { - CMessage* py_cmsg = reinterpret_cast( - PyList_GET_ITEM(child_list, i)); - reflection->AddAllocatedMessage(message, descriptor, py_cmsg->message); + Message* child_message = + reinterpret_cast(PyList_GET_ITEM(child_list, i))->message; + for (Py_ssize_t j = i; j < length; ++j) { + if (child_message == + &reflection->GetRepeatedMessage(*message, descriptor, j)) { + reflection->SwapElements(message, descriptor, i, j); + break; + } + } } } diff --git a/python/setup.py b/python/setup.py index ff67b8938..8849e9a3e 100755 --- a/python/setup.py +++ b/python/setup.py @@ -18,7 +18,6 @@ from setuptools import setup, Extension, find_packages from distutils.command.build_py import build_py as _build_py from distutils.command.clean import clean as _clean -from distutils.command.build_ext import build_ext as _build_ext from distutils.spawn import find_executable # Find the Protocol Compiler. @@ -158,22 +157,6 @@ class build_py(_build_py): if not any(fnmatch.fnmatchcase(fil, pat=pat) for pat in exclude)] -class build_ext(_build_ext): - def get_ext_filename(self, ext_name): - # since python3.5, python extensions' shared libraries use a suffix that corresponds to the value - # of sysconfig.get_config_var('EXT_SUFFIX') and contains info about the architecture the library targets. - # E.g. on x64 linux the suffix is ".cpython-XYZ-x86_64-linux-gnu.so" - # When crosscompiling python wheels, we need to be able to override this suffix - # so that the resulting file name matches the target architecture and we end up with a well-formed - # wheel. - filename = _build_ext.get_ext_filename(self, ext_name) - orig_ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") - new_ext_suffix = os.getenv("PROTOCOL_BUFFERS_OVERRIDE_EXT_SUFFIX") - if new_ext_suffix and filename.endswith(orig_ext_suffix): - filename = filename[:-len(orig_ext_suffix)] + new_ext_suffix - return filename - - class test_conformance(_build_py): target = 'test_python' def run(self): @@ -322,7 +305,6 @@ if __name__ == '__main__': cmdclass={ 'clean': clean, 'build_py': build_py, - 'build_ext': build_ext, 'test_conformance': test_conformance, }, install_requires=install_requires, diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index f061f5a03..867cc371c 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -110,12 +110,12 @@ Any::Any(const Any& from) type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_type_url().empty()) { type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_url(), - GetArena()); + GetArenaForAllocation()); } value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_value().empty()) { value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(), - GetArena()); + GetArenaForAllocation()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.Any) } @@ -132,7 +132,7 @@ Any::~Any() { } void Any::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } @@ -211,7 +211,7 @@ failure: (void) cached_has_bits; // string type_url = 1; - if (this->type_url().size() > 0) { + if (!this->type_url().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_type_url().data(), static_cast(this->_internal_type_url().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -221,7 +221,7 @@ failure: } // bytes value = 2; - if (this->value().size() > 0) { + if (!this->value().empty()) { target = stream->WriteBytesMaybeAliased( 2, this->_internal_value(), target); } @@ -243,14 +243,14 @@ size_t Any::ByteSizeLong() const { (void) cached_has_bits; // string type_url = 1; - if (this->type_url().size() > 0) { + if (!this->type_url().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_type_url()); } // bytes value = 2; - if (this->value().size() > 0) { + if (!this->value().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( this->_internal_value()); @@ -287,10 +287,10 @@ void Any::MergeFrom(const Any& from) { ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; - if (from.type_url().size() > 0) { + if (!from.type_url().empty()) { _internal_set_type_url(from._internal_type_url()); } - if (from.value().size() > 0) { + if (!from.value().empty()) { _internal_set_value(from._internal_value()); } } @@ -316,8 +316,16 @@ bool Any::IsInitialized() const { void Any::InternalSwap(Any* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - type_url_.Swap(&other->type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - value_.Swap(&other->value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &type_url_, GetArenaForAllocation(), + &other->type_url_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &value_, GetArenaForAllocation(), + &other->value_, other->GetArenaForAllocation() + ); } ::PROTOBUF_NAMESPACE_ID::Metadata Any::GetMetadata() const { diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index a8e81e6bb..01a583ab0 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -65,7 +65,7 @@ PROTOBUF_NAMESPACE_OPEN // =================================================================== -class PROTOBUF_EXPORT Any PROTOBUF_FINAL : +class PROTOBUF_EXPORT Any final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Any) */ { public: inline Any() : Any(nullptr) {} @@ -83,8 +83,9 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL : return *this; } inline Any& operator=(Any&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -148,7 +149,7 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL : } inline void Swap(Any* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -156,14 +157,14 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL : } void UnsafeArenaSwap(Any* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline Any* New() const final { - return CreateMaybeMessage(nullptr); + return new Any(); } Any* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -214,11 +215,11 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL : template void set_type_url(ArgT0&& arg0, ArgT... args); std::string* mutable_type_url(); - std::string* release_type_url(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_type_url(); void set_allocated_type_url(std::string* type_url); private: const std::string& _internal_type_url() const; - void _internal_set_type_url(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_type_url(const std::string& value); std::string* _internal_mutable_type_url(); public: @@ -228,11 +229,11 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL : template void set_value(ArgT0&& arg0, ArgT... args); std::string* mutable_value(); - std::string* release_value(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_value(); void set_allocated_value(std::string* value); private: const std::string& _internal_value() const; - void _internal_set_value(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_value(const std::string& value); std::string* _internal_mutable_value(); public: @@ -269,10 +270,10 @@ inline const std::string& Any::type_url() const { return _internal_type_url(); } template -PROTOBUF_ALWAYS_INLINE -inline void Any::set_type_url(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void Any::set_type_url(ArgT0&& arg0, ArgT... args) { - type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url) } inline std::string* Any::mutable_type_url() { @@ -284,15 +285,15 @@ inline const std::string& Any::_internal_type_url() const { } inline void Any::_internal_set_type_url(const std::string& value) { - type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* Any::_internal_mutable_type_url() { - return type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* Any::release_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Any.type_url) - return type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void Any::set_allocated_type_url(std::string* type_url) { if (type_url != nullptr) { @@ -301,7 +302,7 @@ inline void Any::set_allocated_type_url(std::string* type_url) { } type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_url, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url) } @@ -314,10 +315,10 @@ inline const std::string& Any::value() const { return _internal_value(); } template -PROTOBUF_ALWAYS_INLINE -inline void Any::set_value(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void Any::set_value(ArgT0&& arg0, ArgT... args) { - value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Any.value) } inline std::string* Any::mutable_value() { @@ -329,15 +330,15 @@ inline const std::string& Any::_internal_value() const { } inline void Any::_internal_set_value(const std::string& value) { - value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* Any::_internal_mutable_value() { - return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* Any::release_value() { // @@protoc_insertion_point(field_release:google.protobuf.Any.value) - return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void Any::set_allocated_value(std::string* value) { if (value != nullptr) { @@ -346,7 +347,7 @@ inline void Any::set_allocated_value(std::string* value) { } value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value) } diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index e818046f3..1879c60a0 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -173,7 +173,7 @@ void Api::clear_options() { options_.Clear(); } void Api::clear_source_context() { - if (GetArena() == nullptr && source_context_ != nullptr) { + if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) { delete source_context_; } source_context_ = nullptr; @@ -196,12 +196,12 @@ Api::Api(const Api& from) name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } version_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_version().empty()) { version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_version(), - GetArena()); + GetArenaForAllocation()); } if (from._internal_has_source_context()) { source_context_ = new PROTOBUF_NAMESPACE_ID::SourceContext(*from.source_context_); @@ -228,7 +228,7 @@ Api::~Api() { } void Api::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); version_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete source_context_; @@ -255,7 +255,7 @@ void Api::Clear() { mixins_.Clear(); name_.ClearToEmpty(); version_.ClearToEmpty(); - if (GetArena() == nullptr && source_context_ != nullptr) { + if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) { delete source_context_; } source_context_ = nullptr; @@ -368,7 +368,7 @@ failure: (void) cached_has_bits; // string name = 1; - if (this->name().size() > 0) { + if (!this->name().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -394,7 +394,7 @@ failure: } // string version = 4; - if (this->version().size() > 0) { + if (!this->version().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_version().data(), static_cast(this->_internal_version().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -464,14 +464,14 @@ size_t Api::ByteSizeLong() const { } // string name = 1; - if (this->name().size() > 0) { + if (!this->name().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_name()); } // string version = 4; - if (this->version().size() > 0) { + if (!this->version().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_version()); @@ -524,10 +524,10 @@ void Api::MergeFrom(const Api& from) { methods_.MergeFrom(from.methods_); options_.MergeFrom(from.options_); mixins_.MergeFrom(from.mixins_); - if (from.name().size() > 0) { + if (!from.name().empty()) { _internal_set_name(from._internal_name()); } - if (from.version().size() > 0) { + if (!from.version().empty()) { _internal_set_version(from._internal_version()); } if (from.has_source_context()) { @@ -562,8 +562,16 @@ void Api::InternalSwap(Api* other) { methods_.InternalSwap(&other->methods_); options_.InternalSwap(&other->options_); mixins_.InternalSwap(&other->mixins_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - version_.Swap(&other->version_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &version_, GetArenaForAllocation(), + &other->version_, other->GetArenaForAllocation() + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(Api, syntax_) + sizeof(Api::syntax_) @@ -601,17 +609,17 @@ Method::Method(const Method& from) name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } request_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_request_type_url().empty()) { request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_request_type_url(), - GetArena()); + GetArenaForAllocation()); } response_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_response_type_url().empty()) { response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_response_type_url(), - GetArena()); + GetArenaForAllocation()); } ::memcpy(&request_streaming_, &from.request_streaming_, static_cast(reinterpret_cast(&syntax_) - @@ -636,7 +644,7 @@ Method::~Method() { } void Method::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); request_type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); response_type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); @@ -765,7 +773,7 @@ failure: (void) cached_has_bits; // string name = 1; - if (this->name().size() > 0) { + if (!this->name().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -775,7 +783,7 @@ failure: } // string request_type_url = 2; - if (this->request_type_url().size() > 0) { + if (!this->request_type_url().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_request_type_url().data(), static_cast(this->_internal_request_type_url().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -791,7 +799,7 @@ failure: } // string response_type_url = 4; - if (this->response_type_url().size() > 0) { + if (!this->response_type_url().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_response_type_url().data(), static_cast(this->_internal_response_type_url().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -845,21 +853,21 @@ size_t Method::ByteSizeLong() const { } // string name = 1; - if (this->name().size() > 0) { + if (!this->name().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_name()); } // string request_type_url = 2; - if (this->request_type_url().size() > 0) { + if (!this->request_type_url().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_request_type_url()); } // string response_type_url = 4; - if (this->response_type_url().size() > 0) { + if (!this->response_type_url().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_response_type_url()); @@ -913,13 +921,13 @@ void Method::MergeFrom(const Method& from) { (void) cached_has_bits; options_.MergeFrom(from.options_); - if (from.name().size() > 0) { + if (!from.name().empty()) { _internal_set_name(from._internal_name()); } - if (from.request_type_url().size() > 0) { + if (!from.request_type_url().empty()) { _internal_set_request_type_url(from._internal_request_type_url()); } - if (from.response_type_url().size() > 0) { + if (!from.response_type_url().empty()) { _internal_set_response_type_url(from._internal_response_type_url()); } if (from.request_streaming() != 0) { @@ -955,9 +963,21 @@ void Method::InternalSwap(Method* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); options_.InternalSwap(&other->options_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - request_type_url_.Swap(&other->request_type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - response_type_url_.Swap(&other->response_type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &request_type_url_, GetArenaForAllocation(), + &other->request_type_url_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &response_type_url_, GetArenaForAllocation(), + &other->response_type_url_, other->GetArenaForAllocation() + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(Method, syntax_) + sizeof(Method::syntax_) @@ -990,12 +1010,12 @@ Mixin::Mixin(const Mixin& from) name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } root_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_root().empty()) { root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_root(), - GetArena()); + GetArenaForAllocation()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin) } @@ -1012,7 +1032,7 @@ Mixin::~Mixin() { } void Mixin::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); root_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } @@ -1092,7 +1112,7 @@ failure: (void) cached_has_bits; // string name = 1; - if (this->name().size() > 0) { + if (!this->name().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -1102,7 +1122,7 @@ failure: } // string root = 2; - if (this->root().size() > 0) { + if (!this->root().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_root().data(), static_cast(this->_internal_root().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -1128,14 +1148,14 @@ size_t Mixin::ByteSizeLong() const { (void) cached_has_bits; // string name = 1; - if (this->name().size() > 0) { + if (!this->name().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_name()); } // string root = 2; - if (this->root().size() > 0) { + if (!this->root().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_root()); @@ -1172,10 +1192,10 @@ void Mixin::MergeFrom(const Mixin& from) { ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; - if (from.name().size() > 0) { + if (!from.name().empty()) { _internal_set_name(from._internal_name()); } - if (from.root().size() > 0) { + if (!from.root().empty()) { _internal_set_root(from._internal_root()); } } @@ -1201,8 +1221,16 @@ bool Mixin::IsInitialized() const { void Mixin::InternalSwap(Mixin* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - root_.Swap(&other->root_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &root_, GetArenaForAllocation(), + &other->root_, other->GetArenaForAllocation() + ); } ::PROTOBUF_NAMESPACE_ID::Metadata Mixin::GetMetadata() const { diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 889cb4395..bce781732 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -75,7 +75,7 @@ PROTOBUF_NAMESPACE_OPEN // =================================================================== -class PROTOBUF_EXPORT Api PROTOBUF_FINAL : +class PROTOBUF_EXPORT Api final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Api) */ { public: inline Api() : Api(nullptr) {} @@ -93,8 +93,9 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL : return *this; } inline Api& operator=(Api&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -125,7 +126,7 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL : } inline void Swap(Api* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -133,14 +134,14 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL : } void UnsafeArenaSwap(Api* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline Api* New() const final { - return CreateMaybeMessage(nullptr); + return new Api(); } Api* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -250,11 +251,11 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -264,11 +265,11 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL : template void set_version(ArgT0&& arg0, ArgT... args); std::string* mutable_version(); - std::string* release_version(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_version(); void set_allocated_version(std::string* version); private: const std::string& _internal_version() const; - void _internal_set_version(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_version(const std::string& value); std::string* _internal_mutable_version(); public: @@ -318,7 +319,7 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Method PROTOBUF_FINAL : +class PROTOBUF_EXPORT Method final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Method) */ { public: inline Method() : Method(nullptr) {} @@ -336,8 +337,9 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL : return *this; } inline Method& operator=(Method&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -368,7 +370,7 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL : } inline void Swap(Method* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -376,14 +378,14 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL : } void UnsafeArenaSwap(Method* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline Method* New() const final { - return CreateMaybeMessage(nullptr); + return new Method(); } Method* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -457,11 +459,11 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -471,11 +473,11 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL : template void set_request_type_url(ArgT0&& arg0, ArgT... args); std::string* mutable_request_type_url(); - std::string* release_request_type_url(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_request_type_url(); void set_allocated_request_type_url(std::string* request_type_url); private: const std::string& _internal_request_type_url() const; - void _internal_set_request_type_url(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_request_type_url(const std::string& value); std::string* _internal_mutable_request_type_url(); public: @@ -485,11 +487,11 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL : template void set_response_type_url(ArgT0&& arg0, ArgT... args); std::string* mutable_response_type_url(); - std::string* release_response_type_url(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_response_type_url(); void set_allocated_response_type_url(std::string* response_type_url); private: const std::string& _internal_response_type_url() const; - void _internal_set_response_type_url(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_response_type_url(const std::string& value); std::string* _internal_mutable_response_type_url(); public: @@ -539,7 +541,7 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL : +class PROTOBUF_EXPORT Mixin final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Mixin) */ { public: inline Mixin() : Mixin(nullptr) {} @@ -557,8 +559,9 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL : return *this; } inline Mixin& operator=(Mixin&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -589,7 +592,7 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL : } inline void Swap(Mixin* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -597,14 +600,14 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL : } void UnsafeArenaSwap(Mixin* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline Mixin* New() const final { - return CreateMaybeMessage(nullptr); + return new Mixin(); } Mixin* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -655,11 +658,11 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -669,11 +672,11 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL : template void set_root(ArgT0&& arg0, ArgT... args); std::string* mutable_root(); - std::string* release_root(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_root(); void set_allocated_root(std::string* root); private: const std::string& _internal_root() const; - void _internal_set_root(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_root(const std::string& value); std::string* _internal_mutable_root(); public: @@ -709,10 +712,10 @@ inline const std::string& Api::name() const { return _internal_name(); } template -PROTOBUF_ALWAYS_INLINE -inline void Api::set_name(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void Api::set_name(ArgT0&& arg0, ArgT... args) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Api.name) } inline std::string* Api::mutable_name() { @@ -724,15 +727,15 @@ inline const std::string& Api::_internal_name() const { } inline void Api::_internal_set_name(const std::string& value) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* Api::_internal_mutable_name() { - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* Api::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Api.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void Api::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -741,7 +744,7 @@ inline void Api::set_allocated_name(std::string* name) { } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.name) } @@ -829,10 +832,10 @@ inline const std::string& Api::version() const { return _internal_version(); } template -PROTOBUF_ALWAYS_INLINE -inline void Api::set_version(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void Api::set_version(ArgT0&& arg0, ArgT... args) { - version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Api.version) } inline std::string* Api::mutable_version() { @@ -844,15 +847,15 @@ inline const std::string& Api::_internal_version() const { } inline void Api::_internal_set_version(const std::string& value) { - version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* Api::_internal_mutable_version() { - return version_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return version_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* Api::release_version() { // @@protoc_insertion_point(field_release:google.protobuf.Api.version) - return version_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return version_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void Api::set_allocated_version(std::string* version) { if (version != nullptr) { @@ -861,7 +864,7 @@ inline void Api::set_allocated_version(std::string* version) { } version_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), version, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version) } @@ -883,7 +886,7 @@ inline const PROTOBUF_NAMESPACE_ID::SourceContext& Api::source_context() const { } inline void Api::unsafe_arena_set_allocated_source_context( PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); } source_context_ = source_context; @@ -898,7 +901,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Api::release_source_context() { PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_; source_context_ = nullptr; - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -913,7 +916,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Api::unsafe_arena_release_source_co inline PROTOBUF_NAMESPACE_ID::SourceContext* Api::_internal_mutable_source_context() { if (source_context_ == nullptr) { - auto* p = CreateMaybeMessage(GetArena()); + auto* p = CreateMaybeMessage(GetArenaForAllocation()); source_context_ = p; } return source_context_; @@ -923,13 +926,15 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Api::mutable_source_context() { return _internal_mutable_source_context(); } inline void Api::set_allocated_source_context(PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); } if (source_context) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context)->GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper< + ::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena( + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context)); if (message_arena != submessage_arena) { source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, source_context, submessage_arena); @@ -1014,10 +1019,10 @@ inline const std::string& Method::name() const { return _internal_name(); } template -PROTOBUF_ALWAYS_INLINE -inline void Method::set_name(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void Method::set_name(ArgT0&& arg0, ArgT... args) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Method.name) } inline std::string* Method::mutable_name() { @@ -1029,15 +1034,15 @@ inline const std::string& Method::_internal_name() const { } inline void Method::_internal_set_name(const std::string& value) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* Method::_internal_mutable_name() { - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* Method::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Method.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void Method::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -1046,7 +1051,7 @@ inline void Method::set_allocated_name(std::string* name) { } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name) } @@ -1059,10 +1064,10 @@ inline const std::string& Method::request_type_url() const { return _internal_request_type_url(); } template -PROTOBUF_ALWAYS_INLINE -inline void Method::set_request_type_url(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void Method::set_request_type_url(ArgT0&& arg0, ArgT... args) { - request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url) } inline std::string* Method::mutable_request_type_url() { @@ -1074,15 +1079,15 @@ inline const std::string& Method::_internal_request_type_url() const { } inline void Method::_internal_set_request_type_url(const std::string& value) { - request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* Method::_internal_mutable_request_type_url() { - return request_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return request_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* Method::release_request_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Method.request_type_url) - return request_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return request_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void Method::set_allocated_request_type_url(std::string* request_type_url) { if (request_type_url != nullptr) { @@ -1091,7 +1096,7 @@ inline void Method::set_allocated_request_type_url(std::string* request_type_url } request_type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), request_type_url, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url) } @@ -1124,10 +1129,10 @@ inline const std::string& Method::response_type_url() const { return _internal_response_type_url(); } template -PROTOBUF_ALWAYS_INLINE -inline void Method::set_response_type_url(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void Method::set_response_type_url(ArgT0&& arg0, ArgT... args) { - response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url) } inline std::string* Method::mutable_response_type_url() { @@ -1139,15 +1144,15 @@ inline const std::string& Method::_internal_response_type_url() const { } inline void Method::_internal_set_response_type_url(const std::string& value) { - response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* Method::_internal_mutable_response_type_url() { - return response_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return response_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* Method::release_response_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Method.response_type_url) - return response_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return response_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void Method::set_allocated_response_type_url(std::string* response_type_url) { if (response_type_url != nullptr) { @@ -1156,7 +1161,7 @@ inline void Method::set_allocated_response_type_url(std::string* response_type_u } response_type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), response_type_url, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url) } @@ -1249,10 +1254,10 @@ inline const std::string& Mixin::name() const { return _internal_name(); } template -PROTOBUF_ALWAYS_INLINE -inline void Mixin::set_name(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void Mixin::set_name(ArgT0&& arg0, ArgT... args) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name) } inline std::string* Mixin::mutable_name() { @@ -1264,15 +1269,15 @@ inline const std::string& Mixin::_internal_name() const { } inline void Mixin::_internal_set_name(const std::string& value) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* Mixin::_internal_mutable_name() { - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* Mixin::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Mixin.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void Mixin::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -1281,7 +1286,7 @@ inline void Mixin::set_allocated_name(std::string* name) { } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name) } @@ -1294,10 +1299,10 @@ inline const std::string& Mixin::root() const { return _internal_root(); } template -PROTOBUF_ALWAYS_INLINE -inline void Mixin::set_root(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void Mixin::set_root(ArgT0&& arg0, ArgT... args) { - root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root) } inline std::string* Mixin::mutable_root() { @@ -1309,15 +1314,15 @@ inline const std::string& Mixin::_internal_root() const { } inline void Mixin::_internal_set_root(const std::string& value) { - root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* Mixin::_internal_mutable_root() { - return root_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return root_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* Mixin::release_root() { // @@protoc_insertion_point(field_release:google.protobuf.Mixin.root) - return root_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return root_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void Mixin::set_allocated_root(std::string* root) { if (root != nullptr) { @@ -1326,7 +1331,7 @@ inline void Mixin::set_allocated_root(std::string* root) { } root_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), root, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root) } diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 59c9317f2..f84e505eb 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -93,8 +93,8 @@ class EpsCopyInputStream; // defined in parse_context.h template class GenericTypeHandler; // defined in repeated_field.h -PROTOBUF_ALWAYS_INLINE -inline void* AlignTo(void* ptr, size_t align) { +inline PROTOBUF_ALWAYS_INLINE +void* AlignTo(void* ptr, size_t align) { return reinterpret_cast( (reinterpret_cast(ptr) + align - 1) & (~align + 1)); } @@ -399,6 +399,16 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { template class InternalHelper { + public: + // Provides access to protected GetOwningArena to generated messages. + static Arena* GetOwningArena(const T* p) { return p->GetOwningArena(); } + + // Provides access to protected GetArenaForAllocation to generated messages. + static Arena* GetArenaForAllocation(const T* p) { + return p->GetArenaForAllocation(); + } + + private: template static char DestructorSkippable(const typename U::DestructorSkippable_*); template @@ -439,6 +449,10 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { return new (ptr) T(std::forward(args)...); } + static T* New() { + return new T(nullptr); + } + static Arena* GetArena(const T* p) { return p->GetArena(); } friend class Arena; @@ -490,7 +504,9 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { InternalHelper::is_arena_constructable::value, "CreateMessage can only construct types that are ArenaConstructable"); if (arena == NULL) { - return new T(); + // Generated arena constructor T(Arena*) is protected. Call via + // InternalHelper. + return InternalHelper::New(); } else { return arena->DoCreateMessage(); } @@ -678,6 +694,25 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { return nullptr; } + template + PROTOBUF_ALWAYS_INLINE static Arena* GetOwningArena(const T* value) { + return GetOwningArenaInternal( + value, std::is_convertible()); + } + + // Implementation for GetOwningArena(). All and only message objects have + // GetOwningArena() method. + template + PROTOBUF_ALWAYS_INLINE static Arena* GetOwningArenaInternal( + const T* value, std::true_type) { + return InternalHelper::GetOwningArena(value); + } + template + PROTOBUF_ALWAYS_INLINE static Arena* GetOwningArenaInternal( + const T* value, std::false_type) { + return nullptr; + } + // For friends of arena. void* AllocateAligned(size_t n, size_t align = 8) { if (align <= 8) { diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index a9eb5de33..75c16678d 100644 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h @@ -223,11 +223,11 @@ struct PROTOBUF_EXPORT ArenaStringPtr { } // Basic accessors. - const std::string& Get() const PROTOBUF_NDEBUG_INLINE { + PROTOBUF_NDEBUG_INLINE const std::string& Get() const { // Unconditionally mask away the tag. return *tagged_ptr_.Get(); } - const std::string* GetPointer() const PROTOBUF_NDEBUG_INLINE { + PROTOBUF_NDEBUG_INLINE const std::string* GetPointer() const { // Unconditionally mask away the tag. return tagged_ptr_.Get(); } @@ -241,10 +241,10 @@ struct PROTOBUF_EXPORT ArenaStringPtr { // Own()'d by any arena. If the field is not set, this returns NULL. The // caller retains ownership. Clears this field back to NULL state. Used to // implement release_() methods on generated classes. - std::string* Release(const std::string* default_value, - ::google::protobuf::Arena* arena); - std::string* ReleaseNonDefault(const std::string* default_value, - ::google::protobuf::Arena* arena); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* Release( + const std::string* default_value, ::google::protobuf::Arena* arena); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* ReleaseNonDefault( + const std::string* default_value, ::google::protobuf::Arena* arena); // Takes a std::string that is heap-allocated, and takes ownership. The // std::string's destructor is registered with the arena. Used to implement @@ -255,8 +255,9 @@ struct PROTOBUF_EXPORT ArenaStringPtr { // Swaps internal pointers. Arena-safety semantics: this is guarded by the // logic in Swap()/UnsafeArenaSwap() at the message level, so this method is // 'unsafe' if called directly. - inline void Swap(ArenaStringPtr* other, const std::string* default_value, - Arena* arena) PROTOBUF_NDEBUG_INLINE; + inline PROTOBUF_NDEBUG_INLINE static void InternalSwap( + const std::string* default_value, ArenaStringPtr* rhs, Arena* rhs_arena, + ArenaStringPtr* lhs, Arena* lhs_arena); // Frees storage (if not on an arena). void Destroy(const std::string* default_value, ::google::protobuf::Arena* arena); @@ -340,36 +341,28 @@ inline void ArenaStringPtr::UnsafeSetDefault(const std::string* value) { tagged_ptr_.Set(const_cast(value)); } -inline void ArenaStringPtr::Swap(ArenaStringPtr* other, - const std::string* default_value, - Arena* arena) { -#ifndef NDEBUG - // For debug builds, we swap the contents of the string, rather than the - // std::string instances themselves. This invalidates previously taken const - // references that are (per our documentation) invalidated by calling Swap() - // on the message. - // - // If both strings are the default_value, swapping is uninteresting. - // Otherwise, we use ArenaStringPtr::Mutable() to access the std::string, to - // ensure that we do not try to mutate default_value itself. - if (IsDefault(default_value) && other->IsDefault(default_value)) { - return; - } - - if (default_value == nullptr) { - // If we have non-empty default, then `default_value` is null and we can't - // call Mutable the same way. Just do the regular swap. - std::swap(tagged_ptr_, other->tagged_ptr_); - } else { - std::string* this_ptr = Mutable(EmptyDefault{}, arena); - std::string* other_ptr = other->Mutable(EmptyDefault{}, arena); - - this_ptr->swap(*other_ptr); - } -#else +inline PROTOBUF_NDEBUG_INLINE void ArenaStringPtr::InternalSwap( // + const std::string* default_value, // + ArenaStringPtr* rhs, Arena* rhs_arena, // + ArenaStringPtr* lhs, Arena* lhs_arena) { (void)default_value; - (void)arena; - std::swap(tagged_ptr_, other->tagged_ptr_); + std::swap(lhs_arena, rhs_arena); + std::swap(lhs->tagged_ptr_, rhs->tagged_ptr_); +#if 0 // TODO(b/186650244): renable this +#ifndef NDEBUG + auto force_realloc = [default_value](ArenaStringPtr* p, Arena* arena) { + if (p->IsDefault(default_value)) return; + std::string* old_value = p->tagged_ptr_.Get(); + std::string* new_value = + p->IsDonatedString() + ? Arena::Create(arena, *old_value) + : Arena::Create(arena, std::move(*old_value)); + if (arena == nullptr) delete old_value; + p->tagged_ptr_.Set(new_value); + }; + force_realloc(lhs, lhs_arena); + force_realloc(rhs, rhs_arena); +#endif #endif } diff --git a/src/google/protobuf/arenastring_unittest.cc b/src/google/protobuf/arenastring_unittest.cc index bd4b4d845..db988afb5 100644 --- a/src/google/protobuf/arenastring_unittest.cc +++ b/src/google/protobuf/arenastring_unittest.cc @@ -54,121 +54,100 @@ namespace protobuf { using internal::ArenaStringPtr; -static std::string WrapString(const char* value) { return value; } - using EmptyDefault = ArenaStringPtr::EmptyDefault; const internal::LazyString nonempty_default{{{"default", 7}}, {nullptr}}; +const std::string* empty_default = &internal::GetEmptyString(); -// Test ArenaStringPtr with arena == NULL. -TEST(ArenaStringPtrTest, ArenaStringPtrOnHeap) { +class SingleArena : public testing::TestWithParam { + public: + std::unique_ptr GetArena() { + if (this->GetParam()) return nullptr; + return std::unique_ptr(new Arena()); + } +}; + +INSTANTIATE_TEST_SUITE_P(ArenaString, SingleArena, testing::Bool()); + +TEST_P(SingleArena, GetSet) { + auto arena = GetArena(); ArenaStringPtr field; - const std::string* empty_default = &internal::GetEmptyString(); field.UnsafeSetDefault(empty_default); - EXPECT_EQ(std::string(""), field.Get()); - field.Set(empty_default, WrapString("Test short"), NULL); - EXPECT_EQ(std::string("Test short"), field.Get()); - field.Set(empty_default, WrapString("Test long long long long value"), NULL); - EXPECT_EQ(std::string("Test long long long long value"), field.Get()); - field.Set(empty_default, std::string(""), NULL); - field.Destroy(empty_default, NULL); - - ArenaStringPtr field2; - field2.UnsafeSetDefault(empty_default); - std::string* mut = field2.Mutable(EmptyDefault{}, NULL); - EXPECT_EQ(mut, field2.Mutable(EmptyDefault{}, NULL)); - EXPECT_EQ(mut, &field2.Get()); - EXPECT_NE(empty_default, mut); - EXPECT_EQ(std::string(""), *mut); - *mut = "Test long long long long value"; // ensure string allocates storage - EXPECT_EQ(std::string("Test long long long long value"), field2.Get()); - field2.Destroy(empty_default, NULL); - - ArenaStringPtr field3; - field3.UnsafeSetDefault(nullptr); - mut = field3.Mutable(nonempty_default, NULL); - EXPECT_EQ(mut, field3.Mutable(nonempty_default, NULL)); - EXPECT_EQ(mut, &field3.Get()); - EXPECT_NE(nullptr, mut); - EXPECT_EQ(std::string("default"), *mut); - *mut = "Test long long long long value"; // ensure string allocates storage - EXPECT_EQ(std::string("Test long long long long value"), field3.Get()); - field3.Destroy(nullptr, NULL); + EXPECT_EQ("", field.Get()); + field.Set(empty_default, "Test short", arena.get()); + EXPECT_EQ("Test short", field.Get()); + field.Set(empty_default, "Test long long long long value", arena.get()); + EXPECT_EQ("Test long long long long value", field.Get()); + field.Set(empty_default, "", arena.get()); + field.Destroy(empty_default, arena.get()); } -TEST(ArenaStringPtrTest, ArenaStringPtrOnArena) { - Arena arena; +TEST_P(SingleArena, MutableAccessor) { + auto arena = GetArena(); ArenaStringPtr field; const std::string* empty_default = &internal::GetEmptyString(); field.UnsafeSetDefault(empty_default); - EXPECT_EQ(std::string(""), field.Get()); - field.Set(empty_default, WrapString("Test short"), &arena); - EXPECT_EQ(std::string("Test short"), field.Get()); - field.Set(empty_default, WrapString("Test long long long long value"), - &arena); - EXPECT_EQ(std::string("Test long long long long value"), field.Get()); - field.Set(empty_default, std::string(""), &arena); - field.Destroy(empty_default, &arena); - ArenaStringPtr field2; - field2.UnsafeSetDefault(empty_default); - std::string* mut = field2.Mutable(EmptyDefault{}, &arena); - EXPECT_EQ(mut, field2.Mutable(EmptyDefault{}, &arena)); - EXPECT_EQ(mut, &field2.Get()); + std::string* mut = field.Mutable(EmptyDefault{}, arena.get()); + EXPECT_EQ(mut, field.Mutable(EmptyDefault{}, arena.get())); + EXPECT_EQ(mut, &field.Get()); EXPECT_NE(empty_default, mut); - EXPECT_EQ(std::string(""), *mut); + EXPECT_EQ("", *mut); *mut = "Test long long long long value"; // ensure string allocates storage - EXPECT_EQ(std::string("Test long long long long value"), field2.Get()); - field2.Destroy(empty_default, &arena); - - ArenaStringPtr field3; - field3.UnsafeSetDefault(nullptr); - mut = field3.Mutable(nonempty_default, &arena); - EXPECT_EQ(mut, field3.Mutable(nonempty_default, &arena)); - EXPECT_EQ(mut, &field3.Get()); - EXPECT_NE(nullptr, mut); - EXPECT_EQ(std::string("default"), *mut); - *mut = "Test long long long long value"; // ensure string allocates storage - EXPECT_EQ(std::string("Test long long long long value"), field3.Get()); - field3.Destroy(nullptr, &arena); + EXPECT_EQ("Test long long long long value", field.Get()); + field.Destroy(empty_default, arena.get()); } -TEST(ArenaStringPtrTest, ArenaStringPtrOnArenaNoSSO) { - Arena arena; +TEST_P(SingleArena, NullDefault) { + auto arena = GetArena(); + ArenaStringPtr field; - const std::string* empty_default = &internal::GetEmptyString(); - field.UnsafeSetDefault(empty_default); - EXPECT_EQ(std::string(""), field.Get()); - - // Avoid triggering the SSO optimization by setting the string to something - // larger than the internal buffer. - field.Set(empty_default, WrapString("Test long long long long value"), - &arena); - EXPECT_EQ(std::string("Test long long long long value"), field.Get()); - field.Set(empty_default, std::string(""), &arena); - field.Destroy(empty_default, &arena); - - ArenaStringPtr field2; - field2.UnsafeSetDefault(empty_default); - std::string* mut = field2.Mutable(EmptyDefault{}, &arena); - EXPECT_EQ(mut, field2.Mutable(EmptyDefault{}, &arena)); - EXPECT_EQ(mut, &field2.Get()); - EXPECT_NE(empty_default, mut); - EXPECT_EQ(std::string(""), *mut); - *mut = "Test long long long long value"; // ensure string allocates storage - EXPECT_EQ(std::string("Test long long long long value"), field2.Get()); - field2.Destroy(empty_default, &arena); - - ArenaStringPtr field3; - field3.UnsafeSetDefault(nullptr); - mut = field3.Mutable(nonempty_default, &arena); - EXPECT_EQ(mut, field3.Mutable(nonempty_default, &arena)); - EXPECT_EQ(mut, &field3.Get()); + field.UnsafeSetDefault(nullptr); + std::string* mut = field.Mutable(nonempty_default, arena.get()); + EXPECT_EQ(mut, field.Mutable(nonempty_default, arena.get())); + EXPECT_EQ(mut, &field.Get()); EXPECT_NE(nullptr, mut); - EXPECT_EQ(std::string("default"), *mut); + EXPECT_EQ("default", *mut); *mut = "Test long long long long value"; // ensure string allocates storage - EXPECT_EQ(std::string("Test long long long long value"), field3.Get()); - field3.Destroy(nullptr, &arena); + EXPECT_EQ("Test long long long long value", field.Get()); + field.Destroy(nullptr, arena.get()); +} + +class DualArena : public testing::TestWithParam> { + public: + std::unique_ptr GetLhsArena() { + if (std::get<0>(this->GetParam())) return nullptr; + return std::unique_ptr(new Arena()); + } + std::unique_ptr GetRhsArena() { + if (std::get<1>(this->GetParam())) return nullptr; + return std::unique_ptr(new Arena()); + } +}; + +INSTANTIATE_TEST_SUITE_P(ArenaString, DualArena, + testing::Combine(testing::Bool(), testing::Bool())); + +TEST_P(DualArena, Swap) { + auto lhs_arena = GetLhsArena(); + ArenaStringPtr lhs; + lhs.UnsafeSetDefault(empty_default); + ArenaStringPtr rhs; + rhs.UnsafeSetDefault(empty_default); + + { + auto rhs_arena = GetRhsArena(); + lhs.Set(empty_default, "lhs value that has some heft", lhs_arena.get()); + rhs.Set(empty_default, "rhs value that has some heft", rhs_arena.get()); + ArenaStringPtr::InternalSwap(empty_default, // + &lhs, lhs_arena.get(), // + &rhs, rhs_arena.get()); + EXPECT_EQ("rhs value that has some heft", lhs.Get()); + EXPECT_EQ("lhs value that has some heft", rhs.Get()); + lhs.Destroy(empty_default, rhs_arena.get()); + } + EXPECT_EQ("lhs value that has some heft", rhs.Get()); + rhs.Destroy(empty_default, lhs_arena.get()); } diff --git a/src/google/protobuf/compiler/cpp/cpp_generator.cc b/src/google/protobuf/compiler/cpp/cpp_generator.cc index 2c45ca8fa..a1cd06d15 100644 --- a/src/google/protobuf/compiler/cpp/cpp_generator.cc +++ b/src/google/protobuf/compiler/cpp/cpp_generator.cc @@ -108,6 +108,18 @@ bool CppGenerator::Generate(const FileDescriptor* file, file_options.table_driven_parsing = true; } else if (options[i].first == "table_driven_serialization") { file_options.table_driven_serialization = true; + } else if (options[i].first == "experimental_tail_call_table_mode") { + if (options[i].second == "never") { + file_options.tctable_mode = Options::kTCTableNever; + } else if (options[i].second == "guarded") { + file_options.tctable_mode = Options::kTCTableGuarded; + } else if (options[i].second == "always") { + file_options.tctable_mode = Options::kTCTableAlways; + } else { + *error = "Unknown value for experimental_tail_call_table_mode: " + + options[i].second; + return false; + } } else { *error = "Unknown generator option: " + options[i].first; return false; diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index fbca72c41..1bdc96ac7 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -648,25 +648,25 @@ std::string Int32ToString(int number) { } } -std::string Int64ToString(const std::string& macro_prefix, int64_t number) { +static std::string Int64ToString(int64_t number) { if (number == std::numeric_limits::min()) { // This needs to be special-cased, see explanation here: // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661 - return StrCat(macro_prefix, "_LONGLONG(", number + 1, ") - 1"); + return StrCat("int64_t{", number + 1, "} - 1"); } - return StrCat(macro_prefix, "_LONGLONG(", number, ")"); + return StrCat("int64_t{", number, "}"); } -std::string UInt64ToString(const std::string& macro_prefix, uint64_t number) { - return StrCat(macro_prefix, "_ULONGLONG(", number, ")"); +static std::string UInt64ToString(uint64_t number) { + return StrCat("uint64_t{", number, "u}"); } std::string DefaultValue(const FieldDescriptor* field) { switch (field->cpp_type()) { case FieldDescriptor::CPPTYPE_INT64: - return Int64ToString("GG", field->default_value_int64()); + return Int64ToString(field->default_value_int64()); case FieldDescriptor::CPPTYPE_UINT64: - return UInt64ToString("GG", field->default_value_uint64()); + return UInt64ToString(field->default_value_uint64()); default: return DefaultValue(Options(), field); } @@ -679,9 +679,9 @@ std::string DefaultValue(const Options& options, const FieldDescriptor* field) { case FieldDescriptor::CPPTYPE_UINT32: return StrCat(field->default_value_uint32()) + "u"; case FieldDescriptor::CPPTYPE_INT64: - return Int64ToString("PROTOBUF", field->default_value_int64()); + return Int64ToString(field->default_value_int64()); case FieldDescriptor::CPPTYPE_UINT64: - return UInt64ToString("PROTOBUF", field->default_value_uint64()); + return UInt64ToString(field->default_value_uint64()); case FieldDescriptor::CPPTYPE_DOUBLE: { double value = field->default_value_double(); if (value == std::numeric_limits::infinity()) { diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h index 0be693f17..e9c7b64ef 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.h +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h @@ -220,9 +220,6 @@ const char* DeclaredTypeMethodName(FieldDescriptor::Type type); // Return the code that evaluates to the number when compiled. std::string Int32ToString(int number); -// Return the code that evaluates to the number when compiled. -std::string Int64ToString(const Options& options, int64_t number); - // Get code that evaluates to the field's default value. std::string DefaultValue(const Options& options, const FieldDescriptor* field); diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/src/google/protobuf/compiler/cpp/cpp_map_field.cc index b1e3c1e50..4d735c34e 100644 --- a/src/google/protobuf/compiler/cpp/cpp_map_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_map_field.cc @@ -303,6 +303,19 @@ void MapFieldGenerator::GenerateConstinitInitializer( } } +bool MapFieldGenerator::GenerateArenaDestructorCode( + io::Printer* printer) const { + Formatter format(printer, variables_); + if (HasDescriptorMethods(descriptor_->file(), options_)) { + // _this is the object being destructed (we are inside a static method + // here). + format("_this->$name$_. ~MapField();\n"); + return true; + } else { + return false; + } +} + } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.h b/src/google/protobuf/compiler/cpp/cpp_map_field.h index 149e8a35e..33dec91ba 100644 --- a/src/google/protobuf/compiler/cpp/cpp_map_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_map_field.h @@ -58,6 +58,7 @@ class MapFieldGenerator : public FieldGenerator { void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; void GenerateConstinitInitializer(io::Printer* printer) const; + bool GenerateArenaDestructorCode(io::Printer* printer) const override; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator); diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index b9e2e5f4a..8e9110375 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -215,7 +215,7 @@ bool EmitFieldNonDefaultCondition(io::Printer* printer, // if non-zero (numeric) or non-empty (string). if (!field->is_repeated() && !field->containing_oneof()) { if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) { - format("if ($prefix$$name$().size() > 0) {\n"); + format("if (!$prefix$$name$().empty()) {\n"); } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { // Message fields still have has_$name$() methods. format("if ($prefix$has_$name$()) {\n"); @@ -571,6 +571,7 @@ MessageGenerator::MessageGenerator( variables_["classtype"] = QualifiedClassName(descriptor_, options); variables_["full_name"] = descriptor_->full_name(); variables_["superclass"] = SuperClassName(descriptor_, options_); + SetUnknkownFieldsVariable(descriptor_, options_, &variables_); // Compute optimized field order to be used for layout and initialization // purposes. @@ -610,6 +611,8 @@ MessageGenerator::MessageGenerator( } table_driven_ = TableDrivenParsingEnabled(descriptor_, options_); + parse_function_generator_.reset(new ParseFunctionGenerator( + descriptor_, max_has_bit_index_, options_, scc_analyzer_)); } MessageGenerator::~MessageGenerator() = default; @@ -986,9 +989,8 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) { void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { Formatter format(printer, variables_); - format.Set("class_final", ShouldMarkClassAsFinal(descriptor_, options_) - ? "PROTOBUF_FINAL" - : ""); + format.Set("class_final", + ShouldMarkClassAsFinal(descriptor_, options_) ? "final" : ""); if (IsMapEntryMessage(descriptor_)) { std::map vars; @@ -1028,7 +1030,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { " }\n", descriptor_->field(0)->full_name()); } else { - GOOGLE_CHECK_EQ(utf8_check, Utf8CheckMode::kVerify); + GOOGLE_CHECK(utf8_check == Utf8CheckMode::kVerify); format( " static bool ValidateKey(std::string* s) {\n" "#ifndef NDEBUG\n" @@ -1057,7 +1059,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { " }\n", descriptor_->field(1)->full_name()); } else { - GOOGLE_CHECK_EQ(utf8_check, Utf8CheckMode::kVerify); + GOOGLE_CHECK(utf8_check == Utf8CheckMode::kVerify); format( " static bool ValidateValue(std::string* s) {\n" "#ifndef NDEBUG\n" @@ -1109,8 +1111,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { " return *this;\n" "}\n" "inline $classname$& operator=($classname$&& from) noexcept {\n" - " if (GetArena() == from.GetArena()) {\n" - " if (this != &from) InternalSwap(&from);\n" + " if (this == &from) return *this;\n" + " if (GetOwningArena() == from.GetOwningArena()) {\n" + " InternalSwap(&from);\n" " } else {\n" " CopyFrom(from);\n" " }\n" @@ -1126,9 +1129,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "\n"); } - std::map vars; - SetUnknkownFieldsVariable(descriptor_, options_, &vars); - format.AddMap(vars); if (PublicUnknownFieldsAccessors(descriptor_)) { format( "inline const $unknown_fields_type$& unknown_fields() const {\n" @@ -1274,7 +1274,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "}\n" "inline void Swap($classname$* other) {\n" " if (other == this) return;\n" - " if (GetArena() == other->GetArena()) {\n" + " if (GetOwningArena() == other->GetOwningArena()) {\n" " InternalSwap(other);\n" " } else {\n" " ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);\n" @@ -1282,7 +1282,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "}\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"); @@ -1291,7 +1291,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "// implements Message ----------------------------------------------\n" "\n" "inline $classname$* New() const final {\n" - " return CreateMaybeMessage<$classname$>(nullptr);\n" + " return new $classname$();\n" "}\n" "\n" "$classname$* New(::$proto_ns$::Arena* arena) const final {\n" @@ -1324,9 +1324,11 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear()$ clear_final$;\n" "bool IsInitialized() const final;\n" "\n" - "size_t ByteSizeLong() const final;\n" - "const char* _InternalParse(const char* ptr, " - "::$proto_ns$::internal::ParseContext* ctx) final;\n" + "size_t ByteSizeLong() const final;\n"); + + parse_function_generator_->GenerateMethodDecls(printer); + + format( "$uint8$* _InternalSerialize(\n" " $uint8$* target, ::$proto_ns$::io::EpsCopyOutputStream* stream) " "const final;\n"); @@ -1982,7 +1984,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { GenerateClear(printer); format("\n"); - GenerateMergeFromCodedStream(printer); + parse_function_generator_->GenerateMethodImpls(printer); format("\n"); GenerateSerializeWithCachedSizesToArray(printer); @@ -2317,7 +2319,7 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) { format("void $classname$::SharedDtor() {\n"); format.Indent(); - format("$DCHK$(GetArena() == nullptr);\n"); + format("$DCHK$(GetArenaForAllocation() == nullptr);\n"); // Write the destructors for each field except oneof members. // optimized_order_ does not contain oneof fields. for (auto field : optimized_order_) { @@ -3240,24 +3242,6 @@ void MessageGenerator::GenerateCopyFrom(io::Printer* printer) { format("}\n"); } -void MessageGenerator::GenerateMergeFromCodedStream(io::Printer* printer) { - std::map vars = variables_; - SetUnknkownFieldsVariable(descriptor_, options_, &vars); - Formatter format(printer, vars); - if (descriptor_->options().message_set_wire_format()) { - // Special-case MessageSet. - format( - "const char* $classname$::_InternalParse(const char* ptr,\n" - " ::$proto_ns$::internal::ParseContext* ctx) {\n" - " return _extensions_.ParseMessageSet(ptr, \n" - " internal_default_instance(), &_internal_metadata_, ctx);\n" - "}\n"); - return; - } - GenerateParseFunction(descriptor_, max_has_bit_index_, options_, - scc_analyzer_, printer); -} - void MessageGenerator::GenerateSerializeOneofFields( io::Printer* printer, const std::vector& fields) { Formatter format(printer, variables_); diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h index cb1d77c9b..339d6e761 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.h +++ b/src/google/protobuf/compiler/cpp/cpp_message.h @@ -44,6 +44,7 @@ #include #include #include +#include namespace google { namespace protobuf { @@ -133,7 +134,6 @@ class MessageGenerator { // Generate standard Message methods. void GenerateClear(io::Printer* printer); void GenerateOneofClear(io::Printer* printer); - void GenerateMergeFromCodedStream(io::Printer* printer); void GenerateSerializeWithCachedSizes(io::Printer* printer); void GenerateSerializeWithCachedSizesToArray(io::Printer* printer); void GenerateSerializeWithCachedSizesBody(io::Printer* printer); @@ -204,6 +204,7 @@ class MessageGenerator { bool table_driven_; std::unique_ptr message_layout_helper_; + std::unique_ptr parse_function_generator_; MessageSCCAnalyzer* scc_analyzer_; diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/src/google/protobuf/compiler/cpp/cpp_message_field.cc index 18c6f0930..fc7aa4a03 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message_field.cc @@ -109,7 +109,8 @@ void MessageFieldGenerator::GenerateAccessorDeclarations( format( "$deprecated_attr$const $type$& ${1$$name$$}$() const { " "__builtin_trap(); }\n" - "$deprecated_attr$$type$* ${1$$release_name$$}$() { " + "PROTOBUF_FUTURE_MUST_USE_RESULT $deprecated_attr$$type$* " + "${1$$release_name$$}$() { " "__builtin_trap(); }\n" "$deprecated_attr$$type$* ${1$mutable_$name$$}$() { " "__builtin_trap(); }\n" @@ -173,7 +174,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( "$annotate_accessor$" // 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 (GetArena() == nullptr) {\n" + " if (GetArenaForAllocation() == nullptr) {\n" " delete reinterpret_cast<::$proto_ns$::MessageLite*>($name$_);\n" " }\n"); if (implicit_weak_field_) { @@ -198,7 +199,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( " $clear_hasbit$\n" " $type$* temp = $casted_member$;\n" " $name$_ = nullptr;\n" - " if (GetArena() != nullptr) {\n" + " if (GetArenaForAllocation() != nullptr) {\n" " temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n" " }\n" " return temp;\n" @@ -218,7 +219,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( "$type_reference_function$" " $set_hasbit$\n" " if ($name$_ == nullptr) {\n" - " auto* p = CreateMaybeMessage<$type$>(GetArena());\n"); + " auto* p = CreateMaybeMessage<$type$>(GetArenaForAllocation());\n"); if (implicit_weak_field_) { format(" $name$_ = reinterpret_cast<::$proto_ns$::MessageLite*>(p);\n"); } else { @@ -239,7 +240,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( format( "inline void $classname$::set_allocated_$name$($type$* $name$) {\n" "$annotate_accessor$" - " ::$proto_ns$::Arena* message_arena = GetArena();\n"); + " ::$proto_ns$::Arena* message_arena = GetArenaForAllocation();\n"); format(" if (message_arena == nullptr) {\n"); if (IsCrossFileMessage(descriptor_)) { format( @@ -255,12 +256,15 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( // isn't defined in this file. format( " ::$proto_ns$::Arena* submessage_arena =\n" - " " - "reinterpret_cast<::$proto_ns$::MessageLite*>($name$)->GetArena();\n"); + " ::$proto_ns$::Arena::InternalHelper<\n" + " ::$proto_ns$::MessageLite>::GetOwningArena(\n" + " reinterpret_cast<::$proto_ns$::MessageLite*>(" + "$name$));\n"); } else { format( " ::$proto_ns$::Arena* submessage_arena =\n" - " ::$proto_ns$::Arena::GetArena($name$);\n"); + " ::$proto_ns$::Arena::InternalHelper<$type$>::GetOwningArena(" + "$name$);\n"); } format( " if (message_arena != submessage_arena) {\n" @@ -329,11 +333,12 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions( " if ($type_default_instance_ptr$ == nullptr) {\n" " msg->$name$_ = ::$proto_ns$::Arena::CreateMessage<\n" " ::$proto_ns$::internal::ImplicitWeakMessage>(\n" - " msg->GetArena());\n" + " msg->GetArenaForAllocation());\n" " } else {\n" - " msg->$name$_ = reinterpret_cast(\n" - " $type_default_instance_ptr$)->New(msg->GetArena());\n" + " msg->$name$_ = \n" + " reinterpret_cast(\n" + " $type_default_instance_ptr$)->New(\n" + " msg->GetArenaForAllocation());\n" " }\n" " }\n" " return msg->$name$_;\n" @@ -358,7 +363,7 @@ void MessageFieldGenerator::GenerateClearingCode(io::Printer* printer) const { // If we don't have has-bits, message presence is indicated only by ptr != // NULL. Thus on clear, we need to delete the object. format( - "if (GetArena() == nullptr && $name$_ != nullptr) {\n" + "if (GetArenaForAllocation() == nullptr && $name$_ != nullptr) {\n" " delete $name$_;\n" "}\n" "$name$_ = nullptr;\n"); @@ -376,7 +381,7 @@ void MessageFieldGenerator::GenerateMessageClearingCode( // If we don't have has-bits, message presence is indicated only by ptr != // NULL. Thus on clear, we need to delete the object. format( - "if (GetArena() == nullptr && $name$_ != nullptr) {\n" + "if (GetArenaForAllocation() == nullptr && $name$_ != nullptr) {\n" " delete $name$_;\n" "}\n" "$name$_ = nullptr;\n"); @@ -490,7 +495,7 @@ void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions( format( "void $classname$::set_allocated_$name$($type$* $name$) {\n" "$annotate_accessor$" - " ::$proto_ns$::Arena* message_arena = GetArena();\n" + " ::$proto_ns$::Arena* message_arena = GetArenaForAllocation();\n" " clear_$oneof_name$();\n" " if ($name$) {\n"); if (descriptor_->file() != descriptor_->message_type()->file()) { @@ -498,12 +503,15 @@ void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions( // isn't defined in this file. format( " ::$proto_ns$::Arena* submessage_arena =\n" - " " - "reinterpret_cast<::$proto_ns$::MessageLite*>($name$)->GetArena();\n"); + " ::$proto_ns$::Arena::InternalHelper<\n" + " ::$proto_ns$::MessageLite>::GetOwningArena(\n" + " reinterpret_cast<::$proto_ns$::MessageLite*>(" + "$name$));\n"); } else { format( " ::$proto_ns$::Arena* submessage_arena =\n" - " ::$proto_ns$::Arena::GetArena($name$);\n"); + " ::$proto_ns$::Arena::InternalHelper<" + "$type$>::GetOwningArena($name$);\n"); } format( " if (message_arena != submessage_arena) {\n" @@ -527,7 +535,7 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions( " if (_internal_has_$name$()) {\n" " clear_has_$oneof_name$();\n" " $type$* temp = $field_member$;\n" - " if (GetArena() != nullptr) {\n" + " if (GetArenaForAllocation() != nullptr) {\n" " temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n" " }\n" " $field_member$ = nullptr;\n" @@ -579,7 +587,8 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions( " if (!_internal_has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" - " $field_member$ = CreateMaybeMessage< $type$ >(GetArena());\n" + " $field_member$ = CreateMaybeMessage< $type$ " + ">(GetArenaForAllocation());\n" " }\n" " return $field_member$;\n" "}\n" @@ -596,7 +605,7 @@ void MessageOneofFieldGenerator::GenerateClearingCode( Formatter format(printer, variables_); format( - "if (GetArena() == nullptr) {\n" + "if (GetArenaForAllocation() == nullptr) {\n" " delete $field_member$;\n" "}\n"); } diff --git a/src/google/protobuf/compiler/cpp/cpp_options.h b/src/google/protobuf/compiler/cpp/cpp_options.h index 92b554846..7aa3985d7 100644 --- a/src/google/protobuf/compiler/cpp/cpp_options.h +++ b/src/google/protobuf/compiler/cpp/cpp_options.h @@ -69,6 +69,11 @@ struct Options { std::string annotation_pragma_name; std::string annotation_guard_name; const AccessInfoMap* access_info_map = nullptr; + enum { + kTCTableNever, + kTCTableGuarded, + kTCTableAlways + } tctable_mode = kTCTableNever; }; } // namespace cpp diff --git a/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc b/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc index 41be0b51f..5dc370c8a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc +++ b/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc @@ -31,7 +31,6 @@ #include #include -#include namespace google { namespace protobuf { @@ -61,517 +60,555 @@ bool HasInternalAccessors(const FieldOptions::CType ctype) { return ctype == FieldOptions::STRING || ctype == FieldOptions::CORD; } -class ParseFunctionGenerator { - public: - ParseFunctionGenerator(const Descriptor* descriptor, int num_hasbits, - const Options& options, - MessageSCCAnalyzer* scc_analyzer, io::Printer* printer) - : descriptor_(descriptor), - scc_analyzer_(scc_analyzer), - options_(options), - format_(printer), - num_hasbits_(num_hasbits) { - format_.Set("classname", ClassName(descriptor)); - format_.Set("p_ns", "::" + ProtobufNamespace(options_)); - format_.Set("pi_ns", - StrCat("::", ProtobufNamespace(options_), "::internal")); - format_.Set("GOOGLE_PROTOBUF", MacroPrefix(options_)); - std::map vars; - SetCommonVars(options_, &vars); - SetUnknkownFieldsVariable(descriptor, options_, &vars); - format_.AddMap(vars); - } - - void GenerateLoopingParseFunction() { - format_( - "const char* $classname$::_InternalParse(const char* ptr, " - "$pi_ns$::ParseContext* ctx) {\n" - "#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure\n"); - format_.Indent(); - int hasbits_size = 0; - if (num_hasbits_ > 0) { - hasbits_size = (num_hasbits_ + 31) / 32; - } - // For now only optimize small hasbits. - if (hasbits_size != 1) hasbits_size = 0; - if (hasbits_size) { - format_("_Internal::HasBits has_bits{};\n"); - format_.Set("has_bits", "has_bits"); - } else { - format_.Set("has_bits", "_has_bits_"); - } - format_.Set("continue", "continue"); - format_("while (!ctx->Done(&ptr)) {\n"); - format_.Indent(); - - GenerateParseIterationBody(descriptor_, - GetOrderedFields(descriptor_, options_)); - - format_.Outdent(); - format_("} // while\n"); - - format_.Outdent(); - format_("success:\n"); - if (hasbits_size) format_(" _has_bits_.Or(has_bits);\n"); - - format_( - " return ptr;\n" - "failure:\n" - " ptr = nullptr;\n" - " goto success;\n" - "#undef CHK_\n" - "}\n"); - } - - private: - const Descriptor* descriptor_; - MessageSCCAnalyzer* scc_analyzer_; - const Options& options_; - Formatter format_; - int num_hasbits_; - - void GenerateArenaString(const FieldDescriptor* field) { - if (HasHasbit(field)) { - format_("_Internal::set_has_$1$(&$has_bits$);\n", FieldName(field)); - } - std::string default_string = - field->default_value_string().empty() - ? "::" + ProtobufNamespace(options_) + - "::internal::GetEmptyStringAlreadyInited()" - : QualifiedClassName(field->containing_type(), options_) + - "::" + MakeDefaultName(field) + ".get()"; - format_( - "if (arena != nullptr) {\n" - " ptr = ctx->ReadArenaString(ptr, &$1$_, arena);\n" - "} else {\n" - " ptr = " - "$pi_ns$::InlineGreedyStringParser($1$_.MutableNoArenaNoDefault(&$2$" - "), ptr, ctx);" - "\n}\n" - "const std::string* str = &$1$_.Get(); (void)str;\n", - FieldName(field), default_string); - } - - void GenerateStrings(const FieldDescriptor* field, bool check_utf8) { - FieldOptions::CType ctype = FieldOptions::STRING; - if (!options_.opensource_runtime) { - // Open source doesn't support other ctypes; - ctype = field->options().ctype(); - } - if (!field->is_repeated() && !options_.opensource_runtime && - GetOptimizeFor(field->file(), options_) != FileOptions::LITE_RUNTIME && - // For now only use arena string for strings with empty defaults. - field->default_value_string().empty() && - !field->real_containing_oneof() && ctype == FieldOptions::STRING) { - GenerateArenaString(field); - } else { - std::string name; - switch (ctype) { - case FieldOptions::STRING: - name = "GreedyStringParser"; - break; - case FieldOptions::CORD: - name = "CordParser"; - break; - case FieldOptions::STRING_PIECE: - name = "StringPieceParser"; - break; - } - format_( - "auto str = $1$$2$_$3$();\n" - "ptr = $pi_ns$::Inline$4$(str, ptr, ctx);\n", - HasInternalAccessors(ctype) ? "_internal_" : "", - field->is_repeated() && !field->is_packable() ? "add" : "mutable", - FieldName(field), name); - } - if (!check_utf8) return; // return if this is a bytes field - auto level = GetUtf8CheckMode(field, options_); - switch (level) { - case Utf8CheckMode::kNone: - return; - case Utf8CheckMode::kVerify: - format_("#ifndef NDEBUG\n"); - break; - case Utf8CheckMode::kStrict: - format_("CHK_("); - break; - } - std::string field_name; - field_name = "nullptr"; - if (HasDescriptorMethods(field->file(), options_)) { - field_name = StrCat("\"", field->full_name(), "\""); - } - format_("$pi_ns$::VerifyUTF8(str, $1$)", field_name); - switch (level) { - case Utf8CheckMode::kNone: - return; - case Utf8CheckMode::kVerify: - format_( - ";\n" - "#endif // !NDEBUG\n"); - break; - case Utf8CheckMode::kStrict: - format_(");\n"); - break; - } - } - - void GenerateLengthDelim(const FieldDescriptor* field) { - if (field->is_packable()) { - std::string enum_validator; - if (field->type() == FieldDescriptor::TYPE_ENUM && - !HasPreservingUnknownEnumSemantics(field)) { - enum_validator = - StrCat(", ", QualifiedClassName(field->enum_type(), options_), - "_IsValid, &_internal_metadata_, ", field->number()); - format_( - "ptr = " - "$pi_ns$::Packed$1$Parser<$unknown_fields_type$>(_internal_mutable_" - "$2$(), ptr, " - "ctx$3$);\n", - DeclaredTypeMethodName(field->type()), FieldName(field), - enum_validator); - } else { - format_( - "ptr = $pi_ns$::Packed$1$Parser(_internal_mutable_$2$(), ptr, " - "ctx$3$);\n", - DeclaredTypeMethodName(field->type()), FieldName(field), - enum_validator); - } - } else { - auto field_type = field->type(); - switch (field_type) { - case FieldDescriptor::TYPE_STRING: - GenerateStrings(field, true /* utf8 */); - break; - case FieldDescriptor::TYPE_BYTES: - GenerateStrings(field, false /* utf8 */); - break; - case FieldDescriptor::TYPE_MESSAGE: { - if (field->is_map()) { - const FieldDescriptor* val = - field->message_type()->FindFieldByName("value"); - GOOGLE_CHECK(val); - if (val->type() == FieldDescriptor::TYPE_ENUM && - !HasPreservingUnknownEnumSemantics(field)) { - format_( - "auto object = " - "::$proto_ns$::internal::InitEnumParseWrapper<$unknown_" - "fields_type$>(" - "&$1$_, $2$_IsValid, $3$, &_internal_metadata_);\n" - "ptr = ctx->ParseMessage(&object, ptr);\n", - FieldName(field), QualifiedClassName(val->enum_type()), - field->number()); - } else { - format_("ptr = ctx->ParseMessage(&$1$_, ptr);\n", - FieldName(field)); - } - } else if (IsLazy(field, options_)) { - if (field->real_containing_oneof()) { - format_( - "if (!_internal_has_$1$()) {\n" - " clear_$2$();\n" - " $2$_.$1$_ = ::$proto_ns$::Arena::CreateMessage<\n" - " $pi_ns$::LazyField>(GetArena());\n" - " set_has_$1$();\n" - "}\n" - "ptr = ctx->ParseMessage($2$_.$1$_, ptr);\n", - FieldName(field), field->containing_oneof()->name()); - } else if (HasHasbit(field)) { - format_( - "_Internal::set_has_$1$(&$has_bits$);\n" - "ptr = ctx->ParseMessage(&$1$_, ptr);\n", - FieldName(field)); - } else { - format_("ptr = ctx->ParseMessage(&$1$_, ptr);\n", - FieldName(field)); - } - } else if (IsImplicitWeakField(field, options_, scc_analyzer_)) { - if (!field->is_repeated()) { - format_( - "ptr = ctx->ParseMessage(_Internal::mutable_$1$(this), " - "ptr);\n", - FieldName(field)); - } else { - format_( - "ptr = ctx->ParseMessage($1$_.AddWeak(reinterpret_cast($2$::_$3$_default_instance_ptr_)" - "), ptr);\n", - FieldName(field), Namespace(field->message_type(), options_), - ClassName(field->message_type())); - } - } else if (IsWeak(field, options_)) { - format_( - "{\n" - " auto* default_ = &reinterpret_cast($1$);\n" - " ptr = ctx->ParseMessage(_weak_field_map_.MutableMessage($2$," - " default_), ptr);\n" - "}\n", - QualifiedDefaultInstanceName(field->message_type(), options_), - field->number()); - } else { - format_("ptr = ctx->ParseMessage(_internal_$1$_$2$(), ptr);\n", - field->is_repeated() ? "add" : "mutable", FieldName(field)); - } - break; - } - default: - GOOGLE_LOG(FATAL) << "Illegal combination for length delimited wiretype " - << " filed type is " << field->type(); - } - } - } - - // Convert a 1 or 2 byte varint into the equivalent value upon a direct load. - static uint32_t SmallVarintValue(uint32_t x) { - GOOGLE_DCHECK(x < 128 * 128); - if (x >= 128) x += (x & 0xFF80) + 128; - return x; - } - - static bool ShouldRepeat(const FieldDescriptor* descriptor, - internal::WireFormatLite::WireType wiretype) { - constexpr int kMaxTwoByteFieldNumber = 16 * 128; - return descriptor->number() < kMaxTwoByteFieldNumber && - descriptor->is_repeated() && - (!descriptor->is_packable() || - wiretype != internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - } - - void GenerateFieldBody(internal::WireFormatLite::WireType wiretype, - const FieldDescriptor* field) { - uint32_t tag = WireFormatLite::MakeTag(field->number(), wiretype); - switch (wiretype) { - case WireFormatLite::WIRETYPE_VARINT: { - std::string type = PrimitiveTypeName(options_, field->cpp_type()); - std::string prefix = field->is_repeated() ? "add" : "set"; - if (field->type() == FieldDescriptor::TYPE_ENUM) { - format_( - "$uint64$ val = $pi_ns$::ReadVarint64(&ptr);\n" - "CHK_(ptr);\n"); - if (!HasPreservingUnknownEnumSemantics(field)) { - format_("if (PROTOBUF_PREDICT_TRUE($1$_IsValid(val))) {\n", - QualifiedClassName(field->enum_type(), options_)); - format_.Indent(); - } - format_("_internal_$1$_$2$(static_cast<$3$>(val));\n", prefix, - FieldName(field), - QualifiedClassName(field->enum_type(), options_)); - if (!HasPreservingUnknownEnumSemantics(field)) { - format_.Outdent(); - format_( - "} else {\n" - " $pi_ns$::WriteVarint($1$, val, mutable_unknown_fields());\n" - "}\n", - field->number()); - } - } else { - std::string size = (field->type() == FieldDescriptor::TYPE_SINT32 || - field->type() == FieldDescriptor::TYPE_UINT32) - ? "32" - : "64"; - std::string zigzag; - if ((field->type() == FieldDescriptor::TYPE_SINT32 || - field->type() == FieldDescriptor::TYPE_SINT64)) { - zigzag = "ZigZag"; - } - if (field->is_repeated() || field->real_containing_oneof()) { - std::string prefix = field->is_repeated() ? "add" : "set"; - format_( - "_internal_$1$_$2$($pi_ns$::ReadVarint$3$$4$(&ptr));\n" - "CHK_(ptr);\n", - prefix, FieldName(field), zigzag, size); - } else { - if (HasHasbit(field)) { - format_("_Internal::set_has_$1$(&$has_bits$);\n", - FieldName(field)); - } - format_( - "$1$_ = $pi_ns$::ReadVarint$2$$3$(&ptr);\n" - "CHK_(ptr);\n", - FieldName(field), zigzag, size); - } - } - break; - } - case WireFormatLite::WIRETYPE_FIXED32: - case WireFormatLite::WIRETYPE_FIXED64: { - std::string type = PrimitiveTypeName(options_, field->cpp_type()); - if (field->is_repeated() || field->real_containing_oneof()) { - std::string prefix = field->is_repeated() ? "add" : "set"; - format_( - "_internal_$1$_$2$($pi_ns$::UnalignedLoad<$3$>(ptr));\n" - "ptr += sizeof($3$);\n", - prefix, FieldName(field), type); - } else { - if (HasHasbit(field)) { - format_("_Internal::set_has_$1$(&$has_bits$);\n", FieldName(field)); - } - format_( - "$1$_ = $pi_ns$::UnalignedLoad<$2$>(ptr);\n" - "ptr += sizeof($2$);\n", - FieldName(field), type); - } - break; - } - case WireFormatLite::WIRETYPE_LENGTH_DELIMITED: { - GenerateLengthDelim(field); - format_("CHK_(ptr);\n"); - break; - } - case WireFormatLite::WIRETYPE_START_GROUP: { - format_( - "ptr = ctx->ParseGroup(_internal_$1$_$2$(), ptr, $3$);\n" - "CHK_(ptr);\n", - field->is_repeated() ? "add" : "mutable", FieldName(field), tag); - break; - } - case WireFormatLite::WIRETYPE_END_GROUP: { - GOOGLE_LOG(FATAL) << "Can't have end group field\n"; - break; - } - } // switch (wire_type) - } - - // Returns the tag for this field and in case of repeated packable fields, - // sets a fallback tag in fallback_tag_ptr. - static uint32_t ExpectedTag(const FieldDescriptor* field, - uint32_t* fallback_tag_ptr) { - uint32_t expected_tag; - if (field->is_packable()) { - auto expected_wiretype = WireFormat::WireTypeForFieldType(field->type()); - expected_tag = - WireFormatLite::MakeTag(field->number(), expected_wiretype); - GOOGLE_CHECK(expected_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - auto fallback_wiretype = WireFormatLite::WIRETYPE_LENGTH_DELIMITED; - uint32_t fallback_tag = - WireFormatLite::MakeTag(field->number(), fallback_wiretype); - - if (field->is_packed()) std::swap(expected_tag, fallback_tag); - *fallback_tag_ptr = fallback_tag; - } else { - auto expected_wiretype = WireFormat::WireTypeForField(field); - expected_tag = - WireFormatLite::MakeTag(field->number(), expected_wiretype); - } - return expected_tag; - } - - void GenerateParseIterationBody( - const Descriptor* descriptor, - const std::vector& ordered_fields) { - format_( - "$uint32$ tag;\n" - "ptr = $pi_ns$::ReadTag(ptr, &tag);\n"); - if (!ordered_fields.empty()) format_("switch (tag >> 3) {\n"); - - format_.Indent(); - - for (const auto* field : ordered_fields) { - PrintFieldComment(format_, field); - format_("case $1$:\n", field->number()); - format_.Indent(); - uint32_t fallback_tag = 0; - uint32_t expected_tag = ExpectedTag(field, &fallback_tag); - format_( - "if (PROTOBUF_PREDICT_TRUE(static_cast<$uint8$>(tag) == $1$)) {\n", - expected_tag & 0xFF); - format_.Indent(); - auto wiretype = WireFormatLite::GetTagWireType(expected_tag); - uint32_t tag = WireFormatLite::MakeTag(field->number(), wiretype); - int tag_size = io::CodedOutputStream::VarintSize32(tag); - bool is_repeat = ShouldRepeat(field, wiretype); - if (is_repeat) { - format_( - "ptr -= $1$;\n" - "do {\n" - " ptr += $1$;\n", - tag_size); - format_.Indent(); - } - GenerateFieldBody(wiretype, field); - if (is_repeat) { - format_.Outdent(); - format_( - " if (!ctx->DataAvailable(ptr)) break;\n" - "} while ($pi_ns$::ExpectTag<$1$>(ptr));\n", - tag); - } - format_.Outdent(); - if (fallback_tag) { - format_("} else if (static_cast<$uint8$>(tag) == $1$) {\n", - fallback_tag & 0xFF); - format_.Indent(); - GenerateFieldBody(WireFormatLite::GetTagWireType(fallback_tag), field); - format_.Outdent(); - } - format_.Outdent(); - format_( - " } else goto handle_unusual;\n" - " $continue$;\n"); - } // for loop over ordered fields - - // Default case - if (!ordered_fields.empty()) format_("default: {\n"); - if (!ordered_fields.empty()) format_("handle_unusual:\n"); - format_( - " if ((tag == 0) || ((tag & 7) == 4)) {\n" - " CHK_(ptr);\n" - " ctx->SetLastTag(tag);\n" - " goto success;\n" - " }\n"); - if (IsMapEntryMessage(descriptor)) { - format_(" $continue$;\n"); - } else { - if (descriptor->extension_range_count() > 0) { - format_("if ("); - for (int i = 0; i < descriptor->extension_range_count(); i++) { - const Descriptor::ExtensionRange* range = - descriptor->extension_range(i); - if (i > 0) format_(" ||\n "); - - uint32_t start_tag = WireFormatLite::MakeTag( - range->start, static_cast(0)); - uint32_t end_tag = WireFormatLite::MakeTag( - range->end, static_cast(0)); - - if (range->end > FieldDescriptor::kMaxNumber) { - format_("($1$u <= tag)", start_tag); - } else { - format_("($1$u <= tag && tag < $2$u)", start_tag, end_tag); - } - } - format_(") {\n"); - format_( - " ptr = _extensions_.ParseField(tag, ptr,\n" - " internal_default_instance(), &_internal_metadata_, ctx);\n" - " CHK_(ptr != nullptr);\n" - " $continue$;\n" - "}\n"); - } - format_( - " ptr = UnknownFieldParse(tag,\n" - " _internal_metadata_.mutable_unknown_fields<$unknown_" - "fields_type$>(),\n" - " ptr, ctx);\n" - " CHK_(ptr != nullptr);\n" - " $continue$;\n"); - } - if (!ordered_fields.empty()) format_("}\n"); // default case - format_.Outdent(); - if (!ordered_fields.empty()) format_("} // switch\n"); - } -}; +bool IsTCTableEnabled(const Options& options) { + return options.tctable_mode == Options::kTCTableAlways; +} +bool IsTCTableGuarded(const Options& options) { + return options.tctable_mode == Options::kTCTableGuarded; +} +bool IsTCTableDisabled(const Options& options) { + return options.tctable_mode == Options::kTCTableNever; +} } // namespace -void GenerateParseFunction(const Descriptor* descriptor, int num_hasbits, - const Options& options, - MessageSCCAnalyzer* scc_analyzer, - io::Printer* printer) { - ParseFunctionGenerator generator(descriptor, num_hasbits, options, - scc_analyzer, printer); - generator.GenerateLoopingParseFunction(); +ParseFunctionGenerator::ParseFunctionGenerator(const Descriptor* descriptor, + int num_hasbits, + const Options& options, + MessageSCCAnalyzer* scc_analyzer) + : descriptor_(descriptor), + scc_analyzer_(scc_analyzer), + options_(options), + num_hasbits_(num_hasbits) { + SetCommonVars(options_, &variables_); + SetUnknkownFieldsVariable(descriptor_, options_, &variables_); + variables_["classname"] = ClassName(descriptor, false); +} + +void ParseFunctionGenerator::GenerateMethodDecls(io::Printer* printer) { + Formatter format(printer, variables_); + if (IsTCTableGuarded(options_)) { + format.Outdent(); + format("#ifdef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); + format.Indent(); + } + if (IsTCTableGuarded(options_) || IsTCTableEnabled(options_)) { + format.Outdent(); + format("#error Tail Call Table parsing not yet implemented.\n"); + format.Indent(); + } + if (IsTCTableGuarded(options_)) { + format.Outdent(); + format("#else\n"); + format.Indent(); + } + if (IsTCTableGuarded(options_) || IsTCTableDisabled(options_)) { + format( + "const char* _InternalParse(const char* ptr, " + "::$proto_ns$::internal::ParseContext* ctx) final;\n"); + } + if (IsTCTableGuarded(options_)) { + format.Outdent(); + format("#endif\n"); + format.Indent(); + } +} + +void ParseFunctionGenerator::GenerateMethodImpls(io::Printer* printer) { + Formatter format(printer, variables_); + if (descriptor_->options().message_set_wire_format()) { + // Special-case MessageSet. + format( + "const char* $classname$::_InternalParse(const char* ptr,\n" + " ::$proto_ns$::internal::ParseContext* ctx) {\n" + " return _extensions_.ParseMessageSet(ptr, \n" + " internal_default_instance(), &_internal_metadata_, ctx);\n" + "}\n"); + return; + } + if (IsTCTableGuarded(options_)) { + format("#ifdef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); + } + if (IsTCTableGuarded(options_) || IsTCTableEnabled(options_)) { + format("#error Tail Call Table parsing not yet implemented.\n"); + } + if (IsTCTableGuarded(options_)) { + format("#else // PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); + } + if (IsTCTableGuarded(options_) || IsTCTableDisabled(options_)) { + GenerateLoopingParseFunction(format); + } + if (IsTCTableGuarded(options_)) { + format("#endif // PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); + } +} + +void ParseFunctionGenerator::GenerateLoopingParseFunction(Formatter& format) { + format( + "const char* $classname$::_InternalParse(const char* ptr, " + "::$proto_ns$::internal::ParseContext* ctx) {\n" + "#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure\n"); + format.Indent(); + int hasbits_size = 0; + if (num_hasbits_ > 0) { + hasbits_size = (num_hasbits_ + 31) / 32; + } + // For now only optimize small hasbits. + if (hasbits_size != 1) hasbits_size = 0; + if (hasbits_size) { + format("_Internal::HasBits has_bits{};\n"); + format.Set("has_bits", "has_bits"); + } else { + format.Set("has_bits", "_has_bits_"); + } + format.Set("continue", "continue"); + format("while (!ctx->Done(&ptr)) {\n"); + format.Indent(); + + GenerateParseIterationBody(format, descriptor_, + GetOrderedFields(descriptor_, options_)); + + format.Outdent(); + format("} // while\n"); + + format.Outdent(); + format("success:\n"); + if (hasbits_size) format(" _has_bits_.Or(has_bits);\n"); + + format( + " return ptr;\n" + "failure:\n" + " ptr = nullptr;\n" + " goto success;\n" + "#undef CHK_\n" + "}\n"); +} + +void ParseFunctionGenerator::GenerateArenaString(Formatter& format, + const FieldDescriptor* field) { + if (HasHasbit(field)) { + format("_Internal::set_has_$1$(&$has_bits$);\n", FieldName(field)); + } + std::string default_string = + field->default_value_string().empty() + ? "::" + ProtobufNamespace(options_) + + "::internal::GetEmptyStringAlreadyInited()" + : QualifiedClassName(field->containing_type(), options_) + + "::" + MakeDefaultName(field) + ".get()"; + format( + "if (arena != nullptr) {\n" + " ptr = ctx->ReadArenaString(ptr, &$1$_, arena);\n" + "} else {\n" + " ptr = ::$proto_ns$::internal::InlineGreedyStringParser(" + "$1$_.MutableNoArenaNoDefault(&$2$), ptr, ctx);\n" + "}\n" + "const std::string* str = &$1$_.Get(); (void)str;\n", + FieldName(field), default_string); +} + +void ParseFunctionGenerator::GenerateStrings(Formatter& format, + const FieldDescriptor* field, + bool check_utf8) { + FieldOptions::CType ctype = FieldOptions::STRING; + if (!options_.opensource_runtime) { + // Open source doesn't support other ctypes; + ctype = field->options().ctype(); + } + if (!field->is_repeated() && !options_.opensource_runtime && + GetOptimizeFor(field->file(), options_) != FileOptions::LITE_RUNTIME && + // For now only use arena string for strings with empty defaults. + field->default_value_string().empty() && + !field->real_containing_oneof() && ctype == FieldOptions::STRING) { + GenerateArenaString(format, field); + } else { + std::string name; + switch (ctype) { + case FieldOptions::STRING: + name = "GreedyStringParser"; + break; + case FieldOptions::CORD: + name = "CordParser"; + break; + case FieldOptions::STRING_PIECE: + name = "StringPieceParser"; + break; + } + format( + "auto str = $1$$2$_$3$();\n" + "ptr = ::$proto_ns$::internal::Inline$4$(str, ptr, ctx);\n", + HasInternalAccessors(ctype) ? "_internal_" : "", + field->is_repeated() && !field->is_packable() ? "add" : "mutable", + FieldName(field), name); + } + if (!check_utf8) return; // return if this is a bytes field + auto level = GetUtf8CheckMode(field, options_); + switch (level) { + case Utf8CheckMode::kNone: + return; + case Utf8CheckMode::kVerify: + format("#ifndef NDEBUG\n"); + break; + case Utf8CheckMode::kStrict: + format("CHK_("); + break; + } + std::string field_name; + field_name = "nullptr"; + if (HasDescriptorMethods(field->file(), options_)) { + field_name = StrCat("\"", field->full_name(), "\""); + } + format("::$proto_ns$::internal::VerifyUTF8(str, $1$)", field_name); + switch (level) { + case Utf8CheckMode::kNone: + return; + case Utf8CheckMode::kVerify: + format( + ";\n" + "#endif // !NDEBUG\n"); + break; + case Utf8CheckMode::kStrict: + format(");\n"); + break; + } +} + +void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format, + const FieldDescriptor* field) { + if (field->is_packable()) { + std::string enum_validator; + if (field->type() == FieldDescriptor::TYPE_ENUM && + !HasPreservingUnknownEnumSemantics(field)) { + enum_validator = + StrCat(", ", QualifiedClassName(field->enum_type(), options_), + "_IsValid, &_internal_metadata_, ", field->number()); + format( + "ptr = " + "::$proto_ns$::internal::Packed$1$Parser<$unknown_fields_type$>(" + "_internal_mutable_$2$(), ptr, ctx$3$);\n", + DeclaredTypeMethodName(field->type()), FieldName(field), + enum_validator); + } else { + format( + "ptr = ::$proto_ns$::internal::Packed$1$Parser(" + "_internal_mutable_$2$(), ptr, ctx$3$);\n", + DeclaredTypeMethodName(field->type()), FieldName(field), + enum_validator); + } + } else { + auto field_type = field->type(); + switch (field_type) { + case FieldDescriptor::TYPE_STRING: + GenerateStrings(format, field, true /* utf8 */); + break; + case FieldDescriptor::TYPE_BYTES: + GenerateStrings(format, field, false /* utf8 */); + break; + case FieldDescriptor::TYPE_MESSAGE: { + if (field->is_map()) { + const FieldDescriptor* val = + field->message_type()->FindFieldByName("value"); + GOOGLE_CHECK(val); + if (val->type() == FieldDescriptor::TYPE_ENUM && + !HasPreservingUnknownEnumSemantics(field)) { + format( + "auto object = " + "::$proto_ns$::internal::InitEnumParseWrapper<$unknown_" + "fields_type$>(" + "&$1$_, $2$_IsValid, $3$, &_internal_metadata_);\n" + "ptr = ctx->ParseMessage(&object, ptr);\n", + FieldName(field), QualifiedClassName(val->enum_type()), + field->number()); + } else { + format("ptr = ctx->ParseMessage(&$1$_, ptr);\n", FieldName(field)); + } + } else if (IsLazy(field, options_)) { + if (field->real_containing_oneof()) { + format( + "if (!_internal_has_$1$()) {\n" + " clear_$2$();\n" + " $2$_.$1$_ = ::$proto_ns$::Arena::CreateMessage<\n" + " ::$proto_ns$::internal::LazyField>(" + "GetArenaForAllocation());\n" + " set_has_$1$();\n" + "}\n" + "ptr = ctx->ParseMessage($2$_.$1$_, ptr);\n", + FieldName(field), field->containing_oneof()->name()); + } else if (HasHasbit(field)) { + format( + "_Internal::set_has_$1$(&$has_bits$);\n" + "ptr = ctx->ParseMessage(&$1$_, ptr);\n", + FieldName(field)); + } else { + format("ptr = ctx->ParseMessage(&$1$_, ptr);\n", FieldName(field)); + } + } else if (IsImplicitWeakField(field, options_, scc_analyzer_)) { + if (!field->is_repeated()) { + format( + "ptr = ctx->ParseMessage(_Internal::mutable_$1$(this), " + "ptr);\n", + FieldName(field)); + } else { + format( + "ptr = ctx->ParseMessage($1$_.AddWeak(reinterpret_cast($2$::_$3$_default_instance_ptr_)" + "), ptr);\n", + FieldName(field), Namespace(field->message_type(), options_), + ClassName(field->message_type())); + } + } else if (IsWeak(field, options_)) { + format( + "{\n" + " auto* default_ = &reinterpret_cast($1$);\n" + " ptr = ctx->ParseMessage(_weak_field_map_.MutableMessage($2$," + " default_), ptr);\n" + "}\n", + QualifiedDefaultInstanceName(field->message_type(), options_), + field->number()); + } else { + format("ptr = ctx->ParseMessage(_internal_$1$_$2$(), ptr);\n", + field->is_repeated() ? "add" : "mutable", FieldName(field)); + } + break; + } + default: + GOOGLE_LOG(FATAL) << "Illegal combination for length delimited wiretype " + << " filed type is " << field->type(); + } + } +} + +static bool ShouldRepeat(const FieldDescriptor* descriptor, + WireFormatLite::WireType wiretype) { + constexpr int kMaxTwoByteFieldNumber = 16 * 128; + return descriptor->number() < kMaxTwoByteFieldNumber && + descriptor->is_repeated() && + (!descriptor->is_packable() || + wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED); +} + +void ParseFunctionGenerator::GenerateFieldBody( + Formatter& format, WireFormatLite::WireType wiretype, + const FieldDescriptor* field) { + uint32_t tag = WireFormatLite::MakeTag(field->number(), wiretype); + switch (wiretype) { + case WireFormatLite::WIRETYPE_VARINT: { + std::string type = PrimitiveTypeName(options_, field->cpp_type()); + std::string prefix = field->is_repeated() ? "add" : "set"; + if (field->type() == FieldDescriptor::TYPE_ENUM) { + format( + "$uint64$ val = ::$proto_ns$::internal::ReadVarint64(&ptr);\n" + "CHK_(ptr);\n"); + if (!HasPreservingUnknownEnumSemantics(field)) { + format("if (PROTOBUF_PREDICT_TRUE($1$_IsValid(val))) {\n", + QualifiedClassName(field->enum_type(), options_)); + format.Indent(); + } + format("_internal_$1$_$2$(static_cast<$3$>(val));\n", prefix, + FieldName(field), + QualifiedClassName(field->enum_type(), options_)); + if (!HasPreservingUnknownEnumSemantics(field)) { + format.Outdent(); + format( + "} else {\n" + " ::$proto_ns$::internal::WriteVarint(" + "$1$, val, mutable_unknown_fields());\n" + "}\n", + field->number()); + } + } else { + std::string size = (field->type() == FieldDescriptor::TYPE_SINT32 || + field->type() == FieldDescriptor::TYPE_UINT32) + ? "32" + : "64"; + std::string zigzag; + if ((field->type() == FieldDescriptor::TYPE_SINT32 || + field->type() == FieldDescriptor::TYPE_SINT64)) { + zigzag = "ZigZag"; + } + if (field->is_repeated() || field->real_containing_oneof()) { + std::string prefix = field->is_repeated() ? "add" : "set"; + format( + "_internal_$1$_$2$(" + "::$proto_ns$::internal::ReadVarint$3$$4$(&ptr));\n" + "CHK_(ptr);\n", + prefix, FieldName(field), zigzag, size); + } else { + if (HasHasbit(field)) { + format("_Internal::set_has_$1$(&$has_bits$);\n", FieldName(field)); + } + format( + "$1$_ = ::$proto_ns$::internal::ReadVarint$2$$3$(&ptr);\n" + "CHK_(ptr);\n", + FieldName(field), zigzag, size); + } + } + break; + } + case WireFormatLite::WIRETYPE_FIXED32: + case WireFormatLite::WIRETYPE_FIXED64: { + std::string type = PrimitiveTypeName(options_, field->cpp_type()); + if (field->is_repeated() || field->real_containing_oneof()) { + std::string prefix = field->is_repeated() ? "add" : "set"; + format( + "_internal_$1$_$2$(" + "::$proto_ns$::internal::UnalignedLoad<$3$>(ptr));\n" + "ptr += sizeof($3$);\n", + prefix, FieldName(field), type); + } else { + if (HasHasbit(field)) { + format("_Internal::set_has_$1$(&$has_bits$);\n", FieldName(field)); + } + format( + "$1$_ = ::$proto_ns$::internal::UnalignedLoad<$2$>(ptr);\n" + "ptr += sizeof($2$);\n", + FieldName(field), type); + } + break; + } + case WireFormatLite::WIRETYPE_LENGTH_DELIMITED: { + GenerateLengthDelim(format, field); + format("CHK_(ptr);\n"); + break; + } + case WireFormatLite::WIRETYPE_START_GROUP: { + format( + "ptr = ctx->ParseGroup(_internal_$1$_$2$(), ptr, $3$);\n" + "CHK_(ptr);\n", + field->is_repeated() ? "add" : "mutable", FieldName(field), tag); + break; + } + case WireFormatLite::WIRETYPE_END_GROUP: { + GOOGLE_LOG(FATAL) << "Can't have end group field\n"; + break; + } + } // switch (wire_type) +} + +// Returns the tag for this field and in case of repeated packable fields, +// sets a fallback tag in fallback_tag_ptr. +static uint32_t ExpectedTag(const FieldDescriptor* field, + uint32_t* fallback_tag_ptr) { + uint32_t expected_tag; + if (field->is_packable()) { + auto expected_wiretype = WireFormat::WireTypeForFieldType(field->type()); + expected_tag = WireFormatLite::MakeTag(field->number(), expected_wiretype); + GOOGLE_CHECK(expected_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED); + auto fallback_wiretype = WireFormatLite::WIRETYPE_LENGTH_DELIMITED; + uint32_t fallback_tag = + WireFormatLite::MakeTag(field->number(), fallback_wiretype); + + if (field->is_packed()) std::swap(expected_tag, fallback_tag); + *fallback_tag_ptr = fallback_tag; + } else { + auto expected_wiretype = WireFormat::WireTypeForField(field); + expected_tag = WireFormatLite::MakeTag(field->number(), expected_wiretype); + } + return expected_tag; +} + +void ParseFunctionGenerator::GenerateParseIterationBody( + Formatter& format, const Descriptor* descriptor, + const std::vector& ordered_fields) { + format( + "$uint32$ tag;\n" + "ptr = ::$proto_ns$::internal::ReadTag(ptr, &tag);\n"); + if (!ordered_fields.empty()) format("switch (tag >> 3) {\n"); + + format.Indent(); + + for (const auto* field : ordered_fields) { + PrintFieldComment(format, field); + format("case $1$:\n", field->number()); + format.Indent(); + uint32_t fallback_tag = 0; + uint32_t expected_tag = ExpectedTag(field, &fallback_tag); + format("if (PROTOBUF_PREDICT_TRUE(static_cast<$uint8$>(tag) == $1$)) {\n", + expected_tag & 0xFF); + format.Indent(); + auto wiretype = WireFormatLite::GetTagWireType(expected_tag); + uint32_t tag = WireFormatLite::MakeTag(field->number(), wiretype); + int tag_size = io::CodedOutputStream::VarintSize32(tag); + bool is_repeat = ShouldRepeat(field, wiretype); + if (is_repeat) { + format( + "ptr -= $1$;\n" + "do {\n" + " ptr += $1$;\n", + tag_size); + format.Indent(); + } + GenerateFieldBody(format, wiretype, field); + if (is_repeat) { + format.Outdent(); + format( + " if (!ctx->DataAvailable(ptr)) break;\n" + "} while (::$proto_ns$::internal::ExpectTag<$1$>(ptr));\n", + tag); + } + format.Outdent(); + if (fallback_tag) { + format("} else if (static_cast<$uint8$>(tag) == $1$) {\n", + fallback_tag & 0xFF); + format.Indent(); + GenerateFieldBody(format, WireFormatLite::GetTagWireType(fallback_tag), + field); + format.Outdent(); + } + format.Outdent(); + format( + " } else goto handle_unusual;\n" + " $continue$;\n"); + } // for loop over ordered fields + + // Default case + if (!ordered_fields.empty()) format("default: {\n"); + if (!ordered_fields.empty()) format("handle_unusual:\n"); + format( + " if ((tag == 0) || ((tag & 7) == 4)) {\n" + " CHK_(ptr);\n" + " ctx->SetLastTag(tag);\n" + " goto success;\n" + " }\n"); + if (IsMapEntryMessage(descriptor)) { + format(" $continue$;\n"); + } else { + if (descriptor->extension_range_count() > 0) { + format("if ("); + for (int i = 0; i < descriptor->extension_range_count(); i++) { + const Descriptor::ExtensionRange* range = + descriptor->extension_range(i); + if (i > 0) format(" ||\n "); + + uint32_t start_tag = WireFormatLite::MakeTag( + range->start, static_cast(0)); + uint32_t end_tag = WireFormatLite::MakeTag( + range->end, static_cast(0)); + + if (range->end > FieldDescriptor::kMaxNumber) { + format("($1$u <= tag)", start_tag); + } else { + format("($1$u <= tag && tag < $2$u)", start_tag, end_tag); + } + } + format(") {\n"); + format( + " ptr = _extensions_.ParseField(tag, ptr,\n" + " internal_default_instance(), &_internal_metadata_, ctx);\n" + " CHK_(ptr != nullptr);\n" + " $continue$;\n" + "}\n"); + } + format( + " ptr = UnknownFieldParse(tag,\n" + " _internal_metadata_.mutable_unknown_fields<$unknown_" + "fields_type$>(),\n" + " ptr, ctx);\n" + " CHK_(ptr != nullptr);\n" + " $continue$;\n"); + } + if (!ordered_fields.empty()) format("}\n"); // default case + format.Outdent(); + if (!ordered_fields.empty()) format("} // switch\n"); } } // namespace cpp diff --git a/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h b/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h index 5166903f6..704af4a7a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h +++ b/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h @@ -31,20 +31,69 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CPP_PARSE_FUNCTION_GENERATOR_H__ #define GOOGLE_PROTOBUF_COMPILER_CPP_PARSE_FUNCTION_GENERATOR_H__ +#include +#include +#include + #include #include #include #include +#include namespace google { namespace protobuf { namespace compiler { namespace cpp { -void GenerateParseFunction(const Descriptor* descriptor, int num_hasbits, - const Options& options, - MessageSCCAnalyzer* scc_analyzer, - io::Printer* printer); +// ParseFunctionGenerator generates the _InternalParse function for a message +// (and any associated supporting members). +class ParseFunctionGenerator { + public: + ParseFunctionGenerator(const Descriptor* descriptor, int num_hasbits, + const Options& options, + MessageSCCAnalyzer* scc_analyzer); + + // Emits class-level method declarations to `printer`: + void GenerateMethodDecls(io::Printer* printer); + + // Emits out-of-class method implementation definitions to `printer`: + void GenerateMethodImpls(io::Printer* printer); + + private: + // Returns the proto runtime internal namespace. + std::string pi_ns(); + + // Generates a looping `_InternalParse` function. + void GenerateLoopingParseFunction(Formatter& format); + + // Generates parsing code for an `ArenaString` field. + void GenerateArenaString(Formatter& format, const FieldDescriptor* field); + + // Generates parsing code for a string-typed field. + void GenerateStrings(Formatter& format, const FieldDescriptor* field, + bool check_utf8); + + // Generates parsing code for a length-delimited field (strings, messages, + // etc.). + void GenerateLengthDelim(Formatter& format, const FieldDescriptor* field); + + // Generates the parsing code for a known field. + void GenerateFieldBody(Formatter& format, + google::protobuf::internal::WireFormatLite::WireType wiretype, + const FieldDescriptor* field); + + // Generates code to parse the next field from the input stream. + void GenerateParseIterationBody( + Formatter& format, const Descriptor* descriptor, + const std::vector& ordered_fields); + + const Descriptor* descriptor_; + MessageSCCAnalyzer* scc_analyzer_; + const Options& options_; + std::map variables_; + int num_hasbits_; +}; } // namespace cpp } // namespace compiler diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc index dc9d9b8c7..c68a0909b 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -162,14 +162,16 @@ void StringFieldGenerator::GenerateAccessorDeclarations( descriptor_); format( "$deprecated_attr$std::string* ${1$mutable_$name$$}$();\n" - "$deprecated_attr$std::string* ${1$$release_name$$}$();\n" + "PROTOBUF_FUTURE_MUST_USE_RESULT $deprecated_attr$std::string* " + "${1$$release_name$$}$();\n" "$deprecated_attr$void ${1$set_allocated_$name$$}$(std::string* " "$name$);\n", descriptor_); format( "private:\n" "const std::string& _internal_$name$() const;\n" - "void _internal_set_$name$(const std::string& value);\n" + "inline PROTOBUF_ALWAYS_INLINE void " + "_internal_set_$name$(const std::string& value);\n" "std::string* _internal_mutable_$name$();\n" "public:\n"); @@ -196,12 +198,12 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( " return _internal_$name$();\n" "}\n" "template \n" - "PROTOBUF_ALWAYS_INLINE\n" - "inline void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n" + "inline PROTOBUF_ALWAYS_INLINE\n" + "void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n" "$annotate_accessor$" " $set_hasbit$\n" " $name$_.$setter$($default_value_tag$, static_cast(arg0)," - " args..., GetArena());\n" + " args..., GetArenaForAllocation());\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" "inline std::string* $classname$::mutable_$name$() {\n" @@ -215,12 +217,13 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( "inline void $classname$::_internal_set_$name$(const std::string& " "value) {\n" " $set_hasbit$\n" - " $name$_.Set($default_value_tag$, value, GetArena());\n" + " $name$_.Set($default_value_tag$, value, GetArenaForAllocation());\n" "}\n"); format( "inline std::string* $classname$::_internal_mutable_$name$() {\n" " $set_hasbit$\n" - " return $name$_.Mutable($default_variable_or_tag$, GetArena());\n" + " return $name$_.Mutable($default_variable_or_tag$, " + "GetArenaForAllocation());\n" "}\n" "inline std::string* $classname$::$release_name$() {\n" "$annotate_accessor$" @@ -232,9 +235,11 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( " return nullptr;\n" " }\n" " $clear_hasbit$\n" - " return $name$_.ReleaseNonDefault($init_value$, GetArena());\n"); + " return $name$_.ReleaseNonDefault($init_value$, " + "GetArenaForAllocation());\n"); } else { - format(" return $name$_.Release($init_value$, GetArena());\n"); + format( + " return $name$_.Release($init_value$, GetArenaForAllocation());\n"); } format( @@ -247,7 +252,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( " $clear_hasbit$\n" " }\n" " $name$_.SetAllocated($init_value$, $name$,\n" - " GetArena());\n" + " GetArenaForAllocation());\n" " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" "}\n"); } @@ -268,7 +273,8 @@ void StringFieldGenerator::GenerateClearingCode(io::Printer* printer) const { if (descriptor_->default_value_string().empty()) { format("$name$_.ClearToEmpty();\n"); } else { - format("$name$_.ClearToDefault($lazy_variable$, GetArena());\n"); + format( + "$name$_.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n"); } } @@ -294,7 +300,8 @@ void StringFieldGenerator::GenerateMessageClearingCode( } else { // 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. - format("$name$_.ClearToDefault($lazy_variable$, GetArena());\n "); + format( + "$name$_.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n "); } } @@ -306,7 +313,12 @@ void StringFieldGenerator::GenerateMergingCode(io::Printer* printer) const { void StringFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.Swap(&other->$name$_, $init_value$, GetArena());\n"); + format( + "::$proto_ns$::internal::ArenaStringPtr::InternalSwap(\n" + " $init_value$,\n" + " &$name$_, GetArenaForAllocation(),\n" + " &other->$name$_, other->GetArenaForAllocation()\n" + ");\n"); } void StringFieldGenerator::GenerateConstructorCode(io::Printer* printer) const { @@ -330,7 +342,7 @@ void StringFieldGenerator::GenerateCopyConstructorCode( // TODO(gpike): improve this format( "$name$_.Set($default_value_tag$, from._internal_$name$(), \n" - " GetArena());\n"); + " GetArenaForAllocation());\n"); format.Outdent(); format("}\n"); @@ -405,7 +417,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " $field_member$.UnsafeSetDefault($init_value$);\n" " }\n" " $field_member$.$setter$($default_value_tag$," - " static_cast(arg0), args..., GetArena());\n" + " static_cast(arg0), args..., GetArenaForAllocation());\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" "inline std::string* $classname$::mutable_$name$() {\n" @@ -426,7 +438,8 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " set_has_$name$();\n" " $field_member$.UnsafeSetDefault($init_value$);\n" " }\n" - " $field_member$.Set($default_value_tag$, value, GetArena());\n" + " $field_member$.Set($default_value_tag$, value, " + "GetArenaForAllocation());\n" "}\n"); format( "inline std::string* $classname$::_internal_mutable_$name$() {\n" @@ -436,14 +449,15 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " $field_member$.UnsafeSetDefault($init_value$);\n" " }\n" " return $field_member$.Mutable(\n" - " $default_variable_or_tag$, GetArena());\n" + " $default_variable_or_tag$, GetArenaForAllocation());\n" "}\n" "inline std::string* $classname$::$release_name$() {\n" "$annotate_accessor$" " // @@protoc_insertion_point(field_release:$full_name$)\n" " if (_internal_has_$name$()) {\n" " clear_has_$oneof_name$();\n" - " return $field_member$.ReleaseNonDefault($init_value$, GetArena());\n" + " return $field_member$.ReleaseNonDefault($init_value$, " + "GetArenaForAllocation());\n" " } else {\n" " return nullptr;\n" " }\n" @@ -456,7 +470,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " if ($name$ != nullptr) {\n" " set_has_$name$();\n" " $field_member$.UnsafeSetDefault($name$);\n" - " ::$proto_ns$::Arena* arena = GetArena();\n" + " ::$proto_ns$::Arena* arena = GetArenaForAllocation();\n" " if (arena != nullptr) {\n" " arena->Own($name$);\n" " }\n" @@ -468,7 +482,9 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( void StringOneofFieldGenerator::GenerateClearingCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$field_member$.Destroy($default_value_tag$, GetArena());\n"); + format( + "$field_member$.Destroy($default_value_tag$, " + "GetArenaForAllocation());\n"); } void StringOneofFieldGenerator::GenerateMessageClearingCode( diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.inc b/src/google/protobuf/compiler/cpp/cpp_unittest.inc index a717f99e4..08206c21b 100644 --- a/src/google/protobuf/compiler/cpp/cpp_unittest.inc +++ b/src/google/protobuf/compiler/cpp/cpp_unittest.inc @@ -205,9 +205,6 @@ TEST(GENERATED_MESSAGE_TEST_NAME, Trigraph) { TEST(GENERATED_MESSAGE_TEST_NAME, ExtremeSmallIntegerDefault) { const UNITTEST::TestExtremeDefaultValues& extreme_default = UNITTEST::TestExtremeDefaultValues::default_instance(); - EXPECT_EQ(~0x7fffffff, std::numeric_limits::min()); - EXPECT_EQ(PROTOBUF_LONGLONG(~0x7fffffffffffffff), - std::numeric_limits::min()); EXPECT_EQ(std::numeric_limits::min(), extreme_default.really_small_int32()); EXPECT_EQ(std::numeric_limits::min(), diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc index 5425ad9ac..69528eccf 100644 --- a/src/google/protobuf/compiler/java/java_message.cc +++ b/src/google/protobuf/compiler/java/java_message.cc @@ -211,9 +211,14 @@ void ImmutableMessageGenerator::GenerateFieldAccessorTable( " com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\n" " internal_$identifier$_fieldAccessorTable;\n"); + // The following bytecode_estimate calculation logic must stay in sync with + // the similar logic in the GenerateFieldAccessorTableInitializer method below + // to make sure that the generated static final fields are initialized in the + // static initialization block directly. + // // 6 bytes per field and oneof *bytecode_estimate += - 10 + 6 * descriptor_->field_count() + 6 * oneofs_.size(); + 10 + 6 * descriptor_->field_count() + 6 * descriptor_->oneof_decl_count(); } int ImmutableMessageGenerator::GenerateFieldAccessorTableInitializer( @@ -226,6 +231,10 @@ int ImmutableMessageGenerator::GenerateFieldAccessorTableInitializer( " new java.lang.String[] { ", "identifier", UniqueFileScopeIdentifier(descriptor_), "ver", GeneratedCodeVersionSuffix()); + // All the bytecode_estimate calculation logic in this method must stay in + // sync with the similar logic in the GenerateFieldAccessorTable method + // above. See the corresponding comment in GenerateFieldAccessorTable for + // details. for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field); diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc index bbcc8e592..9c4e1e48a 100644 --- a/src/google/protobuf/compiler/parser.cc +++ b/src/google/protobuf/compiler/parser.cc @@ -1782,12 +1782,12 @@ bool Parser::ParseReserved(EnumDescriptorProto* message, DO(Consume("reserved")); if (LookingAtType(io::Tokenizer::TYPE_STRING)) { LocationRecorder location(message_location, - DescriptorProto::kReservedNameFieldNumber); + EnumDescriptorProto::kReservedNameFieldNumber); location.StartAt(start_token); return ParseReservedNames(message, location); } else { LocationRecorder location(message_location, - DescriptorProto::kReservedRangeFieldNumber); + EnumDescriptorProto::kReservedRangeFieldNumber); location.StartAt(start_token); return ParseReservedNumbers(message, location); } diff --git a/src/google/protobuf/compiler/parser_unittest.cc b/src/google/protobuf/compiler/parser_unittest.cc index a413d74d0..32bf1b37d 100644 --- a/src/google/protobuf/compiler/parser_unittest.cc +++ b/src/google/protobuf/compiler/parser_unittest.cc @@ -3139,6 +3139,43 @@ TEST_F(SourceInfoTest, EnumValues) { EXPECT_TRUE(HasSpan(file_.enum_type(0), "name")); } +TEST_F(SourceInfoTest, EnumReservedRange) { + EXPECT_TRUE( + Parse("enum TestEnum {\n" + " $a$reserved $b$1$c$ to $d$10$e$;$f$\n" + "}")); + + const EnumDescriptorProto::EnumReservedRange& bar = + file_.enum_type(0).reserved_range(0); + + EXPECT_TRUE(HasSpan('a', 'f', file_.enum_type(0), "reserved_range")); + EXPECT_TRUE(HasSpan('b', 'e', bar)); + EXPECT_TRUE(HasSpan('b', 'c', bar, "start")); + EXPECT_TRUE(HasSpan('d', 'e', bar, "end")); + + // Ignore these. + EXPECT_TRUE(HasSpan(file_)); + EXPECT_TRUE(HasSpan(file_.enum_type(0))); + EXPECT_TRUE(HasSpan(file_.enum_type(0), "name")); +} + +TEST_F(SourceInfoTest, EnumReservedName) { + EXPECT_TRUE( + Parse("enum TestEnum {\n" + " $a$reserved $b$'foo'$c$;$d$\n" + "}")); + + const EnumDescriptorProto& bar = file_.enum_type(0); + + EXPECT_TRUE(HasSpan('a', 'd', bar, "reserved_name")); + EXPECT_TRUE(HasSpan('b', 'c', bar, "reserved_name", 0)); + + // Ignore these. + EXPECT_TRUE(HasSpan(file_)); + EXPECT_TRUE(HasSpan(file_.enum_type(0))); + EXPECT_TRUE(HasSpan(file_.enum_type(0), "name")); +} + TEST_F(SourceInfoTest, NestedEnums) { EXPECT_TRUE( Parse("message Foo {\n" diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index 1fd80a19f..11715d250 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -67,7 +67,7 @@ constexpr CodeGeneratorResponse::CodeGeneratorResponse( ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) : file_() , error_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , supported_features_(PROTOBUF_ULONGLONG(0)){} + , supported_features_(uint64_t{0u}){} struct CodeGeneratorResponseDefaultTypeInternal { constexpr CodeGeneratorResponseDefaultTypeInternal() : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} @@ -243,7 +243,7 @@ Version::Version(const Version& from) suffix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_suffix()) { suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_suffix(), - GetArena()); + GetArenaForAllocation()); } ::memcpy(&major_, &from.major_, static_cast(reinterpret_cast(&patch_) - @@ -266,7 +266,7 @@ Version::~Version() { } void Version::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); suffix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } @@ -518,7 +518,11 @@ void Version::InternalSwap(Version* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - suffix_.Swap(&other->suffix_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &suffix_, GetArenaForAllocation(), + &other->suffix_, other->GetArenaForAllocation() + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(Version, patch_) + sizeof(Version::patch_) @@ -571,7 +575,7 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from) parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_parameter()) { parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_parameter(), - GetArena()); + GetArenaForAllocation()); } if (from._internal_has_compiler_version()) { compiler_version_ = new PROTOBUF_NAMESPACE_ID::compiler::Version(*from.compiler_version_); @@ -593,7 +597,7 @@ CodeGeneratorRequest::~CodeGeneratorRequest() { } void CodeGeneratorRequest::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); parameter_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete compiler_version_; } @@ -867,7 +871,11 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) { swap(_has_bits_[0], other->_has_bits_[0]); file_to_generate_.InternalSwap(&other->file_to_generate_); proto_file_.InternalSwap(&other->proto_file_); - parameter_.Swap(&other->parameter_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + ¶meter_, GetArenaForAllocation(), + &other->parameter_, other->GetArenaForAllocation() + ); swap(compiler_version_, other->compiler_version_); } @@ -918,17 +926,17 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_insertion_point()) { insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_insertion_point(), - GetArena()); + GetArenaForAllocation()); } content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_content()) { content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_content(), - GetArena()); + GetArenaForAllocation()); } if (from._internal_has_generated_code_info()) { generated_code_info_ = new PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo(*from.generated_code_info_); @@ -952,7 +960,7 @@ CodeGeneratorResponse_File::~CodeGeneratorResponse_File() { } void CodeGeneratorResponse_File::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); insertion_point_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); content_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); @@ -1228,9 +1236,21 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other) using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - insertion_point_.Swap(&other->insertion_point_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - content_.Swap(&other->content_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &insertion_point_, GetArenaForAllocation(), + &other->insertion_point_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &content_, GetArenaForAllocation(), + &other->content_, other->GetArenaForAllocation() + ); swap(generated_code_info_, other->generated_code_info_); } @@ -1268,7 +1288,7 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from) error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_error()) { error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_error(), - GetArena()); + GetArenaForAllocation()); } supported_features_ = from.supported_features_; // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse) @@ -1276,7 +1296,7 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from) void CodeGeneratorResponse::SharedCtor() { error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -supported_features_ = PROTOBUF_ULONGLONG(0); +supported_features_ = uint64_t{0u}; } CodeGeneratorResponse::~CodeGeneratorResponse() { @@ -1286,7 +1306,7 @@ CodeGeneratorResponse::~CodeGeneratorResponse() { } void CodeGeneratorResponse::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); error_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } @@ -1311,7 +1331,7 @@ void CodeGeneratorResponse::Clear() { if (cached_has_bits & 0x00000001u) { error_.ClearNonDefaultToEmpty(); } - supported_features_ = PROTOBUF_ULONGLONG(0); + supported_features_ = uint64_t{0u}; _has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } @@ -1516,7 +1536,11 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) { _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); file_.InternalSwap(&other->file_); - error_.Swap(&other->error_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &error_, GetArenaForAllocation(), + &other->error_, other->GetArenaForAllocation() + ); swap(supported_features_, other->supported_features_); } diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 817a4fb91..44330ab20 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -111,7 +111,7 @@ inline bool CodeGeneratorResponse_Feature_Parse( } // =================================================================== -class PROTOC_EXPORT Version PROTOBUF_FINAL : +class PROTOC_EXPORT Version final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ { public: inline Version() : Version(nullptr) {} @@ -129,8 +129,9 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL : return *this; } inline Version& operator=(Version&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -168,7 +169,7 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL : } inline void Swap(Version* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -176,14 +177,14 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL : } void UnsafeArenaSwap(Version* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline Version* New() const final { - return CreateMaybeMessage(nullptr); + return new Version(); } Version* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -240,11 +241,11 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL : template void set_suffix(ArgT0&& arg0, ArgT... args); std::string* mutable_suffix(); - std::string* release_suffix(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_suffix(); void set_allocated_suffix(std::string* suffix); private: const std::string& _internal_suffix() const; - void _internal_set_suffix(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_suffix(const std::string& value); std::string* _internal_mutable_suffix(); public: @@ -304,7 +305,7 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL : +class PROTOC_EXPORT CodeGeneratorRequest final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorRequest) */ { public: inline CodeGeneratorRequest() : CodeGeneratorRequest(nullptr) {} @@ -322,8 +323,9 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL : return *this; } inline CodeGeneratorRequest& operator=(CodeGeneratorRequest&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -361,7 +363,7 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL : } inline void Swap(CodeGeneratorRequest* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -369,14 +371,14 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL : } void UnsafeArenaSwap(CodeGeneratorRequest* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline CodeGeneratorRequest* New() const final { - return CreateMaybeMessage(nullptr); + return new CodeGeneratorRequest(); } CodeGeneratorRequest* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -475,11 +477,11 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL : template void set_parameter(ArgT0&& arg0, ArgT... args); std::string* mutable_parameter(); - std::string* release_parameter(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_parameter(); void set_allocated_parameter(std::string* parameter); private: const std::string& _internal_parameter() const; - void _internal_set_parameter(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_parameter(const std::string& value); std::string* _internal_mutable_parameter(); public: @@ -518,7 +520,7 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL : +class PROTOC_EXPORT CodeGeneratorResponse_File final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ { public: inline CodeGeneratorResponse_File() : CodeGeneratorResponse_File(nullptr) {} @@ -536,8 +538,9 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL : return *this; } inline CodeGeneratorResponse_File& operator=(CodeGeneratorResponse_File&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -575,7 +578,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL : } inline void Swap(CodeGeneratorResponse_File* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -583,14 +586,14 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL : } void UnsafeArenaSwap(CodeGeneratorResponse_File* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline CodeGeneratorResponse_File* New() const final { - return CreateMaybeMessage(nullptr); + return new CodeGeneratorResponse_File(); } CodeGeneratorResponse_File* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -647,11 +650,11 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -665,11 +668,11 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL : template void set_insertion_point(ArgT0&& arg0, ArgT... args); std::string* mutable_insertion_point(); - std::string* release_insertion_point(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_insertion_point(); void set_allocated_insertion_point(std::string* insertion_point); private: const std::string& _internal_insertion_point() const; - void _internal_set_insertion_point(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_insertion_point(const std::string& value); std::string* _internal_mutable_insertion_point(); public: @@ -683,11 +686,11 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL : template void set_content(ArgT0&& arg0, ArgT... args); std::string* mutable_content(); - std::string* release_content(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_content(); void set_allocated_content(std::string* content); private: const std::string& _internal_content() const; - void _internal_set_content(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_content(const std::string& value); std::string* _internal_mutable_content(); public: @@ -726,7 +729,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL : +class PROTOC_EXPORT CodeGeneratorResponse final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ { public: inline CodeGeneratorResponse() : CodeGeneratorResponse(nullptr) {} @@ -744,8 +747,9 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL : return *this; } inline CodeGeneratorResponse& operator=(CodeGeneratorResponse&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -783,7 +787,7 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL : } inline void Swap(CodeGeneratorResponse* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -791,14 +795,14 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL : } void UnsafeArenaSwap(CodeGeneratorResponse* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline CodeGeneratorResponse* New() const final { - return CreateMaybeMessage(nullptr); + return new CodeGeneratorResponse(); } CodeGeneratorResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -904,11 +908,11 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL : template void set_error(ArgT0&& arg0, ArgT... args); std::string* mutable_error(); - std::string* release_error(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_error(); void set_allocated_error(std::string* error); private: const std::string& _internal_error() const; - void _internal_set_error(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_error(const std::string& value); std::string* _internal_mutable_error(); public: @@ -1051,10 +1055,10 @@ inline const std::string& Version::suffix() const { return _internal_suffix(); } template -PROTOBUF_ALWAYS_INLINE -inline void Version::set_suffix(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void Version::set_suffix(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix) } inline std::string* Version::mutable_suffix() { @@ -1066,11 +1070,11 @@ inline const std::string& Version::_internal_suffix() const { } inline void Version::_internal_set_suffix(const std::string& value) { _has_bits_[0] |= 0x00000001u; - suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* Version::_internal_mutable_suffix() { _has_bits_[0] |= 0x00000001u; - return suffix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return suffix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* Version::release_suffix() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix) @@ -1078,7 +1082,7 @@ inline std::string* Version::release_suffix() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return suffix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return suffix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void Version::set_allocated_suffix(std::string* suffix) { if (suffix != nullptr) { @@ -1087,7 +1091,7 @@ inline void Version::set_allocated_suffix(std::string* suffix) { _has_bits_[0] &= ~0x00000001u; } suffix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), suffix, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix) } @@ -1186,10 +1190,10 @@ inline const std::string& CodeGeneratorRequest::parameter() const { return _internal_parameter(); } template -PROTOBUF_ALWAYS_INLINE -inline void CodeGeneratorRequest::set_parameter(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void CodeGeneratorRequest::set_parameter(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter) } inline std::string* CodeGeneratorRequest::mutable_parameter() { @@ -1201,11 +1205,11 @@ inline const std::string& CodeGeneratorRequest::_internal_parameter() const { } inline void CodeGeneratorRequest::_internal_set_parameter(const std::string& value) { _has_bits_[0] |= 0x00000001u; - parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* CodeGeneratorRequest::_internal_mutable_parameter() { _has_bits_[0] |= 0x00000001u; - return parameter_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return parameter_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* CodeGeneratorRequest::release_parameter() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter) @@ -1213,7 +1217,7 @@ inline std::string* CodeGeneratorRequest::release_parameter() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return parameter_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return parameter_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void CodeGeneratorRequest::set_allocated_parameter(std::string* parameter) { if (parameter != nullptr) { @@ -1222,7 +1226,7 @@ inline void CodeGeneratorRequest::set_allocated_parameter(std::string* parameter _has_bits_[0] &= ~0x00000001u; } parameter_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), parameter, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter) } @@ -1286,7 +1290,7 @@ inline const PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::com } inline void CodeGeneratorRequest::unsafe_arena_set_allocated_compiler_version( PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version) { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(compiler_version_); } compiler_version_ = compiler_version; @@ -1301,7 +1305,7 @@ inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::release_c _has_bits_[0] &= ~0x00000002u; PROTOBUF_NAMESPACE_ID::compiler::Version* temp = compiler_version_; compiler_version_ = nullptr; - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -1316,7 +1320,7 @@ inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::unsafe_ar inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::_internal_mutable_compiler_version() { _has_bits_[0] |= 0x00000002u; if (compiler_version_ == nullptr) { - auto* p = CreateMaybeMessage(GetArena()); + auto* p = CreateMaybeMessage(GetArenaForAllocation()); compiler_version_ = p; } return compiler_version_; @@ -1326,13 +1330,13 @@ inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::mutable_c return _internal_mutable_compiler_version(); } inline void CodeGeneratorRequest::set_allocated_compiler_version(PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { delete compiler_version_; } if (compiler_version) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(compiler_version); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper::GetOwningArena(compiler_version); if (message_arena != submessage_arena) { compiler_version = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, compiler_version, submessage_arena); @@ -1366,10 +1370,10 @@ inline const std::string& CodeGeneratorResponse_File::name() const { return _internal_name(); } template -PROTOBUF_ALWAYS_INLINE -inline void CodeGeneratorResponse_File::set_name(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void CodeGeneratorResponse_File::set_name(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name) } inline std::string* CodeGeneratorResponse_File::mutable_name() { @@ -1381,11 +1385,11 @@ inline const std::string& CodeGeneratorResponse_File::_internal_name() const { } inline void CodeGeneratorResponse_File::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse_File::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse_File::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name) @@ -1393,7 +1397,7 @@ inline std::string* CodeGeneratorResponse_File::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void CodeGeneratorResponse_File::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -1402,7 +1406,7 @@ inline void CodeGeneratorResponse_File::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name) } @@ -1423,10 +1427,10 @@ inline const std::string& CodeGeneratorResponse_File::insertion_point() const { return _internal_insertion_point(); } template -PROTOBUF_ALWAYS_INLINE -inline void CodeGeneratorResponse_File::set_insertion_point(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void CodeGeneratorResponse_File::set_insertion_point(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000002u; - insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } inline std::string* CodeGeneratorResponse_File::mutable_insertion_point() { @@ -1438,11 +1442,11 @@ inline const std::string& CodeGeneratorResponse_File::_internal_insertion_point( } inline void CodeGeneratorResponse_File::_internal_set_insertion_point(const std::string& value) { _has_bits_[0] |= 0x00000002u; - insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse_File::_internal_mutable_insertion_point() { _has_bits_[0] |= 0x00000002u; - return insertion_point_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return insertion_point_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse_File::release_insertion_point() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) @@ -1450,7 +1454,7 @@ inline std::string* CodeGeneratorResponse_File::release_insertion_point() { return nullptr; } _has_bits_[0] &= ~0x00000002u; - return insertion_point_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return insertion_point_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void CodeGeneratorResponse_File::set_allocated_insertion_point(std::string* insertion_point) { if (insertion_point != nullptr) { @@ -1459,7 +1463,7 @@ inline void CodeGeneratorResponse_File::set_allocated_insertion_point(std::strin _has_bits_[0] &= ~0x00000002u; } insertion_point_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), insertion_point, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } @@ -1480,10 +1484,10 @@ inline const std::string& CodeGeneratorResponse_File::content() const { return _internal_content(); } template -PROTOBUF_ALWAYS_INLINE -inline void CodeGeneratorResponse_File::set_content(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void CodeGeneratorResponse_File::set_content(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000004u; - content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content) } inline std::string* CodeGeneratorResponse_File::mutable_content() { @@ -1495,11 +1499,11 @@ inline const std::string& CodeGeneratorResponse_File::_internal_content() const } inline void CodeGeneratorResponse_File::_internal_set_content(const std::string& value) { _has_bits_[0] |= 0x00000004u; - content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse_File::_internal_mutable_content() { _has_bits_[0] |= 0x00000004u; - return content_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return content_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse_File::release_content() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content) @@ -1507,7 +1511,7 @@ inline std::string* CodeGeneratorResponse_File::release_content() { return nullptr; } _has_bits_[0] &= ~0x00000004u; - return content_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return content_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void CodeGeneratorResponse_File::set_allocated_content(std::string* content) { if (content != nullptr) { @@ -1516,7 +1520,7 @@ inline void CodeGeneratorResponse_File::set_allocated_content(std::string* conte _has_bits_[0] &= ~0x00000004u; } content_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), content, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) } @@ -1540,7 +1544,7 @@ inline const PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& CodeGeneratorResponse_Fil } inline void CodeGeneratorResponse_File::unsafe_arena_set_allocated_generated_code_info( PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info) { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info_); } generated_code_info_ = generated_code_info; @@ -1555,7 +1559,7 @@ inline PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::rel _has_bits_[0] &= ~0x00000008u; PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* temp = generated_code_info_; generated_code_info_ = nullptr; - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -1570,7 +1574,7 @@ inline PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::uns inline PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::_internal_mutable_generated_code_info() { _has_bits_[0] |= 0x00000008u; if (generated_code_info_ == nullptr) { - auto* p = CreateMaybeMessage(GetArena()); + auto* p = CreateMaybeMessage(GetArenaForAllocation()); generated_code_info_ = p; } return generated_code_info_; @@ -1580,13 +1584,15 @@ inline PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::mut return _internal_mutable_generated_code_info(); } inline void CodeGeneratorResponse_File::set_allocated_generated_code_info(PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info_); } if (generated_code_info) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info)->GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper< + ::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena( + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info)); if (message_arena != submessage_arena) { generated_code_info = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, generated_code_info, submessage_arena); @@ -1620,10 +1626,10 @@ inline const std::string& CodeGeneratorResponse::error() const { return _internal_error(); } template -PROTOBUF_ALWAYS_INLINE -inline void CodeGeneratorResponse::set_error(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void CodeGeneratorResponse::set_error(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error) } inline std::string* CodeGeneratorResponse::mutable_error() { @@ -1635,11 +1641,11 @@ inline const std::string& CodeGeneratorResponse::_internal_error() const { } inline void CodeGeneratorResponse::_internal_set_error(const std::string& value) { _has_bits_[0] |= 0x00000001u; - error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse::_internal_mutable_error() { _has_bits_[0] |= 0x00000001u; - return error_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return error_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse::release_error() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error) @@ -1647,7 +1653,7 @@ inline std::string* CodeGeneratorResponse::release_error() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return error_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return error_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void CodeGeneratorResponse::set_allocated_error(std::string* error) { if (error != nullptr) { @@ -1656,7 +1662,7 @@ inline void CodeGeneratorResponse::set_allocated_error(std::string* error) { _has_bits_[0] &= ~0x00000001u; } error_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), error, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error) } @@ -1669,7 +1675,7 @@ inline bool CodeGeneratorResponse::has_supported_features() const { return _internal_has_supported_features(); } inline void CodeGeneratorResponse::clear_supported_features() { - supported_features_ = PROTOBUF_ULONGLONG(0); + supported_features_ = uint64_t{0u}; _has_bits_[0] &= ~0x00000002u; } inline ::PROTOBUF_NAMESPACE_ID::uint64 CodeGeneratorResponse::_internal_supported_features() const { diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 047a40126..9fb0dfac8 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -378,8 +378,8 @@ constexpr UninterpretedOption::UninterpretedOption( , identifier_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) , string_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) , aggregate_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , positive_int_value_(PROTOBUF_ULONGLONG(0)) - , negative_int_value_(PROTOBUF_LONGLONG(0)) + , positive_int_value_(uint64_t{0u}) + , negative_int_value_(int64_t{0}) , double_value_(0){} struct UninterpretedOptionDefaultTypeInternal { constexpr UninterpretedOptionDefaultTypeInternal() @@ -1262,7 +1262,7 @@ FileDescriptorSet::~FileDescriptorSet() { } void FileDescriptorSet::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void FileDescriptorSet::ArenaDtor(void* object) { @@ -1487,17 +1487,17 @@ FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from) name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_package()) { package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_package(), - GetArena()); + GetArenaForAllocation()); } syntax_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_syntax()) { syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_syntax(), - GetArena()); + GetArenaForAllocation()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::FileOptions(*from.options_); @@ -1529,7 +1529,7 @@ FileDescriptorProto::~FileDescriptorProto() { } void FileDescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); syntax_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); @@ -2065,9 +2065,21 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) { extension_.InternalSwap(&other->extension_); public_dependency_.InternalSwap(&other->public_dependency_); weak_dependency_.InternalSwap(&other->weak_dependency_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - package_.Swap(&other->package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - syntax_.Swap(&other->syntax_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &package_, GetArenaForAllocation(), + &other->package_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &syntax_, GetArenaForAllocation(), + &other->syntax_, other->GetArenaForAllocation() + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(FileDescriptorProto, source_code_info_) + sizeof(FileDescriptorProto::source_code_info_) @@ -2138,7 +2150,7 @@ DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() { } void DescriptorProto_ExtensionRange::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); if (this != internal_default_instance()) delete options_; } @@ -2421,7 +2433,7 @@ DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() { } void DescriptorProto_ReservedRange::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void DescriptorProto_ReservedRange::ArenaDtor(void* object) { @@ -2675,7 +2687,7 @@ DescriptorProto::DescriptorProto(const DescriptorProto& from) name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::MessageOptions(*from.options_); @@ -2697,7 +2709,7 @@ DescriptorProto::~DescriptorProto() { } void DescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete options_; } @@ -3159,7 +3171,11 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) { oneof_decl_.InternalSwap(&other->oneof_decl_); reserved_range_.InternalSwap(&other->reserved_range_); reserved_name_.InternalSwap(&other->reserved_name_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); swap(options_, other->options_); } @@ -3201,7 +3217,7 @@ ExtensionRangeOptions::~ExtensionRangeOptions() { } void ExtensionRangeOptions::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void ExtensionRangeOptions::ArenaDtor(void* object) { @@ -3444,27 +3460,27 @@ FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from) name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } extendee_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_extendee()) { extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_extendee(), - GetArena()); + GetArenaForAllocation()); } type_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_type_name()) { type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_name(), - GetArena()); + GetArenaForAllocation()); } default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_default_value()) { default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_default_value(), - GetArena()); + GetArenaForAllocation()); } json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_json_name()) { json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_json_name(), - GetArena()); + GetArenaForAllocation()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::FieldOptions(*from.options_); @@ -3498,7 +3514,7 @@ FieldDescriptorProto::~FieldDescriptorProto() { } void FieldDescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); extendee_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); type_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); @@ -3989,11 +4005,31 @@ void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - extendee_.Swap(&other->extendee_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - type_name_.Swap(&other->type_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - default_value_.Swap(&other->default_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - json_name_.Swap(&other->json_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &extendee_, GetArenaForAllocation(), + &other->extendee_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &type_name_, GetArenaForAllocation(), + &other->type_name_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &default_value_, GetArenaForAllocation(), + &other->default_value_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &json_name_, GetArenaForAllocation(), + &other->json_name_, other->GetArenaForAllocation() + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(FieldDescriptorProto, proto3_optional_) + sizeof(FieldDescriptorProto::proto3_optional_) @@ -4041,7 +4077,7 @@ OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from) name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::OneofOptions(*from.options_); @@ -4063,7 +4099,7 @@ OneofDescriptorProto::~OneofDescriptorProto() { } void OneofDescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete options_; } @@ -4272,7 +4308,11 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); swap(options_, other->options_); } @@ -4325,7 +4365,7 @@ EnumDescriptorProto_EnumReservedRange::~EnumDescriptorProto_EnumReservedRange() } void EnumDescriptorProto_EnumReservedRange::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void EnumDescriptorProto_EnumReservedRange::ArenaDtor(void* object) { @@ -4569,7 +4609,7 @@ EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from) name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::EnumOptions(*from.options_); @@ -4591,7 +4631,7 @@ EnumDescriptorProto::~EnumDescriptorProto() { } void EnumDescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete options_; } @@ -4898,7 +4938,11 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) { value_.InternalSwap(&other->value_); reserved_range_.InternalSwap(&other->reserved_range_); reserved_name_.InternalSwap(&other->reserved_name_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); swap(options_, other->options_); } @@ -4942,7 +4986,7 @@ EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProt name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::EnumValueOptions(*from.options_); @@ -4968,7 +5012,7 @@ EnumValueDescriptorProto::~EnumValueDescriptorProto() { } void EnumValueDescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete options_; } @@ -5203,7 +5247,11 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(EnumValueDescriptorProto, number_) + sizeof(EnumValueDescriptorProto::number_) @@ -5251,7 +5299,7 @@ ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& fro name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::ServiceOptions(*from.options_); @@ -5273,7 +5321,7 @@ ServiceDescriptorProto::~ServiceDescriptorProto() { } void ServiceDescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete options_; } @@ -5513,7 +5561,11 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) { _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); method_.InternalSwap(&other->method_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); swap(options_, other->options_); } @@ -5566,17 +5618,17 @@ MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from) name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } input_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_input_type()) { input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_input_type(), - GetArena()); + GetArenaForAllocation()); } output_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_output_type()) { output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_output_type(), - GetArena()); + GetArenaForAllocation()); } if (from._internal_has_options()) { options_ = new PROTOBUF_NAMESPACE_ID::MethodOptions(*from.options_); @@ -5606,7 +5658,7 @@ MethodDescriptorProto::~MethodDescriptorProto() { } void MethodDescriptorProto::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); input_type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); output_type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); @@ -5933,9 +5985,21 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - input_type_.Swap(&other->input_type_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - output_type_.Swap(&other->output_type_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &input_type_, GetArenaForAllocation(), + &other->input_type_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &output_type_, GetArenaForAllocation(), + &other->output_type_, other->GetArenaForAllocation() + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(MethodDescriptorProto, server_streaming_) + sizeof(MethodDescriptorProto::server_streaming_) @@ -6034,52 +6098,52 @@ FileOptions::FileOptions(const FileOptions& from) java_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_java_package()) { java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_java_package(), - GetArena()); + GetArenaForAllocation()); } java_outer_classname_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_java_outer_classname()) { java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_java_outer_classname(), - GetArena()); + GetArenaForAllocation()); } go_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_go_package()) { go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_go_package(), - GetArena()); + GetArenaForAllocation()); } objc_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_objc_class_prefix()) { objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_objc_class_prefix(), - GetArena()); + GetArenaForAllocation()); } csharp_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_csharp_namespace()) { csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_csharp_namespace(), - GetArena()); + GetArenaForAllocation()); } swift_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_swift_prefix()) { swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_swift_prefix(), - GetArena()); + GetArenaForAllocation()); } php_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_php_class_prefix()) { php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_php_class_prefix(), - GetArena()); + GetArenaForAllocation()); } php_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_php_namespace()) { php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_php_namespace(), - GetArena()); + GetArenaForAllocation()); } php_metadata_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_php_metadata_namespace()) { php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_php_metadata_namespace(), - GetArena()); + GetArenaForAllocation()); } ruby_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_ruby_package()) { ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_ruby_package(), - GetArena()); + GetArenaForAllocation()); } ::memcpy(&java_multiple_files_, &from.java_multiple_files_, static_cast(reinterpret_cast(&cc_enable_arenas_) - @@ -6113,7 +6177,7 @@ FileOptions::~FileOptions() { } void FileOptions::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); java_package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); java_outer_classname_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); go_package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); @@ -6904,16 +6968,56 @@ void FileOptions::InternalSwap(FileOptions* other) { _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); - java_package_.Swap(&other->java_package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - java_outer_classname_.Swap(&other->java_outer_classname_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - go_package_.Swap(&other->go_package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - objc_class_prefix_.Swap(&other->objc_class_prefix_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - csharp_namespace_.Swap(&other->csharp_namespace_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - swift_prefix_.Swap(&other->swift_prefix_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - php_class_prefix_.Swap(&other->php_class_prefix_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - php_namespace_.Swap(&other->php_namespace_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - php_metadata_namespace_.Swap(&other->php_metadata_namespace_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - ruby_package_.Swap(&other->ruby_package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &java_package_, GetArenaForAllocation(), + &other->java_package_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &java_outer_classname_, GetArenaForAllocation(), + &other->java_outer_classname_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &go_package_, GetArenaForAllocation(), + &other->go_package_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &objc_class_prefix_, GetArenaForAllocation(), + &other->objc_class_prefix_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &csharp_namespace_, GetArenaForAllocation(), + &other->csharp_namespace_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &swift_prefix_, GetArenaForAllocation(), + &other->swift_prefix_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &php_class_prefix_, GetArenaForAllocation(), + &other->php_class_prefix_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &php_namespace_, GetArenaForAllocation(), + &other->php_namespace_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &php_metadata_namespace_, GetArenaForAllocation(), + &other->php_metadata_namespace_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &ruby_package_, GetArenaForAllocation(), + &other->ruby_package_, other->GetArenaForAllocation() + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(FileOptions, deprecated_) + sizeof(FileOptions::deprecated_) @@ -6983,7 +7087,7 @@ MessageOptions::~MessageOptions() { } void MessageOptions::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void MessageOptions::ArenaDtor(void* object) { @@ -7336,7 +7440,7 @@ FieldOptions::~FieldOptions() { } void FieldOptions::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void FieldOptions::ArenaDtor(void* object) { @@ -7721,7 +7825,7 @@ OneofOptions::~OneofOptions() { } void OneofOptions::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void OneofOptions::ArenaDtor(void* object) { @@ -7953,7 +8057,7 @@ EnumOptions::~EnumOptions() { } void EnumOptions::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void EnumOptions::ArenaDtor(void* object) { @@ -8242,7 +8346,7 @@ EnumValueOptions::~EnumValueOptions() { } void EnumValueOptions::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void EnumValueOptions::ArenaDtor(void* object) { @@ -8496,7 +8600,7 @@ ServiceOptions::~ServiceOptions() { } void ServiceOptions::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void ServiceOptions::ArenaDtor(void* object) { @@ -8758,7 +8862,7 @@ MethodOptions::~MethodOptions() { } void MethodOptions::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void MethodOptions::ArenaDtor(void* object) { @@ -9046,7 +9150,7 @@ UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOp name_part_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_name_part()) { name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name_part(), - GetArena()); + GetArenaForAllocation()); } is_extension_ = from.is_extension_; // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption.NamePart) @@ -9064,7 +9168,7 @@ UninterpretedOption_NamePart::~UninterpretedOption_NamePart() { } void UninterpretedOption_NamePart::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_part_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } @@ -9278,7 +9382,11 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - name_part_.Swap(&other->name_part_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_part_, GetArenaForAllocation(), + &other->name_part_, other->GetArenaForAllocation() + ); swap(is_extension_, other->is_extension_); } @@ -9328,17 +9436,17 @@ UninterpretedOption::UninterpretedOption(const UninterpretedOption& from) identifier_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_identifier_value()) { identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_identifier_value(), - GetArena()); + GetArenaForAllocation()); } string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_string_value()) { string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_string_value(), - GetArena()); + GetArenaForAllocation()); } aggregate_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_aggregate_value()) { aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_aggregate_value(), - GetArena()); + GetArenaForAllocation()); } ::memcpy(&positive_int_value_, &from.positive_int_value_, static_cast(reinterpret_cast(&double_value_) - @@ -9363,7 +9471,7 @@ UninterpretedOption::~UninterpretedOption() { } void UninterpretedOption::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); identifier_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); string_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); aggregate_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); @@ -9709,9 +9817,21 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) { _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); name_.InternalSwap(&other->name_); - identifier_value_.Swap(&other->identifier_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - string_value_.Swap(&other->string_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - aggregate_value_.Swap(&other->aggregate_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &identifier_value_, GetArenaForAllocation(), + &other->identifier_value_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &string_value_, GetArenaForAllocation(), + &other->string_value_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &aggregate_value_, GetArenaForAllocation(), + &other->aggregate_value_, other->GetArenaForAllocation() + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(UninterpretedOption, double_value_) + sizeof(UninterpretedOption::double_value_) @@ -9758,12 +9878,12 @@ SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& leading_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_leading_comments()) { leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_leading_comments(), - GetArena()); + GetArenaForAllocation()); } trailing_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_trailing_comments()) { trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_trailing_comments(), - GetArena()); + GetArenaForAllocation()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location) } @@ -9780,7 +9900,7 @@ SourceCodeInfo_Location::~SourceCodeInfo_Location() { } void SourceCodeInfo_Location::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); leading_comments_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); trailing_comments_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } @@ -10102,8 +10222,16 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) { path_.InternalSwap(&other->path_); span_.InternalSwap(&other->span_); leading_detached_comments_.InternalSwap(&other->leading_detached_comments_); - leading_comments_.Swap(&other->leading_comments_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - trailing_comments_.Swap(&other->trailing_comments_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &leading_comments_, GetArenaForAllocation(), + &other->leading_comments_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &trailing_comments_, GetArenaForAllocation(), + &other->trailing_comments_, other->GetArenaForAllocation() + ); } ::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo_Location::GetMetadata() const { @@ -10142,7 +10270,7 @@ SourceCodeInfo::~SourceCodeInfo() { } void SourceCodeInfo::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void SourceCodeInfo::ArenaDtor(void* object) { @@ -10338,7 +10466,7 @@ GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeIn source_file_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_source_file()) { source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_source_file(), - GetArena()); + GetArenaForAllocation()); } ::memcpy(&begin_, &from.begin_, static_cast(reinterpret_cast(&end_) - @@ -10361,7 +10489,7 @@ GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() { } void GeneratedCodeInfo_Annotation::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); source_file_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } @@ -10626,7 +10754,11 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); path_.InternalSwap(&other->path_); - source_file_.Swap(&other->source_file_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &source_file_, GetArenaForAllocation(), + &other->source_file_, other->GetArenaForAllocation() + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(GeneratedCodeInfo_Annotation, end_) + sizeof(GeneratedCodeInfo_Annotation::end_) @@ -10671,7 +10803,7 @@ GeneratedCodeInfo::~GeneratedCodeInfo() { } void GeneratedCodeInfo::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void GeneratedCodeInfo::ArenaDtor(void* object) { diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index dbd46a7dd..9f5b8514f 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -329,7 +329,7 @@ inline bool MethodOptions_IdempotencyLevel_Parse( } // =================================================================== -class PROTOBUF_EXPORT FileDescriptorSet PROTOBUF_FINAL : +class PROTOBUF_EXPORT FileDescriptorSet final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorSet) */ { public: inline FileDescriptorSet() : FileDescriptorSet(nullptr) {} @@ -347,8 +347,9 @@ class PROTOBUF_EXPORT FileDescriptorSet PROTOBUF_FINAL : return *this; } inline FileDescriptorSet& operator=(FileDescriptorSet&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -386,7 +387,7 @@ class PROTOBUF_EXPORT FileDescriptorSet PROTOBUF_FINAL : } inline void Swap(FileDescriptorSet* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -394,14 +395,14 @@ class PROTOBUF_EXPORT FileDescriptorSet PROTOBUF_FINAL : } void UnsafeArenaSwap(FileDescriptorSet* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline FileDescriptorSet* New() const final { - return CreateMaybeMessage(nullptr); + return new FileDescriptorSet(); } FileDescriptorSet* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -476,7 +477,7 @@ class PROTOBUF_EXPORT FileDescriptorSet PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT FileDescriptorProto PROTOBUF_FINAL : +class PROTOBUF_EXPORT FileDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorProto) */ { public: inline FileDescriptorProto() : FileDescriptorProto(nullptr) {} @@ -494,8 +495,9 @@ class PROTOBUF_EXPORT FileDescriptorProto PROTOBUF_FINAL : return *this; } inline FileDescriptorProto& operator=(FileDescriptorProto&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -533,7 +535,7 @@ class PROTOBUF_EXPORT FileDescriptorProto PROTOBUF_FINAL : } inline void Swap(FileDescriptorProto* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -541,14 +543,14 @@ class PROTOBUF_EXPORT FileDescriptorProto PROTOBUF_FINAL : } void UnsafeArenaSwap(FileDescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline FileDescriptorProto* New() const final { - return CreateMaybeMessage(nullptr); + return new FileDescriptorProto(); } FileDescriptorProto* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -753,11 +755,11 @@ class PROTOBUF_EXPORT FileDescriptorProto PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -771,11 +773,11 @@ class PROTOBUF_EXPORT FileDescriptorProto PROTOBUF_FINAL : template void set_package(ArgT0&& arg0, ArgT... args); std::string* mutable_package(); - std::string* release_package(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_package(); void set_allocated_package(std::string* package); private: const std::string& _internal_package() const; - void _internal_set_package(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_package(const std::string& value); std::string* _internal_mutable_package(); public: @@ -789,11 +791,11 @@ class PROTOBUF_EXPORT FileDescriptorProto PROTOBUF_FINAL : template void set_syntax(ArgT0&& arg0, ArgT... args); std::string* mutable_syntax(); - std::string* release_syntax(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_syntax(); void set_allocated_syntax(std::string* syntax); private: const std::string& _internal_syntax() const; - void _internal_set_syntax(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_syntax(const std::string& value); std::string* _internal_mutable_syntax(); public: @@ -858,7 +860,7 @@ class PROTOBUF_EXPORT FileDescriptorProto PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT DescriptorProto_ExtensionRange PROTOBUF_FINAL : +class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ExtensionRange) */ { public: inline DescriptorProto_ExtensionRange() : DescriptorProto_ExtensionRange(nullptr) {} @@ -876,8 +878,9 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange PROTOBUF_FINAL : return *this; } inline DescriptorProto_ExtensionRange& operator=(DescriptorProto_ExtensionRange&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -915,7 +918,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange PROTOBUF_FINAL : } inline void Swap(DescriptorProto_ExtensionRange* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -923,14 +926,14 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange PROTOBUF_FINAL : } void UnsafeArenaSwap(DescriptorProto_ExtensionRange* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline DescriptorProto_ExtensionRange* New() const final { - return CreateMaybeMessage(nullptr); + return new DescriptorProto_ExtensionRange(); } DescriptorProto_ExtensionRange* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -1036,7 +1039,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT DescriptorProto_ReservedRange PROTOBUF_FINAL : +class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ReservedRange) */ { public: inline DescriptorProto_ReservedRange() : DescriptorProto_ReservedRange(nullptr) {} @@ -1054,8 +1057,9 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange PROTOBUF_FINAL : return *this; } inline DescriptorProto_ReservedRange& operator=(DescriptorProto_ReservedRange&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -1093,7 +1097,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange PROTOBUF_FINAL : } inline void Swap(DescriptorProto_ReservedRange* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1101,14 +1105,14 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange PROTOBUF_FINAL : } void UnsafeArenaSwap(DescriptorProto_ReservedRange* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline DescriptorProto_ReservedRange* New() const final { - return CreateMaybeMessage(nullptr); + return new DescriptorProto_ReservedRange(); } DescriptorProto_ReservedRange* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -1194,7 +1198,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT DescriptorProto PROTOBUF_FINAL : +class PROTOBUF_EXPORT DescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto) */ { public: inline DescriptorProto() : DescriptorProto(nullptr) {} @@ -1212,8 +1216,9 @@ class PROTOBUF_EXPORT DescriptorProto PROTOBUF_FINAL : return *this; } inline DescriptorProto& operator=(DescriptorProto&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -1251,7 +1256,7 @@ class PROTOBUF_EXPORT DescriptorProto PROTOBUF_FINAL : } inline void Swap(DescriptorProto* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1259,14 +1264,14 @@ class PROTOBUF_EXPORT DescriptorProto PROTOBUF_FINAL : } void UnsafeArenaSwap(DescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline DescriptorProto* New() const final { - return CreateMaybeMessage(nullptr); + return new DescriptorProto(); } DescriptorProto* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -1482,11 +1487,11 @@ class PROTOBUF_EXPORT DescriptorProto PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -1531,7 +1536,7 @@ class PROTOBUF_EXPORT DescriptorProto PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT ExtensionRangeOptions PROTOBUF_FINAL : +class PROTOBUF_EXPORT ExtensionRangeOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ExtensionRangeOptions) */ { public: inline ExtensionRangeOptions() : ExtensionRangeOptions(nullptr) {} @@ -1549,8 +1554,9 @@ class PROTOBUF_EXPORT ExtensionRangeOptions PROTOBUF_FINAL : return *this; } inline ExtensionRangeOptions& operator=(ExtensionRangeOptions&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -1588,7 +1594,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions PROTOBUF_FINAL : } inline void Swap(ExtensionRangeOptions* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1596,14 +1602,14 @@ class PROTOBUF_EXPORT ExtensionRangeOptions PROTOBUF_FINAL : } void UnsafeArenaSwap(ExtensionRangeOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline ExtensionRangeOptions* New() const final { - return CreateMaybeMessage(nullptr); + return new ExtensionRangeOptions(); } ExtensionRangeOptions* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -1681,7 +1687,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL : +class PROTOBUF_EXPORT FieldDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldDescriptorProto) */ { public: inline FieldDescriptorProto() : FieldDescriptorProto(nullptr) {} @@ -1699,8 +1705,9 @@ class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL : return *this; } inline FieldDescriptorProto& operator=(FieldDescriptorProto&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -1738,7 +1745,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL : } inline void Swap(FieldDescriptorProto* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1746,14 +1753,14 @@ class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL : } void UnsafeArenaSwap(FieldDescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline FieldDescriptorProto* New() const final { - return CreateMaybeMessage(nullptr); + return new FieldDescriptorProto(); } FieldDescriptorProto* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -1911,11 +1918,11 @@ class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -1929,11 +1936,11 @@ class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL : template void set_extendee(ArgT0&& arg0, ArgT... args); std::string* mutable_extendee(); - std::string* release_extendee(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_extendee(); void set_allocated_extendee(std::string* extendee); private: const std::string& _internal_extendee() const; - void _internal_set_extendee(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_extendee(const std::string& value); std::string* _internal_mutable_extendee(); public: @@ -1947,11 +1954,11 @@ class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL : template void set_type_name(ArgT0&& arg0, ArgT... args); std::string* mutable_type_name(); - std::string* release_type_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_type_name(); void set_allocated_type_name(std::string* type_name); private: const std::string& _internal_type_name() const; - void _internal_set_type_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_type_name(const std::string& value); std::string* _internal_mutable_type_name(); public: @@ -1965,11 +1972,11 @@ class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL : template void set_default_value(ArgT0&& arg0, ArgT... args); std::string* mutable_default_value(); - std::string* release_default_value(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_default_value(); void set_allocated_default_value(std::string* default_value); private: const std::string& _internal_default_value() const; - void _internal_set_default_value(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_default_value(const std::string& value); std::string* _internal_mutable_default_value(); public: @@ -1983,11 +1990,11 @@ class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL : template void set_json_name(ArgT0&& arg0, ArgT... args); std::string* mutable_json_name(); - std::string* release_json_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_json_name(); void set_allocated_json_name(std::string* json_name); private: const std::string& _internal_json_name() const; - void _internal_set_json_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_json_name(const std::string& value); std::string* _internal_mutable_json_name(); public: @@ -2098,7 +2105,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT OneofDescriptorProto PROTOBUF_FINAL : +class PROTOBUF_EXPORT OneofDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofDescriptorProto) */ { public: inline OneofDescriptorProto() : OneofDescriptorProto(nullptr) {} @@ -2116,8 +2123,9 @@ class PROTOBUF_EXPORT OneofDescriptorProto PROTOBUF_FINAL : return *this; } inline OneofDescriptorProto& operator=(OneofDescriptorProto&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -2155,7 +2163,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto PROTOBUF_FINAL : } inline void Swap(OneofDescriptorProto* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -2163,14 +2171,14 @@ class PROTOBUF_EXPORT OneofDescriptorProto PROTOBUF_FINAL : } void UnsafeArenaSwap(OneofDescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline OneofDescriptorProto* New() const final { - return CreateMaybeMessage(nullptr); + return new OneofDescriptorProto(); } OneofDescriptorProto* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -2225,11 +2233,11 @@ class PROTOBUF_EXPORT OneofDescriptorProto PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -2266,7 +2274,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange PROTOBUF_FINAL : +class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto.EnumReservedRange) */ { public: inline EnumDescriptorProto_EnumReservedRange() : EnumDescriptorProto_EnumReservedRange(nullptr) {} @@ -2284,8 +2292,9 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange PROTOBUF_FINAL : return *this; } inline EnumDescriptorProto_EnumReservedRange& operator=(EnumDescriptorProto_EnumReservedRange&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -2323,7 +2332,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange PROTOBUF_FINAL : } inline void Swap(EnumDescriptorProto_EnumReservedRange* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -2331,14 +2340,14 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange PROTOBUF_FINAL : } void UnsafeArenaSwap(EnumDescriptorProto_EnumReservedRange* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline EnumDescriptorProto_EnumReservedRange* New() const final { - return CreateMaybeMessage(nullptr); + return new EnumDescriptorProto_EnumReservedRange(); } EnumDescriptorProto_EnumReservedRange* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -2424,7 +2433,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT EnumDescriptorProto PROTOBUF_FINAL : +class PROTOBUF_EXPORT EnumDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto) */ { public: inline EnumDescriptorProto() : EnumDescriptorProto(nullptr) {} @@ -2442,8 +2451,9 @@ class PROTOBUF_EXPORT EnumDescriptorProto PROTOBUF_FINAL : return *this; } inline EnumDescriptorProto& operator=(EnumDescriptorProto&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -2481,7 +2491,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto PROTOBUF_FINAL : } inline void Swap(EnumDescriptorProto* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -2489,14 +2499,14 @@ class PROTOBUF_EXPORT EnumDescriptorProto PROTOBUF_FINAL : } void UnsafeArenaSwap(EnumDescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline EnumDescriptorProto* New() const final { - return CreateMaybeMessage(nullptr); + return new EnumDescriptorProto(); } EnumDescriptorProto* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -2616,11 +2626,11 @@ class PROTOBUF_EXPORT EnumDescriptorProto PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -2660,7 +2670,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT EnumValueDescriptorProto PROTOBUF_FINAL : +class PROTOBUF_EXPORT EnumValueDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueDescriptorProto) */ { public: inline EnumValueDescriptorProto() : EnumValueDescriptorProto(nullptr) {} @@ -2678,8 +2688,9 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto PROTOBUF_FINAL : return *this; } inline EnumValueDescriptorProto& operator=(EnumValueDescriptorProto&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -2717,7 +2728,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto PROTOBUF_FINAL : } inline void Swap(EnumValueDescriptorProto* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -2725,14 +2736,14 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto PROTOBUF_FINAL : } void UnsafeArenaSwap(EnumValueDescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline EnumValueDescriptorProto* New() const final { - return CreateMaybeMessage(nullptr); + return new EnumValueDescriptorProto(); } EnumValueDescriptorProto* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -2788,11 +2799,11 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -2843,7 +2854,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT ServiceDescriptorProto PROTOBUF_FINAL : +class PROTOBUF_EXPORT ServiceDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceDescriptorProto) */ { public: inline ServiceDescriptorProto() : ServiceDescriptorProto(nullptr) {} @@ -2861,8 +2872,9 @@ class PROTOBUF_EXPORT ServiceDescriptorProto PROTOBUF_FINAL : return *this; } inline ServiceDescriptorProto& operator=(ServiceDescriptorProto&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -2900,7 +2912,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto PROTOBUF_FINAL : } inline void Swap(ServiceDescriptorProto* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -2908,14 +2920,14 @@ class PROTOBUF_EXPORT ServiceDescriptorProto PROTOBUF_FINAL : } void UnsafeArenaSwap(ServiceDescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline ServiceDescriptorProto* New() const final { - return CreateMaybeMessage(nullptr); + return new ServiceDescriptorProto(); } ServiceDescriptorProto* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -2989,11 +3001,11 @@ class PROTOBUF_EXPORT ServiceDescriptorProto PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -3031,7 +3043,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT MethodDescriptorProto PROTOBUF_FINAL : +class PROTOBUF_EXPORT MethodDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodDescriptorProto) */ { public: inline MethodDescriptorProto() : MethodDescriptorProto(nullptr) {} @@ -3049,8 +3061,9 @@ class PROTOBUF_EXPORT MethodDescriptorProto PROTOBUF_FINAL : return *this; } inline MethodDescriptorProto& operator=(MethodDescriptorProto&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -3088,7 +3101,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto PROTOBUF_FINAL : } inline void Swap(MethodDescriptorProto* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -3096,14 +3109,14 @@ class PROTOBUF_EXPORT MethodDescriptorProto PROTOBUF_FINAL : } void UnsafeArenaSwap(MethodDescriptorProto* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline MethodDescriptorProto* New() const final { - return CreateMaybeMessage(nullptr); + return new MethodDescriptorProto(); } MethodDescriptorProto* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -3162,11 +3175,11 @@ class PROTOBUF_EXPORT MethodDescriptorProto PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -3180,11 +3193,11 @@ class PROTOBUF_EXPORT MethodDescriptorProto PROTOBUF_FINAL : template void set_input_type(ArgT0&& arg0, ArgT... args); std::string* mutable_input_type(); - std::string* release_input_type(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_input_type(); void set_allocated_input_type(std::string* input_type); private: const std::string& _internal_input_type() const; - void _internal_set_input_type(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_input_type(const std::string& value); std::string* _internal_mutable_input_type(); public: @@ -3198,11 +3211,11 @@ class PROTOBUF_EXPORT MethodDescriptorProto PROTOBUF_FINAL : template void set_output_type(ArgT0&& arg0, ArgT... args); std::string* mutable_output_type(); - std::string* release_output_type(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_output_type(); void set_allocated_output_type(std::string* output_type); private: const std::string& _internal_output_type() const; - void _internal_set_output_type(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_output_type(const std::string& value); std::string* _internal_mutable_output_type(); public: @@ -3269,7 +3282,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : +class PROTOBUF_EXPORT FileOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileOptions) */ { public: inline FileOptions() : FileOptions(nullptr) {} @@ -3287,8 +3300,9 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : return *this; } inline FileOptions& operator=(FileOptions&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -3326,7 +3340,7 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : } inline void Swap(FileOptions* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -3334,14 +3348,14 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : } void UnsafeArenaSwap(FileOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline FileOptions* New() const final { - return CreateMaybeMessage(nullptr); + return new FileOptions(); } FileOptions* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -3465,11 +3479,11 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : template void set_java_package(ArgT0&& arg0, ArgT... args); std::string* mutable_java_package(); - std::string* release_java_package(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_java_package(); void set_allocated_java_package(std::string* java_package); private: const std::string& _internal_java_package() const; - void _internal_set_java_package(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_java_package(const std::string& value); std::string* _internal_mutable_java_package(); public: @@ -3483,11 +3497,11 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : template void set_java_outer_classname(ArgT0&& arg0, ArgT... args); std::string* mutable_java_outer_classname(); - std::string* release_java_outer_classname(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_java_outer_classname(); void set_allocated_java_outer_classname(std::string* java_outer_classname); private: const std::string& _internal_java_outer_classname() const; - void _internal_set_java_outer_classname(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_java_outer_classname(const std::string& value); std::string* _internal_mutable_java_outer_classname(); public: @@ -3501,11 +3515,11 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : template void set_go_package(ArgT0&& arg0, ArgT... args); std::string* mutable_go_package(); - std::string* release_go_package(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_go_package(); void set_allocated_go_package(std::string* go_package); private: const std::string& _internal_go_package() const; - void _internal_set_go_package(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_go_package(const std::string& value); std::string* _internal_mutable_go_package(); public: @@ -3519,11 +3533,11 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : template void set_objc_class_prefix(ArgT0&& arg0, ArgT... args); std::string* mutable_objc_class_prefix(); - std::string* release_objc_class_prefix(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_objc_class_prefix(); void set_allocated_objc_class_prefix(std::string* objc_class_prefix); private: const std::string& _internal_objc_class_prefix() const; - void _internal_set_objc_class_prefix(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_objc_class_prefix(const std::string& value); std::string* _internal_mutable_objc_class_prefix(); public: @@ -3537,11 +3551,11 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : template void set_csharp_namespace(ArgT0&& arg0, ArgT... args); std::string* mutable_csharp_namespace(); - std::string* release_csharp_namespace(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_csharp_namespace(); void set_allocated_csharp_namespace(std::string* csharp_namespace); private: const std::string& _internal_csharp_namespace() const; - void _internal_set_csharp_namespace(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_csharp_namespace(const std::string& value); std::string* _internal_mutable_csharp_namespace(); public: @@ -3555,11 +3569,11 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : template void set_swift_prefix(ArgT0&& arg0, ArgT... args); std::string* mutable_swift_prefix(); - std::string* release_swift_prefix(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_swift_prefix(); void set_allocated_swift_prefix(std::string* swift_prefix); private: const std::string& _internal_swift_prefix() const; - void _internal_set_swift_prefix(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_swift_prefix(const std::string& value); std::string* _internal_mutable_swift_prefix(); public: @@ -3573,11 +3587,11 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : template void set_php_class_prefix(ArgT0&& arg0, ArgT... args); std::string* mutable_php_class_prefix(); - std::string* release_php_class_prefix(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_php_class_prefix(); void set_allocated_php_class_prefix(std::string* php_class_prefix); private: const std::string& _internal_php_class_prefix() const; - void _internal_set_php_class_prefix(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_php_class_prefix(const std::string& value); std::string* _internal_mutable_php_class_prefix(); public: @@ -3591,11 +3605,11 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : template void set_php_namespace(ArgT0&& arg0, ArgT... args); std::string* mutable_php_namespace(); - std::string* release_php_namespace(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_php_namespace(); void set_allocated_php_namespace(std::string* php_namespace); private: const std::string& _internal_php_namespace() const; - void _internal_set_php_namespace(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_php_namespace(const std::string& value); std::string* _internal_mutable_php_namespace(); public: @@ -3609,11 +3623,11 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : template void set_php_metadata_namespace(ArgT0&& arg0, ArgT... args); std::string* mutable_php_metadata_namespace(); - std::string* release_php_metadata_namespace(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_php_metadata_namespace(); void set_allocated_php_metadata_namespace(std::string* php_metadata_namespace); private: const std::string& _internal_php_metadata_namespace() const; - void _internal_set_php_metadata_namespace(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_php_metadata_namespace(const std::string& value); std::string* _internal_mutable_php_metadata_namespace(); public: @@ -3627,11 +3641,11 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : template void set_ruby_package(ArgT0&& arg0, ArgT... args); std::string* mutable_ruby_package(); - std::string* release_ruby_package(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_ruby_package(); void set_allocated_ruby_package(std::string* ruby_package); private: const std::string& _internal_ruby_package() const; - void _internal_set_ruby_package(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_ruby_package(const std::string& value); std::string* _internal_mutable_ruby_package(); public: @@ -3802,7 +3816,7 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT MessageOptions PROTOBUF_FINAL : +class PROTOBUF_EXPORT MessageOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MessageOptions) */ { public: inline MessageOptions() : MessageOptions(nullptr) {} @@ -3820,8 +3834,9 @@ class PROTOBUF_EXPORT MessageOptions PROTOBUF_FINAL : return *this; } inline MessageOptions& operator=(MessageOptions&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -3859,7 +3874,7 @@ class PROTOBUF_EXPORT MessageOptions PROTOBUF_FINAL : } inline void Swap(MessageOptions* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -3867,14 +3882,14 @@ class PROTOBUF_EXPORT MessageOptions PROTOBUF_FINAL : } void UnsafeArenaSwap(MessageOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline MessageOptions* New() const final { - return CreateMaybeMessage(nullptr); + return new MessageOptions(); } MessageOptions* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -4013,7 +4028,7 @@ class PROTOBUF_EXPORT MessageOptions PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT FieldOptions PROTOBUF_FINAL : +class PROTOBUF_EXPORT FieldOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldOptions) */ { public: inline FieldOptions() : FieldOptions(nullptr) {} @@ -4031,8 +4046,9 @@ class PROTOBUF_EXPORT FieldOptions PROTOBUF_FINAL : return *this; } inline FieldOptions& operator=(FieldOptions&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -4070,7 +4086,7 @@ class PROTOBUF_EXPORT FieldOptions PROTOBUF_FINAL : } inline void Swap(FieldOptions* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -4078,14 +4094,14 @@ class PROTOBUF_EXPORT FieldOptions PROTOBUF_FINAL : } void UnsafeArenaSwap(FieldOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline FieldOptions* New() const final { - return CreateMaybeMessage(nullptr); + return new FieldOptions(); } FieldOptions* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -4318,7 +4334,7 @@ class PROTOBUF_EXPORT FieldOptions PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT OneofOptions PROTOBUF_FINAL : +class PROTOBUF_EXPORT OneofOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofOptions) */ { public: inline OneofOptions() : OneofOptions(nullptr) {} @@ -4336,8 +4352,9 @@ class PROTOBUF_EXPORT OneofOptions PROTOBUF_FINAL : return *this; } inline OneofOptions& operator=(OneofOptions&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -4375,7 +4392,7 @@ class PROTOBUF_EXPORT OneofOptions PROTOBUF_FINAL : } inline void Swap(OneofOptions* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -4383,14 +4400,14 @@ class PROTOBUF_EXPORT OneofOptions PROTOBUF_FINAL : } void UnsafeArenaSwap(OneofOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline OneofOptions* New() const final { - return CreateMaybeMessage(nullptr); + return new OneofOptions(); } OneofOptions* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -4468,7 +4485,7 @@ class PROTOBUF_EXPORT OneofOptions PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT EnumOptions PROTOBUF_FINAL : +class PROTOBUF_EXPORT EnumOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumOptions) */ { public: inline EnumOptions() : EnumOptions(nullptr) {} @@ -4486,8 +4503,9 @@ class PROTOBUF_EXPORT EnumOptions PROTOBUF_FINAL : return *this; } inline EnumOptions& operator=(EnumOptions&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -4525,7 +4543,7 @@ class PROTOBUF_EXPORT EnumOptions PROTOBUF_FINAL : } inline void Swap(EnumOptions* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -4533,14 +4551,14 @@ class PROTOBUF_EXPORT EnumOptions PROTOBUF_FINAL : } void UnsafeArenaSwap(EnumOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline EnumOptions* New() const final { - return CreateMaybeMessage(nullptr); + return new EnumOptions(); } EnumOptions* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -4649,7 +4667,7 @@ class PROTOBUF_EXPORT EnumOptions PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT EnumValueOptions PROTOBUF_FINAL : +class PROTOBUF_EXPORT EnumValueOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueOptions) */ { public: inline EnumValueOptions() : EnumValueOptions(nullptr) {} @@ -4667,8 +4685,9 @@ class PROTOBUF_EXPORT EnumValueOptions PROTOBUF_FINAL : return *this; } inline EnumValueOptions& operator=(EnumValueOptions&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -4706,7 +4725,7 @@ class PROTOBUF_EXPORT EnumValueOptions PROTOBUF_FINAL : } inline void Swap(EnumValueOptions* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -4714,14 +4733,14 @@ class PROTOBUF_EXPORT EnumValueOptions PROTOBUF_FINAL : } void UnsafeArenaSwap(EnumValueOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline EnumValueOptions* New() const final { - return CreateMaybeMessage(nullptr); + return new EnumValueOptions(); } EnumValueOptions* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -4815,7 +4834,7 @@ class PROTOBUF_EXPORT EnumValueOptions PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT ServiceOptions PROTOBUF_FINAL : +class PROTOBUF_EXPORT ServiceOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceOptions) */ { public: inline ServiceOptions() : ServiceOptions(nullptr) {} @@ -4833,8 +4852,9 @@ class PROTOBUF_EXPORT ServiceOptions PROTOBUF_FINAL : return *this; } inline ServiceOptions& operator=(ServiceOptions&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -4872,7 +4892,7 @@ class PROTOBUF_EXPORT ServiceOptions PROTOBUF_FINAL : } inline void Swap(ServiceOptions* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -4880,14 +4900,14 @@ class PROTOBUF_EXPORT ServiceOptions PROTOBUF_FINAL : } void UnsafeArenaSwap(ServiceOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline ServiceOptions* New() const final { - return CreateMaybeMessage(nullptr); + return new ServiceOptions(); } ServiceOptions* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -4981,7 +5001,7 @@ class PROTOBUF_EXPORT ServiceOptions PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT MethodOptions PROTOBUF_FINAL : +class PROTOBUF_EXPORT MethodOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodOptions) */ { public: inline MethodOptions() : MethodOptions(nullptr) {} @@ -4999,8 +5019,9 @@ class PROTOBUF_EXPORT MethodOptions PROTOBUF_FINAL : return *this; } inline MethodOptions& operator=(MethodOptions&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -5038,7 +5059,7 @@ class PROTOBUF_EXPORT MethodOptions PROTOBUF_FINAL : } inline void Swap(MethodOptions* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -5046,14 +5067,14 @@ class PROTOBUF_EXPORT MethodOptions PROTOBUF_FINAL : } void UnsafeArenaSwap(MethodOptions* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline MethodOptions* New() const final { - return CreateMaybeMessage(nullptr); + return new MethodOptions(); } MethodOptions* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -5194,7 +5215,7 @@ class PROTOBUF_EXPORT MethodOptions PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT UninterpretedOption_NamePart PROTOBUF_FINAL : +class PROTOBUF_EXPORT UninterpretedOption_NamePart final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption.NamePart) */ { public: inline UninterpretedOption_NamePart() : UninterpretedOption_NamePart(nullptr) {} @@ -5212,8 +5233,9 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart PROTOBUF_FINAL : return *this; } inline UninterpretedOption_NamePart& operator=(UninterpretedOption_NamePart&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -5251,7 +5273,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart PROTOBUF_FINAL : } inline void Swap(UninterpretedOption_NamePart* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -5259,14 +5281,14 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart PROTOBUF_FINAL : } void UnsafeArenaSwap(UninterpretedOption_NamePart* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline UninterpretedOption_NamePart* New() const final { - return CreateMaybeMessage(nullptr); + return new UninterpretedOption_NamePart(); } UninterpretedOption_NamePart* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -5321,11 +5343,11 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart PROTOBUF_FINAL : template void set_name_part(ArgT0&& arg0, ArgT... args); std::string* mutable_name_part(); - std::string* release_name_part(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name_part(); void set_allocated_name_part(std::string* name_part); private: const std::string& _internal_name_part() const; - void _internal_set_name_part(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name_part(const std::string& value); std::string* _internal_mutable_name_part(); public: @@ -5360,7 +5382,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT UninterpretedOption PROTOBUF_FINAL : +class PROTOBUF_EXPORT UninterpretedOption final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption) */ { public: inline UninterpretedOption() : UninterpretedOption(nullptr) {} @@ -5378,8 +5400,9 @@ class PROTOBUF_EXPORT UninterpretedOption PROTOBUF_FINAL : return *this; } inline UninterpretedOption& operator=(UninterpretedOption&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -5417,7 +5440,7 @@ class PROTOBUF_EXPORT UninterpretedOption PROTOBUF_FINAL : } inline void Swap(UninterpretedOption* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -5425,14 +5448,14 @@ class PROTOBUF_EXPORT UninterpretedOption PROTOBUF_FINAL : } void UnsafeArenaSwap(UninterpretedOption* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline UninterpretedOption* New() const final { - return CreateMaybeMessage(nullptr); + return new UninterpretedOption(); } UninterpretedOption* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -5512,11 +5535,11 @@ class PROTOBUF_EXPORT UninterpretedOption PROTOBUF_FINAL : template void set_identifier_value(ArgT0&& arg0, ArgT... args); std::string* mutable_identifier_value(); - std::string* release_identifier_value(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_identifier_value(); void set_allocated_identifier_value(std::string* identifier_value); private: const std::string& _internal_identifier_value() const; - void _internal_set_identifier_value(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_identifier_value(const std::string& value); std::string* _internal_mutable_identifier_value(); public: @@ -5530,11 +5553,11 @@ class PROTOBUF_EXPORT UninterpretedOption PROTOBUF_FINAL : template void set_string_value(ArgT0&& arg0, ArgT... args); std::string* mutable_string_value(); - std::string* release_string_value(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_string_value(); void set_allocated_string_value(std::string* string_value); private: const std::string& _internal_string_value() const; - void _internal_set_string_value(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_string_value(const std::string& value); std::string* _internal_mutable_string_value(); public: @@ -5548,11 +5571,11 @@ class PROTOBUF_EXPORT UninterpretedOption PROTOBUF_FINAL : template void set_aggregate_value(ArgT0&& arg0, ArgT... args); std::string* mutable_aggregate_value(); - std::string* release_aggregate_value(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_aggregate_value(); void set_allocated_aggregate_value(std::string* aggregate_value); private: const std::string& _internal_aggregate_value() const; - void _internal_set_aggregate_value(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_aggregate_value(const std::string& value); std::string* _internal_mutable_aggregate_value(); public: @@ -5615,7 +5638,7 @@ class PROTOBUF_EXPORT UninterpretedOption PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT SourceCodeInfo_Location PROTOBUF_FINAL : +class PROTOBUF_EXPORT SourceCodeInfo_Location final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo.Location) */ { public: inline SourceCodeInfo_Location() : SourceCodeInfo_Location(nullptr) {} @@ -5633,8 +5656,9 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location PROTOBUF_FINAL : return *this; } inline SourceCodeInfo_Location& operator=(SourceCodeInfo_Location&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -5672,7 +5696,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location PROTOBUF_FINAL : } inline void Swap(SourceCodeInfo_Location* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -5680,14 +5704,14 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location PROTOBUF_FINAL : } void UnsafeArenaSwap(SourceCodeInfo_Location* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline SourceCodeInfo_Location* New() const final { - return CreateMaybeMessage(nullptr); + return new SourceCodeInfo_Location(); } SourceCodeInfo_Location* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -5813,11 +5837,11 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location PROTOBUF_FINAL : template void set_leading_comments(ArgT0&& arg0, ArgT... args); std::string* mutable_leading_comments(); - std::string* release_leading_comments(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_leading_comments(); void set_allocated_leading_comments(std::string* leading_comments); private: const std::string& _internal_leading_comments() const; - void _internal_set_leading_comments(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_leading_comments(const std::string& value); std::string* _internal_mutable_leading_comments(); public: @@ -5831,11 +5855,11 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location PROTOBUF_FINAL : template void set_trailing_comments(ArgT0&& arg0, ArgT... args); std::string* mutable_trailing_comments(); - std::string* release_trailing_comments(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_trailing_comments(); void set_allocated_trailing_comments(std::string* trailing_comments); private: const std::string& _internal_trailing_comments() const; - void _internal_set_trailing_comments(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_trailing_comments(const std::string& value); std::string* _internal_mutable_trailing_comments(); public: @@ -5859,7 +5883,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT SourceCodeInfo PROTOBUF_FINAL : +class PROTOBUF_EXPORT SourceCodeInfo final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo) */ { public: inline SourceCodeInfo() : SourceCodeInfo(nullptr) {} @@ -5877,8 +5901,9 @@ class PROTOBUF_EXPORT SourceCodeInfo PROTOBUF_FINAL : return *this; } inline SourceCodeInfo& operator=(SourceCodeInfo&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -5916,7 +5941,7 @@ class PROTOBUF_EXPORT SourceCodeInfo PROTOBUF_FINAL : } inline void Swap(SourceCodeInfo* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -5924,14 +5949,14 @@ class PROTOBUF_EXPORT SourceCodeInfo PROTOBUF_FINAL : } void UnsafeArenaSwap(SourceCodeInfo* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline SourceCodeInfo* New() const final { - return CreateMaybeMessage(nullptr); + return new SourceCodeInfo(); } SourceCodeInfo* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -6008,7 +6033,7 @@ class PROTOBUF_EXPORT SourceCodeInfo PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation PROTOBUF_FINAL : +class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo.Annotation) */ { public: inline GeneratedCodeInfo_Annotation() : GeneratedCodeInfo_Annotation(nullptr) {} @@ -6026,8 +6051,9 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation PROTOBUF_FINAL : return *this; } inline GeneratedCodeInfo_Annotation& operator=(GeneratedCodeInfo_Annotation&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -6065,7 +6091,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation PROTOBUF_FINAL : } inline void Swap(GeneratedCodeInfo_Annotation* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -6073,14 +6099,14 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation PROTOBUF_FINAL : } void UnsafeArenaSwap(GeneratedCodeInfo_Annotation* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline GeneratedCodeInfo_Annotation* New() const final { - return CreateMaybeMessage(nullptr); + return new GeneratedCodeInfo_Annotation(); } GeneratedCodeInfo_Annotation* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -6159,11 +6185,11 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation PROTOBUF_FINAL : template void set_source_file(ArgT0&& arg0, ArgT... args); std::string* mutable_source_file(); - std::string* release_source_file(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_source_file(); void set_allocated_source_file(std::string* source_file); private: const std::string& _internal_source_file() const; - void _internal_set_source_file(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_source_file(const std::string& value); std::string* _internal_mutable_source_file(); public: @@ -6211,7 +6237,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT GeneratedCodeInfo PROTOBUF_FINAL : +class PROTOBUF_EXPORT GeneratedCodeInfo final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo) */ { public: inline GeneratedCodeInfo() : GeneratedCodeInfo(nullptr) {} @@ -6229,8 +6255,9 @@ class PROTOBUF_EXPORT GeneratedCodeInfo PROTOBUF_FINAL : return *this; } inline GeneratedCodeInfo& operator=(GeneratedCodeInfo&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -6268,7 +6295,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo PROTOBUF_FINAL : } inline void Swap(GeneratedCodeInfo* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -6276,14 +6303,14 @@ class PROTOBUF_EXPORT GeneratedCodeInfo PROTOBUF_FINAL : } void UnsafeArenaSwap(GeneratedCodeInfo* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline GeneratedCodeInfo* New() const final { - return CreateMaybeMessage(nullptr); + return new GeneratedCodeInfo(); } GeneratedCodeInfo* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -6429,10 +6456,10 @@ inline const std::string& FileDescriptorProto::name() const { return _internal_name(); } template -PROTOBUF_ALWAYS_INLINE -inline void FileDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FileDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name) } inline std::string* FileDescriptorProto::mutable_name() { @@ -6444,11 +6471,11 @@ inline const std::string& FileDescriptorProto::_internal_name() const { } inline void FileDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FileDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FileDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.name) @@ -6456,7 +6483,7 @@ inline std::string* FileDescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FileDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -6465,7 +6492,7 @@ inline void FileDescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.name) } @@ -6486,10 +6513,10 @@ inline const std::string& FileDescriptorProto::package() const { return _internal_package(); } template -PROTOBUF_ALWAYS_INLINE -inline void FileDescriptorProto::set_package(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FileDescriptorProto::set_package(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000002u; - package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package) } inline std::string* FileDescriptorProto::mutable_package() { @@ -6501,11 +6528,11 @@ inline const std::string& FileDescriptorProto::_internal_package() const { } inline void FileDescriptorProto::_internal_set_package(const std::string& value) { _has_bits_[0] |= 0x00000002u; - package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FileDescriptorProto::_internal_mutable_package() { _has_bits_[0] |= 0x00000002u; - return package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FileDescriptorProto::release_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.package) @@ -6513,7 +6540,7 @@ inline std::string* FileDescriptorProto::release_package() { return nullptr; } _has_bits_[0] &= ~0x00000002u; - return package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FileDescriptorProto::set_allocated_package(std::string* package) { if (package != nullptr) { @@ -6522,7 +6549,7 @@ inline void FileDescriptorProto::set_allocated_package(std::string* package) { _has_bits_[0] &= ~0x00000002u; } package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), package, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.package) } @@ -6874,7 +6901,7 @@ inline const PROTOBUF_NAMESPACE_ID::FileOptions& FileDescriptorProto::options() } inline void FileDescriptorProto::unsafe_arena_set_allocated_options( PROTOBUF_NAMESPACE_ID::FileOptions* options) { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); } options_ = options; @@ -6889,7 +6916,7 @@ inline PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::release_options( _has_bits_[0] &= ~0x00000008u; PROTOBUF_NAMESPACE_ID::FileOptions* temp = options_; options_ = nullptr; - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -6904,7 +6931,7 @@ inline PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::unsafe_arena_rel inline PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000008u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArena()); + auto* p = CreateMaybeMessage(GetArenaForAllocation()); options_ = p; } return options_; @@ -6914,13 +6941,13 @@ inline PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::mutable_options( return _internal_mutable_options(); } inline void FileDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::FileOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { delete options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper::GetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); @@ -6957,7 +6984,7 @@ inline const PROTOBUF_NAMESPACE_ID::SourceCodeInfo& FileDescriptorProto::source_ } inline void FileDescriptorProto::unsafe_arena_set_allocated_source_code_info( PROTOBUF_NAMESPACE_ID::SourceCodeInfo* source_code_info) { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_code_info_); } source_code_info_ = source_code_info; @@ -6972,7 +6999,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::release_sourc _has_bits_[0] &= ~0x00000010u; PROTOBUF_NAMESPACE_ID::SourceCodeInfo* temp = source_code_info_; source_code_info_ = nullptr; - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -6987,7 +7014,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::unsafe_arena_ inline PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::_internal_mutable_source_code_info() { _has_bits_[0] |= 0x00000010u; if (source_code_info_ == nullptr) { - auto* p = CreateMaybeMessage(GetArena()); + auto* p = CreateMaybeMessage(GetArenaForAllocation()); source_code_info_ = p; } return source_code_info_; @@ -6997,13 +7024,13 @@ inline PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::mutable_sourc return _internal_mutable_source_code_info(); } inline void FileDescriptorProto::set_allocated_source_code_info(PROTOBUF_NAMESPACE_ID::SourceCodeInfo* source_code_info) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { delete source_code_info_; } if (source_code_info) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(source_code_info); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper::GetOwningArena(source_code_info); if (message_arena != submessage_arena) { source_code_info = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, source_code_info, submessage_arena); @@ -7033,10 +7060,10 @@ inline const std::string& FileDescriptorProto::syntax() const { return _internal_syntax(); } template -PROTOBUF_ALWAYS_INLINE -inline void FileDescriptorProto::set_syntax(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FileDescriptorProto::set_syntax(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000004u; - syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax) } inline std::string* FileDescriptorProto::mutable_syntax() { @@ -7048,11 +7075,11 @@ inline const std::string& FileDescriptorProto::_internal_syntax() const { } inline void FileDescriptorProto::_internal_set_syntax(const std::string& value) { _has_bits_[0] |= 0x00000004u; - syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FileDescriptorProto::_internal_mutable_syntax() { _has_bits_[0] |= 0x00000004u; - return syntax_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return syntax_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FileDescriptorProto::release_syntax() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.syntax) @@ -7060,7 +7087,7 @@ inline std::string* FileDescriptorProto::release_syntax() { return nullptr; } _has_bits_[0] &= ~0x00000004u; - return syntax_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return syntax_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FileDescriptorProto::set_allocated_syntax(std::string* syntax) { if (syntax != nullptr) { @@ -7069,7 +7096,7 @@ inline void FileDescriptorProto::set_allocated_syntax(std::string* syntax) { _has_bits_[0] &= ~0x00000004u; } syntax_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), syntax, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax) } @@ -7157,7 +7184,7 @@ inline const PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions& DescriptorProto_Exten } inline void DescriptorProto_ExtensionRange::unsafe_arena_set_allocated_options( PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* options) { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); } options_ = options; @@ -7172,7 +7199,7 @@ inline PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_ExtensionRa _has_bits_[0] &= ~0x00000001u; PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* temp = options_; options_ = nullptr; - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -7187,7 +7214,7 @@ inline PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_ExtensionRa inline PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_ExtensionRange::_internal_mutable_options() { _has_bits_[0] |= 0x00000001u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArena()); + auto* p = CreateMaybeMessage(GetArenaForAllocation()); options_ = p; } return options_; @@ -7197,13 +7224,13 @@ inline PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_ExtensionRa return _internal_mutable_options(); } inline void DescriptorProto_ExtensionRange::set_allocated_options(PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { delete options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper::GetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); @@ -7297,10 +7324,10 @@ inline const std::string& DescriptorProto::name() const { return _internal_name(); } template -PROTOBUF_ALWAYS_INLINE -inline void DescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void DescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name) } inline std::string* DescriptorProto::mutable_name() { @@ -7312,11 +7339,11 @@ inline const std::string& DescriptorProto::_internal_name() const { } inline void DescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* DescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* DescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.name) @@ -7324,7 +7351,7 @@ inline std::string* DescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void DescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -7333,7 +7360,7 @@ inline void DescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.name) } @@ -7595,7 +7622,7 @@ inline const PROTOBUF_NAMESPACE_ID::MessageOptions& DescriptorProto::options() c } inline void DescriptorProto::unsafe_arena_set_allocated_options( PROTOBUF_NAMESPACE_ID::MessageOptions* options) { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); } options_ = options; @@ -7610,7 +7637,7 @@ inline PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::release_options() _has_bits_[0] &= ~0x00000002u; PROTOBUF_NAMESPACE_ID::MessageOptions* temp = options_; options_ = nullptr; - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -7625,7 +7652,7 @@ inline PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::unsafe_arena_rele inline PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000002u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArena()); + auto* p = CreateMaybeMessage(GetArenaForAllocation()); options_ = p; } return options_; @@ -7635,13 +7662,13 @@ inline PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::mutable_options() return _internal_mutable_options(); } inline void DescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::MessageOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { delete options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper::GetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); @@ -7831,10 +7858,10 @@ inline const std::string& FieldDescriptorProto::name() const { return _internal_name(); } template -PROTOBUF_ALWAYS_INLINE -inline void FieldDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FieldDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name) } inline std::string* FieldDescriptorProto::mutable_name() { @@ -7846,11 +7873,11 @@ inline const std::string& FieldDescriptorProto::_internal_name() const { } inline void FieldDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.name) @@ -7858,7 +7885,7 @@ inline std::string* FieldDescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FieldDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -7867,7 +7894,7 @@ inline void FieldDescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.name) } @@ -7974,10 +8001,10 @@ inline const std::string& FieldDescriptorProto::type_name() const { return _internal_type_name(); } template -PROTOBUF_ALWAYS_INLINE -inline void FieldDescriptorProto::set_type_name(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FieldDescriptorProto::set_type_name(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000004u; - type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name) } inline std::string* FieldDescriptorProto::mutable_type_name() { @@ -7989,11 +8016,11 @@ inline const std::string& FieldDescriptorProto::_internal_type_name() const { } inline void FieldDescriptorProto::_internal_set_type_name(const std::string& value) { _has_bits_[0] |= 0x00000004u; - type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::_internal_mutable_type_name() { _has_bits_[0] |= 0x00000004u; - return type_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return type_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::release_type_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.type_name) @@ -8001,7 +8028,7 @@ inline std::string* FieldDescriptorProto::release_type_name() { return nullptr; } _has_bits_[0] &= ~0x00000004u; - return type_name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return type_name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FieldDescriptorProto::set_allocated_type_name(std::string* type_name) { if (type_name != nullptr) { @@ -8010,7 +8037,7 @@ inline void FieldDescriptorProto::set_allocated_type_name(std::string* type_name _has_bits_[0] &= ~0x00000004u; } type_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_name, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.type_name) } @@ -8031,10 +8058,10 @@ inline const std::string& FieldDescriptorProto::extendee() const { return _internal_extendee(); } template -PROTOBUF_ALWAYS_INLINE -inline void FieldDescriptorProto::set_extendee(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FieldDescriptorProto::set_extendee(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000002u; - extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee) } inline std::string* FieldDescriptorProto::mutable_extendee() { @@ -8046,11 +8073,11 @@ inline const std::string& FieldDescriptorProto::_internal_extendee() const { } inline void FieldDescriptorProto::_internal_set_extendee(const std::string& value) { _has_bits_[0] |= 0x00000002u; - extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::_internal_mutable_extendee() { _has_bits_[0] |= 0x00000002u; - return extendee_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return extendee_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::release_extendee() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.extendee) @@ -8058,7 +8085,7 @@ inline std::string* FieldDescriptorProto::release_extendee() { return nullptr; } _has_bits_[0] &= ~0x00000002u; - return extendee_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return extendee_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FieldDescriptorProto::set_allocated_extendee(std::string* extendee) { if (extendee != nullptr) { @@ -8067,7 +8094,7 @@ inline void FieldDescriptorProto::set_allocated_extendee(std::string* extendee) _has_bits_[0] &= ~0x00000002u; } extendee_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), extendee, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.extendee) } @@ -8088,10 +8115,10 @@ inline const std::string& FieldDescriptorProto::default_value() const { return _internal_default_value(); } template -PROTOBUF_ALWAYS_INLINE -inline void FieldDescriptorProto::set_default_value(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FieldDescriptorProto::set_default_value(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000008u; - default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value) } inline std::string* FieldDescriptorProto::mutable_default_value() { @@ -8103,11 +8130,11 @@ inline const std::string& FieldDescriptorProto::_internal_default_value() const } inline void FieldDescriptorProto::_internal_set_default_value(const std::string& value) { _has_bits_[0] |= 0x00000008u; - default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::_internal_mutable_default_value() { _has_bits_[0] |= 0x00000008u; - return default_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return default_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::release_default_value() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.default_value) @@ -8115,7 +8142,7 @@ inline std::string* FieldDescriptorProto::release_default_value() { return nullptr; } _has_bits_[0] &= ~0x00000008u; - return default_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return default_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FieldDescriptorProto::set_allocated_default_value(std::string* default_value) { if (default_value != nullptr) { @@ -8124,7 +8151,7 @@ inline void FieldDescriptorProto::set_allocated_default_value(std::string* defau _has_bits_[0] &= ~0x00000008u; } default_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), default_value, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.default_value) } @@ -8173,10 +8200,10 @@ inline const std::string& FieldDescriptorProto::json_name() const { return _internal_json_name(); } template -PROTOBUF_ALWAYS_INLINE -inline void FieldDescriptorProto::set_json_name(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FieldDescriptorProto::set_json_name(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000010u; - json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name) } inline std::string* FieldDescriptorProto::mutable_json_name() { @@ -8188,11 +8215,11 @@ inline const std::string& FieldDescriptorProto::_internal_json_name() const { } inline void FieldDescriptorProto::_internal_set_json_name(const std::string& value) { _has_bits_[0] |= 0x00000010u; - json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::_internal_mutable_json_name() { _has_bits_[0] |= 0x00000010u; - return json_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return json_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::release_json_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.json_name) @@ -8200,7 +8227,7 @@ inline std::string* FieldDescriptorProto::release_json_name() { return nullptr; } _has_bits_[0] &= ~0x00000010u; - return json_name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return json_name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FieldDescriptorProto::set_allocated_json_name(std::string* json_name) { if (json_name != nullptr) { @@ -8209,7 +8236,7 @@ inline void FieldDescriptorProto::set_allocated_json_name(std::string* json_name _has_bits_[0] &= ~0x00000010u; } json_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), json_name, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.json_name) } @@ -8237,7 +8264,7 @@ inline const PROTOBUF_NAMESPACE_ID::FieldOptions& FieldDescriptorProto::options( } inline void FieldDescriptorProto::unsafe_arena_set_allocated_options( PROTOBUF_NAMESPACE_ID::FieldOptions* options) { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); } options_ = options; @@ -8252,7 +8279,7 @@ inline PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::release_option _has_bits_[0] &= ~0x00000020u; PROTOBUF_NAMESPACE_ID::FieldOptions* temp = options_; options_ = nullptr; - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -8267,7 +8294,7 @@ inline PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::unsafe_arena_r inline PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000020u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArena()); + auto* p = CreateMaybeMessage(GetArenaForAllocation()); options_ = p; } return options_; @@ -8277,13 +8304,13 @@ inline PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::mutable_option return _internal_mutable_options(); } inline void FieldDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::FieldOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { delete options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper::GetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); @@ -8345,10 +8372,10 @@ inline const std::string& OneofDescriptorProto::name() const { return _internal_name(); } template -PROTOBUF_ALWAYS_INLINE -inline void OneofDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void OneofDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name) } inline std::string* OneofDescriptorProto::mutable_name() { @@ -8360,11 +8387,11 @@ inline const std::string& OneofDescriptorProto::_internal_name() const { } inline void OneofDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* OneofDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* OneofDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.name) @@ -8372,7 +8399,7 @@ inline std::string* OneofDescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void OneofDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -8381,7 +8408,7 @@ inline void OneofDescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.name) } @@ -8409,7 +8436,7 @@ inline const PROTOBUF_NAMESPACE_ID::OneofOptions& OneofDescriptorProto::options( } inline void OneofDescriptorProto::unsafe_arena_set_allocated_options( PROTOBUF_NAMESPACE_ID::OneofOptions* options) { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); } options_ = options; @@ -8424,7 +8451,7 @@ inline PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::release_option _has_bits_[0] &= ~0x00000002u; PROTOBUF_NAMESPACE_ID::OneofOptions* temp = options_; options_ = nullptr; - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -8439,7 +8466,7 @@ inline PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::unsafe_arena_r inline PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000002u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArena()); + auto* p = CreateMaybeMessage(GetArenaForAllocation()); options_ = p; } return options_; @@ -8449,13 +8476,13 @@ inline PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::mutable_option return _internal_mutable_options(); } inline void OneofDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::OneofOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { delete options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper::GetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); @@ -8549,10 +8576,10 @@ inline const std::string& EnumDescriptorProto::name() const { return _internal_name(); } template -PROTOBUF_ALWAYS_INLINE -inline void EnumDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void EnumDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name) } inline std::string* EnumDescriptorProto::mutable_name() { @@ -8564,11 +8591,11 @@ inline const std::string& EnumDescriptorProto::_internal_name() const { } inline void EnumDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* EnumDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* EnumDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.name) @@ -8576,7 +8603,7 @@ inline std::string* EnumDescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void EnumDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -8585,7 +8612,7 @@ inline void EnumDescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.name) } @@ -8652,7 +8679,7 @@ inline const PROTOBUF_NAMESPACE_ID::EnumOptions& EnumDescriptorProto::options() } inline void EnumDescriptorProto::unsafe_arena_set_allocated_options( PROTOBUF_NAMESPACE_ID::EnumOptions* options) { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); } options_ = options; @@ -8667,7 +8694,7 @@ inline PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::release_options( _has_bits_[0] &= ~0x00000002u; PROTOBUF_NAMESPACE_ID::EnumOptions* temp = options_; options_ = nullptr; - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -8682,7 +8709,7 @@ inline PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::unsafe_arena_rel inline PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000002u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArena()); + auto* p = CreateMaybeMessage(GetArenaForAllocation()); options_ = p; } return options_; @@ -8692,13 +8719,13 @@ inline PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::mutable_options( return _internal_mutable_options(); } inline void EnumDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::EnumOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { delete options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper::GetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); @@ -8845,10 +8872,10 @@ inline const std::string& EnumValueDescriptorProto::name() const { return _internal_name(); } template -PROTOBUF_ALWAYS_INLINE -inline void EnumValueDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void EnumValueDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name) } inline std::string* EnumValueDescriptorProto::mutable_name() { @@ -8860,11 +8887,11 @@ inline const std::string& EnumValueDescriptorProto::_internal_name() const { } inline void EnumValueDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* EnumValueDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* EnumValueDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.name) @@ -8872,7 +8899,7 @@ inline std::string* EnumValueDescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void EnumValueDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -8881,7 +8908,7 @@ inline void EnumValueDescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.name) } @@ -8937,7 +8964,7 @@ inline const PROTOBUF_NAMESPACE_ID::EnumValueOptions& EnumValueDescriptorProto:: } inline void EnumValueDescriptorProto::unsafe_arena_set_allocated_options( PROTOBUF_NAMESPACE_ID::EnumValueOptions* options) { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); } options_ = options; @@ -8952,7 +8979,7 @@ inline PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::releas _has_bits_[0] &= ~0x00000002u; PROTOBUF_NAMESPACE_ID::EnumValueOptions* temp = options_; options_ = nullptr; - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -8967,7 +8994,7 @@ inline PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::unsafe inline PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000002u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArena()); + auto* p = CreateMaybeMessage(GetArenaForAllocation()); options_ = p; } return options_; @@ -8977,13 +9004,13 @@ inline PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::mutabl return _internal_mutable_options(); } inline void EnumValueDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::EnumValueOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { delete options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper::GetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); @@ -9017,10 +9044,10 @@ inline const std::string& ServiceDescriptorProto::name() const { return _internal_name(); } template -PROTOBUF_ALWAYS_INLINE -inline void ServiceDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void ServiceDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name) } inline std::string* ServiceDescriptorProto::mutable_name() { @@ -9032,11 +9059,11 @@ inline const std::string& ServiceDescriptorProto::_internal_name() const { } inline void ServiceDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* ServiceDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* ServiceDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.name) @@ -9044,7 +9071,7 @@ inline std::string* ServiceDescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void ServiceDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -9053,7 +9080,7 @@ inline void ServiceDescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.name) } @@ -9120,7 +9147,7 @@ inline const PROTOBUF_NAMESPACE_ID::ServiceOptions& ServiceDescriptorProto::opti } inline void ServiceDescriptorProto::unsafe_arena_set_allocated_options( PROTOBUF_NAMESPACE_ID::ServiceOptions* options) { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); } options_ = options; @@ -9135,7 +9162,7 @@ inline PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::release_op _has_bits_[0] &= ~0x00000002u; PROTOBUF_NAMESPACE_ID::ServiceOptions* temp = options_; options_ = nullptr; - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -9150,7 +9177,7 @@ inline PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::unsafe_are inline PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000002u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArena()); + auto* p = CreateMaybeMessage(GetArenaForAllocation()); options_ = p; } return options_; @@ -9160,13 +9187,13 @@ inline PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::mutable_op return _internal_mutable_options(); } inline void ServiceDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::ServiceOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { delete options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper::GetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); @@ -9200,10 +9227,10 @@ inline const std::string& MethodDescriptorProto::name() const { return _internal_name(); } template -PROTOBUF_ALWAYS_INLINE -inline void MethodDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void MethodDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name) } inline std::string* MethodDescriptorProto::mutable_name() { @@ -9215,11 +9242,11 @@ inline const std::string& MethodDescriptorProto::_internal_name() const { } inline void MethodDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* MethodDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* MethodDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.name) @@ -9227,7 +9254,7 @@ inline std::string* MethodDescriptorProto::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void MethodDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -9236,7 +9263,7 @@ inline void MethodDescriptorProto::set_allocated_name(std::string* name) { _has_bits_[0] &= ~0x00000001u; } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.name) } @@ -9257,10 +9284,10 @@ inline const std::string& MethodDescriptorProto::input_type() const { return _internal_input_type(); } template -PROTOBUF_ALWAYS_INLINE -inline void MethodDescriptorProto::set_input_type(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void MethodDescriptorProto::set_input_type(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000002u; - input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type) } inline std::string* MethodDescriptorProto::mutable_input_type() { @@ -9272,11 +9299,11 @@ inline const std::string& MethodDescriptorProto::_internal_input_type() const { } inline void MethodDescriptorProto::_internal_set_input_type(const std::string& value) { _has_bits_[0] |= 0x00000002u; - input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* MethodDescriptorProto::_internal_mutable_input_type() { _has_bits_[0] |= 0x00000002u; - return input_type_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return input_type_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* MethodDescriptorProto::release_input_type() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.input_type) @@ -9284,7 +9311,7 @@ inline std::string* MethodDescriptorProto::release_input_type() { return nullptr; } _has_bits_[0] &= ~0x00000002u; - return input_type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return input_type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void MethodDescriptorProto::set_allocated_input_type(std::string* input_type) { if (input_type != nullptr) { @@ -9293,7 +9320,7 @@ inline void MethodDescriptorProto::set_allocated_input_type(std::string* input_t _has_bits_[0] &= ~0x00000002u; } input_type_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), input_type, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.input_type) } @@ -9314,10 +9341,10 @@ inline const std::string& MethodDescriptorProto::output_type() const { return _internal_output_type(); } template -PROTOBUF_ALWAYS_INLINE -inline void MethodDescriptorProto::set_output_type(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void MethodDescriptorProto::set_output_type(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000004u; - output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type) } inline std::string* MethodDescriptorProto::mutable_output_type() { @@ -9329,11 +9356,11 @@ inline const std::string& MethodDescriptorProto::_internal_output_type() const { } inline void MethodDescriptorProto::_internal_set_output_type(const std::string& value) { _has_bits_[0] |= 0x00000004u; - output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* MethodDescriptorProto::_internal_mutable_output_type() { _has_bits_[0] |= 0x00000004u; - return output_type_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return output_type_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* MethodDescriptorProto::release_output_type() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.output_type) @@ -9341,7 +9368,7 @@ inline std::string* MethodDescriptorProto::release_output_type() { return nullptr; } _has_bits_[0] &= ~0x00000004u; - return output_type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return output_type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void MethodDescriptorProto::set_allocated_output_type(std::string* output_type) { if (output_type != nullptr) { @@ -9350,7 +9377,7 @@ inline void MethodDescriptorProto::set_allocated_output_type(std::string* output _has_bits_[0] &= ~0x00000004u; } output_type_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), output_type, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.output_type) } @@ -9378,7 +9405,7 @@ inline const PROTOBUF_NAMESPACE_ID::MethodOptions& MethodDescriptorProto::option } inline void MethodDescriptorProto::unsafe_arena_set_allocated_options( PROTOBUF_NAMESPACE_ID::MethodOptions* options) { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); } options_ = options; @@ -9393,7 +9420,7 @@ inline PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::release_opti _has_bits_[0] &= ~0x00000008u; PROTOBUF_NAMESPACE_ID::MethodOptions* temp = options_; options_ = nullptr; - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } return temp; @@ -9408,7 +9435,7 @@ inline PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::unsafe_arena inline PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::_internal_mutable_options() { _has_bits_[0] |= 0x00000008u; if (options_ == nullptr) { - auto* p = CreateMaybeMessage(GetArena()); + auto* p = CreateMaybeMessage(GetArenaForAllocation()); options_ = p; } return options_; @@ -9418,13 +9445,13 @@ inline PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::mutable_opti return _internal_mutable_options(); } inline void MethodDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::MethodOptions* options) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { delete options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper::GetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); @@ -9514,10 +9541,10 @@ inline const std::string& FileOptions::java_package() const { return _internal_java_package(); } template -PROTOBUF_ALWAYS_INLINE -inline void FileOptions::set_java_package(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FileOptions::set_java_package(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package) } inline std::string* FileOptions::mutable_java_package() { @@ -9529,11 +9556,11 @@ inline const std::string& FileOptions::_internal_java_package() const { } inline void FileOptions::_internal_set_java_package(const std::string& value) { _has_bits_[0] |= 0x00000001u; - java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_java_package() { _has_bits_[0] |= 0x00000001u; - return java_package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return java_package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FileOptions::release_java_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_package) @@ -9541,7 +9568,7 @@ inline std::string* FileOptions::release_java_package() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return java_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return java_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FileOptions::set_allocated_java_package(std::string* java_package) { if (java_package != nullptr) { @@ -9550,7 +9577,7 @@ inline void FileOptions::set_allocated_java_package(std::string* java_package) { _has_bits_[0] &= ~0x00000001u; } java_package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), java_package, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_package) } @@ -9571,10 +9598,10 @@ inline const std::string& FileOptions::java_outer_classname() const { return _internal_java_outer_classname(); } template -PROTOBUF_ALWAYS_INLINE -inline void FileOptions::set_java_outer_classname(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FileOptions::set_java_outer_classname(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000002u; - java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname) } inline std::string* FileOptions::mutable_java_outer_classname() { @@ -9586,11 +9613,11 @@ inline const std::string& FileOptions::_internal_java_outer_classname() const { } inline void FileOptions::_internal_set_java_outer_classname(const std::string& value) { _has_bits_[0] |= 0x00000002u; - java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_java_outer_classname() { _has_bits_[0] |= 0x00000002u; - return java_outer_classname_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return java_outer_classname_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FileOptions::release_java_outer_classname() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_outer_classname) @@ -9598,7 +9625,7 @@ inline std::string* FileOptions::release_java_outer_classname() { return nullptr; } _has_bits_[0] &= ~0x00000002u; - return java_outer_classname_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return java_outer_classname_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FileOptions::set_allocated_java_outer_classname(std::string* java_outer_classname) { if (java_outer_classname != nullptr) { @@ -9607,7 +9634,7 @@ inline void FileOptions::set_allocated_java_outer_classname(std::string* java_ou _has_bits_[0] &= ~0x00000002u; } java_outer_classname_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), java_outer_classname, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_outer_classname) } @@ -9741,10 +9768,10 @@ inline const std::string& FileOptions::go_package() const { return _internal_go_package(); } template -PROTOBUF_ALWAYS_INLINE -inline void FileOptions::set_go_package(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FileOptions::set_go_package(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000004u; - go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package) } inline std::string* FileOptions::mutable_go_package() { @@ -9756,11 +9783,11 @@ inline const std::string& FileOptions::_internal_go_package() const { } inline void FileOptions::_internal_set_go_package(const std::string& value) { _has_bits_[0] |= 0x00000004u; - go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_go_package() { _has_bits_[0] |= 0x00000004u; - return go_package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return go_package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FileOptions::release_go_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.go_package) @@ -9768,7 +9795,7 @@ inline std::string* FileOptions::release_go_package() { return nullptr; } _has_bits_[0] &= ~0x00000004u; - return go_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return go_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FileOptions::set_allocated_go_package(std::string* go_package) { if (go_package != nullptr) { @@ -9777,7 +9804,7 @@ inline void FileOptions::set_allocated_go_package(std::string* go_package) { _has_bits_[0] &= ~0x00000004u; } go_package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), go_package, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.go_package) } @@ -9966,10 +9993,10 @@ inline const std::string& FileOptions::objc_class_prefix() const { return _internal_objc_class_prefix(); } template -PROTOBUF_ALWAYS_INLINE -inline void FileOptions::set_objc_class_prefix(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FileOptions::set_objc_class_prefix(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000008u; - objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix) } inline std::string* FileOptions::mutable_objc_class_prefix() { @@ -9981,11 +10008,11 @@ inline const std::string& FileOptions::_internal_objc_class_prefix() const { } inline void FileOptions::_internal_set_objc_class_prefix(const std::string& value) { _has_bits_[0] |= 0x00000008u; - objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_objc_class_prefix() { _has_bits_[0] |= 0x00000008u; - return objc_class_prefix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return objc_class_prefix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FileOptions::release_objc_class_prefix() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.objc_class_prefix) @@ -9993,7 +10020,7 @@ inline std::string* FileOptions::release_objc_class_prefix() { return nullptr; } _has_bits_[0] &= ~0x00000008u; - return objc_class_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return objc_class_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FileOptions::set_allocated_objc_class_prefix(std::string* objc_class_prefix) { if (objc_class_prefix != nullptr) { @@ -10002,7 +10029,7 @@ inline void FileOptions::set_allocated_objc_class_prefix(std::string* objc_class _has_bits_[0] &= ~0x00000008u; } objc_class_prefix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), objc_class_prefix, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.objc_class_prefix) } @@ -10023,10 +10050,10 @@ inline const std::string& FileOptions::csharp_namespace() const { return _internal_csharp_namespace(); } template -PROTOBUF_ALWAYS_INLINE -inline void FileOptions::set_csharp_namespace(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FileOptions::set_csharp_namespace(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000010u; - csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace) } inline std::string* FileOptions::mutable_csharp_namespace() { @@ -10038,11 +10065,11 @@ inline const std::string& FileOptions::_internal_csharp_namespace() const { } inline void FileOptions::_internal_set_csharp_namespace(const std::string& value) { _has_bits_[0] |= 0x00000010u; - csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_csharp_namespace() { _has_bits_[0] |= 0x00000010u; - return csharp_namespace_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return csharp_namespace_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FileOptions::release_csharp_namespace() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.csharp_namespace) @@ -10050,7 +10077,7 @@ inline std::string* FileOptions::release_csharp_namespace() { return nullptr; } _has_bits_[0] &= ~0x00000010u; - return csharp_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return csharp_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FileOptions::set_allocated_csharp_namespace(std::string* csharp_namespace) { if (csharp_namespace != nullptr) { @@ -10059,7 +10086,7 @@ inline void FileOptions::set_allocated_csharp_namespace(std::string* csharp_name _has_bits_[0] &= ~0x00000010u; } csharp_namespace_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), csharp_namespace, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } @@ -10080,10 +10107,10 @@ inline const std::string& FileOptions::swift_prefix() const { return _internal_swift_prefix(); } template -PROTOBUF_ALWAYS_INLINE -inline void FileOptions::set_swift_prefix(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FileOptions::set_swift_prefix(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000020u; - swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix) } inline std::string* FileOptions::mutable_swift_prefix() { @@ -10095,11 +10122,11 @@ inline const std::string& FileOptions::_internal_swift_prefix() const { } inline void FileOptions::_internal_set_swift_prefix(const std::string& value) { _has_bits_[0] |= 0x00000020u; - swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_swift_prefix() { _has_bits_[0] |= 0x00000020u; - return swift_prefix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return swift_prefix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FileOptions::release_swift_prefix() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.swift_prefix) @@ -10107,7 +10134,7 @@ inline std::string* FileOptions::release_swift_prefix() { return nullptr; } _has_bits_[0] &= ~0x00000020u; - return swift_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return swift_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FileOptions::set_allocated_swift_prefix(std::string* swift_prefix) { if (swift_prefix != nullptr) { @@ -10116,7 +10143,7 @@ inline void FileOptions::set_allocated_swift_prefix(std::string* swift_prefix) { _has_bits_[0] &= ~0x00000020u; } swift_prefix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), swift_prefix, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix) } @@ -10137,10 +10164,10 @@ inline const std::string& FileOptions::php_class_prefix() const { return _internal_php_class_prefix(); } template -PROTOBUF_ALWAYS_INLINE -inline void FileOptions::set_php_class_prefix(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FileOptions::set_php_class_prefix(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000040u; - php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_class_prefix) } inline std::string* FileOptions::mutable_php_class_prefix() { @@ -10152,11 +10179,11 @@ inline const std::string& FileOptions::_internal_php_class_prefix() const { } inline void FileOptions::_internal_set_php_class_prefix(const std::string& value) { _has_bits_[0] |= 0x00000040u; - php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_php_class_prefix() { _has_bits_[0] |= 0x00000040u; - return php_class_prefix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return php_class_prefix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FileOptions::release_php_class_prefix() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_class_prefix) @@ -10164,7 +10191,7 @@ inline std::string* FileOptions::release_php_class_prefix() { return nullptr; } _has_bits_[0] &= ~0x00000040u; - return php_class_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return php_class_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FileOptions::set_allocated_php_class_prefix(std::string* php_class_prefix) { if (php_class_prefix != nullptr) { @@ -10173,7 +10200,7 @@ inline void FileOptions::set_allocated_php_class_prefix(std::string* php_class_p _has_bits_[0] &= ~0x00000040u; } php_class_prefix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), php_class_prefix, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_class_prefix) } @@ -10194,10 +10221,10 @@ inline const std::string& FileOptions::php_namespace() const { return _internal_php_namespace(); } template -PROTOBUF_ALWAYS_INLINE -inline void FileOptions::set_php_namespace(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FileOptions::set_php_namespace(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000080u; - php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_namespace) } inline std::string* FileOptions::mutable_php_namespace() { @@ -10209,11 +10236,11 @@ inline const std::string& FileOptions::_internal_php_namespace() const { } inline void FileOptions::_internal_set_php_namespace(const std::string& value) { _has_bits_[0] |= 0x00000080u; - php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_php_namespace() { _has_bits_[0] |= 0x00000080u; - return php_namespace_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return php_namespace_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FileOptions::release_php_namespace() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_namespace) @@ -10221,7 +10248,7 @@ inline std::string* FileOptions::release_php_namespace() { return nullptr; } _has_bits_[0] &= ~0x00000080u; - return php_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return php_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FileOptions::set_allocated_php_namespace(std::string* php_namespace) { if (php_namespace != nullptr) { @@ -10230,7 +10257,7 @@ inline void FileOptions::set_allocated_php_namespace(std::string* php_namespace) _has_bits_[0] &= ~0x00000080u; } php_namespace_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), php_namespace, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_namespace) } @@ -10251,10 +10278,10 @@ inline const std::string& FileOptions::php_metadata_namespace() const { return _internal_php_metadata_namespace(); } template -PROTOBUF_ALWAYS_INLINE -inline void FileOptions::set_php_metadata_namespace(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FileOptions::set_php_metadata_namespace(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000100u; - php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_metadata_namespace) } inline std::string* FileOptions::mutable_php_metadata_namespace() { @@ -10266,11 +10293,11 @@ inline const std::string& FileOptions::_internal_php_metadata_namespace() const } inline void FileOptions::_internal_set_php_metadata_namespace(const std::string& value) { _has_bits_[0] |= 0x00000100u; - php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_php_metadata_namespace() { _has_bits_[0] |= 0x00000100u; - return php_metadata_namespace_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return php_metadata_namespace_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FileOptions::release_php_metadata_namespace() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_metadata_namespace) @@ -10278,7 +10305,7 @@ inline std::string* FileOptions::release_php_metadata_namespace() { return nullptr; } _has_bits_[0] &= ~0x00000100u; - return php_metadata_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return php_metadata_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FileOptions::set_allocated_php_metadata_namespace(std::string* php_metadata_namespace) { if (php_metadata_namespace != nullptr) { @@ -10287,7 +10314,7 @@ inline void FileOptions::set_allocated_php_metadata_namespace(std::string* php_m _has_bits_[0] &= ~0x00000100u; } php_metadata_namespace_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), php_metadata_namespace, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_metadata_namespace) } @@ -10308,10 +10335,10 @@ inline const std::string& FileOptions::ruby_package() const { return _internal_ruby_package(); } template -PROTOBUF_ALWAYS_INLINE -inline void FileOptions::set_ruby_package(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void FileOptions::set_ruby_package(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000200u; - ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.ruby_package) } inline std::string* FileOptions::mutable_ruby_package() { @@ -10323,11 +10350,11 @@ inline const std::string& FileOptions::_internal_ruby_package() const { } inline void FileOptions::_internal_set_ruby_package(const std::string& value) { _has_bits_[0] |= 0x00000200u; - ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_ruby_package() { _has_bits_[0] |= 0x00000200u; - return ruby_package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return ruby_package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* FileOptions::release_ruby_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.ruby_package) @@ -10335,7 +10362,7 @@ inline std::string* FileOptions::release_ruby_package() { return nullptr; } _has_bits_[0] &= ~0x00000200u; - return ruby_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return ruby_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void FileOptions::set_allocated_ruby_package(std::string* ruby_package) { if (ruby_package != nullptr) { @@ -10344,7 +10371,7 @@ inline void FileOptions::set_allocated_ruby_package(std::string* ruby_package) { _has_bits_[0] &= ~0x00000200u; } ruby_package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ruby_package, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.ruby_package) } @@ -11160,10 +11187,10 @@ inline const std::string& UninterpretedOption_NamePart::name_part() const { return _internal_name_part(); } template -PROTOBUF_ALWAYS_INLINE -inline void UninterpretedOption_NamePart::set_name_part(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void UninterpretedOption_NamePart::set_name_part(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part) } inline std::string* UninterpretedOption_NamePart::mutable_name_part() { @@ -11175,11 +11202,11 @@ inline const std::string& UninterpretedOption_NamePart::_internal_name_part() co } inline void UninterpretedOption_NamePart::_internal_set_name_part(const std::string& value) { _has_bits_[0] |= 0x00000001u; - name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* UninterpretedOption_NamePart::_internal_mutable_name_part() { _has_bits_[0] |= 0x00000001u; - return name_part_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return name_part_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* UninterpretedOption_NamePart::release_name_part() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.NamePart.name_part) @@ -11187,7 +11214,7 @@ inline std::string* UninterpretedOption_NamePart::release_name_part() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_part_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return name_part_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void UninterpretedOption_NamePart::set_allocated_name_part(std::string* name_part) { if (name_part != nullptr) { @@ -11196,7 +11223,7 @@ inline void UninterpretedOption_NamePart::set_allocated_name_part(std::string* n _has_bits_[0] &= ~0x00000001u; } name_part_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name_part, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part) } @@ -11288,10 +11315,10 @@ inline const std::string& UninterpretedOption::identifier_value() const { return _internal_identifier_value(); } template -PROTOBUF_ALWAYS_INLINE -inline void UninterpretedOption::set_identifier_value(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void UninterpretedOption::set_identifier_value(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value) } inline std::string* UninterpretedOption::mutable_identifier_value() { @@ -11303,11 +11330,11 @@ inline const std::string& UninterpretedOption::_internal_identifier_value() cons } inline void UninterpretedOption::_internal_set_identifier_value(const std::string& value) { _has_bits_[0] |= 0x00000001u; - identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* UninterpretedOption::_internal_mutable_identifier_value() { _has_bits_[0] |= 0x00000001u; - return identifier_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return identifier_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* UninterpretedOption::release_identifier_value() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.identifier_value) @@ -11315,7 +11342,7 @@ inline std::string* UninterpretedOption::release_identifier_value() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return identifier_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return identifier_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void UninterpretedOption::set_allocated_identifier_value(std::string* identifier_value) { if (identifier_value != nullptr) { @@ -11324,7 +11351,7 @@ inline void UninterpretedOption::set_allocated_identifier_value(std::string* ide _has_bits_[0] &= ~0x00000001u; } identifier_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), identifier_value, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.identifier_value) } @@ -11337,7 +11364,7 @@ inline bool UninterpretedOption::has_positive_int_value() const { return _internal_has_positive_int_value(); } inline void UninterpretedOption::clear_positive_int_value() { - positive_int_value_ = PROTOBUF_ULONGLONG(0); + positive_int_value_ = uint64_t{0u}; _has_bits_[0] &= ~0x00000008u; } inline ::PROTOBUF_NAMESPACE_ID::uint64 UninterpretedOption::_internal_positive_int_value() const { @@ -11365,7 +11392,7 @@ inline bool UninterpretedOption::has_negative_int_value() const { return _internal_has_negative_int_value(); } inline void UninterpretedOption::clear_negative_int_value() { - negative_int_value_ = PROTOBUF_LONGLONG(0); + negative_int_value_ = int64_t{0}; _has_bits_[0] &= ~0x00000010u; } inline ::PROTOBUF_NAMESPACE_ID::int64 UninterpretedOption::_internal_negative_int_value() const { @@ -11429,10 +11456,10 @@ inline const std::string& UninterpretedOption::string_value() const { return _internal_string_value(); } template -PROTOBUF_ALWAYS_INLINE -inline void UninterpretedOption::set_string_value(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void UninterpretedOption::set_string_value(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000002u; - string_value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + string_value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value) } inline std::string* UninterpretedOption::mutable_string_value() { @@ -11444,11 +11471,11 @@ inline const std::string& UninterpretedOption::_internal_string_value() const { } inline void UninterpretedOption::_internal_set_string_value(const std::string& value) { _has_bits_[0] |= 0x00000002u; - string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* UninterpretedOption::_internal_mutable_string_value() { _has_bits_[0] |= 0x00000002u; - return string_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return string_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* UninterpretedOption::release_string_value() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.string_value) @@ -11456,7 +11483,7 @@ inline std::string* UninterpretedOption::release_string_value() { return nullptr; } _has_bits_[0] &= ~0x00000002u; - return string_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return string_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void UninterpretedOption::set_allocated_string_value(std::string* string_value) { if (string_value != nullptr) { @@ -11465,7 +11492,7 @@ inline void UninterpretedOption::set_allocated_string_value(std::string* string_ _has_bits_[0] &= ~0x00000002u; } string_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), string_value, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.string_value) } @@ -11486,10 +11513,10 @@ inline const std::string& UninterpretedOption::aggregate_value() const { return _internal_aggregate_value(); } template -PROTOBUF_ALWAYS_INLINE -inline void UninterpretedOption::set_aggregate_value(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void UninterpretedOption::set_aggregate_value(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000004u; - aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value) } inline std::string* UninterpretedOption::mutable_aggregate_value() { @@ -11501,11 +11528,11 @@ inline const std::string& UninterpretedOption::_internal_aggregate_value() const } inline void UninterpretedOption::_internal_set_aggregate_value(const std::string& value) { _has_bits_[0] |= 0x00000004u; - aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* UninterpretedOption::_internal_mutable_aggregate_value() { _has_bits_[0] |= 0x00000004u; - return aggregate_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return aggregate_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* UninterpretedOption::release_aggregate_value() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.aggregate_value) @@ -11513,7 +11540,7 @@ inline std::string* UninterpretedOption::release_aggregate_value() { return nullptr; } _has_bits_[0] &= ~0x00000004u; - return aggregate_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return aggregate_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void UninterpretedOption::set_allocated_aggregate_value(std::string* aggregate_value) { if (aggregate_value != nullptr) { @@ -11522,7 +11549,7 @@ inline void UninterpretedOption::set_allocated_aggregate_value(std::string* aggr _has_bits_[0] &= ~0x00000004u; } aggregate_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), aggregate_value, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value) } @@ -11641,10 +11668,10 @@ inline const std::string& SourceCodeInfo_Location::leading_comments() const { return _internal_leading_comments(); } template -PROTOBUF_ALWAYS_INLINE -inline void SourceCodeInfo_Location::set_leading_comments(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void SourceCodeInfo_Location::set_leading_comments(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments) } inline std::string* SourceCodeInfo_Location::mutable_leading_comments() { @@ -11656,11 +11683,11 @@ inline const std::string& SourceCodeInfo_Location::_internal_leading_comments() } inline void SourceCodeInfo_Location::_internal_set_leading_comments(const std::string& value) { _has_bits_[0] |= 0x00000001u; - leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* SourceCodeInfo_Location::_internal_mutable_leading_comments() { _has_bits_[0] |= 0x00000001u; - return leading_comments_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return leading_comments_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* SourceCodeInfo_Location::release_leading_comments() { // @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.leading_comments) @@ -11668,7 +11695,7 @@ inline std::string* SourceCodeInfo_Location::release_leading_comments() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return leading_comments_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return leading_comments_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void SourceCodeInfo_Location::set_allocated_leading_comments(std::string* leading_comments) { if (leading_comments != nullptr) { @@ -11677,7 +11704,7 @@ inline void SourceCodeInfo_Location::set_allocated_leading_comments(std::string* _has_bits_[0] &= ~0x00000001u; } leading_comments_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), leading_comments, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.leading_comments) } @@ -11698,10 +11725,10 @@ inline const std::string& SourceCodeInfo_Location::trailing_comments() const { return _internal_trailing_comments(); } template -PROTOBUF_ALWAYS_INLINE -inline void SourceCodeInfo_Location::set_trailing_comments(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void SourceCodeInfo_Location::set_trailing_comments(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000002u; - trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments) } inline std::string* SourceCodeInfo_Location::mutable_trailing_comments() { @@ -11713,11 +11740,11 @@ inline const std::string& SourceCodeInfo_Location::_internal_trailing_comments() } inline void SourceCodeInfo_Location::_internal_set_trailing_comments(const std::string& value) { _has_bits_[0] |= 0x00000002u; - trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* SourceCodeInfo_Location::_internal_mutable_trailing_comments() { _has_bits_[0] |= 0x00000002u; - return trailing_comments_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return trailing_comments_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* SourceCodeInfo_Location::release_trailing_comments() { // @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.trailing_comments) @@ -11725,7 +11752,7 @@ inline std::string* SourceCodeInfo_Location::release_trailing_comments() { return nullptr; } _has_bits_[0] &= ~0x00000002u; - return trailing_comments_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return trailing_comments_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void SourceCodeInfo_Location::set_allocated_trailing_comments(std::string* trailing_comments) { if (trailing_comments != nullptr) { @@ -11734,7 +11761,7 @@ inline void SourceCodeInfo_Location::set_allocated_trailing_comments(std::string _has_bits_[0] &= ~0x00000002u; } trailing_comments_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), trailing_comments, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.trailing_comments) } @@ -11923,10 +11950,10 @@ inline const std::string& GeneratedCodeInfo_Annotation::source_file() const { return _internal_source_file(); } template -PROTOBUF_ALWAYS_INLINE -inline void GeneratedCodeInfo_Annotation::set_source_file(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void GeneratedCodeInfo_Annotation::set_source_file(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; - source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } inline std::string* GeneratedCodeInfo_Annotation::mutable_source_file() { @@ -11938,11 +11965,11 @@ inline const std::string& GeneratedCodeInfo_Annotation::_internal_source_file() } inline void GeneratedCodeInfo_Annotation::_internal_set_source_file(const std::string& value) { _has_bits_[0] |= 0x00000001u; - source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* GeneratedCodeInfo_Annotation::_internal_mutable_source_file() { _has_bits_[0] |= 0x00000001u; - return source_file_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return source_file_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* GeneratedCodeInfo_Annotation::release_source_file() { // @@protoc_insertion_point(field_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file) @@ -11950,7 +11977,7 @@ inline std::string* GeneratedCodeInfo_Annotation::release_source_file() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return source_file_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return source_file_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void GeneratedCodeInfo_Annotation::set_allocated_source_file(std::string* source_file) { if (source_file != nullptr) { @@ -11959,7 +11986,7 @@ inline void GeneratedCodeInfo_Annotation::set_allocated_source_file(std::string* _has_bits_[0] &= ~0x00000001u; } source_file_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), source_file, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc index b454ed5ad..ce0979181 100644 --- a/src/google/protobuf/descriptor_unittest.cc +++ b/src/google/protobuf/descriptor_unittest.cc @@ -2071,6 +2071,84 @@ TEST_F(ExtensionDescriptorTest, DuplicateFieldNumber) { // =================================================================== +// Ensure that overlapping extension ranges are not allowed. +TEST(OverlappingExtensionRangeTest, ExtensionRangeInternal) { + // Build descriptors for the following definitions: + // + // message Foo { + // extensions 10 to 19; + // extensions 15; + // } + FileDescriptorProto foo_file; + foo_file.set_name("foo.proto"); + + DescriptorProto* foo = AddMessage(&foo_file, "Foo"); + AddExtensionRange(foo, 10, 20); + AddExtensionRange(foo, 15, 16); + + DescriptorPool pool; + MockErrorCollector error_collector; + // The extensions ranges are invalid, so the proto shouldn't build. + ASSERT_TRUE(pool.BuildFileCollectingErrors(foo_file, &error_collector) == + nullptr); + ASSERT_EQ( + "foo.proto: Foo: NUMBER: Extension range 15 to 15 overlaps with " + "already-defined range 10 to 19.\n", + error_collector.text_); +} + +TEST(OverlappingExtensionRangeTest, ExtensionRangeAfter) { + // Build descriptors for the following definitions: + // + // message Foo { + // extensions 10 to 19; + // extensions 15 to 24; + // } + FileDescriptorProto foo_file; + foo_file.set_name("foo.proto"); + + DescriptorProto* foo = AddMessage(&foo_file, "Foo"); + AddExtensionRange(foo, 10, 20); + AddExtensionRange(foo, 15, 25); + + DescriptorPool pool; + MockErrorCollector error_collector; + // The extensions ranges are invalid, so the proto shouldn't build. + ASSERT_TRUE(pool.BuildFileCollectingErrors(foo_file, &error_collector) == + nullptr); + ASSERT_EQ( + "foo.proto: Foo: NUMBER: Extension range 15 to 24 overlaps with " + "already-defined range 10 to 19.\n", + error_collector.text_); +} + +TEST(OverlappingExtensionRangeTest, ExtensionRangeBefore) { + // Build descriptors for the following definitions: + // + // message Foo { + // extensions 10 to 19; + // extensions 5 to 14; + // } + FileDescriptorProto foo_file; + foo_file.set_name("foo.proto"); + + DescriptorProto* foo = AddMessage(&foo_file, "Foo"); + AddExtensionRange(foo, 10, 20); + AddExtensionRange(foo, 5, 15); + + DescriptorPool pool; + MockErrorCollector error_collector; + // The extensions ranges are invalid, so the proto shouldn't build. + ASSERT_TRUE(pool.BuildFileCollectingErrors(foo_file, &error_collector) == + nullptr); + ASSERT_EQ( + "foo.proto: Foo: NUMBER: Extension range 5 to 14 overlaps with " + "already-defined range 10 to 19.\n", + error_collector.text_); +} + +// =================================================================== + // Test reserved fields. class ReservedDescriptorTest : public testing::Test { protected: diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index 53307632b..164d2956b 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -19,7 +19,7 @@ PROTOBUF_PRAGMA_INIT_SEG PROTOBUF_NAMESPACE_OPEN constexpr Duration::Duration( ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : seconds_(PROTOBUF_LONGLONG(0)) + : seconds_(int64_t{0}) , nanos_(0){} struct DurationDefaultTypeInternal { constexpr DurationDefaultTypeInternal() @@ -110,7 +110,7 @@ Duration::~Duration() { } void Duration::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void Duration::ArenaDtor(void* object) { diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index cd5f43ae0..fd6879588 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -65,7 +65,7 @@ PROTOBUF_NAMESPACE_OPEN // =================================================================== -class PROTOBUF_EXPORT Duration PROTOBUF_FINAL : +class PROTOBUF_EXPORT Duration final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Duration) */ { public: inline Duration() : Duration(nullptr) {} @@ -83,8 +83,9 @@ class PROTOBUF_EXPORT Duration PROTOBUF_FINAL : return *this; } inline Duration& operator=(Duration&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -115,7 +116,7 @@ class PROTOBUF_EXPORT Duration PROTOBUF_FINAL : } inline void Swap(Duration* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -123,14 +124,14 @@ class PROTOBUF_EXPORT Duration PROTOBUF_FINAL : } void UnsafeArenaSwap(Duration* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline Duration* New() const final { - return CreateMaybeMessage(nullptr); + return new Duration(); } Duration* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -218,7 +219,7 @@ class PROTOBUF_EXPORT Duration PROTOBUF_FINAL : // int64 seconds = 1; inline void Duration::clear_seconds() { - seconds_ = PROTOBUF_LONGLONG(0); + seconds_ = int64_t{0}; } inline ::PROTOBUF_NAMESPACE_ID::int64 Duration::_internal_seconds() const { return seconds_; diff --git a/src/google/protobuf/dynamic_message.cc b/src/google/protobuf/dynamic_message.cc index ef7e1f2e7..0bfb94a3a 100644 --- a/src/google/protobuf/dynamic_message.cc +++ b/src/google/protobuf/dynamic_message.cc @@ -355,7 +355,7 @@ void DynamicMessage::SharedCtor(bool lock_factory) { if (type_info_->extensions_offset != -1) { new (OffsetToPointer(type_info_->extensions_offset)) - ExtensionSet(GetArena()); + ExtensionSet(GetArenaForAllocation()); } for (int i = 0; i < descriptor->field_count(); i++) { const FieldDescriptor* field = descriptor->field(i); @@ -364,13 +364,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(GetArena()); \ - } \ +#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(GetArenaForAllocation()); \ + } \ break; HANDLE_TYPE(INT32, int32); @@ -386,7 +386,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(GetArena()); + new (field_ptr) RepeatedField(GetArenaForAllocation()); } break; @@ -402,7 +402,8 @@ void DynamicMessage::SharedCtor(bool lock_factory) { ArenaStringPtr* asp = new (field_ptr) ArenaStringPtr(); asp->UnsafeSetDefault(default_value); } else { - new (field_ptr) RepeatedPtrField(GetArena()); + new (field_ptr) + RepeatedPtrField(GetArenaForAllocation()); } break; } @@ -417,20 +418,30 @@ 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 (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { new (field_ptr) DynamicMapField( type_info_->factory->GetPrototype(field->message_type()), - GetArena()); + GetArenaForAllocation()); + if (GetOwningArena() != nullptr) { + // Needs to destroy the mutex member. + GetOwningArena()->OwnDestructor( + static_cast(field_ptr)); + } } else { new (field_ptr) DynamicMapField( type_info_->factory->GetPrototype(field->message_type())); } } else { - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { new (field_ptr) DynamicMapField(type_info_->factory->GetPrototypeNoLock( field->message_type()), - GetArena()); + GetArenaForAllocation()); + if (GetOwningArena() != nullptr) { + // Needs to destroy the mutex member. + GetOwningArena()->OwnDestructor( + static_cast(field_ptr)); + } } else { new (field_ptr) DynamicMapField(type_info_->factory->GetPrototypeNoLock( @@ -438,7 +449,7 @@ void DynamicMessage::SharedCtor(bool lock_factory) { } } } else { - new (field_ptr) RepeatedPtrField(GetArena()); + new (field_ptr) RepeatedPtrField(GetArenaForAllocation()); } } break; diff --git a/src/google/protobuf/dynamic_message_unittest.cc b/src/google/protobuf/dynamic_message_unittest.cc index 37f9574b0..dcd5b8839 100644 --- a/src/google/protobuf/dynamic_message_unittest.cc +++ b/src/google/protobuf/dynamic_message_unittest.cc @@ -286,6 +286,7 @@ TEST_F(DynamicMessageTest, Arena) { // Return without freeing: should not leak. } + TEST_F(DynamicMessageTest, Proto3) { Message* message = proto3_prototype_->New(); const Reflection* refl = message->GetReflection(); diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index 2adc793c1..15761e979 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -98,7 +98,7 @@ Empty::~Empty() { } void Empty::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void Empty::ArenaDtor(void* object) { diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 0f1479e26..dbb5c68b1 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -65,7 +65,7 @@ PROTOBUF_NAMESPACE_OPEN // =================================================================== -class PROTOBUF_EXPORT Empty PROTOBUF_FINAL : +class PROTOBUF_EXPORT Empty final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Empty) */ { public: inline Empty() : Empty(nullptr) {} @@ -83,8 +83,9 @@ class PROTOBUF_EXPORT Empty PROTOBUF_FINAL : return *this; } inline Empty& operator=(Empty&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -115,7 +116,7 @@ class PROTOBUF_EXPORT Empty PROTOBUF_FINAL : } inline void Swap(Empty* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -123,14 +124,14 @@ class PROTOBUF_EXPORT Empty PROTOBUF_FINAL : } void UnsafeArenaSwap(Empty* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline Empty* New() const final { - return CreateMaybeMessage(nullptr); + return new Empty(); } Empty* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc index aa57e67ec..5814dc98a 100644 --- a/src/google/protobuf/extension_set.cc +++ b/src/google/protobuf/extension_set.cc @@ -616,7 +616,7 @@ void ExtensionSet::SetAllocatedMessage(int number, FieldType type, ClearExtension(number); return; } - Arena* message_arena = message->GetArena(); + Arena* message_arena = message->GetOwningArena(); Extension* extension; if (MaybeNewExtension(number, descriptor, &extension)) { extension->type = type; @@ -1071,6 +1071,7 @@ void ExtensionSet::Swap(ExtensionSet* x) { void ExtensionSet::InternalSwap(ExtensionSet* other) { using std::swap; + swap(arena_, other->arena_); swap(flat_capacity_, other->flat_capacity_); swap(flat_size_, other->flat_size_); swap(map_, other->map_); diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h index 55492a6d3..acfe47d8d 100644 --- a/src/google/protobuf/extension_set.h +++ b/src/google/protobuf/extension_set.h @@ -282,12 +282,13 @@ class PROTOBUF_EXPORT ExtensionSet { void UnsafeArenaSetAllocatedMessage(int number, FieldType type, const FieldDescriptor* descriptor, MessageLite* message); - MessageLite* ReleaseMessage(int number, const MessageLite& prototype); + PROTOBUF_FUTURE_MUST_USE_RESULT MessageLite* ReleaseMessage( + int number, const MessageLite& prototype); MessageLite* UnsafeArenaReleaseMessage(int number, const MessageLite& prototype); - MessageLite* ReleaseMessage(const FieldDescriptor* descriptor, - MessageFactory* factory); + PROTOBUF_FUTURE_MUST_USE_RESULT MessageLite* ReleaseMessage( + const FieldDescriptor* descriptor, MessageFactory* factory); MessageLite* UnsafeArenaReleaseMessage(const FieldDescriptor* descriptor, MessageFactory* factory); #undef desc @@ -354,7 +355,7 @@ class PROTOBUF_EXPORT ExtensionSet { #undef desc void RemoveLast(int number); - MessageLite* ReleaseLast(int number); + PROTOBUF_FUTURE_MUST_USE_RESULT MessageLite* ReleaseLast(int number); void SwapElements(int number, int index1, int index2); // ----------------------------------------------------------------- @@ -534,7 +535,8 @@ class PROTOBUF_EXPORT ExtensionSet { virtual MessageLite* MutableMessage(const MessageLite& prototype) = 0; virtual void SetAllocatedMessage(MessageLite* message) = 0; virtual void UnsafeArenaSetAllocatedMessage(MessageLite* message) = 0; - virtual MessageLite* ReleaseMessage(const MessageLite& prototype) = 0; + virtual PROTOBUF_FUTURE_MUST_USE_RESULT MessageLite* ReleaseMessage( + const MessageLite& prototype) = 0; virtual MessageLite* UnsafeArenaReleaseMessage( const MessageLite& prototype) = 0; @@ -1260,8 +1262,8 @@ class MessageTypeTraits { ExtensionSet* set) { set->UnsafeArenaSetAllocatedMessage(number, field_type, NULL, message); } - static inline MutableType Release(int number, FieldType /* field_type */, - ExtensionSet* set) { + static inline PROTOBUF_FUTURE_MUST_USE_RESULT MutableType + Release(int number, FieldType /* field_type */, ExtensionSet* set) { return static_cast( set->ReleaseMessage(number, Type::default_instance())); } @@ -1476,9 +1478,11 @@ class ExtensionIdentifier { template \ - inline typename _proto_TypeTraits::Singular::MutableType ReleaseExtension( \ - const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \ - CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \ + inline PROTOBUF_FUTURE_MUST_USE_RESULT \ + typename _proto_TypeTraits::Singular::MutableType \ + ReleaseExtension( \ + const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \ + CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \ return _proto_TypeTraits::Release(id.number(), _field_type, \ &_extensions_); \ } \ diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index f83f62d18..1174f1edc 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -103,7 +103,7 @@ FieldMask::~FieldMask() { } void FieldMask::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void FieldMask::ArenaDtor(void* object) { diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index bdf2d1f12..873c3c30d 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -65,7 +65,7 @@ PROTOBUF_NAMESPACE_OPEN // =================================================================== -class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL : +class PROTOBUF_EXPORT FieldMask final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldMask) */ { public: inline FieldMask() : FieldMask(nullptr) {} @@ -83,8 +83,9 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL : return *this; } inline FieldMask& operator=(FieldMask&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -115,7 +116,7 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL : } inline void Swap(FieldMask* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -123,14 +124,14 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL : } void UnsafeArenaSwap(FieldMask* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline FieldMask* New() const final { - return CreateMaybeMessage(nullptr); + return new FieldMask(); } FieldMask* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index 3260e30a4..ea3c71d0f 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc @@ -235,6 +235,16 @@ UnknownFieldSet* Reflection::MutableUnknownFields(Message* message) const { ->mutable_unknown_fields(); } +bool Reflection::IsLazilyVerifiedLazyField(const FieldDescriptor* field) const { + return field->options().lazy(); +} + +bool Reflection::IsEagerlyVerifiedLazyField( + const FieldDescriptor* field) const { + return (field->type() == FieldDescriptor::TYPE_MESSAGE && + schema_.IsEagerlyVerifiedLazyField(field)); +} + size_t Reflection::SpaceUsedLong(const Message& message) const { // object_size_ already includes the in-memory representation of each field // in the message, so we only need to account for additional memory used by @@ -411,7 +421,8 @@ void Reflection::SwapField(Message* message1, Message* message2, SWAP_VALUES(ENUM, int); #undef SWAP_VALUES case FieldDescriptor::CPPTYPE_MESSAGE: - if (GetArena(message1) == GetArena(message2)) { + if (message1->GetArenaForAllocation() == + message2->GetArenaForAllocation()) { std::swap(*MutableRaw(message1, field), *MutableRaw(message2, field)); } else { @@ -423,13 +434,17 @@ void Reflection::SwapField(Message* message1, Message* message2, break; } if (*sub_msg1 == nullptr) { - *sub_msg1 = (*sub_msg2)->New(message1->GetArena()); + *sub_msg1 = (*sub_msg2)->New(message1->GetArenaForAllocation()); (*sub_msg1)->CopyFrom(**sub_msg2); ClearField(message2, field); + // Ensures has bit is unchanged after ClearField. + SetBit(message2, field); } else { - *sub_msg2 = (*sub_msg1)->New(message2->GetArena()); + *sub_msg2 = (*sub_msg1)->New(message2->GetArenaForAllocation()); (*sub_msg2)->CopyFrom(**sub_msg1); ClearField(message1, field); + // Ensures has bit is unchanged after ClearField. + SetBit(message1, field); } } break; @@ -438,25 +453,30 @@ void Reflection::SwapField(Message* message1, Message* message2, switch (field->options().ctype()) { default: // TODO(kenton): Support other string reps. case FieldOptions::STRING: { - Arena* arena1 = GetArena(message1); - Arena* arena2 = GetArena(message2); + const std::string* default_ptr = + DefaultRaw(field).GetPointer(); + Arena* arena1 = message1->GetArenaForAllocation(); + Arena* arena2 = message2->GetArenaForAllocation(); ArenaStringPtr* string1 = MutableRaw(message1, field); ArenaStringPtr* string2 = MutableRaw(message2, field); - const std::string* default_ptr = - DefaultRaw(field).GetPointer(); - if (arena1 == arena2) { - string1->Swap(string2, default_ptr, arena1); + if (message1->GetOwningArena() == message2->GetOwningArena()) { + ArenaStringPtr::InternalSwap(default_ptr, string1, arena1, + string2, arena2); } else if (string1->IsDefault(default_ptr) && string2->IsDefault(default_ptr)) { // Nothing to do. } else if (string1->IsDefault(default_ptr)) { string1->Set(default_ptr, string2->Get(), arena1); + // string2 needs to be destroyed before overwritten. + string2->Destroy(default_ptr, arena2); string2->UnsafeSetDefault(default_ptr); } else if (string2->IsDefault(default_ptr)) { string2->Set(default_ptr, string1->Get(), arena2); + // string1 needs to be destroyed before overwritten. + string1->Destroy(default_ptr, arena1); string1->UnsafeSetDefault(default_ptr); } else { std::string temp = string1->Get(); @@ -612,19 +632,38 @@ 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. - if (GetArena(message1) != GetArena(message2)) { - // Slow copy path. - // Use our arena as temp space, if available. - Message* temp = message1->New(GetArena(message1)); + if (message1->GetOwningArena() != message2->GetOwningArena()) { + // One of the two is guaranteed to have an arena. Switch things around + // to guarantee that message1 has an arena. + Arena* arena = message1->GetOwningArena(); + if (arena == nullptr) { + arena = message2->GetOwningArena(); + std::swap(message1, message2); // Swapping names for pointers! + } + + Message* temp = message1->New(arena); temp->MergeFrom(*message2); message2->CopyFrom(*message1); Swap(message1, temp); - if (GetArena(message1) == nullptr) { - delete temp; - } return; } + for (int i = 0; i <= last_non_weak_field_index_; i++) { + const FieldDescriptor* field = descriptor_->field(i); + if (schema_.InRealOneof(field)) continue; + if (schema_.IsFieldStripped(field)) continue; + SwapField(message1, message2, field); + } + const int oneof_decl_count = descriptor_->oneof_decl_count(); + for (int i = 0; i < oneof_decl_count; i++) { + const OneofDescriptor* oneof = descriptor_->oneof_decl(i); + if (!oneof->is_synthetic()) { + SwapOneofField(message1, message2, oneof); + } + } + + // Swapping bits need to happen after swapping fields, because the latter may + // depend on the has bit information. if (schema_.HasHasbits()) { uint32* has_bits1 = MutableHasBits(message1); uint32* has_bits2 = MutableHasBits(message2); @@ -645,20 +684,6 @@ void Reflection::Swap(Message* message1, Message* message2) const { } } - for (int i = 0; i <= last_non_weak_field_index_; i++) { - const FieldDescriptor* field = descriptor_->field(i); - if (schema_.InRealOneof(field)) continue; - if (schema_.IsFieldStripped(field)) continue; - SwapField(message1, message2, field); - } - const int oneof_decl_count = descriptor_->oneof_decl_count(); - for (int i = 0; i < oneof_decl_count; i++) { - const OneofDescriptor* oneof = descriptor_->oneof_decl(i); - if (!oneof->is_synthetic()) { - SwapOneofField(message1, message2, oneof); - } - } - if (schema_.HasExtensionSet()) { MutableExtensionSet(message1)->Swap(MutableExtensionSet(message2)); } @@ -708,13 +733,14 @@ void Reflection::SwapFields( swapped_oneof.insert(oneof_index); SwapOneofField(message1, message2, field->containing_oneof()); } else { + // Swap field. + SwapField(message1, message2, field); // Swap has bit for non-repeated fields. We have already checked for - // oneof already. + // oneof already. This has to be done after SwapField, because SwapField + // may depend on the information in has bits. if (!field->is_repeated()) { SwapBit(message1, message2, field); } - // Swap field. - SwapField(message1, message2, field); } } } @@ -828,7 +854,8 @@ void Reflection::ClearField(Message* message, const std::string* default_ptr = DefaultRaw(field).GetPointer(); MutableRaw(message, field) - ->SetAllocated(default_ptr, nullptr, GetArena(message)); + ->SetAllocated(default_ptr, nullptr, + message->GetArenaForAllocation()); break; } } @@ -839,7 +866,7 @@ void Reflection::ClearField(Message* message, if (schema_.HasBitIndex(field) == static_cast(-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 (GetArena(message) == nullptr) { + if (message->GetArenaForAllocation() == nullptr) { delete *MutableRaw(message, field); } *MutableRaw(message, field) = nullptr; @@ -1242,7 +1269,8 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field, ->UnsafeSetDefault(default_ptr); } MutableField(message, field) - ->Set(default_ptr, std::move(value), GetArena(message)); + ->Set(default_ptr, std::move(value), + message->GetArenaForAllocation()); break; } } @@ -1494,7 +1522,7 @@ const Message* Reflection::GetDefaultMessageInstance( // This is an optimization to avoid going to GetPrototype() below, as that // requires a lock and a map lookup. if (!field->is_extension() && !field->options().weak() && - !field->options().lazy() && !schema_.InRealOneof(field)) { + !IsLazyField(field) && !schema_.InRealOneof(field)) { auto* res = DefaultRaw(field); if (res != nullptr) { return res; @@ -1548,7 +1576,7 @@ Message* Reflection::MutableMessage(Message* message, ClearOneof(message, field->containing_oneof()); result_holder = MutableField(message, field); const Message* default_message = GetDefaultMessageInstance(field); - *result_holder = default_message->New(message->GetArena()); + *result_holder = default_message->New(message->GetArenaForAllocation()); } } else { SetBit(message, field); @@ -1556,7 +1584,7 @@ Message* Reflection::MutableMessage(Message* message, if (*result_holder == nullptr) { const Message* default_message = GetDefaultMessageInstance(field); - *result_holder = default_message->New(message->GetArena()); + *result_holder = default_message->New(message->GetArenaForAllocation()); } result = *result_holder; return result; @@ -1590,7 +1618,7 @@ void Reflection::UnsafeArenaSetAllocatedMessage( SetBit(message, field); } Message** sub_message_holder = MutableRaw(message, field); - if (GetArena(message) == nullptr) { + if (message->GetArenaForAllocation() == nullptr) { delete *sub_message_holder; } *sub_message_holder = sub_message; @@ -1605,12 +1633,13 @@ void Reflection::SetAllocatedMessage(Message* message, Message* sub_message, // (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->GetArenaForAllocation()) { + if (sub_message->GetOwningArena() == nullptr && + message->GetArenaForAllocation() != 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->GetArena()->Own(sub_message); + message->GetArenaForAllocation()->Own(sub_message); UnsafeArenaSetAllocatedMessage(message, sub_message, field); } else { // Case 2: all other cases. We need to make a copy. MutableMessage() will @@ -1661,7 +1690,7 @@ Message* Reflection::ReleaseMessage(Message* message, CheckInvalidAccess(schema_, field); Message* released = UnsafeArenaReleaseMessage(message, field, factory); - if (GetArena(message) != nullptr && released != nullptr) { + if (message->GetArenaForAllocation() != nullptr && released != nullptr) { Message* copy_from_arena = released->New(); copy_from_arena->CopyFrom(*released); released = copy_from_arena; @@ -1743,7 +1772,7 @@ Message* Reflection::AddMessage(Message* message, const FieldDescriptor* field, } else { prototype = &repeated->Get >(0); } - result = prototype->New(message->GetArena()); + result = prototype->New(message->GetArenaForAllocation()); // 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. @@ -1988,10 +2017,6 @@ ExtensionSet* Reflection::MutableExtensionSet(Message* message) const { schema_.GetExtensionSetOffset()); } -Arena* Reflection::GetArena(Message* message) const { - return GetInternalMetadata(*message).arena(); -} - const InternalMetadata& Reflection::GetInternalMetadata( const Message& message) const { return GetConstRefAtOffset(message, @@ -2137,7 +2162,7 @@ void Reflection::ClearOneof(Message* message, uint32 oneof_case = GetOneofCase(*message, oneof_descriptor); if (oneof_case > 0) { const FieldDescriptor* field = descriptor_->FindFieldByNumber(oneof_case); - if (GetArena(message) == nullptr) { + if (message->GetArenaForAllocation() == nullptr) { switch (field->cpp_type()) { case FieldDescriptor::CPPTYPE_STRING: { switch (field->options().ctype()) { @@ -2148,7 +2173,7 @@ void Reflection::ClearOneof(Message* message, // work. This allows us to not have the real default accessible // from reflection. MutableField(message, field) - ->Destroy(nullptr, GetArena(message)); + ->Destroy(nullptr, message->GetArenaForAllocation()); break; } } diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h index b34f7227b..1771b474c 100644 --- a/src/google/protobuf/generated_message_reflection.h +++ b/src/google/protobuf/generated_message_reflection.h @@ -198,6 +198,13 @@ struct ReflectionSchema { OffsetValue(offsets_[field->index()], field->type()); } + // Returns true if the field is implicitly backed by LazyField. + bool IsEagerlyVerifiedLazyField(const FieldDescriptor* field) const { + GOOGLE_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_MESSAGE); + (void)field; + return false; + } + // Returns true if the field's accessor is called by any external code (aka, // non proto library code). bool IsFieldUsed(const FieldDescriptor* field) const { @@ -235,8 +242,11 @@ struct ReflectionSchema { int weak_field_map_offset_; // We tag offset values to provide additional data about fields (such as - // "unused"). - static uint32 OffsetValue(uint32 v, FieldDescriptor::Type /* type */) { + // "unused" or "lazy"). + static uint32 OffsetValue(uint32 v, FieldDescriptor::Type type) { + if (type == FieldDescriptor::TYPE_MESSAGE) { + return v & 0x7FFFFFFEu; + } return v & 0x7FFFFFFFu; } }; diff --git a/src/google/protobuf/generated_message_reflection_unittest.cc b/src/google/protobuf/generated_message_reflection_unittest.cc index 8b14662f1..b4c013a54 100644 --- a/src/google/protobuf/generated_message_reflection_unittest.cc +++ b/src/google/protobuf/generated_message_reflection_unittest.cc @@ -266,6 +266,39 @@ TEST(GeneratedMessageReflectionTest, SwapFieldsAll) { TestUtil::ExpectClear(message2); } +TEST(GeneratedMessageReflectionTest, SwapFieldsAllOnDifferentArena) { + Arena arena1, arena2; + auto* message1 = Arena::CreateMessage(&arena1); + auto* message2 = Arena::CreateMessage(&arena2); + + TestUtil::SetAllFields(message2); + + std::vector fields; + const Reflection* reflection = message1->GetReflection(); + reflection->ListFields(*message2, &fields); + reflection->SwapFields(message1, message2, fields); + + TestUtil::ExpectAllFieldsSet(*message1); + TestUtil::ExpectClear(*message2); +} + +TEST(GeneratedMessageReflectionTest, SwapFieldsAllOnArenaHeap) { + Arena arena; + auto* message1 = Arena::CreateMessage(&arena); + std::unique_ptr message2( + Arena::CreateMessage(nullptr)); + + TestUtil::SetAllFields(message2.get()); + + std::vector fields; + const Reflection* reflection = message1->GetReflection(); + reflection->ListFields(*message2, &fields); + reflection->SwapFields(message1, message2.get(), fields); + + TestUtil::ExpectAllFieldsSet(*message1); + TestUtil::ExpectClear(*message2); +} + TEST(GeneratedMessageReflectionTest, SwapFieldsAllExtension) { unittest::TestAllExtensions message1; unittest::TestAllExtensions message2; diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc index bc7936591..4fd6211f5 100644 --- a/src/google/protobuf/generated_message_util.cc +++ b/src/google/protobuf/generated_message_util.cc @@ -718,7 +718,8 @@ void GenericSwap(MessageLite* m1, MessageLite* m2) { MessageLite* GetOwnedMessageInternal(Arena* message_arena, MessageLite* submessage, Arena* submessage_arena) { - GOOGLE_DCHECK(submessage->GetArena() == submessage_arena); + GOOGLE_DCHECK(Arena::InternalHelper::GetOwningArena(submessage) == + submessage_arena); GOOGLE_DCHECK(message_arena != submessage_arena); if (message_arena != NULL && submessage_arena == NULL) { message_arena->Own(submessage); diff --git a/src/google/protobuf/has_bits.h b/src/google/protobuf/has_bits.h index 7fd92343c..66d3cd496 100644 --- a/src/google/protobuf/has_bits.h +++ b/src/google/protobuf/has_bits.h @@ -47,17 +47,17 @@ namespace internal { template class HasBits { public: - constexpr HasBits() PROTOBUF_NDEBUG_INLINE : has_bits_{} {} + PROTOBUF_NDEBUG_INLINE constexpr HasBits() : has_bits_{} {} - void Clear() PROTOBUF_NDEBUG_INLINE { + PROTOBUF_NDEBUG_INLINE void Clear() { memset(has_bits_, 0, sizeof(has_bits_)); } - uint32& operator[](int index) PROTOBUF_NDEBUG_INLINE { + PROTOBUF_NDEBUG_INLINE uint32& operator[](int index) { return has_bits_[index]; } - const uint32& operator[](int index) const PROTOBUF_NDEBUG_INLINE { + PROTOBUF_NDEBUG_INLINE const uint32& operator[](int index) const { return has_bits_[index]; } diff --git a/src/google/protobuf/io/coded_stream_unittest.cc b/src/google/protobuf/io/coded_stream_unittest.cc index d2f8959c7..d02cc88f5 100644 --- a/src/google/protobuf/io/coded_stream_unittest.cc +++ b/src/google/protobuf/io/coded_stream_unittest.cc @@ -51,11 +51,6 @@ #include -// This declares an unsigned long long integer literal in a portable way. -// (The original macro is way too big and ruins my formatting.) -#undef ULL -#define ULL(x) PROTOBUF_ULONGLONG(x) - namespace google { namespace protobuf { @@ -168,24 +163,25 @@ VarintCase kVarintCases[] = { {{0xbe, 0xf7, 0x92, 0x84, 0x0b}, 5, // 2961488830 (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | - (ULL(0x0b) << 28)}, + (uint64_t{0x0bu} << 28)}, // 64-bit {{0xbe, 0xf7, 0x92, 0x84, 0x1b}, 5, // 7256456126 (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | - (ULL(0x1b) << 28)}, + (uint64_t{0x1bu} << 28)}, {{0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49}, 8, // 41256202580718336 (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | - (ULL(0x43) << 28) | (ULL(0x49) << 35) | (ULL(0x24) << 42) | - (ULL(0x49) << 49)}, + (uint64_t{0x43u} << 28) | (uint64_t{0x49u} << 35) | + (uint64_t{0x24u} << 42) | (uint64_t{0x49u} << 49)}, // 11964378330978735131 {{0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01}, 10, (0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | - (ULL(0x3b) << 28) | (ULL(0x56) << 35) | (ULL(0x00) << 42) | - (ULL(0x05) << 49) | (ULL(0x26) << 56) | (ULL(0x01) << 63)}, + (uint64_t{0x3bu} << 28) | (uint64_t{0x56u} << 35) | + (uint64_t{0x00u} << 42) | (uint64_t{0x05u} << 49) | + (uint64_t{0x26u} << 56) | (uint64_t{0x01u} << 63)}, }; TEST_2D(CodedStreamTest, ReadVarint32, kVarintCases, kBlockSizes) { @@ -313,7 +309,7 @@ TEST_2D(CodedStreamTest, ReadVarint64, kVarintCases, kBlockSizes) { } TEST_2D(CodedStreamTest, WriteVarint32, kVarintCases, kBlockSizes) { - if (kVarintCases_case.value > ULL(0x00000000FFFFFFFF)) { + if (kVarintCases_case.value > uint64_t{0x00000000FFFFFFFFu}) { // Skip this test for the 64-bit values. return; } @@ -500,8 +496,8 @@ VarintSizeCase kVarintSizeCases[] = { {128u, 2}, {758923u, 3}, {4000000000u, 5}, - {ULL(41256202580718336), 8}, - {ULL(11964378330978735131), 10}, + {uint64_t{41256202580718336u}, 8}, + {uint64_t{11964378330978735131u}, 10}, }; TEST_1D(CodedStreamTest, VarintSize32, kVarintSizeCases) { @@ -569,8 +565,10 @@ Fixed32Case kFixed32Cases[] = { }; Fixed64Case kFixed64Cases[] = { - {{0xef, 0xcd, 0xab, 0x90, 0x12, 0x34, 0x56, 0x78}, ULL(0x7856341290abcdef)}, - {{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}, ULL(0x8877665544332211)}, + {{0xef, 0xcd, 0xab, 0x90, 0x12, 0x34, 0x56, 0x78}, + uint64_t{0x7856341290abcdefu}}, + {{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}, + uint64_t{0x8877665544332211u}}, }; TEST_2D(CodedStreamTest, ReadLittleEndian32, kFixed32Cases, kBlockSizes) { diff --git a/src/google/protobuf/map_entry_lite.h b/src/google/protobuf/map_entry_lite.h index 1caf59dfe..722481b1b 100644 --- a/src/google/protobuf/map_entry_lite.h +++ b/src/google/protobuf/map_entry_lite.h @@ -194,7 +194,7 @@ class MapEntryImpl : public Base { _has_bits_{} {} ~MapEntryImpl() { - if (Base::GetArena() != NULL) return; + if (Base::GetArenaForAllocation() != NULL) return; KeyTypeHandler::DeleteNoArena(key_); ValueTypeHandler::DeleteNoArena(value_); } @@ -209,11 +209,12 @@ class MapEntryImpl : public Base { } inline KeyMapEntryAccessorType* mutable_key() { set_has_key(); - return KeyTypeHandler::EnsureMutable(&key_, Base::GetArena()); + return KeyTypeHandler::EnsureMutable(&key_, Base::GetArenaForAllocation()); } inline ValueMapEntryAccessorType* mutable_value() { set_has_value(); - return ValueTypeHandler::EnsureMutable(&value_, Base::GetArena()); + return ValueTypeHandler::EnsureMutable(&value_, + Base::GetArenaForAllocation()); } // implements MessageLite ========================================= @@ -301,13 +302,14 @@ class MapEntryImpl : public Base { void MergeFromInternal(const MapEntryImpl& from) { if (from._has_bits_[0]) { if (from.has_key()) { - KeyTypeHandler::EnsureMutable(&key_, Base::GetArena()); - KeyTypeHandler::Merge(from.key(), &key_, Base::GetArena()); + KeyTypeHandler::EnsureMutable(&key_, Base::GetArenaForAllocation()); + KeyTypeHandler::Merge(from.key(), &key_, Base::GetArenaForAllocation()); set_has_key(); } if (from.has_value()) { - ValueTypeHandler::EnsureMutable(&value_, Base::GetArena()); - ValueTypeHandler::Merge(from.value(), &value_, Base::GetArena()); + ValueTypeHandler::EnsureMutable(&value_, Base::GetArenaForAllocation()); + ValueTypeHandler::Merge(from.value(), &value_, + Base::GetArenaForAllocation()); set_has_value(); } } @@ -315,8 +317,8 @@ class MapEntryImpl : public Base { public: void Clear() override { - KeyTypeHandler::Clear(&key_, Base::GetArena()); - ValueTypeHandler::Clear(&value_, Base::GetArena()); + KeyTypeHandler::Clear(&key_, Base::GetArenaForAllocation()); + ValueTypeHandler::Clear(&value_, Base::GetArenaForAllocation()); clear_has_key(); clear_has_value(); } @@ -328,7 +330,8 @@ class MapEntryImpl : public Base { public: explicit Parser(MapField* mf) : mf_(mf), map_(mf->MutableMap()) {} ~Parser() { - if (entry_ != nullptr && entry_->GetArena() == nullptr) delete entry_; + if (entry_ != nullptr && entry_->GetArenaForAllocation() == nullptr) + delete entry_; } // This does what the typical MergePartialFromCodedStream() is expected to diff --git a/src/google/protobuf/map_field.cc b/src/google/protobuf/map_field.cc index 23f36d03e..1afdc9d67 100644 --- a/src/google/protobuf/map_field.cc +++ b/src/google/protobuf/map_field.cc @@ -62,6 +62,7 @@ void MapFieldBase::Swap(MapFieldBase* other) { } void MapFieldBase::InternalSwap(MapFieldBase* other) { + std::swap(arena_, other->arena_); std::swap(repeated_field_, other->repeated_field_); // a relaxed swap of the atomic auto other_state = other->state_.load(std::memory_order_relaxed); @@ -136,12 +137,8 @@ void MapFieldBase::SyncRepeatedFieldWithMap() const { // Double check state if (state_.load(std::memory_order_relaxed) == CLEAN) { if (repeated_field_ == nullptr) { - if (arena_ == nullptr) { - repeated_field_ = new RepeatedPtrField(); - } else { - repeated_field_ = - Arena::CreateMessage >(arena_); - } + repeated_field_ = + Arena::CreateMessage >(arena_); } state_.store(CLEAN, std::memory_order_release); } @@ -186,11 +183,11 @@ DynamicMapField::DynamicMapField(const Message* default_entry, Arena* arena) default_entry_(default_entry) {} DynamicMapField::~DynamicMapField() { - // DynamicMapField owns map values. Need to delete them before clearing - // the map. - for (Map::iterator iter = map_.begin(); - iter != map_.end(); ++iter) { - iter->second.DeleteData(); + if (arena_ != nullptr) return; + // DynamicMapField owns map values. Need to delete them before clearing the + // map. + for (auto& kv : map_) { + kv.second.DeleteData(); } map_.clear(); } @@ -402,13 +399,8 @@ void DynamicMapField::SyncRepeatedFieldWithMapNoLock() const { const FieldDescriptor* key_des = default_entry_->GetDescriptor()->map_key(); const FieldDescriptor* val_des = default_entry_->GetDescriptor()->map_value(); if (MapFieldBase::repeated_field_ == NULL) { - if (MapFieldBase::arena_ == NULL) { - MapFieldBase::repeated_field_ = new RepeatedPtrField(); - } else { - MapFieldBase::repeated_field_ = - Arena::CreateMessage >( - MapFieldBase::arena_); - } + MapFieldBase::repeated_field_ = + Arena::CreateMessage >(MapFieldBase::arena_); } MapFieldBase::repeated_field_->Clear(); diff --git a/src/google/protobuf/map_field.h b/src/google/protobuf/map_field.h index 452c463a0..5f357b36c 100644 --- a/src/google/protobuf/map_field.h +++ b/src/google/protobuf/map_field.h @@ -336,13 +336,7 @@ class PROTOBUF_EXPORT MapFieldBase { mutex_(GOOGLE_PROTOBUF_LINKER_INITIALIZED), state_(STATE_MODIFIED_MAP) {} explicit MapFieldBase(Arena* arena) - : arena_(arena), repeated_field_(NULL), state_(STATE_MODIFIED_MAP) { - // Mutex's destructor needs to be called explicitly to release resources - // acquired in its constructor. - if (arena) { - arena->OwnDestructor(&mutex_); - } - } + : arena_(arena), repeated_field_(nullptr), state_(STATE_MODIFIED_MAP) {} virtual ~MapFieldBase(); // Returns reference to internal repeated field. Data written using diff --git a/src/google/protobuf/map_field_inl.h b/src/google/protobuf/map_field_inl.h index 55648951d..82206c699 100644 --- a/src/google/protobuf/map_field_inl.h +++ b/src/google/protobuf/map_field_inl.h @@ -297,13 +297,9 @@ template ::SyncRepeatedFieldWithMapNoLock() const { if (this->MapFieldBase::repeated_field_ == NULL) { - if (this->MapFieldBase::arena_ == NULL) { - this->MapFieldBase::repeated_field_ = new RepeatedPtrField(); - } else { - this->MapFieldBase::repeated_field_ = - Arena::CreateMessage >( - this->MapFieldBase::arena_); - } + this->MapFieldBase::repeated_field_ = + Arena::CreateMessage >( + this->MapFieldBase::arena_); } const Map& map = impl_.GetMap(); RepeatedPtrField* repeated_field = diff --git a/src/google/protobuf/map_field_test.cc b/src/google/protobuf/map_field_test.cc index e581f2038..982a34ffb 100644 --- a/src/google/protobuf/map_field_test.cc +++ b/src/google/protobuf/map_field_test.cc @@ -100,6 +100,11 @@ class MapFieldBaseStub : public MapFieldBase { void CopyIterator(MapIterator* this_iterator, const MapIterator& other_iterator) const override {} void IncreaseIterator(MapIterator* map_iter) const override {} + + Arena* GetArenaForInternalRepeatedField() { + auto* repeated_field = MutableRepeatedField(); + return repeated_field->GetArena(); + } }; class MapFieldBasePrimitiveTest : public testing::TestWithParam { @@ -205,9 +210,17 @@ TEST_P(MapFieldBasePrimitiveTest, Arena) { // Trigger conversion to repeated field. EXPECT_TRUE(map_field->MutableRepeatedField() != NULL); + + EXPECT_EQ(map_field->GetArenaForInternalRepeatedField(), &arena); } } +TEST_P(MapFieldBasePrimitiveTest, EnforceNoArena) { + std::unique_ptr map_field( + Arena::CreateMessage(nullptr)); + EXPECT_EQ(map_field->GetArenaForInternalRepeatedField(), nullptr); +} + namespace { enum State { CLEAN, MAP_DIRTY, REPEATED_DIRTY }; } // anonymous namespace diff --git a/src/google/protobuf/map_test.cc b/src/google/protobuf/map_test.cc index 3124f3bb6..1414fc34f 100644 --- a/src/google/protobuf/map_test.cc +++ b/src/google/protobuf/map_test.cc @@ -3754,6 +3754,22 @@ TEST(ArenaTest, DynamicMapFieldOnArena) { MapTestUtil::ExpectMapFieldsSet(message2); } +TEST(ArenaTest, DynamicMapFieldOnArenaMemoryLeak) { + auto* desc = unittest::TestMap::descriptor(); + auto* field = desc->FindFieldByName("map_int32_int32"); + + Arena arena; + DynamicMessageFactory factory; + auto* message = factory.GetPrototype(desc)->New(&arena); + auto* reflection = message->GetReflection(); + reflection->AddMessage(message, field); + + // Force internal syncing, which initializes the mutex. + MapReflectionTester reflection_tester(unittest::TestMap::descriptor()); + int size = reflection_tester.MapSize(*message, "map_int32_int32"); + EXPECT_EQ(size, 1); +} + TEST(MoveTest, MoveConstructorWorks) { Map original_map; original_map[42].mutable_optional_nested_message()->set_bb(42); diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index 1a5c77560..722842906 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -346,18 +346,8 @@ template <> PROTOBUF_NOINLINE #endif Arena* - GenericTypeHandler::GetArena(Message* value) { - return value->GetArena(); -} -template <> -#if defined(_MSC_VER) && (_MSC_VER >= 1800) -// Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue -// #240 -PROTOBUF_NOINLINE -#endif - void* - GenericTypeHandler::GetMaybeArenaPointer(Message* value) { - return value->GetMaybeArenaPointer(); + GenericTypeHandler::GetOwningArena(Message* value) { + return value->GetOwningArena(); } } // namespace internal diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index 9cfa5e171..068324b86 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -951,6 +951,24 @@ class PROTOBUF_EXPORT Reflection final { const Message& message, bool should_fail, std::vector* output) const; + // Returns true if the message field is backed by a LazyField. + // + // A message field may be backed by a LazyField without the user annotation + // ([lazy = true]). While the user-annotated LazyField is lazily verified on + // first touch (i.e. failure on access rather than parsing if the LazyField is + // not initialized), the inferred LazyField is eagerly verified to avoid lazy + // parsing error at the cost of lower efficiency. When reflecting a message + // field, use this API instead of checking field->options().lazy(). + bool IsLazyField(const FieldDescriptor* field) const { + return IsLazilyVerifiedLazyField(field) || + IsEagerlyVerifiedLazyField(field); + } + + bool IsLazilyVerifiedLazyField(const FieldDescriptor* field) const; + bool IsEagerlyVerifiedLazyField(const FieldDescriptor* field) const; + + friend class FastReflectionMessageMutator; + const Descriptor* const descriptor_; const internal::ReflectionSchema schema_; const DescriptorPool* const descriptor_pool_; @@ -1067,7 +1085,6 @@ class PROTOBUF_EXPORT Reflection final { } const internal::ExtensionSet& GetExtensionSet(const Message& message) const; internal::ExtensionSet* MutableExtensionSet(Message* message) const; - inline Arena* GetArena(Message* message) const; inline const internal::InternalMetadata& GetInternalMetadata( const Message& message) const; diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index 68cfa039b..f753e65b9 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -64,6 +64,10 @@ namespace protobuf { template class RepeatedPtrField; +class FastReflectionMessageMutator; +class FastReflectionStringSetter; +class Reflection; + namespace io { class CodedInputStream; @@ -83,10 +87,15 @@ struct ConstantInitialized { // See parse_context.h for explanation class ParseContext; +class ExtensionSet; +class LazyField; class RepeatedPtrFieldBase; class WireFormatLite; class WeakFieldMap; +template +class GenericTypeHandler; // defined in repeated_field.h + // We compute sizes as size_t but cache them as int. This function converts a // computed size to a cached size. Since we don't proceed with serialization // if the total size was > INT_MAX, it is not important what this function @@ -209,12 +218,8 @@ class PROTOBUF_EXPORT MessageLite { // if arena is a NULL. Default implementation for backwards compatibility. virtual MessageLite* New(Arena* arena) const; - // Get the arena, if any, associated with this message. Virtual method - // required for generic operations but most arena-related operations should - // use the GetArena() generated-code method. Default implementation - // to reduce code size by avoiding the need for per-type implementations - // when types do not implement arena support. - Arena* GetArena() const { return _internal_metadata_.arena(); } + // Same as GetOwningArena. + Arena* GetArena() const { return GetOwningArena(); } // Get a pointer that may be equal to this message's arena, or may not be. // If the value returned by this method is equal to some arena pointer, then @@ -469,6 +474,17 @@ 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(); } + + // 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(); } + internal::InternalMetadata _internal_metadata_; public: @@ -502,9 +518,19 @@ class PROTOBUF_EXPORT MessageLite { // TODO(gerbens) make this a pure abstract function virtual const void* InternalGetTable() const { return NULL; } - friend class internal::WireFormatLite; + friend class FastReflectionMessageMutator; + friend class FastReflectionStringSetter; friend class Message; + friend class Reflection; + friend class internal::ExtensionSet; + friend class internal::LazyField; friend class internal::WeakFieldMap; + friend class internal::WireFormatLite; + + template + friend class Arena::InternalHelper; + template + friend class internal::GenericTypeHandler; void LogInitializationErrorMessage() const; diff --git a/src/google/protobuf/message_unittest.inc b/src/google/protobuf/message_unittest.inc index dc307505e..408c23325 100644 --- a/src/google/protobuf/message_unittest.inc +++ b/src/google/protobuf/message_unittest.inc @@ -548,8 +548,9 @@ TEST(MESSAGE_TEST_NAME, ReleaseMustUseResult) { message.set_allocated_optional_foreign_message(f); auto* mf = message.mutable_optional_foreign_message(); EXPECT_EQ(mf, f); - EXPECT_NE(message.release_optional_foreign_message(), nullptr); - delete f; + std::unique_ptr rf( + message.release_optional_foreign_message()); + EXPECT_NE(rf.get(), nullptr); } TEST(MESSAGE_TEST_NAME, ParseFailsOnInvalidMessageEnd) { diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 8a6474957..4189b611a 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -48,129 +48,85 @@ // detect/prohibit anytime it is #included twice without a corresponding // #undef. -// These macros are private and should always be #undef'd from headers. -// If any of these errors fire, you should either properly #include -// port_undef.h at the end of your header that #includes port.h, or -// don't #include port.h twice in a .cc file. -#ifdef PROTOBUF_NAMESPACE -#error PROTOBUF_NAMESPACE was previously defined +// The definitions in this file are intended to be portable across Clang, +// GCC, and MSVC. Function-like macros are usable without an #ifdef guard. +// Syntax macros (for example, attributes) are always defined, although +// they may be empty. + +// Portable fallbacks for C++20 feature test macros: +// https://en.cppreference.com/w/cpp/feature_test +#ifndef __has_cpp_attribute +#define __has_cpp_attribute(x) 0 +#define PROTOBUF_has_cpp_attribute_DEFINED_ #endif -#ifdef PROTOBUF_NAMESPACE_ID -#error PROTOBUF_NAMESPACE_ID was previously defined + +// Portable fallback for Clang's __has_feature macro: +// https://clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension +#ifndef __has_feature +#define __has_feature(x) 0 +#define PROTOBUF_has_feature_DEFINED_ #endif -#ifdef PROTOBUF_ALWAYS_INLINE -#error PROTOBUF_ALWAYS_INLINE was previously defined + +// Portable fallback for Clang's __has_warning macro: +#ifndef __has_warning +#define __has_warning(x) 0 +#define PROTOBUF_has_warning_DEFINED_ #endif -#ifdef PROTOBUF_NDEBUG_INLINE -#error PROTOBUF_NDEBUG_INLINE was previously defined + +// Portable fallbacks for the __has_attribute macro (GCC and Clang): +// https://clang.llvm.org/docs/LanguageExtensions.html#has-attribute +// https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html +#ifndef __has_attribute +#define __has_attribute(x) 0 +#define PROTOBUF_has_attribute_DEFINED_ #endif -#ifdef PROTOBUF_COLD -#error PROTOBUF_COLD was previously defined + +// Portable fallback for __has_builtin (GCC and Clang): +// https://clang.llvm.org/docs/LanguageExtensions.html#has-builtin +// https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fbuiltin.html +#ifndef __has_builtin +#define __has_builtin(x) 0 +#define PROTOBUF_has_builtin_DEFINED_ #endif -#ifdef PROTOBUF_NOINLINE -#error PROTOBUF_NOINLINE was previously defined -#endif -#ifdef PROTOBUF_SECTION_VARIABLE -#error PROTOBUF_SECTION_VARIABLE was previously defined -#endif -#ifdef PROTOBUF_DEPRECATED -#error PROTOBUF_DEPRECATED was previously defined -#endif -#ifdef PROTOBUF_DEPRECATED_MSG -#error PROTOBUF_DEPRECATED_MSG was previously defined -#endif -#ifdef PROTOBUF_FUNC_ALIGN -#error PROTOBUF_FUNC_ALIGN was previously defined -#endif -#ifdef PROTOBUF_RETURNS_NONNULL -#error PROTOBUF_RETURNS_NONNULL was previously defined -#endif -#ifdef PROTOBUF_ATTRIBUTE_REINITIALIZES -#error PROTOBUF_ATTRIBUTE_REINITIALIZES was previously defined -#endif -#ifdef PROTOBUF_RTTI -#error PROTOBUF_RTTI was previously defined + +// Portable check for GCC minimum version: +// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html +#if defined(__GNUC__) && defined(__GNUC_MINOR__) \ + && defined(__GNUC_PATCHLEVEL__) +# define PROTOBUF_GNUC_MIN(x, y) \ + (__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y)) +#else +# define PROTOBUF_GNUC_MIN(x, y) 0 #endif + +// Future versions of protobuf will include breaking changes to some APIs. +// This macro can be set to enable these API changes ahead of time, so that +// user code can be updated before upgrading versions of protobuf. +// #define PROTOBUF_FUTURE_BREAKING_CHANGES 1 + #ifdef PROTOBUF_VERSION #error PROTOBUF_VERSION was previously defined #endif -#ifdef PROTOBUF_VERSION_SUFFIX -#error PROTOBUF_VERSION_SUFFIX was previously defined -#endif +#define PROTOBUF_VERSION 3015008 + #ifdef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC #error PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC was previously defined #endif +#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3015000 + #ifdef PROTOBUF_MIN_PROTOC_VERSION #error PROTOBUF_MIN_PROTOC_VERSION was previously defined #endif -#ifdef PROTOBUF_PREDICT_TRUE -#error PROTOBUF_PREDICT_TRUE was previously defined -#endif -#ifdef PROTOBUF_PREDICT_FALSE -#error PROTOBUF_PREDICT_FALSE was previously defined -#endif -#ifdef PROTOBUF_FIELD_OFFSET -#error PROTOBUF_FIELD_OFFSET was previously defined -#endif -#ifdef PROTOBUF_LL_FORMAT -#error PROTOBUF_LL_FORMAT was previously defined -#endif -#ifdef PROTOBUF_GUARDED_BY -#error PROTOBUF_GUARDED_BY was previously defined -#endif -#ifdef PROTOBUF_LONGLONG -#error PROTOBUF_LONGLONG was previously defined -#endif -#ifdef PROTOBUF_ULONGLONG -#error PROTOBUF_ULONGLONG was previously defined -#endif -#ifdef PROTOBUF_FALLTHROUGH_INTENDED -#error PROTOBUF_FALLTHROUGH_INTENDED was previously defined -#endif -#ifdef PROTOBUF_EXPORT -#error PROTOBUF_EXPORT was previously defined -#endif -#ifdef PROTOC_EXPORT -#error PROTOC_EXPORT was previously defined -#endif -#ifdef PROTOBUF_MUST_USE_RESULT -#error PROTOBUF_MUST_USE_RESULT was previously defined -#endif -#ifdef PROTOBUF_UNUSED -#error PROTOBUF_UNUSED was previously defined -#endif -#ifdef PROTOBUF_FINAL -#error PROTOBUF_FINAL was previously defined -#endif -#ifdef PROTOBUF_ENABLE_MSVC_UNION_WARNING -#error PROTOBUF_ENABLE_MSVC_UNION_WARNING was previously defined -#endif -#ifdef PROTOBUF_CONSTINIT -#error PROTOBUF_CONSTINIT was previously defined -#endif -#ifdef PROTOBUF_ATTRIBUTE_NO_DESTROY -#error PROTOBUF_ATTRIBUTE_NO_DESTROY was previously defined -#endif -#ifdef PROTOBUF_ATTRIBUTE_INIT_PRIORITY -#error PROTOBUF_ATTRIBUTE_INIT_PRIORITY was previously defined -#endif -#ifdef PROTOBUF_PRAGMA_INIT_SEG -#error PROTOBUF_PRAGMA_INIT_SEG was previously defined -#endif -#ifdef PROTOBUF_ATTRIBUTE_WEAK -#error PROTOBUF_ATTRIBUTE_WEAK was previously defined -#endif -#ifdef PROTOBUF_ASAN -#error PROTOBUF_ASAN was previously defined -#endif -#ifdef PROTOBUF_MSAN -#error PROTOBUF_MSAN was previously defined -#endif -#ifdef PROTOBUF_TSAN -#error PROTOBUF_TSAN was previously defined -#endif +#define PROTOBUF_MIN_PROTOC_VERSION 3015000 +#ifdef PROTOBUF_VERSION_SUFFIX +#error PROTOBUF_VERSION_SUFFIX was previously defined +#endif +#define PROTOBUF_VERSION_SUFFIX "" +#if defined(PROTOBUF_NAMESPACE) || defined(PROTOBUF_NAMESPACE_ID) +#error PROTOBUF_NAMESPACE or PROTOBUF_NAMESPACE_ID was previously defined +#endif #define PROTOBUF_NAMESPACE "google::protobuf" #define PROTOBUF_NAMESPACE_ID google::protobuf #define PROTOBUF_NAMESPACE_OPEN \ @@ -180,193 +136,170 @@ } /* namespace protobuf */ \ } /* namespace google */ -#if defined(__clang__) -#define PROTOBUF_DEPRECATED __attribute__((deprecated)) -#define PROTOBUF_DEPRECATED_ENUM __attribute__((deprecated)) -#define PROTOBUF_DEPRECATED_MSG(msg) __attribute__((deprecated(msg))) -#elif defined(__GNUC__) -#define PROTOBUF_DEPRECATED __attribute__((deprecated)) -#define PROTOBUF_DEPRECATED_MSG(msg) __attribute__((deprecated(msg))) -#if __GNUC__ >= 6 -#define PROTOBUF_DEPRECATED_ENUM __attribute__((deprecated)) -#else -#define PROTOBUF_DEPRECATED_ENUM +#ifdef PROTOBUF_ALWAYS_INLINE +#error PROTOBUF_ALWAYS_INLINE was previously defined #endif -#elif defined(_MSC_VER) -#define PROTOBUF_DEPRECATED __declspec(deprecated) -#define PROTOBUF_DEPRECATED_ENUM -#define PROTOBUF_DEPRECATED_MSG(msg) __declspec(deprecated(msg)) -#endif - -#define PROTOBUF_SECTION_VARIABLE(x) -#define PROTOBUF_MUST_USE_RESULT -#define PROTOBUF_FUTURE_MUST_USE_RESULT - -// ---------------------------------------------------------------------------- -// Annotations: Some parts of the code have been annotated in ways that might -// be useful to some compilers or tools, but are not supported universally. -// You can #define these annotations yourself if the default implementation -// is not right for you. - -#ifndef PROTOBUF_NO_INLINE -#ifdef GOOGLE_ATTRIBUTE_ALWAYS_INLINE -#define PROTOBUF_ALWAYS_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE -#define PROTOBUF_NDEBUG_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE -#elif defined(__GNUC__) && \ - (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) // For functions we want to force inline. -// Introduced in gcc 3.1. -#define PROTOBUF_ALWAYS_INLINE __attribute__((always_inline)) -#define PROTOBUF_NDEBUG_INLINE __attribute__((always_inline)) -#endif -#endif - -#ifndef PROTOBUF_ALWAYS_INLINE -// Other compilers will have to figure it out for themselves. -#define PROTOBUF_ALWAYS_INLINE -#define PROTOBUF_NDEBUG_INLINE -#endif - -#ifdef GOOGLE_ATTRIBUTE_NOINLINE -#define PROTOBUF_NOINLINE GOOGLE_ATTRIBUTE_NOINLINE +#if defined(PROTOBUF_NO_INLINE) +# define PROTOBUF_ALWAYS_INLINE +#elif PROTOBUF_GNUC_MIN(3, 1) +# define PROTOBUF_ALWAYS_INLINE __attribute__((always_inline)) +#elif defined(_MSC_VER) +# define PROTOBUF_ALWAYS_INLINE __forceinline #else -#if defined(__GNUC__) && \ - (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) -// For functions we want to force not inline. -// Introduced in gcc 3.1. -#define PROTOBUF_NOINLINE __attribute__((noinline)) -#elif defined(_MSC_VER) && (_MSC_VER >= 1400) +# define PROTOBUF_ALWAYS_INLINE +#endif + +#ifdef PROTOBUF_NDEBUG_INLINE +#error PROTOBUF_NDEBUG_INLINE was previously defined +#endif +// Avoid excessive inlining in non-optimized builds. Without other optimizations +// the inlining is not going to provide benefits anyway and the huge resulting +// functions, especially in the proto-generated serialization functions, produce +// stack frames so large that many tests run into stack overflows (b/32192897). +#if defined(NDEBUG) || (defined(_MSC_VER) && !defined(_DEBUG)) +# define PROTOBUF_NDEBUG_INLINE PROTOBUF_ALWAYS_INLINE +#else +# define PROTOBUF_NDEBUG_INLINE +#endif + +// Note that PROTOBUF_NOINLINE is an attribute applied to functions, to prevent +// them from being inlined by the compiler. This is different from +// PROTOBUF_NO_INLINE, which is a user-supplied macro that disables forced +// inlining by PROTOBUF_(ALWAYS|NDEBUG)_INLINE. +#ifdef PROTOBUF_NOINLINE +#error PROTOBUF_NOINLINE was previously defined +#endif +#if PROTOBUF_GNUC_MIN(3, 1) +# define PROTOBUF_NOINLINE __attribute__((noinline)) +#elif defined(_MSC_VER) // Seems to have been around since at least Visual Studio 2005 -#define PROTOBUF_NOINLINE __declspec(noinline) -#else -// Other compilers will have to figure it out for themselves. -#define PROTOBUF_NOINLINE -#endif +# define PROTOBUF_NOINLINE __declspec(noinline) #endif -#ifdef GOOGLE_ATTRIBUTE_FUNC_ALIGN -#define PROTOBUF_FUNC_ALIGN GOOGLE_ATTRIBUTE_FUNC_ALIGN +#ifdef PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED +#error PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED was previously defined +#endif +#if __has_attribute(exclusive_locks_required) +#define PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED(...) \ + __attribute__((exclusive_locks_required(__VA_ARGS__))) #else -#if defined(__clang__) || \ - defined(__GNUC__) && \ - (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) -// Function alignment attribute introduced in gcc 4.3 +#define PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED(...) +#endif + +#ifdef PROTOBUF_NO_THREAD_SAFETY_ANALYSIS +#error PROTOBUF_NO_THREAD_SAFETY_ANALYSIS was previously defined +#endif +#if __has_attribute(no_thread_safety_analysis) +#define PROTOBUF_NO_THREAD_SAFETY_ANALYSIS \ + __attribute__((no_thread_safety_analysis)) +#else +#define PROTOBUF_NO_THREAD_SAFETY_ANALYSIS +#endif + +#ifdef PROTOBUF_GUARDED_BY +#error PROTOBUF_GUARDED_BY was previously defined +#endif +#if __has_attribute(guarded_by) +#define PROTOBUF_GUARDED_BY(x) __attribute__((guarded_by(x))) +#else +#define PROTOBUF_GUARDED_BY(x) +#endif + +#ifdef PROTOBUF_LOCKS_EXCLUDED +#error PROTOBUF_LOCKS_EXCLUDED was previously defined +#endif +#if __has_attribute(locks_excluded) +#define PROTOBUF_LOCKS_EXCLUDED(...) \ + __attribute__((locks_excluded(__VA_ARGS__))) +#else +#define PROTOBUF_LOCKS_EXCLUDED(...) +#endif + +#ifdef PROTOBUF_COLD +#error PROTOBUF_COLD was previously defined +#endif +#if __has_attribute(cold) || PROTOBUF_GNUC_MIN(4, 3) +# define PROTOBUF_COLD __attribute__((cold)) +#else +# define PROTOBUF_COLD +#endif + +#ifdef PROTOBUF_SECTION_VARIABLE +#error PROTOBUF_SECTION_VARIABLE was previously defined +#endif +#define PROTOBUF_SECTION_VARIABLE(x) + +#if defined(PROTOBUF_DEPRECATED) +#error PROTOBUF_DEPRECATED was previously defined +#endif +#if defined(PROTOBUF_DEPRECATED_MSG) +#error PROTOBUF_DEPRECATED_MSG was previously defined +#endif +#if __has_attribute(deprecated) || PROTOBUF_GNUC_MIN(3, 0) +# define PROTOBUF_DEPRECATED __attribute__((deprecated)) +# define PROTOBUF_DEPRECATED_MSG(msg) __attribute__((deprecated(msg))) +#elif defined(_MSC_VER) +# define PROTOBUF_DEPRECATED __declspec(deprecated) +# define PROTOBUF_DEPRECATED_MSG(msg) __declspec(deprecated(msg)) +#else +# define PROTOBUF_DEPRECATED +# define PROTOBUF_DEPRECATED_MSG(msg) +#endif + +#if defined(PROTOBUF_DEPRECATED_ENUM) +#error PROTOBUF_DEPRECATED_ENUM was previously defined +#endif +#if defined(__clang__) || PROTOBUF_GNUC_MIN(6, 0) +// https://gcc.gnu.org/gcc-6/changes.html +# define PROTOBUF_DEPRECATED_ENUM __attribute__((deprecated)) +#else +# define PROTOBUF_DEPRECATED_ENUM +#endif + +#ifdef PROTOBUF_FUNC_ALIGN +#error PROTOBUF_FUNC_ALIGN was previously defined +#endif +#if __has_attribute(aligned) || PROTOBUF_GNUC_MIN(4, 3) #define PROTOBUF_FUNC_ALIGN(bytes) __attribute__((aligned(bytes))) #else #define PROTOBUF_FUNC_ALIGN(bytes) #endif -#endif -#ifdef GOOGLE_PREDICT_TRUE -#define PROTOBUF_PREDICT_TRUE GOOGLE_PREDICT_TRUE -#else -#ifdef __GNUC__ -// Provided at least since GCC 3.0. -#define PROTOBUF_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1)) -#else -#define PROTOBUF_PREDICT_TRUE(x) (x) +#ifdef PROTOBUF_RETURNS_NONNULL +#error PROTOBUF_RETURNS_NONNULL was previously defined #endif -#endif - -#ifdef GOOGLE_PREDICT_FALSE -#define PROTOBUF_PREDICT_FALSE GOOGLE_PREDICT_FALSE -#else -#ifdef __GNUC__ -// Provided at least since GCC 3.0. -#define PROTOBUF_PREDICT_FALSE(x) (__builtin_expect(x, 0)) -#else -#define PROTOBUF_PREDICT_FALSE(x) (x) -#endif -#endif - -#ifdef GOOGLE_PROTOBUF_ATTRIBUTE_RETURNS_NONNULL -#define PROTOBUF_RETURNS_NONNULL GOOGLE_PROTOBUF_ATTRIBUTE_RETURNS_NONNULL -#else -#if defined(__has_attribute) -#if __has_attribute(returns_nonnull) +#if __has_attribute(returns_nonnull) || PROTOBUF_GNUC_MIN(4, 9) #define PROTOBUF_RETURNS_NONNULL __attribute__((returns_nonnull)) -#endif -#endif -#endif -#ifndef PROTOBUF_RETURNS_NONNULL +#else #define PROTOBUF_RETURNS_NONNULL #endif -#if defined(__has_cpp_attribute) +#ifdef PROTOBUF_ATTRIBUTE_REINITIALIZES +#error PROTOBUF_ATTRIBUTE_REINITIALIZES was previously defined +#endif #if __has_cpp_attribute(clang::reinitializes) #define PROTOBUF_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]] -#endif -#endif -#ifndef PROTOBUF_ATTRIBUTE_REINITIALIZES +#else #define PROTOBUF_ATTRIBUTE_REINITIALIZES #endif -#define PROTOBUF_GUARDED_BY(x) -#define PROTOBUF_COLD - -// Copied from ABSL. -#if defined(__clang__) && defined(__has_warning) -#if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") -#define PROTOBUF_FALLTHROUGH_INTENDED [[clang::fallthrough]] -#endif -#elif defined(__GNUC__) && __GNUC__ >= 7 -#define PROTOBUF_FALLTHROUGH_INTENDED [[gnu::fallthrough]] -#endif - -#ifndef PROTOBUF_FALLTHROUGH_INTENDED -#define PROTOBUF_FALLTHROUGH_INTENDED -#endif - -#if defined(__has_cpp_attribute) -#define HAS_ATTRIBUTE(attr) __has_cpp_attribute(attr) -#else -#define HAS_ATTRIBUTE(attr) 0 -#endif - -#if HAS_ATTRIBUTE(unused) || (defined(__GNUC__) && !defined(__clang__)) -#define PROTOBUF_UNUSED __attribute__((__unused__)) -#else -#define PROTOBUF_UNUSED -#endif - -#undef HAS_ATTRIBUTE - -#ifdef _MSC_VER -#define PROTOBUF_LONGLONG(x) x##I64 -#define PROTOBUF_ULONGLONG(x) x##UI64 -#define PROTOBUF_LL_FORMAT "I64" // As in printf("%I64d", ...) -#else -// By long long, we actually mean int64. -#define PROTOBUF_LONGLONG(x) x##LL -#define PROTOBUF_ULONGLONG(x) x##ULL -// Used to format real long long integers. -#define PROTOBUF_LL_FORMAT \ - "ll" // As in "%lld". Note that "q" is poor form also. -#endif - - -#define PROTOBUF_VERSION 3015008 -#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3015000 -#define PROTOBUF_MIN_PROTOC_VERSION 3015000 -#define PROTOBUF_VERSION_SUFFIX "" - // The minimum library version which works with the current version of the // headers. #define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3015000 +#ifdef PROTOBUF_RTTI +#error PROTOBUF_RTTI was previously defined +#endif #if defined(GOOGLE_PROTOBUF_NO_RTTI) && GOOGLE_PROTOBUF_NO_RTTI #define PROTOBUF_RTTI 0 -#elif defined(__has_feature) -// https://clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension -#define PROTOBUF_RTTI __has_feature(cxx_rtti) -#elif !defined(__cxx_rtti) -// https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros#C.2B.2B98 -#define PROTOBUF_RTTI 0 -#elif defined(__GNUC__) && !defined(__GXX_RTTI) -#https: // gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html -#define PROTOBUF_RTTI 0 -#else +#elif __has_feature(cxx_rtti) #define PROTOBUF_RTTI 1 +#elif defined(__cxx_rtti) +// https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros#C.2B.2B98 +#define PROTOBUF_RTTI 1 +#else +#define PROTOBUF_RTTI 0 #endif // Returns the offset of the given field within the given aggregate type. @@ -377,6 +310,9 @@ // which the offsets of the direct fields of a class are non-constant. // Fields inherited from superclasses *can* have non-constant offsets, // but that's not what this macro will be used for. +#ifdef PROTOBUF_FIELD_OFFSET +#error PROTOBUF_FIELD_OFFSET was previously defined +#endif #if defined(__clang__) // For Clang we use __builtin_offsetof() and suppress the warning, // to avoid Control Flow Integrity and UBSan vptr sanitizers from @@ -386,8 +322,7 @@ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ __builtin_offsetof(TYPE, FIELD) \ _Pragma("clang diagnostic pop") -#elif defined(__GNUC__) && \ - (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) +#elif PROTOBUF_GNUC_MIN(4, 8) #define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) __builtin_offsetof(TYPE, FIELD) #else // defined(__clang__) // Note that we calculate relative to the pointer value 16 here since if we @@ -400,43 +335,234 @@ reinterpret_cast(16)) #endif -#if defined(PROTOBUF_USE_DLLS) +#ifdef PROTOBUF_EXPORT +#error PROTOBUF_EXPORT was previously defined +#endif + +#if defined(PROTOBUF_USE_DLLS) && defined(_MSC_VER) +# if defined(LIBPROTOBUF_EXPORTS) +# define PROTOBUF_EXPORT __declspec(dllexport) +# define PROTOBUF_EXPORT_TEMPLATE_DECLARE +# define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllexport) +# else +# define PROTOBUF_EXPORT __declspec(dllimport) +# define PROTOBUF_EXPORT_TEMPLATE_DECLARE +# define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllimport) +# endif // defined(LIBPROTOBUF_EXPORTS) +#elif defined(PROTOBUF_USE_DLLS) && defined(LIBPROTOBUF_EXPORTS) +# define PROTOBUF_EXPORT __attribute__((visibility("default"))) +# define PROTOBUF_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default"))) +# define PROTOBUF_EXPORT_TEMPLATE_DEFINE +#else +# define PROTOBUF_EXPORT +# define PROTOBUF_EXPORT_TEMPLATE_DECLARE +# define PROTOBUF_EXPORT_TEMPLATE_DEFINE +#endif + +#ifdef PROTOC_EXPORT +#error PROTOC_EXPORT was previously defined +#endif + +#if defined(PROTOBUF_USE_DLLS) && defined(_MSC_VER) +# if defined(LIBPROTOC_EXPORTS) +# define PROTOC_EXPORT __declspec(dllexport) +# else +# define PROTOC_EXPORT __declspec(dllimport) +# endif // defined(LIBPROTOC_EXPORTS) +#elif defined(PROTOBUF_USE_DLLS) && defined(LIBPROTOBUF_EXPORTS) +# define PROTOC_EXPORT __attribute__((visibility("default"))) +#else +# define PROTOC_EXPORT +#endif + +#if defined(PROTOBUF_PREDICT_TRUE) || defined(PROTOBUF_PREDICT_FALSE) +#error PROTOBUF_PREDICT_(TRUE|FALSE) was previously defined +#endif +#if PROTOBUF_GNUC_MIN(3, 0) +# define PROTOBUF_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1)) +# define PROTOBUF_PREDICT_FALSE(x) (__builtin_expect((x), 0)) +#else +# define PROTOBUF_PREDICT_TRUE(x) (x) +# define PROTOBUF_PREDICT_FALSE(x) (x) +#endif + +#ifdef PROTOBUF_MUST_USE_RESULT +#error PROTOBUF_MUST_USE_RESULT was previously defined +#endif +# define PROTOBUF_FUTURE_MUST_USE_RESULT +# define PROTOBUF_MUST_USE_RESULT + +#ifdef PROTOBUF_FALLTHROUGH_INTENDED +#error PROTOBUF_FALLTHROUGH_INTENDED was previously defined +#endif +#if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") +#define PROTOBUF_FALLTHROUGH_INTENDED [[clang::fallthrough]] +#elif PROTOBUF_GNUC_MIN(7, 0) +#define PROTOBUF_FALLTHROUGH_INTENDED [[gnu::fallthrough]] +#else +#define PROTOBUF_FALLTHROUGH_INTENDED +#endif + +// PROTOBUF_ASSUME(pred) tells the compiler that it can assume pred is true. To +// be safe, we also validate the assumption with a GOOGLE_DCHECK in unoptimized +// builds. The macro does not do anything useful if the compiler does not +// support __builtin_assume. +#ifdef PROTOBUF_ASSUME +#error PROTOBUF_ASSUME was previously defined +#endif +#if __has_builtin(__builtin_assume) +#define PROTOBUF_ASSUME(pred) \ + GOOGLE_DCHECK(pred); \ + __builtin_assume(pred) +#else +#define PROTOBUF_ASSUME(pred) GOOGLE_DCHECK(pred) +#endif + +// Specify memory alignment for structs, classes, etc. +// Use like: +// class PROTOBUF_ALIGNAS(16) MyClass { ... } +// PROTOBUF_ALIGNAS(16) int array[4]; +// +// In most places you can use the C++11 keyword "alignas", which is preferred. +// +// But compilers have trouble mixing __attribute__((...)) syntax with +// alignas(...) syntax. +// +// Doesn't work in clang or gcc: +// struct alignas(16) __attribute__((packed)) S { char c; }; +// Works in clang but not gcc: +// struct __attribute__((packed)) alignas(16) S2 { char c; }; +// Works in clang and gcc: +// struct alignas(16) S3 { char c; } __attribute__((packed)); +// +// There are also some attributes that must be specified *before* a class +// definition: visibility (used for exporting functions/classes) is one of +// these attributes. This means that it is not possible to use alignas() with a +// class that is marked as exported. +#ifdef PROTOBUF_ALIGNAS +#error PROTOBUF_ALIGNAS was previously defined +#endif #if defined(_MSC_VER) -#ifdef LIBPROTOBUF_EXPORTS -#define PROTOBUF_EXPORT __declspec(dllexport) -#define PROTOBUF_EXPORT_TEMPLATE_DECLARE -#define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllexport) +#define PROTOBUF_ALIGNAS(byte_alignment) __declspec(align(byte_alignment)) +#elif PROTOBUF_GNUC_MIN(3, 0) +#define PROTOBUF_ALIGNAS(byte_alignment) \ + __attribute__((aligned(byte_alignment))) #else -#define PROTOBUF_EXPORT __declspec(dllimport) -#define PROTOBUF_EXPORT_TEMPLATE_DECLARE -#define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllimport) +#define PROTOBUF_ALIGNAS(byte_alignment) alignas(byte_alignment) #endif -#ifdef LIBPROTOC_EXPORTS -#define PROTOC_EXPORT __declspec(dllexport) + +#ifdef PROTOBUF_THREAD_LOCAL +#error PROTOBUF_THREAD_LOCAL was previously defined +#endif +#if defined(_MSC_VER) +#define PROTOBUF_THREAD_LOCAL __declspec(thread) #else -#define PROTOC_EXPORT __declspec(dllimport) +#define PROTOBUF_THREAD_LOCAL __thread #endif -#else // defined(_MSC_VER) -#ifdef LIBPROTOBUF_EXPORTS -#define PROTOBUF_EXPORT __attribute__((visibility("default"))) -#define PROTOBUF_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default"))) -#define PROTOBUF_EXPORT_TEMPLATE_DEFINE + +// For enabling message owned arena, one major blocker is semantic change from +// moving to copying when there is ownership transfer (e.g., move ctor, swap, +// set allocated, release). This change not only causes performance regression +// but also breaks users code (e.g., dangling reference). For top-level +// messages, since it owns the arena, we can mitigate the issue by transferring +// ownership of arena. However, we cannot do that for nested messages. In order +// to tell how many usages of nested messages affected by message owned arena, +// we need to simulate the arena ownership. +// This experiment is purely for the purpose of gathering data. All code guarded +// by this flag is supposed to be removed after this experiment. +// #define PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT +#ifdef PROTOBUF_CONSTINIT +#error PROTOBUF_CONSTINIT was previously defined +#endif +#if defined(__cpp_constinit) && !PROTOBUF_GNUC_MIN(3, 0) +// Our use of constinit does not yet work with GCC: +// https://github.com/protocolbuffers/protobuf/issues/8310 +#define PROTOBUF_CONSTINIT constinit +#elif __has_cpp_attribute(clang::require_constant_initialization) +#define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]] #else -#define PROTOBUF_EXPORT -#define PROTOBUF_EXPORT_TEMPLATE_DECLARE -#define PROTOBUF_EXPORT_TEMPLATE_DEFINE +#define PROTOBUF_CONSTINIT #endif -#ifdef LIBPROTOC_EXPORTS -#define PROTOC_EXPORT __attribute__((visibility("default"))) + +// Some globals with an empty non-trivial destructor are annotated with +// no_destroy for performance reasons. It reduces the cost of these globals in +// non-opt mode and under sanitizers. +#ifdef PROTOBUF_ATTRIBUTE_NO_DESTROY +#error PROTOBUF_ATTRIBUTE_NO_DESTROY was previously defined +#endif +#if __has_cpp_attribute(clang::no_destroy) +#define PROTOBUF_ATTRIBUTE_NO_DESTROY [[clang::no_destroy]] #else -#define PROTOC_EXPORT +#define PROTOBUF_ATTRIBUTE_NO_DESTROY #endif + +// Protobuf extensions and reflection require registration of the protos linked +// in the binary. Not until everything is registered does the runtime have a +// complete view on all protos. When code is using reflection or extensions +// in between registration calls this can lead to surprising behavior. By +// having the registration run first we mitigate this scenario. +// Highest priority is 101. We use 102 to allow code that really wants to +// higher priority to still beat us. +#ifdef PROTOBUF_ATTRIBUTE_INIT_PRIORITY +#error PROTOBUF_ATTRIBUTE_INIT_PRIORITY was previously defined #endif -#else // defined(PROTOBUF_USE_DLLS) -#define PROTOBUF_EXPORT -#define PROTOC_EXPORT -#define PROTOBUF_EXPORT_TEMPLATE_DECLARE -#define PROTOBUF_EXPORT_TEMPLATE_DEFINE +#if PROTOBUF_GNUC_MIN(3, 0) +#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY __attribute__((init_priority((102)))) +#else +#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY +#endif + +#ifdef PROTOBUF_PRAGMA_INIT_SEG +#error PROTOBUF_PRAGMA_INIT_SEG was previously defined +#endif +#if _MSC_VER +#define PROTOBUF_PRAGMA_INIT_SEG __pragma(init_seg(lib)) +#else +#define PROTOBUF_PRAGMA_INIT_SEG +#endif + +#ifdef PROTOBUF_ATTRIBUTE_WEAK +#error PROTOBUF_ATTRIBUTE_WEAK was previously defined +#endif +#if __has_attribute(weak) && !defined(__MINGW32__) +#define PROTOBUF_ATTRIBUTE_WEAK __attribute__((weak)) +#else +#define PROTOBUF_ATTRIBUTE_WEAK +#endif + +// Macros to detect sanitizers. +#ifdef PROTOBUF_ASAN +#error PROTOBUF_ASAN was previously defined +#endif +#ifdef PROTOBUF_MSAN +#error PROTOBUF_MSAN was previously defined +#endif +#ifdef PROTOBUF_TSAN +#error PROTOBUF_TSAN was previously defined +#endif +#if defined(__clang__) +# if __has_feature(address_sanitizer) +# define PROTOBUF_ASAN 1 +# endif +# if __has_feature(thread_sanitizer) +# define PROTOBUF_TSAN 1 +# endif +# if __has_feature(memory_sanitizer) +# define PROTOBUF_MSAN 1 +# endif +#elif PROTOBUF_GNUC_MIN(3, 0) +# define PROTOBUF_ASAN __SANITIZE_ADDRESS__ +# define PROTOBUF_TSAN __SANITIZE_THREAD__ +#endif + +#ifdef PROTOBUF_UNUSED +#error PROTOBUF_UNUSED was previously defined +#endif +#if __has_cpp_attribute(unused) || \ + (PROTOBUF_GNUC_MIN(3, 0) && !defined(__clang__)) +#define PROTOBUF_UNUSED __attribute__((__unused__)) +#else +#define PROTOBUF_UNUSED #endif // Windows declares several inconvenient macro names. We #undef them and then @@ -490,19 +616,19 @@ #undef timezone #endif // _MSC_VER -#if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) +#if defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER) // Don't let Objective-C Macros interfere with proto identifiers with the same // name. #pragma push_macro("DEBUG") #undef DEBUG -#endif // defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) +#endif // defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER) #if defined(__clang__) #pragma clang diagnostic push // TODO(gerbens) ideally we cleanup the code. But a cursory try shows many // violations. So let's ignore for now. #pragma clang diagnostic ignored "-Wshorten-64-to-32" -#elif defined(__GNUC__) +#elif PROTOBUF_GNUC_MIN(3, 0) // GCC does not allow disabling diagnostics within an expression: // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60875, so we disable this one // globally even though it's only used for PROTOBUF_FIELD_OFFSET. @@ -510,141 +636,6 @@ #pragma GCC diagnostic ignored "-Winvalid-offsetof" #endif -// PROTOBUF_ASSUME(pred) tells the compiler that it can assume pred is true. To -// be safe, we also validate the assumption with a GOOGLE_DCHECK in unoptimized -// builds. The macro does not do anything useful if the compiler does not -// support __builtin_assume. -#ifdef __has_builtin -#if __has_builtin(__builtin_assume) -#define PROTOBUF_ASSUME(pred) \ - GOOGLE_DCHECK(pred); \ - __builtin_assume(pred) -#else -#define PROTOBUF_ASSUME(pred) GOOGLE_DCHECK(pred) -#endif -#else -#define PROTOBUF_ASSUME(pred) GOOGLE_DCHECK(pred) -#endif - -// Specify memory alignment for structs, classes, etc. -// Use like: -// class PROTOBUF_ALIGNAS(16) MyClass { ... } -// PROTOBUF_ALIGNAS(16) int array[4]; -// -// In most places you can use the C++11 keyword "alignas", which is preferred. -// -// But compilers have trouble mixing __attribute__((...)) syntax with -// alignas(...) syntax. -// -// Doesn't work in clang or gcc: -// struct alignas(16) __attribute__((packed)) S { char c; }; -// Works in clang but not gcc: -// struct __attribute__((packed)) alignas(16) S2 { char c; }; -// Works in clang and gcc: -// struct alignas(16) S3 { char c; } __attribute__((packed)); -// -// There are also some attributes that must be specified *before* a class -// definition: visibility (used for exporting functions/classes) is one of -// these attributes. This means that it is not possible to use alignas() with a -// class that is marked as exported. -#if defined(_MSC_VER) -#define PROTOBUF_ALIGNAS(byte_alignment) __declspec(align(byte_alignment)) -#elif defined(__GNUC__) -#define PROTOBUF_ALIGNAS(byte_alignment) \ - __attribute__((aligned(byte_alignment))) -#else -#define PROTOBUF_ALIGNAS(byte_alignment) alignas(byte_alignment) -#endif - -#define PROTOBUF_FINAL final - -#if defined(_MSC_VER) -#define PROTOBUF_THREAD_LOCAL __declspec(thread) -#else -#define PROTOBUF_THREAD_LOCAL __thread -#endif - -// For enabling message owned arena, one major blocker is semantic change from -// moving to copying when there is ownership transfer (e.g., move ctor, swap, -// set allocated, release). This change not only causes performance regression -// but also breaks users code (e.g., dangling reference). For top-level -// messages, since it owns the arena, we can mitigate the issue by transferring -// ownership of arena. However, we cannot do that for nested messages. In order -// to tell how many usages of nested messages affected by message owned arena, -// we need to simulate the arena ownership. -// This experiment is purely for the purpose of gathering data. All code guarded -// by this flag is supposed to be removed after this experiment. -// #define PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT - -// Our use of constinit does not yet work with GCC: -// https://github.com/protocolbuffers/protobuf/issues/8310 -#if defined(__cpp_constinit) && !defined(__GNUC__) -#define PROTOBUF_CONSTINIT constinit -#elif defined(__has_cpp_attribute) -#if __has_cpp_attribute(clang::require_constant_initialization) -#define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]] -#endif -#endif -#ifndef PROTOBUF_CONSTINIT -#define PROTOBUF_CONSTINIT -#endif - -// Some globals with an empty non-trivial destructor are annotated with -// no_destroy for performance reasons. It reduces the cost of these globals in -// non-opt mode and under sanitizers. -#if defined(__has_cpp_attribute) -#if __has_cpp_attribute(clang::no_destroy) -#define PROTOBUF_ATTRIBUTE_NO_DESTROY [[clang::no_destroy]] -#endif -#endif -#if !defined(PROTOBUF_ATTRIBUTE_NO_DESTROY) -#define PROTOBUF_ATTRIBUTE_NO_DESTROY -#endif - -#if defined(__GNUC__) -// Protobuf extensions and reflection require registration of the protos linked -// in the binary. Not until everything is registered does the runtime have a -// complete view on all protos. When code is using reflection or extensions -// in between registration calls this can lead to surprising behavior. By -// having the registration run first we mitigate this scenario. -// Highest priority is 101. We use 102 to allow code that really wants to -// higher priority to still beat us. -#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY __attribute__((init_priority((102)))) -#else -#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY -#endif - -#if _MSC_VER -#define PROTOBUF_PRAGMA_INIT_SEG __pragma(init_seg(lib)) -#else -#define PROTOBUF_PRAGMA_INIT_SEG -#endif - -#if defined(__has_attribute) && !defined(__MINGW32__) -#if __has_attribute(weak) -#define PROTOBUF_ATTRIBUTE_WEAK __attribute__((weak)) -#endif -#endif -#if !defined(PROTOBUF_ATTRIBUTE_WEAK) -#define PROTOBUF_ATTRIBUTE_WEAK -#endif - -// Macros to detect sanitizers. -#if defined(__clang__) -# if __has_feature(address_sanitizer) -# define PROTOBUF_ASAN 1 -# endif -# if __has_feature(thread_sanitizer) -# define PROTOBUF_TSAN 1 -# endif -# if __has_feature(memory_sanitizer) -# define PROTOBUF_MSAN 1 -# endif -#elif defined(__GNUC__) -# define PROTOBUF_ASAN __SANITIZE_ADDRESS__ -# define PROTOBUF_TSAN __SANITIZE_THREAD__ -#endif - // Silence some MSVC warnings in all our code. #if _MSC_VER #pragma warning(push) @@ -656,3 +647,28 @@ // To silence the fact that we will pop this push from another file #pragma warning(disable : 5031) #endif + +// We don't want code outside port_def doing complex testing, so +// remove our portable condition test macros to nudge folks away from +// using it themselves. +#ifdef PROTOBUF_has_cpp_attribute_DEFINED_ +# undef __has_cpp_attribute +# undef PROTOBUF_has_cpp_attribute_DEFINED_ +#endif +#ifdef PROTOBUF_has_feature_DEFINED_ +# undef __has_feature +# undef PROTOBUF_has_feature_DEFINED_ +#endif +#ifdef PROTOBUF_has_warning_DEFINED_ +# undef __has_warning +# undef PROTOBUF_has_warning_DEFINED_ +#endif +#ifdef PROTOBUF_has_attribute_DEFINED_ +# undef __has_attribute +# undef PROTOBUF_has_attribute_DEFINED_ +#endif +#ifdef PROTOBUF_has_builtin_DEFINED_ +# undef __has_builtin +# undef PROTOBUF_has_builtin_DEFINED_ +#endif +#undef PROTOBUF_GNUC_MIN diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc index e40ac0da9..82fe794b8 100644 --- a/src/google/protobuf/port_undef.inc +++ b/src/google/protobuf/port_undef.inc @@ -55,10 +55,6 @@ #undef PROTOBUF_MIN_PROTOC_VERSION #undef PROTOBUF_PREDICT_TRUE #undef PROTOBUF_PREDICT_FALSE -#undef PROTOBUF_LONGLONG -#undef PROTOBUF_ULONGLONG -#undef PROTOBUF_LL_FORMAT -#undef PROTOBUF_GUARDED_BY #undef PROTOBUF_FALLTHROUGH_INTENDED #undef PROTOBUF_EXPORT #undef PROTOC_EXPORT @@ -70,7 +66,6 @@ #undef PROTOBUF_EXPORT_TEMPLATE_DECLARE #undef PROTOBUF_EXPORT_TEMPLATE_DEFINE #undef PROTOBUF_ALIGNAS -#undef PROTOBUF_FINAL #undef PROTOBUF_THREAD_LOCAL #undef PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT #undef PROTOBUF_CONSTINIT @@ -81,6 +76,10 @@ #undef PROTOBUF_ASAN #undef PROTOBUF_MSAN #undef PROTOBUF_TSAN +#undef PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED +#undef PROTOBUF_LOCKS_EXCLUDED +#undef PROTOBUF_NO_THREAD_SAFETY_ANALYSIS +#undef PROTOBUF_GUARDED_BY #ifdef PROTOBUF_FUTURE_BREAKING_CHANGES #undef PROTOBUF_FUTURE_BREAKING_CHANGES diff --git a/src/google/protobuf/reflection_ops.cc b/src/google/protobuf/reflection_ops.cc index 9a622f4ac..1c521e4cc 100644 --- a/src/google/protobuf/reflection_ops.cc +++ b/src/google/protobuf/reflection_ops.cc @@ -418,19 +418,24 @@ void ReflectionOps::FindInitializationErrors(const Message& message, } } -void GenericSwap(Message* m1, Message* m2) { - Arena* m2_arena = m2->GetArena(); - GOOGLE_DCHECK(m1->GetArena() != m2_arena); +void GenericSwap(Message* lhs, Message* rhs) { + GOOGLE_DCHECK(Arena::InternalHelper::GetOwningArena(lhs) != + Arena::InternalHelper::GetOwningArena(rhs)); + // At least one of these must have an arena, so make `rhs` point to it. + Arena* arena = Arena::InternalHelper::GetOwningArena(rhs); + if (arena == nullptr) { + std::swap(lhs, rhs); + arena = Arena::InternalHelper::GetOwningArena(rhs); + } - // Copy semantics in this case. We try to improve efficiency by placing the - // temporary on |m2|'s arena so that messages are copied twice rather than - // three times. - Message* tmp = m2->New(m2_arena); - std::unique_ptr tmp_deleter(m2_arena == nullptr ? tmp : nullptr); - tmp->CheckTypeAndMergeFrom(*m1); - m1->Clear(); - m1->CheckTypeAndMergeFrom(*m2); - m2->GetReflection()->Swap(tmp, m2); + // Improve efficiency by placing the temporary on an arena so that messages + // are copied twice rather than three times. + GOOGLE_DCHECK(arena != nullptr); + Message* tmp = rhs->New(arena); + tmp->CheckTypeAndMergeFrom(*lhs); + lhs->Clear(); + lhs->CheckTypeAndMergeFrom(*rhs); + rhs->GetReflection()->Swap(tmp, rhs); } } // namespace internal diff --git a/src/google/protobuf/reflection_ops_unittest.cc b/src/google/protobuf/reflection_ops_unittest.cc index dee2af2c5..8c4da218a 100644 --- a/src/google/protobuf/reflection_ops_unittest.cc +++ b/src/google/protobuf/reflection_ops_unittest.cc @@ -535,8 +535,8 @@ TEST(ReflectionOpsTest, GenericSwap) { TestUtil::ExpectAllFieldsSet(message); TestUtil::ExpectClear(*arena_message); - // The temp shouldn't be allocated on the arena in this case. - EXPECT_EQ(arena.SpaceUsed(), initial_arena_size); + // The temp should be allocated on the arena in this case. + EXPECT_GT(arena.SpaceUsed(), initial_arena_size); } } diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index ebccf1896..57bc7eeaa 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -595,12 +595,10 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { #endif } - public: // Must be called from destructor. template void Destroy(); - protected: bool empty() const; int size() const; @@ -800,6 +798,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { // reinterpreting pointers as being to Message instead of a specific Message // subclass. friend class MapFieldBase; + friend class MapFieldBaseStub; // The table-driven MergePartialFromCodedStream implementation needs to // operate on RepeatedPtrField. @@ -830,11 +829,8 @@ class GenericTypeHandler { delete value; } } - static inline Arena* GetArena(GenericType* value) { - return Arena::GetArena(value); - } - static inline void* GetMaybeArenaPointer(GenericType* value) { - return Arena::GetArena(value); + static inline Arena* GetOwningArena(GenericType* value) { + return Arena::GetOwningArena(value); } static inline void Clear(GenericType* value) { value->Clear(); } @@ -863,13 +859,9 @@ template <> MessageLite* GenericTypeHandler::NewFromPrototype( const MessageLite* prototype, Arena* arena); template <> -inline Arena* GenericTypeHandler::GetArena(MessageLite* value) { - return value->GetArena(); -} -template <> -inline void* GenericTypeHandler::GetMaybeArenaPointer( +inline Arena* GenericTypeHandler::GetOwningArena( MessageLite* value) { - return value->GetMaybeArenaPointer(); + return value->GetOwningArena(); } template <> void GenericTypeHandler::Merge(const MessageLite& from, @@ -889,9 +881,7 @@ template <> PROTOBUF_EXPORT Message* GenericTypeHandler::NewFromPrototype( const Message* prototype, Arena* arena); template <> -PROTOBUF_EXPORT Arena* GenericTypeHandler::GetArena(Message* value); -template <> -PROTOBUF_EXPORT void* GenericTypeHandler::GetMaybeArenaPointer( +PROTOBUF_EXPORT Arena* GenericTypeHandler::GetOwningArena( Message* value); class StringTypeHandler { @@ -909,10 +899,7 @@ class StringTypeHandler { Arena* arena) { return New(arena); } - static inline Arena* GetArena(std::string*) { return NULL; } - static inline void* GetMaybeArenaPointer(std::string* /* value */) { - return NULL; - } + static inline Arena* GetOwningArena(std::string*) { return nullptr; } static inline void Delete(std::string* value, Arena* arena) { if (arena == NULL) { delete value; @@ -1496,7 +1483,6 @@ inline const Element* RepeatedField::data() const { template inline void RepeatedField::InternalSwap(RepeatedField* other) { GOOGLE_DCHECK(this != other); - GOOGLE_DCHECK(GetArena() == other->GetArena()); // Swap all fields at once. static_assert(std::is_standard_layout>::value, @@ -1944,7 +1930,7 @@ template void RepeatedPtrFieldBase::AddAllocatedInternal( typename TypeHandler::Type* value, std::true_type) { Arena* element_arena = - reinterpret_cast(TypeHandler::GetMaybeArenaPointer(value)); + reinterpret_cast(TypeHandler::GetOwningArena(value)); Arena* arena = GetArena(); if (arena == element_arena && rep_ && rep_->allocated_size < total_size_) { // Fast path: underlying arena representation (tagged pointer) is equal to @@ -1960,8 +1946,7 @@ void RepeatedPtrFieldBase::AddAllocatedInternal( current_size_ = current_size_ + 1; rep_->allocated_size = rep_->allocated_size + 1; } else { - AddAllocatedSlowWithCopy(value, TypeHandler::GetArena(value), - arena); + AddAllocatedSlowWithCopy(value, element_arena, arena); } } @@ -2093,7 +2078,7 @@ inline void RepeatedPtrFieldBase::AddCleared( typename TypeHandler::Type* value) { GOOGLE_DCHECK(GetArena() == NULL) << "AddCleared() can only be used on a RepeatedPtrField not on an arena."; - GOOGLE_DCHECK(TypeHandler::GetArena(value) == NULL) + GOOGLE_DCHECK(TypeHandler::GetOwningArena(value) == nullptr) << "AddCleared() can only accept values not on an arena."; if (!rep_ || rep_->allocated_size == total_size_) { Reserve(total_size_ + 1); @@ -2635,17 +2620,14 @@ class RepeatedPtrOverPtrsIterator { void RepeatedPtrFieldBase::InternalSwap(RepeatedPtrFieldBase* other) { GOOGLE_DCHECK(this != other); - GOOGLE_DCHECK(GetArena() == other->GetArena()); // Swap all fields at once. static_assert(std::is_standard_layout::value, "offsetof() requires standard layout before c++17"); internal::memswaprep_) - - offsetof(RepeatedPtrFieldBase, current_size_)>( - reinterpret_cast(this) + - offsetof(RepeatedPtrFieldBase, current_size_), - reinterpret_cast(other) + - offsetof(RepeatedPtrFieldBase, current_size_)); + offsetof(RepeatedPtrFieldBase, arena_)>( + reinterpret_cast(this) + offsetof(RepeatedPtrFieldBase, arena_), + reinterpret_cast(other) + offsetof(RepeatedPtrFieldBase, arena_)); } } // namespace internal diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index 4dae9363b..019e04592 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -91,7 +91,7 @@ SourceContext::SourceContext(const SourceContext& from) file_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_file_name().empty()) { file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_file_name(), - GetArena()); + GetArenaForAllocation()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext) } @@ -107,7 +107,7 @@ SourceContext::~SourceContext() { } void SourceContext::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); file_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } @@ -176,7 +176,7 @@ failure: (void) cached_has_bits; // string file_name = 1; - if (this->file_name().size() > 0) { + if (!this->file_name().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_file_name().data(), static_cast(this->_internal_file_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -202,7 +202,7 @@ size_t SourceContext::ByteSizeLong() const { (void) cached_has_bits; // string file_name = 1; - if (this->file_name().size() > 0) { + if (!this->file_name().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_file_name()); @@ -239,7 +239,7 @@ void SourceContext::MergeFrom(const SourceContext& from) { ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; - if (from.file_name().size() > 0) { + if (!from.file_name().empty()) { _internal_set_file_name(from._internal_file_name()); } } @@ -265,7 +265,11 @@ bool SourceContext::IsInitialized() const { void SourceContext::InternalSwap(SourceContext* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - file_name_.Swap(&other->file_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &file_name_, GetArenaForAllocation(), + &other->file_name_, other->GetArenaForAllocation() + ); } ::PROTOBUF_NAMESPACE_ID::Metadata SourceContext::GetMetadata() const { diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 7bc259dbf..3138c262a 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -65,7 +65,7 @@ PROTOBUF_NAMESPACE_OPEN // =================================================================== -class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL : +class PROTOBUF_EXPORT SourceContext final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceContext) */ { public: inline SourceContext() : SourceContext(nullptr) {} @@ -83,8 +83,9 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL : return *this; } inline SourceContext& operator=(SourceContext&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -115,7 +116,7 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL : } inline void Swap(SourceContext* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -123,14 +124,14 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL : } void UnsafeArenaSwap(SourceContext* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline SourceContext* New() const final { - return CreateMaybeMessage(nullptr); + return new SourceContext(); } SourceContext* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -180,11 +181,11 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL : template void set_file_name(ArgT0&& arg0, ArgT... args); std::string* mutable_file_name(); - std::string* release_file_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_file_name(); void set_allocated_file_name(std::string* file_name); private: const std::string& _internal_file_name() const; - void _internal_set_file_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_file_name(const std::string& value); std::string* _internal_mutable_file_name(); public: @@ -219,10 +220,10 @@ inline const std::string& SourceContext::file_name() const { return _internal_file_name(); } template -PROTOBUF_ALWAYS_INLINE -inline void SourceContext::set_file_name(ArgT0&& arg0, ArgT... args) { +inline PROTOBUF_ALWAYS_INLINE +void SourceContext::set_file_name(ArgT0&& arg0, ArgT... args) { - file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name) } inline std::string* SourceContext::mutable_file_name() { @@ -234,15 +235,15 @@ inline const std::string& SourceContext::_internal_file_name() const { } inline void SourceContext::_internal_set_file_name(const std::string& value) { - file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* SourceContext::_internal_mutable_file_name() { - return file_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + return file_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* SourceContext::release_file_name() { // @@protoc_insertion_point(field_release:google.protobuf.SourceContext.file_name) - return file_name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return file_name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } inline void SourceContext::set_allocated_file_name(std::string* file_name) { if (file_name != nullptr) { @@ -251,7 +252,7 @@ inline void SourceContext::set_allocated_file_name(std::string* file_name) { } file_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), file_name, - GetArena()); + GetArenaForAllocation()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name) } diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index 1b2fbc7ae..960b29c8a 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -213,14 +213,18 @@ Struct::~Struct() { } void Struct::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void Struct::ArenaDtor(void* object) { Struct* _this = reinterpret_cast< Struct* >(object); (void)_this; + _this->fields_. ~MapField(); } -void Struct::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +inline void Struct::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena) { + if (arena != nullptr) { + arena->OwnCustomDestructor(this, &Struct::ArenaDtor); + } } void Struct::SetCachedSize(int size) const { _cached_size_.Set(size); @@ -291,6 +295,7 @@ failure: typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByDerefFirst Less; struct Utf8Check { static void Check(ConstPtr p) { + (void)p; ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( p->first.data(), static_cast(p->first.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -430,11 +435,11 @@ Value::_Internal::list_value(const Value* msg) { return *msg->kind_.list_value_; } void Value::set_allocated_struct_value(PROTOBUF_NAMESPACE_ID::Struct* struct_value) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); clear_kind(); if (struct_value) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(struct_value); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper::GetOwningArena(struct_value); if (message_arena != submessage_arena) { struct_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, struct_value, submessage_arena); @@ -445,11 +450,11 @@ void Value::set_allocated_struct_value(PROTOBUF_NAMESPACE_ID::Struct* struct_val // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.struct_value) } void Value::set_allocated_list_value(PROTOBUF_NAMESPACE_ID::ListValue* list_value) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); clear_kind(); if (list_value) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(list_value); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper::GetOwningArena(list_value); if (message_arena != submessage_arena) { list_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, list_value, submessage_arena); @@ -512,7 +517,7 @@ Value::~Value() { } void Value::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); if (has_kind()) { clear_kind(); } @@ -540,7 +545,7 @@ void Value::clear_kind() { break; } case kStringValue: { - kind_.string_value_.Destroy(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + kind_.string_value_.Destroy(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); break; } case kBoolValue: { @@ -548,13 +553,13 @@ void Value::clear_kind() { break; } case kStructValue: { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete kind_.struct_value_; } break; } case kListValue: { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete kind_.list_value_; } break; @@ -883,7 +888,7 @@ ListValue::~ListValue() { } void ListValue::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void ListValue::ArenaDtor(void* object) { diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index a51448261..31f79fadb 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -130,7 +130,7 @@ public: // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Struct PROTOBUF_FINAL : +class PROTOBUF_EXPORT Struct final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Struct) */ { public: inline Struct() : Struct(nullptr) {} @@ -148,8 +148,9 @@ class PROTOBUF_EXPORT Struct PROTOBUF_FINAL : return *this; } inline Struct& operator=(Struct&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -180,7 +181,7 @@ class PROTOBUF_EXPORT Struct PROTOBUF_FINAL : } inline void Swap(Struct* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -188,14 +189,14 @@ class PROTOBUF_EXPORT Struct PROTOBUF_FINAL : } void UnsafeArenaSwap(Struct* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline Struct* New() const final { - return CreateMaybeMessage(nullptr); + return new Struct(); } Struct* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -274,7 +275,7 @@ class PROTOBUF_EXPORT Struct PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Value PROTOBUF_FINAL : +class PROTOBUF_EXPORT Value final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Value) */ { public: inline Value() : Value(nullptr) {} @@ -292,8 +293,9 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL : return *this; } inline Value& operator=(Value&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -334,7 +336,7 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL : } inline void Swap(Value* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -342,14 +344,14 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL : } void UnsafeArenaSwap(Value* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline Value* New() const final { - return CreateMaybeMessage(nullptr); + return new Value(); } Value* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -434,11 +436,11 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL : template void set_string_value(ArgT0&& arg0, ArgT... args); std::string* mutable_string_value(); - std::string* release_string_value(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_string_value(); void set_allocated_string_value(std::string* string_value); private: const std::string& _internal_string_value() const; - void _internal_set_string_value(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_string_value(const std::string& value); std::string* _internal_mutable_string_value(); public: @@ -526,7 +528,7 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT ListValue PROTOBUF_FINAL : +class PROTOBUF_EXPORT ListValue final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ListValue) */ { public: inline ListValue() : ListValue(nullptr) {} @@ -544,8 +546,9 @@ class PROTOBUF_EXPORT ListValue PROTOBUF_FINAL : return *this; } inline ListValue& operator=(ListValue&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -576,7 +579,7 @@ class PROTOBUF_EXPORT ListValue PROTOBUF_FINAL : } inline void Swap(ListValue* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -584,14 +587,14 @@ class PROTOBUF_EXPORT ListValue PROTOBUF_FINAL : } void UnsafeArenaSwap(ListValue* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline ListValue* New() const final { - return CreateMaybeMessage(nullptr); + return new ListValue(); } ListValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -798,7 +801,7 @@ inline void Value::set_has_string_value() { } inline void Value::clear_string_value() { if (_internal_has_string_value()) { - kind_.string_value_.Destroy(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + kind_.string_value_.Destroy(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); clear_has_kind(); } } @@ -813,7 +816,7 @@ inline void Value::set_string_value(ArgT0&& arg0, ArgT... args) { set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } - kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArena()); + kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) } inline std::string* Value::mutable_string_value() { @@ -832,7 +835,7 @@ inline void Value::_internal_set_string_value(const std::string& value) { set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } - kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); + kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); } inline std::string* Value::_internal_mutable_string_value() { if (!_internal_has_string_value()) { @@ -841,13 +844,13 @@ inline std::string* Value::_internal_mutable_string_value() { kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } return kind_.string_value_.Mutable( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); } inline std::string* Value::release_string_value() { // @@protoc_insertion_point(field_release:google.protobuf.Value.string_value) if (_internal_has_string_value()) { clear_has_kind(); - return kind_.string_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return kind_.string_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); } else { return nullptr; } @@ -859,7 +862,7 @@ inline void Value::set_allocated_string_value(std::string* string_value) { if (string_value != nullptr) { set_has_string_value(); kind_.string_value_.UnsafeSetDefault(string_value); - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaForAllocation(); if (arena != nullptr) { arena->Own(string_value); } @@ -917,7 +920,7 @@ inline void Value::set_has_struct_value() { } inline void Value::clear_struct_value() { if (_internal_has_struct_value()) { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete kind_.struct_value_; } clear_has_kind(); @@ -928,7 +931,7 @@ inline PROTOBUF_NAMESPACE_ID::Struct* Value::release_struct_value() { if (_internal_has_struct_value()) { clear_has_kind(); PROTOBUF_NAMESPACE_ID::Struct* temp = kind_.struct_value_; - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } kind_.struct_value_ = nullptr; @@ -969,7 +972,7 @@ inline PROTOBUF_NAMESPACE_ID::Struct* Value::_internal_mutable_struct_value() { if (!_internal_has_struct_value()) { clear_kind(); set_has_struct_value(); - kind_.struct_value_ = CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::Struct >(GetArena()); + kind_.struct_value_ = CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::Struct >(GetArenaForAllocation()); } return kind_.struct_value_; } @@ -990,7 +993,7 @@ inline void Value::set_has_list_value() { } inline void Value::clear_list_value() { if (_internal_has_list_value()) { - if (GetArena() == nullptr) { + if (GetArenaForAllocation() == nullptr) { delete kind_.list_value_; } clear_has_kind(); @@ -1001,7 +1004,7 @@ inline PROTOBUF_NAMESPACE_ID::ListValue* Value::release_list_value() { if (_internal_has_list_value()) { clear_has_kind(); PROTOBUF_NAMESPACE_ID::ListValue* temp = kind_.list_value_; - if (GetArena() != nullptr) { + if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } kind_.list_value_ = nullptr; @@ -1042,7 +1045,7 @@ inline PROTOBUF_NAMESPACE_ID::ListValue* Value::_internal_mutable_list_value() { if (!_internal_has_list_value()) { clear_kind(); set_has_list_value(); - kind_.list_value_ = CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::ListValue >(GetArena()); + kind_.list_value_ = CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::ListValue >(GetArenaForAllocation()); } return kind_.list_value_; } diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc index f2859e94b..9067818a5 100644 --- a/src/google/protobuf/stubs/common.cc +++ b/src/google/protobuf/stubs/common.cc @@ -211,32 +211,29 @@ LogMessage& LogMessage::operator<<(const uint128& value) { return *this; } -// Since this is just for logging, we don't care if the current locale changes -// the results -- in fact, we probably prefer that. So we use snprintf() -// instead of Simple*toa(). +LogMessage& LogMessage::operator<<(char value) { + return *this << StringPiece(&value, 1); +} + +LogMessage& LogMessage::operator<<(void* value) { + StrAppend(&message_, strings::Hex(reinterpret_cast(value))); + return *this; +} + #undef DECLARE_STREAM_OPERATOR -#define DECLARE_STREAM_OPERATOR(TYPE, FORMAT) \ - LogMessage& LogMessage::operator<<(TYPE value) { \ - /* 128 bytes should be big enough for any of the primitive */ \ - /* values which we print with this, but well use snprintf() */ \ - /* anyway to be extra safe. */ \ - char buffer[128]; \ - snprintf(buffer, sizeof(buffer), FORMAT, value); \ - /* Guard against broken MSVC snprintf(). */ \ - buffer[sizeof(buffer)-1] = '\0'; \ - message_ += buffer; \ - return *this; \ +#define DECLARE_STREAM_OPERATOR(TYPE) \ + LogMessage& LogMessage::operator<<(TYPE value) { \ + StrAppend(&message_, value); \ + return *this; \ } -DECLARE_STREAM_OPERATOR(char , "%c" ) -DECLARE_STREAM_OPERATOR(int , "%d" ) -DECLARE_STREAM_OPERATOR(unsigned int , "%u" ) -DECLARE_STREAM_OPERATOR(long , "%ld") -DECLARE_STREAM_OPERATOR(unsigned long, "%lu") -DECLARE_STREAM_OPERATOR(double , "%g" ) -DECLARE_STREAM_OPERATOR(void* , "%p" ) -DECLARE_STREAM_OPERATOR(long long , "%" PROTOBUF_LL_FORMAT "d") -DECLARE_STREAM_OPERATOR(unsigned long long, "%" PROTOBUF_LL_FORMAT "u") +DECLARE_STREAM_OPERATOR(int) +DECLARE_STREAM_OPERATOR(unsigned int) +DECLARE_STREAM_OPERATOR(long) // NOLINT(runtime/int) +DECLARE_STREAM_OPERATOR(unsigned long) // NOLINT(runtime/int) +DECLARE_STREAM_OPERATOR(double) +DECLARE_STREAM_OPERATOR(long long) // NOLINT(runtime/int) +DECLARE_STREAM_OPERATOR(unsigned long long) // NOLINT(runtime/int) #undef DECLARE_STREAM_OPERATOR LogMessage::LogMessage(LogLevel level, const char* filename, int line) diff --git a/src/google/protobuf/stubs/int128.cc b/src/google/protobuf/stubs/int128.cc index 7fc7dd8c5..e5e159e1f 100644 --- a/src/google/protobuf/stubs/int128.cc +++ b/src/google/protobuf/stubs/int128.cc @@ -41,10 +41,8 @@ namespace google { namespace protobuf { -const uint128_pod kuint128max = { - static_cast(PROTOBUF_LONGLONG(0xFFFFFFFFFFFFFFFF)), - static_cast(PROTOBUF_LONGLONG(0xFFFFFFFFFFFFFFFF)) -}; +const uint128_pod kuint128max = {uint64_t{0xFFFFFFFFFFFFFFFFu}, + uint64_t{0xFFFFFFFFFFFFFFFFu}}; // Returns the 0-based position of the last set bit (i.e., most significant bit) // in the given uint64. The argument may not be 0. @@ -67,7 +65,7 @@ static inline int Fls64(uint64 n) { STEP(uint32, n32, pos, 0x10); STEP(uint32, n32, pos, 0x08); STEP(uint32, n32, pos, 0x04); - return pos + ((PROTOBUF_ULONGLONG(0x3333333322221100) >> (n32 << 2)) & 0x3); + return pos + ((uint64_t{0x3333333322221100u} >> (n32 << 2)) & 0x3); } #undef STEP @@ -134,17 +132,17 @@ std::ostream& operator<<(std::ostream& o, const uint128& b) { switch (flags & std::ios::basefield) { case std::ios::hex: div = - static_cast(PROTOBUF_ULONGLONG(0x1000000000000000)); // 16^15 + static_cast(uint64_t{0x1000000000000000u}); // 16^15 div_base_log = 15; break; case std::ios::oct: div = static_cast( - PROTOBUF_ULONGLONG(01000000000000000000000)); // 8^21 + uint64_t{01000000000000000000000u}); // 8^21 div_base_log = 21; break; default: // std::ios::dec div = static_cast( - PROTOBUF_ULONGLONG(10000000000000000000)); // 10^19 + uint64_t{10000000000000000000u}); // 10^19 div_base_log = 19; break; } diff --git a/src/google/protobuf/stubs/int128_unittest.cc b/src/google/protobuf/stubs/int128_unittest.cc index 53dbd09ec..77e41cc17 100644 --- a/src/google/protobuf/stubs/int128_unittest.cc +++ b/src/google/protobuf/stubs/int128_unittest.cc @@ -293,26 +293,20 @@ TEST(Int128, Multiply) { } // Verified with dc. - a = uint128(PROTOBUF_ULONGLONG(0xffffeeeeddddcccc), - PROTOBUF_ULONGLONG(0xbbbbaaaa99998888)); - b = uint128(PROTOBUF_ULONGLONG(0x7777666655554444), - PROTOBUF_ULONGLONG(0x3333222211110000)); + a = uint128(uint64_t{0xffffeeeeddddccccu}, uint64_t{0xbbbbaaaa99998888u}); + b = uint128(uint64_t{0x7777666655554444u}, uint64_t{0x3333222211110000u}); c = a * b; - EXPECT_EQ(uint128(PROTOBUF_ULONGLONG(0x530EDA741C71D4C3), - PROTOBUF_ULONGLONG(0xBF25975319080000)), - c); + EXPECT_EQ( + uint128(uint64_t{0x530EDA741C71D4C3u}, uint64_t{0xBF25975319080000u}), c); EXPECT_EQ(0, c - b * a); EXPECT_EQ(a * a - b * b, (a + b) * (a - b)); // Verified with dc. - a = uint128(PROTOBUF_ULONGLONG(0x0123456789abcdef), - PROTOBUF_ULONGLONG(0xfedcba9876543210)); - b = uint128(PROTOBUF_ULONGLONG(0x02468ace13579bdf), - PROTOBUF_ULONGLONG(0xfdb97531eca86420)); + a = uint128(uint64_t{0x0123456789abcdefu}, uint64_t{0xfedcba9876543210u}); + b = uint128(uint64_t{0x02468ace13579bdfu}, uint64_t{0xfdb97531eca86420u}); c = a * b; - EXPECT_EQ(uint128(PROTOBUF_ULONGLONG(0x97a87f4f261ba3f2), - PROTOBUF_ULONGLONG(0x342d0bbf48948200)), - c); + EXPECT_EQ( + uint128(uint64_t{0x97a87f4f261ba3f2u}, uint64_t{0x342d0bbf48948200u}), c); EXPECT_EQ(0, c - b * a); EXPECT_EQ(a*a - b*b, (a+b) * (a-b)); } @@ -359,10 +353,8 @@ TEST(Int128, DivideAndMod) { EXPECT_EQ(0, q); EXPECT_EQ(0, r); - a = uint128(PROTOBUF_ULONGLONG(0x530eda741c71d4c3), - PROTOBUF_ULONGLONG(0xbf25975319080000)); - q = uint128(PROTOBUF_ULONGLONG(0x4de2cab081), - PROTOBUF_ULONGLONG(0x14c34ab4676e4bab)); + a = uint128(uint64_t{0x530eda741c71d4c3u}, uint64_t{0xbf25975319080000u}); + q = uint128(uint64_t{0x4de2cab081u}, uint64_t{0x14c34ab4676e4babu}); b = uint128(0x1110001); r = uint128(0x3eb455); ASSERT_EQ(a, q * b + r); // Sanity-check. @@ -400,8 +392,8 @@ TEST(Int128, DivideAndMod) { // Try a large remainder. b = a / 2 + 1; - uint128 expected_r(PROTOBUF_ULONGLONG(0x29876d3a0e38ea61), - PROTOBUF_ULONGLONG(0xdf92cba98c83ffff)); + uint128 expected_r(uint64_t{0x29876d3a0e38ea61u}, + uint64_t{0xdf92cba98c83ffffu}); // Sanity checks. ASSERT_EQ(a / 2 - 1, expected_r); ASSERT_EQ(a, b + expected_r); @@ -471,12 +463,12 @@ TEST(Int128, OStream) { {uint128(1, 0), std::ios::oct, 0, '_', "2000000000000000000000"}, {uint128(1, 0), std::ios::hex, 0, '_', "10000000000000000"}, // just the top bit - {uint128(PROTOBUF_ULONGLONG(0x8000000000000000), 0), std::ios::dec, 0, - '_', "170141183460469231731687303715884105728"}, - {uint128(PROTOBUF_ULONGLONG(0x8000000000000000), 0), std::ios::oct, 0, - '_', "2000000000000000000000000000000000000000000"}, - {uint128(PROTOBUF_ULONGLONG(0x8000000000000000), 0), std::ios::hex, 0, - '_', "80000000000000000000000000000000"}, + {uint128(uint64_t{0x8000000000000000u}, 0), std::ios::dec, 0, '_', + "170141183460469231731687303715884105728"}, + {uint128(uint64_t{0x8000000000000000u}, 0), std::ios::oct, 0, '_', + "2000000000000000000000000000000000000000000"}, + {uint128(uint64_t{0x8000000000000000u}, 0), std::ios::hex, 0, '_', + "80000000000000000000000000000000"}, // maximum uint128 value {uint128(-1, -1), std::ios::dec, 0, '_', "340282366920938463463374607431768211455"}, diff --git a/src/google/protobuf/stubs/macros.h b/src/google/protobuf/stubs/macros.h index fcb06875f..ae9a8b987 100644 --- a/src/google/protobuf/stubs/macros.h +++ b/src/google/protobuf/stubs/macros.h @@ -35,8 +35,8 @@ namespace google { namespace protobuf { #undef GOOGLE_DISALLOW_EVIL_CONSTRUCTORS -#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName) \ - TypeName(const TypeName&) = delete; \ +#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName) \ + TypeName(const TypeName&) = delete; \ void operator=(const TypeName&) = delete #undef GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index 6badd3ff6..eec96faf3 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -136,10 +136,10 @@ typedef uint64_t uint64; static const int32 kint32max = 0x7FFFFFFF; static const int32 kint32min = -kint32max - 1; -static const int64 kint64max = PROTOBUF_LONGLONG(0x7FFFFFFFFFFFFFFF); +static const int64 kint64max = int64_t{0x7FFFFFFFFFFFFFFF}; static const int64 kint64min = -kint64max - 1; static const uint32 kuint32max = 0xFFFFFFFFu; -static const uint64 kuint64max = PROTOBUF_ULONGLONG(0xFFFFFFFFFFFFFFFF); +static const uint64 kuint64max = uint64_t{0xFFFFFFFFFFFFFFFFu}; #if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) ||\ defined(MEMORY_SANITIZER) @@ -263,14 +263,14 @@ static inline uint32 bswap_32(uint32 x) { #ifndef bswap_64 static inline uint64 bswap_64(uint64 x) { - return (((x & PROTOBUF_ULONGLONG(0xFF)) << 56) | - ((x & PROTOBUF_ULONGLONG(0xFF00)) << 40) | - ((x & PROTOBUF_ULONGLONG(0xFF0000)) << 24) | - ((x & PROTOBUF_ULONGLONG(0xFF000000)) << 8) | - ((x & PROTOBUF_ULONGLONG(0xFF00000000)) >> 8) | - ((x & PROTOBUF_ULONGLONG(0xFF0000000000)) >> 24) | - ((x & PROTOBUF_ULONGLONG(0xFF000000000000)) >> 40) | - ((x & PROTOBUF_ULONGLONG(0xFF00000000000000)) >> 56)); + return (((x & uint64_t{0xFFu)) << 56) | + ((x & uint64_t{0xFF00u)) << 40) | + ((x & uint64_t{0xFF0000u)) << 24) | + ((x & uint64_t{0xFF000000u)) << 8) | + ((x & uint64_t{0xFF00000000u)) >> 8) | + ((x & uint64_t{0xFF0000000000u)) >> 24) | + ((x & uint64_t{0xFF000000000000u)) >> 40) | + ((x & uint64_t{0xFF00000000000000u)) >> 56)); } #define bswap_64(x) bswap_64(x) #endif diff --git a/src/google/protobuf/stubs/stringpiece.cc b/src/google/protobuf/stubs/stringpiece.cc index a014d1f33..71880464c 100644 --- a/src/google/protobuf/stubs/stringpiece.cc +++ b/src/google/protobuf/stubs/stringpiece.cc @@ -46,6 +46,10 @@ std::ostream& operator<<(std::ostream& o, StringPiece piece) { return o; } +void StringPiece::LogFatalSizeTooBig(size_t size, const char* details) { + GOOGLE_LOG(FATAL) << "size too big: " << size << " details: " << details; +} + void StringPiece::CopyToString(std::string* target) const { target->assign(ptr_, length_); } @@ -71,8 +75,8 @@ bool StringPiece::ConsumeFromEnd(StringPiece x) { return false; } -StringPiece::size_type StringPiece::copy( - char* buf, size_type n, size_type pos) const { +StringPiece::size_type StringPiece::copy(char* buf, size_type n, + size_type pos) const { size_type ret = std::min(length_ - pos, n); memcpy(buf, ptr_ + pos, ret); return ret; @@ -82,8 +86,7 @@ bool StringPiece::contains(StringPiece s) const { return find(s, 0) != npos; } -StringPiece::size_type StringPiece::find( - StringPiece s, size_type pos) const { +StringPiece::size_type StringPiece::find(StringPiece s, size_type pos) const { if (length_ <= 0 || pos > static_cast(length_)) { if (length_ == 0 && pos == 0 && s.length_ == 0) return 0; return npos; @@ -116,12 +119,11 @@ StringPiece::size_type StringPiece::rfind(StringPiece s, size_type pos) const { StringPiece::size_type StringPiece::rfind(char c, size_type pos) const { // Note: memrchr() is not available on Windows. if (empty()) return npos; - for (difference_type i = - std::min(pos, static_cast(length_ - 1)); - i >= 0; --i) { + for (size_type i = std::min(pos, length_ - 1);; --i) { if (ptr_[i] == c) { return i; } + if (i == 0) break; } return npos; } @@ -143,8 +145,8 @@ static inline void BuildLookupTable(StringPiece characters_wanted, } } -StringPiece::size_type StringPiece::find_first_of( - StringPiece s, size_type pos) const { +StringPiece::size_type StringPiece::find_first_of(StringPiece s, + size_type pos) const { if (empty() || s.empty()) { return npos; } @@ -161,8 +163,8 @@ StringPiece::size_type StringPiece::find_first_of( return npos; } -StringPiece::size_type StringPiece::find_first_not_of( - StringPiece s, size_type pos) const { +StringPiece::size_type StringPiece::find_first_not_of(StringPiece s, + size_type pos) const { if (empty()) return npos; if (s.empty()) return 0; // Avoid the cost of BuildLookupTable() for a single-character search. @@ -178,8 +180,8 @@ StringPiece::size_type StringPiece::find_first_not_of( return npos; } -StringPiece::size_type StringPiece::find_first_not_of( - char c, size_type pos) const { +StringPiece::size_type StringPiece::find_first_not_of(char c, + size_type pos) const { if (empty()) return npos; for (; pos < static_cast(length_); ++pos) { @@ -190,28 +192,28 @@ StringPiece::size_type StringPiece::find_first_not_of( return npos; } -StringPiece::size_type StringPiece::find_last_of( - StringPiece s, size_type pos) const { +StringPiece::size_type StringPiece::find_last_of(StringPiece s, + size_type pos) const { if (empty() || s.empty()) return npos; // Avoid the cost of BuildLookupTable() for a single-character search. if (s.length_ == 1) return find_last_of(s.ptr_[0], pos); bool lookup[UCHAR_MAX + 1] = { false }; BuildLookupTable(s, lookup); - for (difference_type i = - std::min(pos, static_cast(length_ - 1)); i >= 0; --i) { + for (size_type i = std::min(pos, length_ - 1);; --i) { if (lookup[static_cast(ptr_[i])]) { return i; } + if (i == 0) break; } return npos; } -StringPiece::size_type StringPiece::find_last_not_of( - StringPiece s, size_type pos) const { +StringPiece::size_type StringPiece::find_last_not_of(StringPiece s, + size_type pos) const { if (empty()) return npos; - size_type i = std::min(pos, length()-1); + size_type i = std::min(pos, length() - 1); if (s.empty()) return i; // Avoid the cost of BuildLookupTable() for a single-character search. @@ -219,23 +221,24 @@ StringPiece::size_type StringPiece::find_last_not_of( bool lookup[UCHAR_MAX + 1] = { false }; BuildLookupTable(s, lookup); - for (; i >= 0; --i) { + for (;; --i) { if (!lookup[static_cast(ptr_[i])]) { return i; } + if (i == 0) break; } return npos; } -StringPiece::size_type StringPiece::find_last_not_of( - char c, size_type pos) const { +StringPiece::size_type StringPiece::find_last_not_of(char c, + size_type pos) const { if (empty()) return npos; - - for (difference_type i = - std::min(pos, static_cast(length_ - 1)); i >= 0; --i) { + size_type i = std::min(pos, length_ - 1); + for (;; --i) { if (ptr_[i] != c) { return i; } + if (i == 0) break; } return npos; } diff --git a/src/google/protobuf/stubs/stringpiece.h b/src/google/protobuf/stubs/stringpiece.h index 1e896e099..e6f5c714e 100644 --- a/src/google/protobuf/stubs/stringpiece.h +++ b/src/google/protobuf/stubs/stringpiece.h @@ -175,6 +175,23 @@ class PROTOBUF_EXPORT StringPiece { const char* ptr_; size_type length_; + static constexpr size_type kMaxSize = + (std::numeric_limits::max)(); + + static size_type CheckSize(size_type size) { +#if !defined(NDEBUG) || defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 + if (PROTOBUF_PREDICT_FALSE(size > kMaxSize)) { + // Some people grep for this message in logs + // so take care if you ever change it. + LogFatalSizeTooBig(size, "string length exceeds max size"); + } +#endif + return size; + } + + // Out-of-line error path. + static void LogFatalSizeTooBig(size_type size, const char* details); + public: // We provide non-explicit singleton constructors so users can pass // in a "const char*" or a "string" wherever a "StringPiece" is @@ -187,7 +204,7 @@ class PROTOBUF_EXPORT StringPiece { StringPiece(const char* str) // NOLINT(runtime/explicit) : ptr_(str), length_(0) { if (str != nullptr) { - length_ = strlen(str); + length_ = CheckSize(strlen(str)); } } @@ -195,11 +212,11 @@ class PROTOBUF_EXPORT StringPiece { StringPiece( // NOLINT(runtime/explicit) const std::basic_string, Allocator>& str) : ptr_(str.data()), length_(0) { - length_ = str.size(); + length_ = CheckSize(str.size()); } StringPiece(const char* offset, size_type len) - : ptr_(offset), length_(len) {} + : ptr_(offset), length_(CheckSize(len)) {} // data() may return a pointer to a buffer with embedded NULs, and the // returned buffer may or may not be null terminated. Therefore it is @@ -304,8 +321,7 @@ class PROTOBUF_EXPORT StringPiece { size_type find_last_of(char c, size_type pos = npos) const { return rfind(c, pos); } - size_type find_last_not_of(StringPiece s, - size_type pos = npos) const; + size_type find_last_not_of(StringPiece s, size_type pos = npos) const; size_type find_last_not_of(char c, size_type pos = npos) const; StringPiece substr(size_type pos, size_type n = npos) const; diff --git a/src/google/protobuf/stubs/stringpiece_unittest.cc b/src/google/protobuf/stubs/stringpiece_unittest.cc index e85a2e577..ba904cbf2 100644 --- a/src/google/protobuf/stubs/stringpiece_unittest.cc +++ b/src/google/protobuf/stubs/stringpiece_unittest.cc @@ -590,13 +590,13 @@ TEST(StringPiece, Custom) { } { - StringPiece str("foobar"); - EXPECT_TRUE(str.ConsumeFromEnd("bar")); - EXPECT_EQ(str, "foo"); - EXPECT_FALSE(str.ConsumeFromEnd("bar")); - EXPECT_FALSE(str.ConsumeFromEnd("foofoo")); - EXPECT_FALSE(str.ConsumeFromEnd("fo")); - EXPECT_EQ(str, "foo"); + StringPiece str("foobar"); + EXPECT_TRUE(str.ConsumeFromEnd("bar")); + EXPECT_EQ(str, "foo"); + EXPECT_FALSE(str.ConsumeFromEnd("bar")); + EXPECT_FALSE(str.ConsumeFromEnd("foofoo")); + EXPECT_FALSE(str.ConsumeFromEnd("fo")); + EXPECT_EQ(str, "foo"); } } @@ -685,7 +685,7 @@ TEST(FindOneCharTest, EdgeCases) { #ifdef PROTOBUF_HAS_DEATH_TEST #ifndef NDEBUG TEST(NonNegativeLenTest, NonNegativeLen) { - EXPECT_DEATH(StringPiece("xyz", -1), "len >= 0"); + EXPECT_DEATH(StringPiece("xyz", -1), "string length exceeds max size"); } #endif // ndef DEBUG #endif // PROTOBUF_HAS_DEATH_TEST diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc index 84ea62eb9..bbc581e63 100644 --- a/src/google/protobuf/stubs/strutil.cc +++ b/src/google/protobuf/stubs/strutil.cc @@ -1622,7 +1622,8 @@ int GlobalReplaceSubstring(const std::string &substring, for (StringPiece::size_type match_pos = s->find(substring.data(), pos, substring.length()); match_pos != std::string::npos; pos = match_pos + substring.length(), - match_pos = s->find(substring.data(), pos, substring.length())) { + match_pos = s->find(substring.data(), pos, + substring.length())) { ++num_replacements; // Append the original content before the match. tmp.append(*s, pos, match_pos - pos); diff --git a/src/google/protobuf/text_format_unittest.cc b/src/google/protobuf/text_format_unittest.cc index 449a78c6d..cedc92837 100644 --- a/src/google/protobuf/text_format_unittest.cc +++ b/src/google/protobuf/text_format_unittest.cc @@ -1069,13 +1069,8 @@ static std::string RemoveRedundantZeros(std::string text) { TEST_F(TextFormatTest, PrintExotic) { unittest::TestAllTypes message; - // Note: In C, a negative integer literal is actually the unary negation - // operator being applied to a positive integer literal, and - // 9223372036854775808 is outside the range of int64. However, it is not - // outside the range of uint64. Confusingly, this means that everything - // works if we make the literal unsigned, even though we are negating it. - message.add_repeated_int64(-PROTOBUF_ULONGLONG(9223372036854775808)); - message.add_repeated_uint64(PROTOBUF_ULONGLONG(18446744073709551615)); + message.add_repeated_int64(int64_t{-9223372036854775807} - 1); + message.add_repeated_uint64(uint64_t{18446744073709551615u}); message.add_repeated_double(123.456); message.add_repeated_double(1.23e21); message.add_repeated_double(1.23e-18); @@ -1240,32 +1235,19 @@ TEST_F(TextFormatTest, ParseExotic) { ASSERT_EQ(2, message.repeated_int32_size()); EXPECT_EQ(-1, message.repeated_int32(0)); - // Note: In C, a negative integer literal is actually the unary negation - // operator being applied to a positive integer literal, and 2147483648 is - // outside the range of int32. However, it is not outside the range of - // uint32. Confusingly, this means that everything works if we make the - // literal unsigned, even though we are negating it. - EXPECT_EQ(-2147483648u, message.repeated_int32(1)); + EXPECT_EQ(-2147483648, message.repeated_int32(1)); ASSERT_EQ(2, message.repeated_int64_size()); EXPECT_EQ(-1, message.repeated_int64(0)); - // Note: In C, a negative integer literal is actually the unary negation - // operator being applied to a positive integer literal, and - // 9223372036854775808 is outside the range of int64. However, it is not - // outside the range of uint64. Confusingly, this means that everything - // works if we make the literal unsigned, even though we are negating it. - EXPECT_EQ(-PROTOBUF_ULONGLONG(9223372036854775808), - message.repeated_int64(1)); + EXPECT_EQ(int64_t{-9223372036854775807} - 1, message.repeated_int64(1)); ASSERT_EQ(2, message.repeated_uint32_size()); EXPECT_EQ(4294967295u, message.repeated_uint32(0)); EXPECT_EQ(2147483648u, message.repeated_uint32(1)); ASSERT_EQ(2, message.repeated_uint64_size()); - EXPECT_EQ(PROTOBUF_ULONGLONG(18446744073709551615), - message.repeated_uint64(0)); - EXPECT_EQ(PROTOBUF_ULONGLONG(9223372036854775808), - message.repeated_uint64(1)); + EXPECT_EQ(uint64_t{18446744073709551615u}, message.repeated_uint64(0)); + EXPECT_EQ(uint64_t{9223372036854775808u}, message.repeated_uint64(1)); ASSERT_EQ(13, message.repeated_double_size()); EXPECT_EQ(123.0, message.repeated_double(0)); diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index 1828f839e..d83037e6f 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -19,7 +19,7 @@ PROTOBUF_PRAGMA_INIT_SEG PROTOBUF_NAMESPACE_OPEN constexpr Timestamp::Timestamp( ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : seconds_(PROTOBUF_LONGLONG(0)) + : seconds_(int64_t{0}) , nanos_(0){} struct TimestampDefaultTypeInternal { constexpr TimestampDefaultTypeInternal() @@ -110,7 +110,7 @@ Timestamp::~Timestamp() { } void Timestamp::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void Timestamp::ArenaDtor(void* object) { diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index 50a46c9fb..664fcda5e 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -65,7 +65,7 @@ PROTOBUF_NAMESPACE_OPEN // =================================================================== -class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL : +class PROTOBUF_EXPORT Timestamp final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Timestamp) */ { public: inline Timestamp() : Timestamp(nullptr) {} @@ -83,8 +83,9 @@ class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL : return *this; } inline Timestamp& operator=(Timestamp&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -115,7 +116,7 @@ class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL : } inline void Swap(Timestamp* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -123,14 +124,14 @@ class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL : } void UnsafeArenaSwap(Timestamp* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline Timestamp* New() const final { - return CreateMaybeMessage(nullptr); + return new Timestamp(); } Timestamp* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -218,7 +219,7 @@ class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL : // int64 seconds = 1; inline void Timestamp::clear_seconds() { - seconds_ = PROTOBUF_LONGLONG(0); + seconds_ = int64_t{0}; } inline ::PROTOBUF_NAMESPACE_ID::int64 Timestamp::_internal_seconds() const { return seconds_; diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index 214d205a6..812072189 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -343,7 +343,7 @@ Type::_Internal::source_context(const Type* msg) { return *msg->source_context_; } void Type::clear_source_context() { - if (GetArena() == nullptr && source_context_ != nullptr) { + if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) { delete source_context_; } source_context_ = nullptr; @@ -366,7 +366,7 @@ Type::Type(const Type& from) name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } if (from._internal_has_source_context()) { source_context_ = new PROTOBUF_NAMESPACE_ID::SourceContext(*from.source_context_); @@ -392,7 +392,7 @@ Type::~Type() { } void Type::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete source_context_; } @@ -417,7 +417,7 @@ void Type::Clear() { oneofs_.Clear(); options_.Clear(); name_.ClearToEmpty(); - if (GetArena() == nullptr && source_context_ != nullptr) { + if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) { delete source_context_; } source_context_ = nullptr; @@ -523,7 +523,7 @@ failure: (void) cached_has_bits; // string name = 1; - if (this->name().size() > 0) { + if (!this->name().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -612,7 +612,7 @@ size_t Type::ByteSizeLong() const { } // string name = 1; - if (this->name().size() > 0) { + if (!this->name().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_name()); @@ -665,7 +665,7 @@ void Type::MergeFrom(const Type& from) { fields_.MergeFrom(from.fields_); oneofs_.MergeFrom(from.oneofs_); options_.MergeFrom(from.options_); - if (from.name().size() > 0) { + if (!from.name().empty()) { _internal_set_name(from._internal_name()); } if (from.has_source_context()) { @@ -700,7 +700,11 @@ void Type::InternalSwap(Type* other) { fields_.InternalSwap(&other->fields_); oneofs_.InternalSwap(&other->oneofs_); options_.InternalSwap(&other->options_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(Type, syntax_) + sizeof(Type::syntax_) @@ -735,22 +739,22 @@ Field::Field(const Field& from) name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_type_url().empty()) { type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_url(), - GetArena()); + GetArenaForAllocation()); } json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_json_name().empty()) { json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_json_name(), - GetArena()); + GetArenaForAllocation()); } default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_default_value().empty()) { default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_default_value(), - GetArena()); + GetArenaForAllocation()); } ::memcpy(&kind_, &from.kind_, static_cast(reinterpret_cast(&packed_) - @@ -776,7 +780,7 @@ Field::~Field() { } void Field::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); json_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); @@ -951,7 +955,7 @@ failure: } // string name = 4; - if (this->name().size() > 0) { + if (!this->name().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -961,7 +965,7 @@ failure: } // string type_url = 6; - if (this->type_url().size() > 0) { + if (!this->type_url().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_type_url().data(), static_cast(this->_internal_type_url().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -991,7 +995,7 @@ failure: } // string json_name = 10; - if (this->json_name().size() > 0) { + if (!this->json_name().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_json_name().data(), static_cast(this->_internal_json_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -1001,7 +1005,7 @@ failure: } // string default_value = 11; - if (this->default_value().size() > 0) { + if (!this->default_value().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_default_value().data(), static_cast(this->_internal_default_value().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -1034,28 +1038,28 @@ size_t Field::ByteSizeLong() const { } // string name = 4; - if (this->name().size() > 0) { + if (!this->name().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_name()); } // string type_url = 6; - if (this->type_url().size() > 0) { + if (!this->type_url().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_type_url()); } // string json_name = 10; - if (this->json_name().size() > 0) { + if (!this->json_name().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_json_name()); } // string default_value = 11; - if (this->default_value().size() > 0) { + if (!this->default_value().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_default_value()); @@ -1124,16 +1128,16 @@ void Field::MergeFrom(const Field& from) { (void) cached_has_bits; options_.MergeFrom(from.options_); - if (from.name().size() > 0) { + if (!from.name().empty()) { _internal_set_name(from._internal_name()); } - if (from.type_url().size() > 0) { + if (!from.type_url().empty()) { _internal_set_type_url(from._internal_type_url()); } - if (from.json_name().size() > 0) { + if (!from.json_name().empty()) { _internal_set_json_name(from._internal_json_name()); } - if (from.default_value().size() > 0) { + if (!from.default_value().empty()) { _internal_set_default_value(from._internal_default_value()); } if (from.kind() != 0) { @@ -1175,10 +1179,26 @@ void Field::InternalSwap(Field* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); options_.InternalSwap(&other->options_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - type_url_.Swap(&other->type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - json_name_.Swap(&other->json_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - default_value_.Swap(&other->default_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &type_url_, GetArenaForAllocation(), + &other->type_url_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &json_name_, GetArenaForAllocation(), + &other->json_name_, other->GetArenaForAllocation() + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &default_value_, GetArenaForAllocation(), + &other->default_value_, other->GetArenaForAllocation() + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(Field, packed_) + sizeof(Field::packed_) @@ -1205,7 +1225,7 @@ Enum::_Internal::source_context(const Enum* msg) { return *msg->source_context_; } void Enum::clear_source_context() { - if (GetArena() == nullptr && source_context_ != nullptr) { + if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) { delete source_context_; } source_context_ = nullptr; @@ -1226,7 +1246,7 @@ Enum::Enum(const Enum& from) name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } if (from._internal_has_source_context()) { source_context_ = new PROTOBUF_NAMESPACE_ID::SourceContext(*from.source_context_); @@ -1252,7 +1272,7 @@ Enum::~Enum() { } void Enum::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete source_context_; } @@ -1276,7 +1296,7 @@ void Enum::Clear() { enumvalue_.Clear(); options_.Clear(); name_.ClearToEmpty(); - if (GetArena() == nullptr && source_context_ != nullptr) { + if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) { delete source_context_; } source_context_ = nullptr; @@ -1368,7 +1388,7 @@ failure: (void) cached_has_bits; // string name = 1; - if (this->name().size() > 0) { + if (!this->name().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -1439,7 +1459,7 @@ size_t Enum::ByteSizeLong() const { } // string name = 1; - if (this->name().size() > 0) { + if (!this->name().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_name()); @@ -1491,7 +1511,7 @@ void Enum::MergeFrom(const Enum& from) { enumvalue_.MergeFrom(from.enumvalue_); options_.MergeFrom(from.options_); - if (from.name().size() > 0) { + if (!from.name().empty()) { _internal_set_name(from._internal_name()); } if (from.has_source_context()) { @@ -1525,7 +1545,11 @@ void Enum::InternalSwap(Enum* other) { _internal_metadata_.InternalSwap(&other->_internal_metadata_); enumvalue_.InternalSwap(&other->enumvalue_); options_.InternalSwap(&other->options_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(Enum, syntax_) + sizeof(Enum::syntax_) @@ -1560,7 +1584,7 @@ EnumValue::EnumValue(const EnumValue& from) name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } number_ = from.number_; // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValue) @@ -1578,7 +1602,7 @@ EnumValue::~EnumValue() { } void EnumValue::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } @@ -1668,7 +1692,7 @@ failure: (void) cached_has_bits; // string name = 1; - if (this->name().size() > 0) { + if (!this->name().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -1715,7 +1739,7 @@ size_t EnumValue::ByteSizeLong() const { } // string name = 1; - if (this->name().size() > 0) { + if (!this->name().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_name()); @@ -1760,7 +1784,7 @@ void EnumValue::MergeFrom(const EnumValue& from) { (void) cached_has_bits; options_.MergeFrom(from.options_); - if (from.name().size() > 0) { + if (!from.name().empty()) { _internal_set_name(from._internal_name()); } if (from.number() != 0) { @@ -1790,7 +1814,11 @@ void EnumValue::InternalSwap(EnumValue* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); options_.InternalSwap(&other->options_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); swap(number_, other->number_); } @@ -1812,7 +1840,7 @@ Option::_Internal::value(const Option* msg) { return *msg->value_; } void Option::clear_value() { - if (GetArena() == nullptr && value_ != nullptr) { + if (GetArenaForAllocation() == nullptr && value_ != nullptr) { delete value_; } value_ = nullptr; @@ -1829,7 +1857,7 @@ Option::Option(const Option& from) name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_name().empty()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); + GetArenaForAllocation()); } if (from._internal_has_value()) { value_ = new PROTOBUF_NAMESPACE_ID::Any(*from.value_); @@ -1851,7 +1879,7 @@ Option::~Option() { } void Option::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete value_; } @@ -1873,7 +1901,7 @@ void Option::Clear() { (void) cached_has_bits; name_.ClearToEmpty(); - if (GetArena() == nullptr && value_ != nullptr) { + if (GetArenaForAllocation() == nullptr && value_ != nullptr) { delete value_; } value_ = nullptr; @@ -1932,7 +1960,7 @@ failure: (void) cached_has_bits; // string name = 1; - if (this->name().size() > 0) { + if (!this->name().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, @@ -1966,7 +1994,7 @@ size_t Option::ByteSizeLong() const { (void) cached_has_bits; // string name = 1; - if (this->name().size() > 0) { + if (!this->name().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_name()); @@ -2010,7 +2038,7 @@ void Option::MergeFrom(const Option& from) { ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; - if (from.name().size() > 0) { + if (!from.name().empty()) { _internal_set_name(from._internal_name()); } if (from.has_value()) { @@ -2039,7 +2067,11 @@ bool Option::IsInitialized() const { void Option::InternalSwap(Option* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + &name_, GetArenaForAllocation(), + &other->name_, other->GetArenaForAllocation() + ); swap(value_, other->value_); } diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index fc73c205d..8e08b182e 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -178,7 +178,7 @@ inline bool Syntax_Parse( } // =================================================================== -class PROTOBUF_EXPORT Type PROTOBUF_FINAL : +class PROTOBUF_EXPORT Type final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Type) */ { public: inline Type() : Type(nullptr) {} @@ -196,8 +196,9 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL : return *this; } inline Type& operator=(Type&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -228,7 +229,7 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL : } inline void Swap(Type* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -236,14 +237,14 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL : } void UnsafeArenaSwap(Type* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline Type* New() const final { - return CreateMaybeMessage(nullptr); + return new Type(); } Type* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -358,11 +359,11 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -411,7 +412,7 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Field PROTOBUF_FINAL : +class PROTOBUF_EXPORT Field final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Field) */ { public: inline Field() : Field(nullptr) {} @@ -429,8 +430,9 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL : return *this; } inline Field& operator=(Field&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -461,7 +463,7 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL : } inline void Swap(Field* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -469,14 +471,14 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL : } void UnsafeArenaSwap(Field* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline Field* New() const final { - return CreateMaybeMessage(nullptr); + return new Field(); } Field* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -651,11 +653,11 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -665,11 +667,11 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL : template void set_type_url(ArgT0&& arg0, ArgT... args); std::string* mutable_type_url(); - std::string* release_type_url(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_type_url(); void set_allocated_type_url(std::string* type_url); private: const std::string& _internal_type_url() const; - void _internal_set_type_url(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_type_url(const std::string& value); std::string* _internal_mutable_type_url(); public: @@ -679,11 +681,11 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL : template void set_json_name(ArgT0&& arg0, ArgT... args); std::string* mutable_json_name(); - std::string* release_json_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_json_name(); void set_allocated_json_name(std::string* json_name); private: const std::string& _internal_json_name() const; - void _internal_set_json_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_json_name(const std::string& value); std::string* _internal_mutable_json_name(); public: @@ -693,11 +695,11 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL : template void set_default_value(ArgT0&& arg0, ArgT... args); std::string* mutable_default_value(); - std::string* release_default_value(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_default_value(); void set_allocated_default_value(std::string* default_value); private: const std::string& _internal_default_value() const; - void _internal_set_default_value(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_default_value(const std::string& value); std::string* _internal_mutable_default_value(); public: @@ -768,7 +770,7 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Enum PROTOBUF_FINAL : +class PROTOBUF_EXPORT Enum final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Enum) */ { public: inline Enum() : Enum(nullptr) {} @@ -786,8 +788,9 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL : return *this; } inline Enum& operator=(Enum&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -818,7 +821,7 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL : } inline void Swap(Enum* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -826,14 +829,14 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL : } void UnsafeArenaSwap(Enum* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline Enum* New() const final { - return CreateMaybeMessage(nullptr); + return new Enum(); } Enum* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -923,11 +926,11 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -975,7 +978,7 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL : +class PROTOBUF_EXPORT EnumValue final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValue) */ { public: inline EnumValue() : EnumValue(nullptr) {} @@ -993,8 +996,9 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL : return *this; } inline EnumValue& operator=(EnumValue&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -1025,7 +1029,7 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL : } inline void Swap(EnumValue* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1033,14 +1037,14 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL : } void UnsafeArenaSwap(EnumValue* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline EnumValue* New() const final { - return CreateMaybeMessage(nullptr); + return new EnumValue(); } EnumValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { @@ -1110,11 +1114,11 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL : template void set_name(ArgT0&& arg0, ArgT... args); std::string* mutable_name(); - std::string* release_name(); + PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name(); void set_allocated_name(std::string* name); private: const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); + inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); std::string* _internal_mutable_name(); public: @@ -1142,7 +1146,7 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL : }; // ------------------------------------------------------------------- -class PROTOBUF_EXPORT Option PROTOBUF_FINAL : +class PROTOBUF_EXPORT Option final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Option) */ { public: inline Option() : Option(nullptr) {} @@ -1160,8 +1164,9 @@ class PROTOBUF_EXPORT Option PROTOBUF_FINAL : return *this; } inline Option& operator=(Option&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena()) { + InternalSwap(&from); } else { CopyFrom(from); } @@ -1192,7 +1197,7 @@ class PROTOBUF_EXPORT Option PROTOBUF_FINAL : } inline void Swap(Option* other) { if (other == this) return; - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -1200,14 +1205,14 @@ class PROTOBUF_EXPORT Option PROTOBUF_FINAL : } void UnsafeArenaSwap(Option* other) { if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } // implements Message ---------------------------------------------- inline Option* New() const final { - return CreateMaybeMessage