Merge tag 'refs/tags/sync-piper' into sync-stage

This commit is contained in:
Joshua Haberman 2021-04-30 16:12:51 -07:00
commit 535ddf1c4f
92 changed files with 3546 additions and 2803 deletions

5
benchmarks/download_data.sh Executable file
View File

@ -0,0 +1,5 @@
#! /bin/sh
curl -O https://storage.googleapis.com/protobuf_opensource_benchmark_data/datasets.tar.gz
tar -zvxf datasets.tar.gz

View File

@ -32,9 +32,9 @@ namespace Google.Protobuf.Examples.AddressBook {
"Eg4KBm51bWJlchgBIAEoCRIoCgR0eXBlGAIgASgOMhoudHV0b3JpYWwuUGVy", "Eg4KBm51bWJlchgBIAEoCRIoCgR0eXBlGAIgASgOMhoudHV0b3JpYWwuUGVy",
"c29uLlBob25lVHlwZSIrCglQaG9uZVR5cGUSCgoGTU9CSUxFEAASCAoESE9N", "c29uLlBob25lVHlwZSIrCglQaG9uZVR5cGUSCgoGTU9CSUxFEAASCAoESE9N",
"RRABEggKBFdPUksQAiIvCgtBZGRyZXNzQm9vaxIgCgZwZW9wbGUYASADKAsy", "RRABEggKBFdPUksQAiIvCgtBZGRyZXNzQm9vaxIgCgZwZW9wbGUYASADKAsy",
"EC50dXRvcmlhbC5QZXJzb25CWQobY29tLmV4YW1wbGUudHV0b3JpYWwucHJv", "EC50dXRvcmlhbC5QZXJzb25CZgobY29tLmV4YW1wbGUudHV0b3JpYWwucHJv",
"dG9zQhFBZGRyZXNzQm9va1Byb3Rvc1ABqgIkR29vZ2xlLlByb3RvYnVmLkV4", "dG9zQhFBZGRyZXNzQm9va1Byb3Rvc1ABWgsuLi90dXRvcmlhbKoCJEdvb2ds",
"YW1wbGVzLkFkZHJlc3NCb29rYgZwcm90bzM=")); "ZS5Qcm90b2J1Zi5FeGFtcGxlcy5BZGRyZXNzQm9va2IGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, }, new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {

View File

@ -724,12 +724,12 @@ public final class Descriptors {
/** Determines if the given field number is an extension. */ /** Determines if the given field number is an extension. */
public boolean isExtensionNumber(final int number) { public boolean isExtensionNumber(final int number) {
for (final DescriptorProto.ExtensionRange range : proto.getExtensionRangeList()) { int index = Arrays.binarySearch(extensionRangeLowerBounds, number);
if (range.getStart() <= number && number < range.getEnd()) { if (index < 0) {
return true; 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. */ /** Determines if the given field number is reserved. */
@ -831,6 +831,9 @@ public final class Descriptors {
private final OneofDescriptor[] oneofs; private final OneofDescriptor[] oneofs;
private final int realOneofCount; private final int realOneofCount;
private final int[] extensionRangeLowerBounds;
private final int[] extensionRangeUpperBounds;
// Used to create a placeholder when the type cannot be found. // Used to create a placeholder when the type cannot be found.
Descriptor(final String fullname) throws DescriptorValidationException { Descriptor(final String fullname) throws DescriptorValidationException {
String name = fullname; String name = fullname;
@ -859,6 +862,9 @@ public final class Descriptors {
// Create a placeholder FileDescriptor to hold this message. // Create a placeholder FileDescriptor to hold this message.
this.file = new FileDescriptor(packageName, this); this.file = new FileDescriptor(packageName, this);
extensionRangeLowerBounds = new int[] {1};
extensionRangeUpperBounds = new int[] {536870912};
} }
private Descriptor( private Descriptor(
@ -922,6 +928,20 @@ public final class Descriptors {
this.realOneofCount = this.oneofs.length - syntheticOneofCount; this.realOneofCount = this.oneofs.length - syntheticOneofCount;
file.pool.addSymbol(this); 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. */ /** Look up and cross-link all field types, etc. */

View File

@ -804,4 +804,8 @@ public class DescriptorsTest extends TestCase {
.build(); .build();
assertEquals(8, msg.getExtension(NestedExtension.MyNestedExtension.default_).intValue()); assertEquals(8, msg.getExtension(NestedExtension.MyNestedExtension.default_).intValue());
} }
public void testDefaultDescriptorExtensionRange() throws Exception {
assertTrue(new Descriptor("default").isExtensionNumber(1));
}
} }

View File

@ -224,7 +224,6 @@ describe('binaryDecoderTest', function() {
/** /**
* Verifies that misuse of the decoder class triggers assertions. * Verifies that misuse of the decoder class triggers assertions.
* @suppress {checkTypes|visibility}
*/ */
it('testDecodeErrors', function() { it('testDecodeErrors', function() {
// Reading a value past the end of the stream should trigger an assertion. // Reading a value past the end of the stream should trigger an assertion.

View File

@ -912,7 +912,7 @@ class MethodDescriptor(DescriptorBase):
self.containing_service = containing_service self.containing_service = containing_service
self.input_type = input_type self.input_type = input_type
self.output_type = output_type self.output_type = output_type
def CopyToProto(self, proto): def CopyToProto(self, proto):
"""Copies this to a descriptor_pb2.MethodDescriptorProto. """Copies this to a descriptor_pb2.MethodDescriptorProto.

View File

@ -42,6 +42,7 @@ except ImportError:
import unittest import unittest
from google.protobuf import descriptor_pb2 from google.protobuf import descriptor_pb2
from google.protobuf import descriptor
from google.protobuf import descriptor_pool from google.protobuf import descriptor_pool
from google.protobuf import proto_builder from google.protobuf import proto_builder
from google.protobuf import text_format from google.protobuf import text_format
@ -91,6 +92,23 @@ class ProtoBuilderTest(unittest.TestCase):
pool=pool) pool=pool)
self.assertIs(proto_cls1.DESCRIPTOR, proto_cls2.DESCRIPTOR) 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__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@ -31,13 +31,14 @@
"""Dynamic Protobuf class creator.""" """Dynamic Protobuf class creator."""
try: try:
from collections import OrderedDict from collections import OrderedDict
except ImportError: except ImportError:
from ordereddict import OrderedDict #PY26 from ordereddict import OrderedDict #PY26
import hashlib import hashlib
import os import os
from google.protobuf import descriptor_pb2 from google.protobuf import descriptor_pb2
from google.protobuf import descriptor
from google.protobuf import message_factory 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): for f_number, (f_name, f_type) in enumerate(field_items, 1):
field_proto = desc_proto.field.add() field_proto = desc_proto.field.add()
field_proto.name = f_name 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.number = f_number
field_proto.label = descriptor_pb2.FieldDescriptorProto.LABEL_OPTIONAL field_proto.label = descriptor_pb2.FieldDescriptorProto.LABEL_OPTIONAL
field_proto.type = f_type field_proto.type = f_type

View File

@ -379,16 +379,19 @@ static void ReorderAttached(RepeatedCompositeContainer* self,
const FieldDescriptor* descriptor = self->parent_field_descriptor; const FieldDescriptor* descriptor = self->parent_field_descriptor;
const Py_ssize_t length = Length(reinterpret_cast<PyObject*>(self)); const Py_ssize_t length = Length(reinterpret_cast<PyObject*>(self));
// Since Python protobuf objects are never arena-allocated, adding and // We need to rearrange things to match python's sort order. Because there
// removing message pointers to the underlying array is just updating // was already an O(n*log(n)) step in python and a bunch of reflection, we
// pointers. // expect an O(n**2) step in C++ won't hurt too much.
for (Py_ssize_t i = 0; i < length; ++i)
reflection->ReleaseLast(message, descriptor);
for (Py_ssize_t i = 0; i < length; ++i) { for (Py_ssize_t i = 0; i < length; ++i) {
CMessage* py_cmsg = reinterpret_cast<CMessage*>( Message* child_message =
PyList_GET_ITEM(child_list, i)); reinterpret_cast<CMessage*>(PyList_GET_ITEM(child_list, i))->message;
reflection->AddAllocatedMessage(message, descriptor, py_cmsg->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;
}
}
} }
} }

View File

@ -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.build_py import build_py as _build_py
from distutils.command.clean import clean as _clean 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 from distutils.spawn import find_executable
# Find the Protocol Compiler. # 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)] 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): class test_conformance(_build_py):
target = 'test_python' target = 'test_python'
def run(self): def run(self):
@ -322,7 +305,6 @@ if __name__ == '__main__':
cmdclass={ cmdclass={
'clean': clean, 'clean': clean,
'build_py': build_py, 'build_py': build_py,
'build_ext': build_ext,
'test_conformance': test_conformance, 'test_conformance': test_conformance,
}, },
install_requires=install_requires, install_requires=install_requires,

View File

@ -110,12 +110,12 @@ Any::Any(const Any& from)
type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_type_url().empty()) { if (!from._internal_type_url().empty()) {
type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_url(), type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_url(),
GetArena()); GetArenaForAllocation());
} }
value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_value().empty()) { if (!from._internal_value().empty()) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(), value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(),
GetArena()); GetArenaForAllocation());
} }
// @@protoc_insertion_point(copy_constructor:google.protobuf.Any) // @@protoc_insertion_point(copy_constructor:google.protobuf.Any)
} }
@ -132,7 +132,7 @@ Any::~Any() {
} }
void Any::SharedDtor() { void Any::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
} }
@ -211,7 +211,7 @@ failure:
(void) cached_has_bits; (void) cached_has_bits;
// string type_url = 1; // string type_url = 1;
if (this->type_url().size() > 0) { if (!this->type_url().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_type_url().data(), static_cast<int>(this->_internal_type_url().length()), this->_internal_type_url().data(), static_cast<int>(this->_internal_type_url().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -221,7 +221,7 @@ failure:
} }
// bytes value = 2; // bytes value = 2;
if (this->value().size() > 0) { if (!this->value().empty()) {
target = stream->WriteBytesMaybeAliased( target = stream->WriteBytesMaybeAliased(
2, this->_internal_value(), target); 2, this->_internal_value(), target);
} }
@ -243,14 +243,14 @@ size_t Any::ByteSizeLong() const {
(void) cached_has_bits; (void) cached_has_bits;
// string type_url = 1; // string type_url = 1;
if (this->type_url().size() > 0) { if (!this->type_url().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_type_url()); this->_internal_type_url());
} }
// bytes value = 2; // bytes value = 2;
if (this->value().size() > 0) { if (!this->value().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
this->_internal_value()); this->_internal_value());
@ -287,10 +287,10 @@ void Any::MergeFrom(const Any& from) {
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits; (void) cached_has_bits;
if (from.type_url().size() > 0) { if (!from.type_url().empty()) {
_internal_set_type_url(from._internal_type_url()); _internal_set_type_url(from._internal_type_url());
} }
if (from.value().size() > 0) { if (!from.value().empty()) {
_internal_set_value(from._internal_value()); _internal_set_value(from._internal_value());
} }
} }
@ -316,8 +316,16 @@ bool Any::IsInitialized() const {
void Any::InternalSwap(Any* other) { void Any::InternalSwap(Any* other) {
using std::swap; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
type_url_.Swap(&other->type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
value_.Swap(&other->value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &::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 { ::PROTOBUF_NAMESPACE_ID::Metadata Any::GetMetadata() const {

View File

@ -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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Any) */ {
public: public:
inline Any() : Any(nullptr) {} inline Any() : Any(nullptr) {}
@ -83,8 +83,9 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL :
return *this; return *this;
} }
inline Any& operator=(Any&& from) noexcept { inline Any& operator=(Any&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -148,7 +149,7 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL :
} }
inline void Swap(Any* other) { inline void Swap(Any* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -156,14 +157,14 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Any* other) { void UnsafeArenaSwap(Any* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Any* New() const final { inline Any* New() const final {
return CreateMaybeMessage<Any>(nullptr); return new Any();
} }
Any* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { Any* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -214,11 +215,11 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_type_url(ArgT0&& arg0, ArgT... args); void set_type_url(ArgT0&& arg0, ArgT... args);
std::string* mutable_type_url(); 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); void set_allocated_type_url(std::string* type_url);
private: private:
const std::string& _internal_type_url() const; 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(); std::string* _internal_mutable_type_url();
public: public:
@ -228,11 +229,11 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_value(ArgT0&& arg0, ArgT... args); void set_value(ArgT0&& arg0, ArgT... args);
std::string* mutable_value(); std::string* mutable_value();
std::string* release_value(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_value();
void set_allocated_value(std::string* value); void set_allocated_value(std::string* value);
private: private:
const std::string& _internal_value() const; 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(); std::string* _internal_mutable_value();
public: public:
@ -269,10 +270,10 @@ inline const std::string& Any::type_url() const {
return _internal_type_url(); return _internal_type_url();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Any::set_type_url(ArgT0&& arg0, ArgT... args) { void Any::set_type_url(ArgT0&& arg0, ArgT... args) {
type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Any.type_url) // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)
} }
inline std::string* Any::mutable_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) { 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() { 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() { inline std::string* Any::release_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Any.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) { inline void Any::set_allocated_type_url(std::string* type_url) {
if (type_url != nullptr) { 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, type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_url,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url) // @@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(); return _internal_value();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Any::set_value(ArgT0&& arg0, ArgT... args) { void Any::set_value(ArgT0&& arg0, ArgT... args) {
value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Any.value) // @@protoc_insertion_point(field_set:google.protobuf.Any.value)
} }
inline std::string* Any::mutable_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) { 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() { 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() { inline std::string* Any::release_value() {
// @@protoc_insertion_point(field_release:google.protobuf.Any.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) { inline void Any::set_allocated_value(std::string* value) {
if (value != nullptr) { if (value != nullptr) {
@ -346,7 +347,7 @@ inline void Any::set_allocated_value(std::string* value) {
} }
value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value)
} }

View File

@ -173,7 +173,7 @@ void Api::clear_options() {
options_.Clear(); options_.Clear();
} }
void Api::clear_source_context() { void Api::clear_source_context() {
if (GetArena() == nullptr && source_context_ != nullptr) { if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) {
delete source_context_; delete source_context_;
} }
source_context_ = nullptr; source_context_ = nullptr;
@ -196,12 +196,12 @@ Api::Api(const Api& from)
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
version_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); version_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_version().empty()) { if (!from._internal_version().empty()) {
version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_version(), version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_version(),
GetArena()); GetArenaForAllocation());
} }
if (from._internal_has_source_context()) { if (from._internal_has_source_context()) {
source_context_ = new PROTOBUF_NAMESPACE_ID::SourceContext(*from.source_context_); source_context_ = new PROTOBUF_NAMESPACE_ID::SourceContext(*from.source_context_);
@ -228,7 +228,7 @@ Api::~Api() {
} }
void Api::SharedDtor() { void Api::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
version_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); version_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete source_context_; if (this != internal_default_instance()) delete source_context_;
@ -255,7 +255,7 @@ void Api::Clear() {
mixins_.Clear(); mixins_.Clear();
name_.ClearToEmpty(); name_.ClearToEmpty();
version_.ClearToEmpty(); version_.ClearToEmpty();
if (GetArena() == nullptr && source_context_ != nullptr) { if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) {
delete source_context_; delete source_context_;
} }
source_context_ = nullptr; source_context_ = nullptr;
@ -368,7 +368,7 @@ failure:
(void) cached_has_bits; (void) cached_has_bits;
// string name = 1; // string name = 1;
if (this->name().size() > 0) { if (!this->name().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()), this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -394,7 +394,7 @@ failure:
} }
// string version = 4; // string version = 4;
if (this->version().size() > 0) { if (!this->version().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_version().data(), static_cast<int>(this->_internal_version().length()), this->_internal_version().data(), static_cast<int>(this->_internal_version().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -464,14 +464,14 @@ size_t Api::ByteSizeLong() const {
} }
// string name = 1; // string name = 1;
if (this->name().size() > 0) { if (!this->name().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_name()); this->_internal_name());
} }
// string version = 4; // string version = 4;
if (this->version().size() > 0) { if (!this->version().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_version()); this->_internal_version());
@ -524,10 +524,10 @@ void Api::MergeFrom(const Api& from) {
methods_.MergeFrom(from.methods_); methods_.MergeFrom(from.methods_);
options_.MergeFrom(from.options_); options_.MergeFrom(from.options_);
mixins_.MergeFrom(from.mixins_); mixins_.MergeFrom(from.mixins_);
if (from.name().size() > 0) { if (!from.name().empty()) {
_internal_set_name(from._internal_name()); _internal_set_name(from._internal_name());
} }
if (from.version().size() > 0) { if (!from.version().empty()) {
_internal_set_version(from._internal_version()); _internal_set_version(from._internal_version());
} }
if (from.has_source_context()) { if (from.has_source_context()) {
@ -562,8 +562,16 @@ void Api::InternalSwap(Api* other) {
methods_.InternalSwap(&other->methods_); methods_.InternalSwap(&other->methods_);
options_.InternalSwap(&other->options_); options_.InternalSwap(&other->options_);
mixins_.InternalSwap(&other->mixins_); mixins_.InternalSwap(&other->mixins_);
name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
version_.Swap(&other->version_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &::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_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(Api, syntax_) PROTOBUF_FIELD_OFFSET(Api, syntax_)
+ sizeof(Api::syntax_) + sizeof(Api::syntax_)
@ -601,17 +609,17 @@ Method::Method(const Method& from)
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
request_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); request_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_request_type_url().empty()) { if (!from._internal_request_type_url().empty()) {
request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_request_type_url(), 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()); response_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_response_type_url().empty()) { if (!from._internal_response_type_url().empty()) {
response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_response_type_url(), response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_response_type_url(),
GetArena()); GetArenaForAllocation());
} }
::memcpy(&request_streaming_, &from.request_streaming_, ::memcpy(&request_streaming_, &from.request_streaming_,
static_cast<size_t>(reinterpret_cast<char*>(&syntax_) - static_cast<size_t>(reinterpret_cast<char*>(&syntax_) -
@ -636,7 +644,7 @@ Method::~Method() {
} }
void Method::SharedDtor() { void Method::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
request_type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); request_type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
response_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; (void) cached_has_bits;
// string name = 1; // string name = 1;
if (this->name().size() > 0) { if (!this->name().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()), this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -775,7 +783,7 @@ failure:
} }
// string request_type_url = 2; // string request_type_url = 2;
if (this->request_type_url().size() > 0) { if (!this->request_type_url().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_request_type_url().data(), static_cast<int>(this->_internal_request_type_url().length()), this->_internal_request_type_url().data(), static_cast<int>(this->_internal_request_type_url().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -791,7 +799,7 @@ failure:
} }
// string response_type_url = 4; // string response_type_url = 4;
if (this->response_type_url().size() > 0) { if (!this->response_type_url().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_response_type_url().data(), static_cast<int>(this->_internal_response_type_url().length()), this->_internal_response_type_url().data(), static_cast<int>(this->_internal_response_type_url().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -845,21 +853,21 @@ size_t Method::ByteSizeLong() const {
} }
// string name = 1; // string name = 1;
if (this->name().size() > 0) { if (!this->name().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_name()); this->_internal_name());
} }
// string request_type_url = 2; // string request_type_url = 2;
if (this->request_type_url().size() > 0) { if (!this->request_type_url().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_request_type_url()); this->_internal_request_type_url());
} }
// string response_type_url = 4; // string response_type_url = 4;
if (this->response_type_url().size() > 0) { if (!this->response_type_url().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_response_type_url()); this->_internal_response_type_url());
@ -913,13 +921,13 @@ void Method::MergeFrom(const Method& from) {
(void) cached_has_bits; (void) cached_has_bits;
options_.MergeFrom(from.options_); options_.MergeFrom(from.options_);
if (from.name().size() > 0) { if (!from.name().empty()) {
_internal_set_name(from._internal_name()); _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()); _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()); _internal_set_response_type_url(from._internal_response_type_url());
} }
if (from.request_streaming() != 0) { if (from.request_streaming() != 0) {
@ -955,9 +963,21 @@ void Method::InternalSwap(Method* other) {
using std::swap; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
options_.InternalSwap(&other->options_); options_.InternalSwap(&other->options_);
name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
request_type_url_.Swap(&other->request_type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
response_type_url_.Swap(&other->response_type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &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_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(Method, syntax_) PROTOBUF_FIELD_OFFSET(Method, syntax_)
+ sizeof(Method::syntax_) + sizeof(Method::syntax_)
@ -990,12 +1010,12 @@ Mixin::Mixin(const Mixin& from)
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
root_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); root_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_root().empty()) { if (!from._internal_root().empty()) {
root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_root(), root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_root(),
GetArena()); GetArenaForAllocation());
} }
// @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin) // @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin)
} }
@ -1012,7 +1032,7 @@ Mixin::~Mixin() {
} }
void Mixin::SharedDtor() { void Mixin::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
root_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); root_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
} }
@ -1092,7 +1112,7 @@ failure:
(void) cached_has_bits; (void) cached_has_bits;
// string name = 1; // string name = 1;
if (this->name().size() > 0) { if (!this->name().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()), this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -1102,7 +1122,7 @@ failure:
} }
// string root = 2; // string root = 2;
if (this->root().size() > 0) { if (!this->root().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_root().data(), static_cast<int>(this->_internal_root().length()), this->_internal_root().data(), static_cast<int>(this->_internal_root().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -1128,14 +1148,14 @@ size_t Mixin::ByteSizeLong() const {
(void) cached_has_bits; (void) cached_has_bits;
// string name = 1; // string name = 1;
if (this->name().size() > 0) { if (!this->name().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_name()); this->_internal_name());
} }
// string root = 2; // string root = 2;
if (this->root().size() > 0) { if (!this->root().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_root()); this->_internal_root());
@ -1172,10 +1192,10 @@ void Mixin::MergeFrom(const Mixin& from) {
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits; (void) cached_has_bits;
if (from.name().size() > 0) { if (!from.name().empty()) {
_internal_set_name(from._internal_name()); _internal_set_name(from._internal_name());
} }
if (from.root().size() > 0) { if (!from.root().empty()) {
_internal_set_root(from._internal_root()); _internal_set_root(from._internal_root());
} }
} }
@ -1201,8 +1221,16 @@ bool Mixin::IsInitialized() const {
void Mixin::InternalSwap(Mixin* other) { void Mixin::InternalSwap(Mixin* other) {
using std::swap; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
root_.Swap(&other->root_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &::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 { ::PROTOBUF_NAMESPACE_ID::Metadata Mixin::GetMetadata() const {

View File

@ -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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Api) */ {
public: public:
inline Api() : Api(nullptr) {} inline Api() : Api(nullptr) {}
@ -93,8 +93,9 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
return *this; return *this;
} }
inline Api& operator=(Api&& from) noexcept { inline Api& operator=(Api&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -125,7 +126,7 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
} }
inline void Swap(Api* other) { inline void Swap(Api* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -133,14 +134,14 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Api* other) { void UnsafeArenaSwap(Api* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Api* New() const final { inline Api* New() const final {
return CreateMaybeMessage<Api>(nullptr); return new Api();
} }
Api* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { Api* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -250,11 +251,11 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_name(ArgT0&& arg0, ArgT... args); void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name(); std::string* mutable_name();
std::string* release_name(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name); void set_allocated_name(std::string* name);
private: private:
const std::string& _internal_name() const; 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(); std::string* _internal_mutable_name();
public: public:
@ -264,11 +265,11 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_version(ArgT0&& arg0, ArgT... args); void set_version(ArgT0&& arg0, ArgT... args);
std::string* mutable_version(); std::string* mutable_version();
std::string* release_version(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_version();
void set_allocated_version(std::string* version); void set_allocated_version(std::string* version);
private: private:
const std::string& _internal_version() const; 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(); std::string* _internal_mutable_version();
public: 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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Method) */ {
public: public:
inline Method() : Method(nullptr) {} inline Method() : Method(nullptr) {}
@ -336,8 +337,9 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
return *this; return *this;
} }
inline Method& operator=(Method&& from) noexcept { inline Method& operator=(Method&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -368,7 +370,7 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
} }
inline void Swap(Method* other) { inline void Swap(Method* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -376,14 +378,14 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Method* other) { void UnsafeArenaSwap(Method* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Method* New() const final { inline Method* New() const final {
return CreateMaybeMessage<Method>(nullptr); return new Method();
} }
Method* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { Method* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -457,11 +459,11 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_name(ArgT0&& arg0, ArgT... args); void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name(); std::string* mutable_name();
std::string* release_name(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name); void set_allocated_name(std::string* name);
private: private:
const std::string& _internal_name() const; 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(); std::string* _internal_mutable_name();
public: public:
@ -471,11 +473,11 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_request_type_url(ArgT0&& arg0, ArgT... args); void set_request_type_url(ArgT0&& arg0, ArgT... args);
std::string* mutable_request_type_url(); 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); void set_allocated_request_type_url(std::string* request_type_url);
private: private:
const std::string& _internal_request_type_url() const; 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(); std::string* _internal_mutable_request_type_url();
public: public:
@ -485,11 +487,11 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_response_type_url(ArgT0&& arg0, ArgT... args); void set_response_type_url(ArgT0&& arg0, ArgT... args);
std::string* mutable_response_type_url(); 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); void set_allocated_response_type_url(std::string* response_type_url);
private: private:
const std::string& _internal_response_type_url() const; 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(); std::string* _internal_mutable_response_type_url();
public: 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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Mixin) */ {
public: public:
inline Mixin() : Mixin(nullptr) {} inline Mixin() : Mixin(nullptr) {}
@ -557,8 +559,9 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
return *this; return *this;
} }
inline Mixin& operator=(Mixin&& from) noexcept { inline Mixin& operator=(Mixin&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -589,7 +592,7 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
} }
inline void Swap(Mixin* other) { inline void Swap(Mixin* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -597,14 +600,14 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Mixin* other) { void UnsafeArenaSwap(Mixin* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Mixin* New() const final { inline Mixin* New() const final {
return CreateMaybeMessage<Mixin>(nullptr); return new Mixin();
} }
Mixin* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { Mixin* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -655,11 +658,11 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_name(ArgT0&& arg0, ArgT... args); void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name(); std::string* mutable_name();
std::string* release_name(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name); void set_allocated_name(std::string* name);
private: private:
const std::string& _internal_name() const; 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(); std::string* _internal_mutable_name();
public: public:
@ -669,11 +672,11 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_root(ArgT0&& arg0, ArgT... args); void set_root(ArgT0&& arg0, ArgT... args);
std::string* mutable_root(); std::string* mutable_root();
std::string* release_root(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_root();
void set_allocated_root(std::string* root); void set_allocated_root(std::string* root);
private: private:
const std::string& _internal_root() const; 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(); std::string* _internal_mutable_root();
public: public:
@ -709,10 +712,10 @@ inline const std::string& Api::name() const {
return _internal_name(); return _internal_name();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Api::set_name(ArgT0&& arg0, ArgT... args) { void Api::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Api.name) // @@protoc_insertion_point(field_set:google.protobuf.Api.name)
} }
inline std::string* Api::mutable_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) { 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() { 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() { inline std::string* Api::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Api.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) { inline void Api::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -741,7 +744,7 @@ inline void Api::set_allocated_name(std::string* name) {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.name)
} }
@ -829,10 +832,10 @@ inline const std::string& Api::version() const {
return _internal_version(); return _internal_version();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Api::set_version(ArgT0&& arg0, ArgT... args) { void Api::set_version(ArgT0&& arg0, ArgT... args) {
version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Api.version) // @@protoc_insertion_point(field_set:google.protobuf.Api.version)
} }
inline std::string* Api::mutable_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) { 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() { 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() { inline std::string* Api::release_version() {
// @@protoc_insertion_point(field_release:google.protobuf.Api.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) { inline void Api::set_allocated_version(std::string* version) {
if (version != nullptr) { if (version != nullptr) {
@ -861,7 +864,7 @@ inline void Api::set_allocated_version(std::string* version) {
} }
version_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), version, version_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), version,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version) // @@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( inline void Api::unsafe_arena_set_allocated_source_context(
PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { PROTOBUF_NAMESPACE_ID::SourceContext* source_context) {
if (GetArena() == nullptr) { if (GetArenaForAllocation() == nullptr) {
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_);
} }
source_context_ = 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_; PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_;
source_context_ = nullptr; source_context_ = nullptr;
if (GetArena() != nullptr) { if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
} }
return 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() { inline PROTOBUF_NAMESPACE_ID::SourceContext* Api::_internal_mutable_source_context() {
if (source_context_ == nullptr) { if (source_context_ == nullptr) {
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::SourceContext>(GetArena()); auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::SourceContext>(GetArenaForAllocation());
source_context_ = p; source_context_ = p;
} }
return source_context_; return source_context_;
@ -923,13 +926,15 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Api::mutable_source_context() {
return _internal_mutable_source_context(); return _internal_mutable_source_context();
} }
inline void Api::set_allocated_source_context(PROTOBUF_NAMESPACE_ID::SourceContext* 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) { if (message_arena == nullptr) {
delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_);
} }
if (source_context) { if (source_context) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::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) { if (message_arena != submessage_arena) {
source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, source_context, submessage_arena); message_arena, source_context, submessage_arena);
@ -1014,10 +1019,10 @@ inline const std::string& Method::name() const {
return _internal_name(); return _internal_name();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Method::set_name(ArgT0&& arg0, ArgT... args) { void Method::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Method.name) // @@protoc_insertion_point(field_set:google.protobuf.Method.name)
} }
inline std::string* Method::mutable_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) { 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() { 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() { inline std::string* Method::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Method.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) { inline void Method::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -1046,7 +1051,7 @@ inline void Method::set_allocated_name(std::string* name) {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name) // @@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(); return _internal_request_type_url();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Method::set_request_type_url(ArgT0&& arg0, ArgT... args) { void Method::set_request_type_url(ArgT0&& arg0, ArgT... args) {
request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url) // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url)
} }
inline std::string* Method::mutable_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) { 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() { 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() { inline std::string* Method::release_request_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Method.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) { inline void Method::set_allocated_request_type_url(std::string* request_type_url) {
if (request_type_url != nullptr) { 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, 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) // @@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(); return _internal_response_type_url();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Method::set_response_type_url(ArgT0&& arg0, ArgT... args) { void Method::set_response_type_url(ArgT0&& arg0, ArgT... args) {
response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url) // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url)
} }
inline std::string* Method::mutable_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) { 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() { 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() { inline std::string* Method::release_response_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Method.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) { inline void Method::set_allocated_response_type_url(std::string* response_type_url) {
if (response_type_url != nullptr) { 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, 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) // @@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(); return _internal_name();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Mixin::set_name(ArgT0&& arg0, ArgT... args) { void Mixin::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.name) // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name)
} }
inline std::string* Mixin::mutable_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) { 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() { 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() { inline std::string* Mixin::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Mixin.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) { inline void Mixin::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -1281,7 +1286,7 @@ inline void Mixin::set_allocated_name(std::string* name) {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name)
} }
@ -1294,10 +1299,10 @@ inline const std::string& Mixin::root() const {
return _internal_root(); return _internal_root();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Mixin::set_root(ArgT0&& arg0, ArgT... args) { void Mixin::set_root(ArgT0&& arg0, ArgT... args) {
root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.root) // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root)
} }
inline std::string* Mixin::mutable_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) { 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() { 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() { inline std::string* Mixin::release_root() {
// @@protoc_insertion_point(field_release:google.protobuf.Mixin.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) { inline void Mixin::set_allocated_root(std::string* root) {
if (root != nullptr) { if (root != nullptr) {
@ -1326,7 +1331,7 @@ inline void Mixin::set_allocated_root(std::string* root) {
} }
root_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), root, root_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), root,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root)
} }

View File

@ -93,8 +93,8 @@ class EpsCopyInputStream; // defined in parse_context.h
template <typename Type> template <typename Type>
class GenericTypeHandler; // defined in repeated_field.h class GenericTypeHandler; // defined in repeated_field.h
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void* AlignTo(void* ptr, size_t align) { void* AlignTo(void* ptr, size_t align) {
return reinterpret_cast<void*>( return reinterpret_cast<void*>(
(reinterpret_cast<uintptr_t>(ptr) + align - 1) & (~align + 1)); (reinterpret_cast<uintptr_t>(ptr) + align - 1) & (~align + 1));
} }
@ -399,6 +399,16 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
template <typename T> template <typename T>
class InternalHelper { 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 <typename U> template <typename U>
static char DestructorSkippable(const typename U::DestructorSkippable_*); static char DestructorSkippable(const typename U::DestructorSkippable_*);
template <typename U> template <typename U>
@ -439,6 +449,10 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
return new (ptr) T(std::forward<Args>(args)...); return new (ptr) T(std::forward<Args>(args)...);
} }
static T* New() {
return new T(nullptr);
}
static Arena* GetArena(const T* p) { return p->GetArena(); } static Arena* GetArena(const T* p) { return p->GetArena(); }
friend class Arena; friend class Arena;
@ -490,7 +504,9 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
InternalHelper<T>::is_arena_constructable::value, InternalHelper<T>::is_arena_constructable::value,
"CreateMessage can only construct types that are ArenaConstructable"); "CreateMessage can only construct types that are ArenaConstructable");
if (arena == NULL) { if (arena == NULL) {
return new T(); // Generated arena constructor T(Arena*) is protected. Call via
// InternalHelper.
return InternalHelper<T>::New();
} else { } else {
return arena->DoCreateMessage<T>(); return arena->DoCreateMessage<T>();
} }
@ -678,6 +694,25 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
return nullptr; return nullptr;
} }
template <typename T>
PROTOBUF_ALWAYS_INLINE static Arena* GetOwningArena(const T* value) {
return GetOwningArenaInternal(
value, std::is_convertible<T*, MessageLite*>());
}
// Implementation for GetOwningArena(). All and only message objects have
// GetOwningArena() method.
template <typename T>
PROTOBUF_ALWAYS_INLINE static Arena* GetOwningArenaInternal(
const T* value, std::true_type) {
return InternalHelper<T>::GetOwningArena(value);
}
template <typename T>
PROTOBUF_ALWAYS_INLINE static Arena* GetOwningArenaInternal(
const T* value, std::false_type) {
return nullptr;
}
// For friends of arena. // For friends of arena.
void* AllocateAligned(size_t n, size_t align = 8) { void* AllocateAligned(size_t n, size_t align = 8) {
if (align <= 8) { if (align <= 8) {

View File

@ -223,11 +223,11 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
} }
// Basic accessors. // Basic accessors.
const std::string& Get() const PROTOBUF_NDEBUG_INLINE { PROTOBUF_NDEBUG_INLINE const std::string& Get() const {
// Unconditionally mask away the tag. // Unconditionally mask away the tag.
return *tagged_ptr_.Get(); 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. // Unconditionally mask away the tag.
return tagged_ptr_.Get(); 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 // 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 // caller retains ownership. Clears this field back to NULL state. Used to
// implement release_<field>() methods on generated classes. // implement release_<field>() methods on generated classes.
std::string* Release(const std::string* default_value, PROTOBUF_FUTURE_MUST_USE_RESULT std::string* Release(
::google::protobuf::Arena* arena); const std::string* default_value, ::google::protobuf::Arena* arena);
std::string* ReleaseNonDefault(const std::string* default_value, PROTOBUF_FUTURE_MUST_USE_RESULT std::string* ReleaseNonDefault(
::google::protobuf::Arena* arena); const std::string* default_value, ::google::protobuf::Arena* arena);
// Takes a std::string that is heap-allocated, and takes ownership. The // Takes a std::string that is heap-allocated, and takes ownership. The
// std::string's destructor is registered with the arena. Used to implement // 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 // Swaps internal pointers. Arena-safety semantics: this is guarded by the
// logic in Swap()/UnsafeArenaSwap() at the message level, so this method is // logic in Swap()/UnsafeArenaSwap() at the message level, so this method is
// 'unsafe' if called directly. // 'unsafe' if called directly.
inline void Swap(ArenaStringPtr* other, const std::string* default_value, inline PROTOBUF_NDEBUG_INLINE static void InternalSwap(
Arena* arena) PROTOBUF_NDEBUG_INLINE; const std::string* default_value, ArenaStringPtr* rhs, Arena* rhs_arena,
ArenaStringPtr* lhs, Arena* lhs_arena);
// Frees storage (if not on an arena). // Frees storage (if not on an arena).
void Destroy(const std::string* default_value, ::google::protobuf::Arena* 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<std::string*>(value)); tagged_ptr_.Set(const_cast<std::string*>(value));
} }
inline void ArenaStringPtr::Swap(ArenaStringPtr* other, inline PROTOBUF_NDEBUG_INLINE void ArenaStringPtr::InternalSwap( //
const std::string* default_value, const std::string* default_value, //
Arena* arena) { ArenaStringPtr* rhs, Arena* rhs_arena, //
#ifndef NDEBUG ArenaStringPtr* lhs, Arena* lhs_arena) {
// 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
(void)default_value; (void)default_value;
(void)arena; std::swap(lhs_arena, rhs_arena);
std::swap(tagged_ptr_, other->tagged_ptr_); 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<std::string>(arena, *old_value)
: Arena::Create<std::string>(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 #endif
} }

View File

@ -54,121 +54,100 @@ namespace protobuf {
using internal::ArenaStringPtr; using internal::ArenaStringPtr;
static std::string WrapString(const char* value) { return value; }
using EmptyDefault = ArenaStringPtr::EmptyDefault; using EmptyDefault = ArenaStringPtr::EmptyDefault;
const internal::LazyString nonempty_default{{{"default", 7}}, {nullptr}}; const internal::LazyString nonempty_default{{{"default", 7}}, {nullptr}};
const std::string* empty_default = &internal::GetEmptyString();
// Test ArenaStringPtr with arena == NULL. class SingleArena : public testing::TestWithParam<bool> {
TEST(ArenaStringPtrTest, ArenaStringPtrOnHeap) { public:
std::unique_ptr<Arena> GetArena() {
if (this->GetParam()) return nullptr;
return std::unique_ptr<Arena>(new Arena());
}
};
INSTANTIATE_TEST_SUITE_P(ArenaString, SingleArena, testing::Bool());
TEST_P(SingleArena, GetSet) {
auto arena = GetArena();
ArenaStringPtr field; ArenaStringPtr field;
const std::string* empty_default = &internal::GetEmptyString();
field.UnsafeSetDefault(empty_default); field.UnsafeSetDefault(empty_default);
EXPECT_EQ(std::string(""), field.Get()); EXPECT_EQ("", field.Get());
field.Set(empty_default, WrapString("Test short"), NULL); field.Set(empty_default, "Test short", arena.get());
EXPECT_EQ(std::string("Test short"), field.Get()); EXPECT_EQ("Test short", field.Get());
field.Set(empty_default, WrapString("Test long long long long value"), NULL); field.Set(empty_default, "Test long long long long value", arena.get());
EXPECT_EQ(std::string("Test long long long long value"), field.Get()); EXPECT_EQ("Test long long long long value", field.Get());
field.Set(empty_default, std::string(""), NULL); field.Set(empty_default, "", arena.get());
field.Destroy(empty_default, NULL); field.Destroy(empty_default, arena.get());
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);
} }
TEST(ArenaStringPtrTest, ArenaStringPtrOnArena) { TEST_P(SingleArena, MutableAccessor) {
Arena arena; auto arena = GetArena();
ArenaStringPtr field; ArenaStringPtr field;
const std::string* empty_default = &internal::GetEmptyString(); const std::string* empty_default = &internal::GetEmptyString();
field.UnsafeSetDefault(empty_default); 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; std::string* mut = field.Mutable(EmptyDefault{}, arena.get());
field2.UnsafeSetDefault(empty_default); EXPECT_EQ(mut, field.Mutable(EmptyDefault{}, arena.get()));
std::string* mut = field2.Mutable(EmptyDefault{}, &arena); EXPECT_EQ(mut, &field.Get());
EXPECT_EQ(mut, field2.Mutable(EmptyDefault{}, &arena));
EXPECT_EQ(mut, &field2.Get());
EXPECT_NE(empty_default, mut); EXPECT_NE(empty_default, mut);
EXPECT_EQ(std::string(""), *mut); EXPECT_EQ("", *mut);
*mut = "Test long long long long value"; // ensure string allocates storage *mut = "Test long long long long value"; // ensure string allocates storage
EXPECT_EQ(std::string("Test long long long long value"), field2.Get()); EXPECT_EQ("Test long long long long value", field.Get());
field2.Destroy(empty_default, &arena); field.Destroy(empty_default, arena.get());
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);
} }
TEST(ArenaStringPtrTest, ArenaStringPtrOnArenaNoSSO) { TEST_P(SingleArena, NullDefault) {
Arena arena; auto arena = GetArena();
ArenaStringPtr field; ArenaStringPtr field;
const std::string* empty_default = &internal::GetEmptyString(); field.UnsafeSetDefault(nullptr);
field.UnsafeSetDefault(empty_default); std::string* mut = field.Mutable(nonempty_default, arena.get());
EXPECT_EQ(std::string(""), field.Get()); EXPECT_EQ(mut, field.Mutable(nonempty_default, arena.get()));
EXPECT_EQ(mut, &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());
EXPECT_NE(nullptr, mut); 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 *mut = "Test long long long long value"; // ensure string allocates storage
EXPECT_EQ(std::string("Test long long long long value"), field3.Get()); EXPECT_EQ("Test long long long long value", field.Get());
field3.Destroy(nullptr, &arena); field.Destroy(nullptr, arena.get());
}
class DualArena : public testing::TestWithParam<std::tuple<bool, bool>> {
public:
std::unique_ptr<Arena> GetLhsArena() {
if (std::get<0>(this->GetParam())) return nullptr;
return std::unique_ptr<Arena>(new Arena());
}
std::unique_ptr<Arena> GetRhsArena() {
if (std::get<1>(this->GetParam())) return nullptr;
return std::unique_ptr<Arena>(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());
} }

View File

@ -108,6 +108,18 @@ bool CppGenerator::Generate(const FileDescriptor* file,
file_options.table_driven_parsing = true; file_options.table_driven_parsing = true;
} else if (options[i].first == "table_driven_serialization") { } else if (options[i].first == "table_driven_serialization") {
file_options.table_driven_serialization = true; 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 { } else {
*error = "Unknown generator option: " + options[i].first; *error = "Unknown generator option: " + options[i].first;
return false; return false;

View File

@ -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<int64_t>::min()) { if (number == std::numeric_limits<int64_t>::min()) {
// This needs to be special-cased, see explanation here: // This needs to be special-cased, see explanation here:
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661 // 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) { static std::string UInt64ToString(uint64_t number) {
return StrCat(macro_prefix, "_ULONGLONG(", number, ")"); return StrCat("uint64_t{", number, "u}");
} }
std::string DefaultValue(const FieldDescriptor* field) { std::string DefaultValue(const FieldDescriptor* field) {
switch (field->cpp_type()) { switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT64: case FieldDescriptor::CPPTYPE_INT64:
return Int64ToString("GG", field->default_value_int64()); return Int64ToString(field->default_value_int64());
case FieldDescriptor::CPPTYPE_UINT64: case FieldDescriptor::CPPTYPE_UINT64:
return UInt64ToString("GG", field->default_value_uint64()); return UInt64ToString(field->default_value_uint64());
default: default:
return DefaultValue(Options(), field); return DefaultValue(Options(), field);
} }
@ -679,9 +679,9 @@ std::string DefaultValue(const Options& options, const FieldDescriptor* field) {
case FieldDescriptor::CPPTYPE_UINT32: case FieldDescriptor::CPPTYPE_UINT32:
return StrCat(field->default_value_uint32()) + "u"; return StrCat(field->default_value_uint32()) + "u";
case FieldDescriptor::CPPTYPE_INT64: case FieldDescriptor::CPPTYPE_INT64:
return Int64ToString("PROTOBUF", field->default_value_int64()); return Int64ToString(field->default_value_int64());
case FieldDescriptor::CPPTYPE_UINT64: case FieldDescriptor::CPPTYPE_UINT64:
return UInt64ToString("PROTOBUF", field->default_value_uint64()); return UInt64ToString(field->default_value_uint64());
case FieldDescriptor::CPPTYPE_DOUBLE: { case FieldDescriptor::CPPTYPE_DOUBLE: {
double value = field->default_value_double(); double value = field->default_value_double();
if (value == std::numeric_limits<double>::infinity()) { if (value == std::numeric_limits<double>::infinity()) {

View File

@ -220,9 +220,6 @@ const char* DeclaredTypeMethodName(FieldDescriptor::Type type);
// Return the code that evaluates to the number when compiled. // Return the code that evaluates to the number when compiled.
std::string Int32ToString(int number); 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. // Get code that evaluates to the field's default value.
std::string DefaultValue(const Options& options, const FieldDescriptor* field); std::string DefaultValue(const Options& options, const FieldDescriptor* field);

View File

@ -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 cpp
} // namespace compiler } // namespace compiler
} // namespace protobuf } // namespace protobuf

View File

@ -58,6 +58,7 @@ class MapFieldGenerator : public FieldGenerator {
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
void GenerateByteSize(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const;
void GenerateConstinitInitializer(io::Printer* printer) const; void GenerateConstinitInitializer(io::Printer* printer) const;
bool GenerateArenaDestructorCode(io::Printer* printer) const override;
private: private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator);

View File

@ -215,7 +215,7 @@ bool EmitFieldNonDefaultCondition(io::Printer* printer,
// if non-zero (numeric) or non-empty (string). // if non-zero (numeric) or non-empty (string).
if (!field->is_repeated() && !field->containing_oneof()) { if (!field->is_repeated() && !field->containing_oneof()) {
if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) { 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) { } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
// Message fields still have has_$name$() methods. // Message fields still have has_$name$() methods.
format("if ($prefix$has_$name$()) {\n"); format("if ($prefix$has_$name$()) {\n");
@ -571,6 +571,7 @@ MessageGenerator::MessageGenerator(
variables_["classtype"] = QualifiedClassName(descriptor_, options); variables_["classtype"] = QualifiedClassName(descriptor_, options);
variables_["full_name"] = descriptor_->full_name(); variables_["full_name"] = descriptor_->full_name();
variables_["superclass"] = SuperClassName(descriptor_, options_); variables_["superclass"] = SuperClassName(descriptor_, options_);
SetUnknkownFieldsVariable(descriptor_, options_, &variables_);
// Compute optimized field order to be used for layout and initialization // Compute optimized field order to be used for layout and initialization
// purposes. // purposes.
@ -610,6 +611,8 @@ MessageGenerator::MessageGenerator(
} }
table_driven_ = TableDrivenParsingEnabled(descriptor_, options_); table_driven_ = TableDrivenParsingEnabled(descriptor_, options_);
parse_function_generator_.reset(new ParseFunctionGenerator(
descriptor_, max_has_bit_index_, options_, scc_analyzer_));
} }
MessageGenerator::~MessageGenerator() = default; MessageGenerator::~MessageGenerator() = default;
@ -986,9 +989,8 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) {
void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format.Set("class_final", ShouldMarkClassAsFinal(descriptor_, options_) format.Set("class_final",
? "PROTOBUF_FINAL" ShouldMarkClassAsFinal(descriptor_, options_) ? "final" : "");
: "");
if (IsMapEntryMessage(descriptor_)) { if (IsMapEntryMessage(descriptor_)) {
std::map<std::string, std::string> vars; std::map<std::string, std::string> vars;
@ -1028,7 +1030,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" }\n", " }\n",
descriptor_->field(0)->full_name()); descriptor_->field(0)->full_name());
} else { } else {
GOOGLE_CHECK_EQ(utf8_check, Utf8CheckMode::kVerify); GOOGLE_CHECK(utf8_check == Utf8CheckMode::kVerify);
format( format(
" static bool ValidateKey(std::string* s) {\n" " static bool ValidateKey(std::string* s) {\n"
"#ifndef NDEBUG\n" "#ifndef NDEBUG\n"
@ -1057,7 +1059,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" }\n", " }\n",
descriptor_->field(1)->full_name()); descriptor_->field(1)->full_name());
} else { } else {
GOOGLE_CHECK_EQ(utf8_check, Utf8CheckMode::kVerify); GOOGLE_CHECK(utf8_check == Utf8CheckMode::kVerify);
format( format(
" static bool ValidateValue(std::string* s) {\n" " static bool ValidateValue(std::string* s) {\n"
"#ifndef NDEBUG\n" "#ifndef NDEBUG\n"
@ -1109,8 +1111,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" return *this;\n" " return *this;\n"
"}\n" "}\n"
"inline $classname$& operator=($classname$&& from) noexcept {\n" "inline $classname$& operator=($classname$&& from) noexcept {\n"
" if (GetArena() == from.GetArena()) {\n" " if (this == &from) return *this;\n"
" if (this != &from) InternalSwap(&from);\n" " if (GetOwningArena() == from.GetOwningArena()) {\n"
" InternalSwap(&from);\n"
" } else {\n" " } else {\n"
" CopyFrom(from);\n" " CopyFrom(from);\n"
" }\n" " }\n"
@ -1126,9 +1129,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"\n"); "\n");
} }
std::map<std::string, std::string> vars;
SetUnknkownFieldsVariable(descriptor_, options_, &vars);
format.AddMap(vars);
if (PublicUnknownFieldsAccessors(descriptor_)) { if (PublicUnknownFieldsAccessors(descriptor_)) {
format( format(
"inline const $unknown_fields_type$& unknown_fields() const {\n" "inline const $unknown_fields_type$& unknown_fields() const {\n"
@ -1274,7 +1274,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"}\n" "}\n"
"inline void Swap($classname$* other) {\n" "inline void Swap($classname$* other) {\n"
" if (other == this) return;\n" " if (other == this) return;\n"
" if (GetArena() == other->GetArena()) {\n" " if (GetOwningArena() == other->GetOwningArena()) {\n"
" InternalSwap(other);\n" " InternalSwap(other);\n"
" } else {\n" " } else {\n"
" ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);\n" " ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);\n"
@ -1282,7 +1282,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"}\n" "}\n"
"void UnsafeArenaSwap($classname$* other) {\n" "void UnsafeArenaSwap($classname$* other) {\n"
" if (other == this) return;\n" " if (other == this) return;\n"
" $DCHK$(GetArena() == other->GetArena());\n" " $DCHK$(GetOwningArena() == other->GetOwningArena());\n"
" InternalSwap(other);\n" " InternalSwap(other);\n"
"}\n"); "}\n");
@ -1291,7 +1291,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"// implements Message ----------------------------------------------\n" "// implements Message ----------------------------------------------\n"
"\n" "\n"
"inline $classname$* New() const final {\n" "inline $classname$* New() const final {\n"
" return CreateMaybeMessage<$classname$>(nullptr);\n" " return new $classname$();\n"
"}\n" "}\n"
"\n" "\n"
"$classname$* New(::$proto_ns$::Arena* arena) const final {\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" "PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear()$ clear_final$;\n"
"bool IsInitialized() const final;\n" "bool IsInitialized() const final;\n"
"\n" "\n"
"size_t ByteSizeLong() const final;\n" "size_t ByteSizeLong() const final;\n");
"const char* _InternalParse(const char* ptr, "
"::$proto_ns$::internal::ParseContext* ctx) final;\n" parse_function_generator_->GenerateMethodDecls(printer);
format(
"$uint8$* _InternalSerialize(\n" "$uint8$* _InternalSerialize(\n"
" $uint8$* target, ::$proto_ns$::io::EpsCopyOutputStream* stream) " " $uint8$* target, ::$proto_ns$::io::EpsCopyOutputStream* stream) "
"const final;\n"); "const final;\n");
@ -1982,7 +1984,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
GenerateClear(printer); GenerateClear(printer);
format("\n"); format("\n");
GenerateMergeFromCodedStream(printer); parse_function_generator_->GenerateMethodImpls(printer);
format("\n"); format("\n");
GenerateSerializeWithCachedSizesToArray(printer); GenerateSerializeWithCachedSizesToArray(printer);
@ -2317,7 +2319,7 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) {
format("void $classname$::SharedDtor() {\n"); format("void $classname$::SharedDtor() {\n");
format.Indent(); format.Indent();
format("$DCHK$(GetArena() == nullptr);\n"); format("$DCHK$(GetArenaForAllocation() == nullptr);\n");
// Write the destructors for each field except oneof members. // Write the destructors for each field except oneof members.
// optimized_order_ does not contain oneof fields. // optimized_order_ does not contain oneof fields.
for (auto field : optimized_order_) { for (auto field : optimized_order_) {
@ -3240,24 +3242,6 @@ void MessageGenerator::GenerateCopyFrom(io::Printer* printer) {
format("}\n"); format("}\n");
} }
void MessageGenerator::GenerateMergeFromCodedStream(io::Printer* printer) {
std::map<std::string, std::string> 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( void MessageGenerator::GenerateSerializeOneofFields(
io::Printer* printer, const std::vector<const FieldDescriptor*>& fields) { io::Printer* printer, const std::vector<const FieldDescriptor*>& fields) {
Formatter format(printer, variables_); Formatter format(printer, variables_);

View File

@ -44,6 +44,7 @@
#include <google/protobuf/compiler/cpp/cpp_helpers.h> #include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/compiler/cpp/cpp_message_layout_helper.h> #include <google/protobuf/compiler/cpp/cpp_message_layout_helper.h>
#include <google/protobuf/compiler/cpp/cpp_options.h> #include <google/protobuf/compiler/cpp/cpp_options.h>
#include <google/protobuf/compiler/cpp/cpp_parse_function_generator.h>
namespace google { namespace google {
namespace protobuf { namespace protobuf {
@ -133,7 +134,6 @@ class MessageGenerator {
// Generate standard Message methods. // Generate standard Message methods.
void GenerateClear(io::Printer* printer); void GenerateClear(io::Printer* printer);
void GenerateOneofClear(io::Printer* printer); void GenerateOneofClear(io::Printer* printer);
void GenerateMergeFromCodedStream(io::Printer* printer);
void GenerateSerializeWithCachedSizes(io::Printer* printer); void GenerateSerializeWithCachedSizes(io::Printer* printer);
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer); void GenerateSerializeWithCachedSizesToArray(io::Printer* printer);
void GenerateSerializeWithCachedSizesBody(io::Printer* printer); void GenerateSerializeWithCachedSizesBody(io::Printer* printer);
@ -204,6 +204,7 @@ class MessageGenerator {
bool table_driven_; bool table_driven_;
std::unique_ptr<MessageLayoutHelper> message_layout_helper_; std::unique_ptr<MessageLayoutHelper> message_layout_helper_;
std::unique_ptr<ParseFunctionGenerator> parse_function_generator_;
MessageSCCAnalyzer* scc_analyzer_; MessageSCCAnalyzer* scc_analyzer_;

View File

@ -109,7 +109,8 @@ void MessageFieldGenerator::GenerateAccessorDeclarations(
format( format(
"$deprecated_attr$const $type$& ${1$$name$$}$() const { " "$deprecated_attr$const $type$& ${1$$name$$}$() const { "
"__builtin_trap(); }\n" "__builtin_trap(); }\n"
"$deprecated_attr$$type$* ${1$$release_name$$}$() { " "PROTOBUF_FUTURE_MUST_USE_RESULT $deprecated_attr$$type$* "
"${1$$release_name$$}$() { "
"__builtin_trap(); }\n" "__builtin_trap(); }\n"
"$deprecated_attr$$type$* ${1$mutable_$name$$}$() { " "$deprecated_attr$$type$* ${1$mutable_$name$$}$() { "
"__builtin_trap(); }\n" "__builtin_trap(); }\n"
@ -173,7 +174,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_accessor$" "$annotate_accessor$"
// If we're not on an arena, free whatever we were holding before. // 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 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" " delete reinterpret_cast<::$proto_ns$::MessageLite*>($name$_);\n"
" }\n"); " }\n");
if (implicit_weak_field_) { if (implicit_weak_field_) {
@ -198,7 +199,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
" $clear_hasbit$\n" " $clear_hasbit$\n"
" $type$* temp = $casted_member$;\n" " $type$* temp = $casted_member$;\n"
" $name$_ = nullptr;\n" " $name$_ = nullptr;\n"
" if (GetArena() != nullptr) {\n" " if (GetArenaForAllocation() != nullptr) {\n"
" temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n" " temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n"
" }\n" " }\n"
" return temp;\n" " return temp;\n"
@ -218,7 +219,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
"$type_reference_function$" "$type_reference_function$"
" $set_hasbit$\n" " $set_hasbit$\n"
" if ($name$_ == nullptr) {\n" " if ($name$_ == nullptr) {\n"
" auto* p = CreateMaybeMessage<$type$>(GetArena());\n"); " auto* p = CreateMaybeMessage<$type$>(GetArenaForAllocation());\n");
if (implicit_weak_field_) { if (implicit_weak_field_) {
format(" $name$_ = reinterpret_cast<::$proto_ns$::MessageLite*>(p);\n"); format(" $name$_ = reinterpret_cast<::$proto_ns$::MessageLite*>(p);\n");
} else { } else {
@ -239,7 +240,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
format( format(
"inline void $classname$::set_allocated_$name$($type$* $name$) {\n" "inline void $classname$::set_allocated_$name$($type$* $name$) {\n"
"$annotate_accessor$" "$annotate_accessor$"
" ::$proto_ns$::Arena* message_arena = GetArena();\n"); " ::$proto_ns$::Arena* message_arena = GetArenaForAllocation();\n");
format(" if (message_arena == nullptr) {\n"); format(" if (message_arena == nullptr) {\n");
if (IsCrossFileMessage(descriptor_)) { if (IsCrossFileMessage(descriptor_)) {
format( format(
@ -255,12 +256,15 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
// isn't defined in this file. // isn't defined in this file.
format( format(
" ::$proto_ns$::Arena* submessage_arena =\n" " ::$proto_ns$::Arena* submessage_arena =\n"
" " " ::$proto_ns$::Arena::InternalHelper<\n"
"reinterpret_cast<::$proto_ns$::MessageLite*>($name$)->GetArena();\n"); " ::$proto_ns$::MessageLite>::GetOwningArena(\n"
" reinterpret_cast<::$proto_ns$::MessageLite*>("
"$name$));\n");
} else { } else {
format( format(
" ::$proto_ns$::Arena* submessage_arena =\n" " ::$proto_ns$::Arena* submessage_arena =\n"
" ::$proto_ns$::Arena::GetArena($name$);\n"); " ::$proto_ns$::Arena::InternalHelper<$type$>::GetOwningArena("
"$name$);\n");
} }
format( format(
" if (message_arena != submessage_arena) {\n" " if (message_arena != submessage_arena) {\n"
@ -329,11 +333,12 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions(
" if ($type_default_instance_ptr$ == nullptr) {\n" " if ($type_default_instance_ptr$ == nullptr) {\n"
" msg->$name$_ = ::$proto_ns$::Arena::CreateMessage<\n" " msg->$name$_ = ::$proto_ns$::Arena::CreateMessage<\n"
" ::$proto_ns$::internal::ImplicitWeakMessage>(\n" " ::$proto_ns$::internal::ImplicitWeakMessage>(\n"
" msg->GetArena());\n" " msg->GetArenaForAllocation());\n"
" } else {\n" " } else {\n"
" msg->$name$_ = reinterpret_cast<const " " msg->$name$_ = \n"
"::$proto_ns$::MessageLite*>(\n" " reinterpret_cast<const ::$proto_ns$::MessageLite*>(\n"
" $type_default_instance_ptr$)->New(msg->GetArena());\n" " $type_default_instance_ptr$)->New(\n"
" msg->GetArenaForAllocation());\n"
" }\n" " }\n"
" }\n" " }\n"
" return msg->$name$_;\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 != // If we don't have has-bits, message presence is indicated only by ptr !=
// NULL. Thus on clear, we need to delete the object. // NULL. Thus on clear, we need to delete the object.
format( format(
"if (GetArena() == nullptr && $name$_ != nullptr) {\n" "if (GetArenaForAllocation() == nullptr && $name$_ != nullptr) {\n"
" delete $name$_;\n" " delete $name$_;\n"
"}\n" "}\n"
"$name$_ = nullptr;\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 != // If we don't have has-bits, message presence is indicated only by ptr !=
// NULL. Thus on clear, we need to delete the object. // NULL. Thus on clear, we need to delete the object.
format( format(
"if (GetArena() == nullptr && $name$_ != nullptr) {\n" "if (GetArenaForAllocation() == nullptr && $name$_ != nullptr) {\n"
" delete $name$_;\n" " delete $name$_;\n"
"}\n" "}\n"
"$name$_ = nullptr;\n"); "$name$_ = nullptr;\n");
@ -490,7 +495,7 @@ void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions(
format( format(
"void $classname$::set_allocated_$name$($type$* $name$) {\n" "void $classname$::set_allocated_$name$($type$* $name$) {\n"
"$annotate_accessor$" "$annotate_accessor$"
" ::$proto_ns$::Arena* message_arena = GetArena();\n" " ::$proto_ns$::Arena* message_arena = GetArenaForAllocation();\n"
" clear_$oneof_name$();\n" " clear_$oneof_name$();\n"
" if ($name$) {\n"); " if ($name$) {\n");
if (descriptor_->file() != descriptor_->message_type()->file()) { if (descriptor_->file() != descriptor_->message_type()->file()) {
@ -498,12 +503,15 @@ void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions(
// isn't defined in this file. // isn't defined in this file.
format( format(
" ::$proto_ns$::Arena* submessage_arena =\n" " ::$proto_ns$::Arena* submessage_arena =\n"
" " " ::$proto_ns$::Arena::InternalHelper<\n"
"reinterpret_cast<::$proto_ns$::MessageLite*>($name$)->GetArena();\n"); " ::$proto_ns$::MessageLite>::GetOwningArena(\n"
" reinterpret_cast<::$proto_ns$::MessageLite*>("
"$name$));\n");
} else { } else {
format( format(
" ::$proto_ns$::Arena* submessage_arena =\n" " ::$proto_ns$::Arena* submessage_arena =\n"
" ::$proto_ns$::Arena::GetArena($name$);\n"); " ::$proto_ns$::Arena::InternalHelper<"
"$type$>::GetOwningArena($name$);\n");
} }
format( format(
" if (message_arena != submessage_arena) {\n" " if (message_arena != submessage_arena) {\n"
@ -527,7 +535,7 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" if (_internal_has_$name$()) {\n" " if (_internal_has_$name$()) {\n"
" clear_has_$oneof_name$();\n" " clear_has_$oneof_name$();\n"
" $type$* temp = $field_member$;\n" " $type$* temp = $field_member$;\n"
" if (GetArena() != nullptr) {\n" " if (GetArenaForAllocation() != nullptr) {\n"
" temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n" " temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n"
" }\n" " }\n"
" $field_member$ = nullptr;\n" " $field_member$ = nullptr;\n"
@ -579,7 +587,8 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" if (!_internal_has_$name$()) {\n" " if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n" " clear_$oneof_name$();\n"
" set_has_$name$();\n" " set_has_$name$();\n"
" $field_member$ = CreateMaybeMessage< $type$ >(GetArena());\n" " $field_member$ = CreateMaybeMessage< $type$ "
">(GetArenaForAllocation());\n"
" }\n" " }\n"
" return $field_member$;\n" " return $field_member$;\n"
"}\n" "}\n"
@ -596,7 +605,7 @@ void MessageOneofFieldGenerator::GenerateClearingCode(
Formatter format(printer, variables_); Formatter format(printer, variables_);
format( format(
"if (GetArena() == nullptr) {\n" "if (GetArenaForAllocation() == nullptr) {\n"
" delete $field_member$;\n" " delete $field_member$;\n"
"}\n"); "}\n");
} }

View File

@ -69,6 +69,11 @@ struct Options {
std::string annotation_pragma_name; std::string annotation_pragma_name;
std::string annotation_guard_name; std::string annotation_guard_name;
const AccessInfoMap* access_info_map = nullptr; const AccessInfoMap* access_info_map = nullptr;
enum {
kTCTableNever,
kTCTableGuarded,
kTCTableAlways
} tctable_mode = kTCTableNever;
}; };
} // namespace cpp } // namespace cpp

View File

@ -31,20 +31,69 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_PARSE_FUNCTION_GENERATOR_H__ #ifndef GOOGLE_PROTOBUF_COMPILER_CPP_PARSE_FUNCTION_GENERATOR_H__
#define GOOGLE_PROTOBUF_COMPILER_CPP_PARSE_FUNCTION_GENERATOR_H__ #define GOOGLE_PROTOBUF_COMPILER_CPP_PARSE_FUNCTION_GENERATOR_H__
#include <map>
#include <string>
#include <vector>
#include <google/protobuf/compiler/cpp/cpp_helpers.h> #include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/compiler/cpp/cpp_options.h> #include <google/protobuf/compiler/cpp/cpp_options.h>
#include <google/protobuf/io/printer.h> #include <google/protobuf/io/printer.h>
#include <google/protobuf/descriptor.h> #include <google/protobuf/descriptor.h>
#include <google/protobuf/wire_format_lite.h>
namespace google { namespace google {
namespace protobuf { namespace protobuf {
namespace compiler { namespace compiler {
namespace cpp { namespace cpp {
void GenerateParseFunction(const Descriptor* descriptor, int num_hasbits, // ParseFunctionGenerator generates the _InternalParse function for a message
const Options& options, // (and any associated supporting members).
MessageSCCAnalyzer* scc_analyzer, class ParseFunctionGenerator {
io::Printer* printer); 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<const FieldDescriptor*>& ordered_fields);
const Descriptor* descriptor_;
MessageSCCAnalyzer* scc_analyzer_;
const Options& options_;
std::map<std::string, std::string> variables_;
int num_hasbits_;
};
} // namespace cpp } // namespace cpp
} // namespace compiler } // namespace compiler

View File

@ -162,14 +162,16 @@ void StringFieldGenerator::GenerateAccessorDeclarations(
descriptor_); descriptor_);
format( format(
"$deprecated_attr$std::string* ${1$mutable_$name$$}$();\n" "$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* " "$deprecated_attr$void ${1$set_allocated_$name$$}$(std::string* "
"$name$);\n", "$name$);\n",
descriptor_); descriptor_);
format( format(
"private:\n" "private:\n"
"const std::string& _internal_$name$() const;\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" "std::string* _internal_mutable_$name$();\n"
"public:\n"); "public:\n");
@ -196,12 +198,12 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
" return _internal_$name$();\n" " return _internal_$name$();\n"
"}\n" "}\n"
"template <typename ArgT0, typename... ArgT>\n" "template <typename ArgT0, typename... ArgT>\n"
"PROTOBUF_ALWAYS_INLINE\n" "inline PROTOBUF_ALWAYS_INLINE\n"
"inline void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n" "void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n"
"$annotate_accessor$" "$annotate_accessor$"
" $set_hasbit$\n" " $set_hasbit$\n"
" $name$_.$setter$($default_value_tag$, static_cast<ArgT0 &&>(arg0)," " $name$_.$setter$($default_value_tag$, static_cast<ArgT0 &&>(arg0),"
" args..., GetArena());\n" " args..., GetArenaForAllocation());\n"
" // @@protoc_insertion_point(field_set:$full_name$)\n" " // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n" "}\n"
"inline std::string* $classname$::mutable_$name$() {\n" "inline std::string* $classname$::mutable_$name$() {\n"
@ -215,12 +217,13 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
"inline void $classname$::_internal_set_$name$(const std::string& " "inline void $classname$::_internal_set_$name$(const std::string& "
"value) {\n" "value) {\n"
" $set_hasbit$\n" " $set_hasbit$\n"
" $name$_.Set($default_value_tag$, value, GetArena());\n" " $name$_.Set($default_value_tag$, value, GetArenaForAllocation());\n"
"}\n"); "}\n");
format( format(
"inline std::string* $classname$::_internal_mutable_$name$() {\n" "inline std::string* $classname$::_internal_mutable_$name$() {\n"
" $set_hasbit$\n" " $set_hasbit$\n"
" return $name$_.Mutable($default_variable_or_tag$, GetArena());\n" " return $name$_.Mutable($default_variable_or_tag$, "
"GetArenaForAllocation());\n"
"}\n" "}\n"
"inline std::string* $classname$::$release_name$() {\n" "inline std::string* $classname$::$release_name$() {\n"
"$annotate_accessor$" "$annotate_accessor$"
@ -232,9 +235,11 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
" return nullptr;\n" " return nullptr;\n"
" }\n" " }\n"
" $clear_hasbit$\n" " $clear_hasbit$\n"
" return $name$_.ReleaseNonDefault($init_value$, GetArena());\n"); " return $name$_.ReleaseNonDefault($init_value$, "
"GetArenaForAllocation());\n");
} else { } else {
format(" return $name$_.Release($init_value$, GetArena());\n"); format(
" return $name$_.Release($init_value$, GetArenaForAllocation());\n");
} }
format( format(
@ -247,7 +252,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
" $clear_hasbit$\n" " $clear_hasbit$\n"
" }\n" " }\n"
" $name$_.SetAllocated($init_value$, $name$,\n" " $name$_.SetAllocated($init_value$, $name$,\n"
" GetArena());\n" " GetArenaForAllocation());\n"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
"}\n"); "}\n");
} }
@ -268,7 +273,8 @@ void StringFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
if (descriptor_->default_value_string().empty()) { if (descriptor_->default_value_string().empty()) {
format("$name$_.ClearToEmpty();\n"); format("$name$_.ClearToEmpty();\n");
} else { } else {
format("$name$_.ClearToDefault($lazy_variable$, GetArena());\n"); format(
"$name$_.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n");
} }
} }
@ -294,7 +300,8 @@ void StringFieldGenerator::GenerateMessageClearingCode(
} else { } else {
// Clear to a non-empty default is more involved, as we try to use the // 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. // 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 { void StringFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
Formatter format(printer, variables_); 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 { void StringFieldGenerator::GenerateConstructorCode(io::Printer* printer) const {
@ -330,7 +342,7 @@ void StringFieldGenerator::GenerateCopyConstructorCode(
// TODO(gpike): improve this // TODO(gpike): improve this
format( format(
"$name$_.Set($default_value_tag$, from._internal_$name$(), \n" "$name$_.Set($default_value_tag$, from._internal_$name$(), \n"
" GetArena());\n"); " GetArenaForAllocation());\n");
format.Outdent(); format.Outdent();
format("}\n"); format("}\n");
@ -405,7 +417,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" $field_member$.UnsafeSetDefault($init_value$);\n" " $field_member$.UnsafeSetDefault($init_value$);\n"
" }\n" " }\n"
" $field_member$.$setter$($default_value_tag$," " $field_member$.$setter$($default_value_tag$,"
" static_cast<ArgT0 &&>(arg0), args..., GetArena());\n" " static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());\n"
" // @@protoc_insertion_point(field_set:$full_name$)\n" " // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n" "}\n"
"inline std::string* $classname$::mutable_$name$() {\n" "inline std::string* $classname$::mutable_$name$() {\n"
@ -426,7 +438,8 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" set_has_$name$();\n" " set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($init_value$);\n" " $field_member$.UnsafeSetDefault($init_value$);\n"
" }\n" " }\n"
" $field_member$.Set($default_value_tag$, value, GetArena());\n" " $field_member$.Set($default_value_tag$, value, "
"GetArenaForAllocation());\n"
"}\n"); "}\n");
format( format(
"inline std::string* $classname$::_internal_mutable_$name$() {\n" "inline std::string* $classname$::_internal_mutable_$name$() {\n"
@ -436,14 +449,15 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" $field_member$.UnsafeSetDefault($init_value$);\n" " $field_member$.UnsafeSetDefault($init_value$);\n"
" }\n" " }\n"
" return $field_member$.Mutable(\n" " return $field_member$.Mutable(\n"
" $default_variable_or_tag$, GetArena());\n" " $default_variable_or_tag$, GetArenaForAllocation());\n"
"}\n" "}\n"
"inline std::string* $classname$::$release_name$() {\n" "inline std::string* $classname$::$release_name$() {\n"
"$annotate_accessor$" "$annotate_accessor$"
" // @@protoc_insertion_point(field_release:$full_name$)\n" " // @@protoc_insertion_point(field_release:$full_name$)\n"
" if (_internal_has_$name$()) {\n" " if (_internal_has_$name$()) {\n"
" clear_has_$oneof_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" " } else {\n"
" return nullptr;\n" " return nullptr;\n"
" }\n" " }\n"
@ -456,7 +470,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" if ($name$ != nullptr) {\n" " if ($name$ != nullptr) {\n"
" set_has_$name$();\n" " set_has_$name$();\n"
" $field_member$.UnsafeSetDefault($name$);\n" " $field_member$.UnsafeSetDefault($name$);\n"
" ::$proto_ns$::Arena* arena = GetArena();\n" " ::$proto_ns$::Arena* arena = GetArenaForAllocation();\n"
" if (arena != nullptr) {\n" " if (arena != nullptr) {\n"
" arena->Own($name$);\n" " arena->Own($name$);\n"
" }\n" " }\n"
@ -468,7 +482,9 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
void StringOneofFieldGenerator::GenerateClearingCode( void StringOneofFieldGenerator::GenerateClearingCode(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); 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( void StringOneofFieldGenerator::GenerateMessageClearingCode(

View File

@ -205,9 +205,6 @@ TEST(GENERATED_MESSAGE_TEST_NAME, Trigraph) {
TEST(GENERATED_MESSAGE_TEST_NAME, ExtremeSmallIntegerDefault) { TEST(GENERATED_MESSAGE_TEST_NAME, ExtremeSmallIntegerDefault) {
const UNITTEST::TestExtremeDefaultValues& extreme_default = const UNITTEST::TestExtremeDefaultValues& extreme_default =
UNITTEST::TestExtremeDefaultValues::default_instance(); UNITTEST::TestExtremeDefaultValues::default_instance();
EXPECT_EQ(~0x7fffffff, std::numeric_limits<int32_t>::min());
EXPECT_EQ(PROTOBUF_LONGLONG(~0x7fffffffffffffff),
std::numeric_limits<int64_t>::min());
EXPECT_EQ(std::numeric_limits<int32_t>::min(), EXPECT_EQ(std::numeric_limits<int32_t>::min(),
extreme_default.really_small_int32()); extreme_default.really_small_int32());
EXPECT_EQ(std::numeric_limits<int64_t>::min(), EXPECT_EQ(std::numeric_limits<int64_t>::min(),

View File

@ -211,9 +211,14 @@ void ImmutableMessageGenerator::GenerateFieldAccessorTable(
" com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\n" " com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\n"
" internal_$identifier$_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 // 6 bytes per field and oneof
*bytecode_estimate += *bytecode_estimate +=
10 + 6 * descriptor_->field_count() + 6 * oneofs_.size(); 10 + 6 * descriptor_->field_count() + 6 * descriptor_->oneof_decl_count();
} }
int ImmutableMessageGenerator::GenerateFieldAccessorTableInitializer( int ImmutableMessageGenerator::GenerateFieldAccessorTableInitializer(
@ -226,6 +231,10 @@ int ImmutableMessageGenerator::GenerateFieldAccessorTableInitializer(
" new java.lang.String[] { ", " new java.lang.String[] { ",
"identifier", UniqueFileScopeIdentifier(descriptor_), "ver", "identifier", UniqueFileScopeIdentifier(descriptor_), "ver",
GeneratedCodeVersionSuffix()); 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++) { for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i); const FieldDescriptor* field = descriptor_->field(i);
const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field); const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);

View File

@ -1782,12 +1782,12 @@ bool Parser::ParseReserved(EnumDescriptorProto* message,
DO(Consume("reserved")); DO(Consume("reserved"));
if (LookingAtType(io::Tokenizer::TYPE_STRING)) { if (LookingAtType(io::Tokenizer::TYPE_STRING)) {
LocationRecorder location(message_location, LocationRecorder location(message_location,
DescriptorProto::kReservedNameFieldNumber); EnumDescriptorProto::kReservedNameFieldNumber);
location.StartAt(start_token); location.StartAt(start_token);
return ParseReservedNames(message, location); return ParseReservedNames(message, location);
} else { } else {
LocationRecorder location(message_location, LocationRecorder location(message_location,
DescriptorProto::kReservedRangeFieldNumber); EnumDescriptorProto::kReservedRangeFieldNumber);
location.StartAt(start_token); location.StartAt(start_token);
return ParseReservedNumbers(message, location); return ParseReservedNumbers(message, location);
} }

View File

@ -3139,6 +3139,43 @@ TEST_F(SourceInfoTest, EnumValues) {
EXPECT_TRUE(HasSpan(file_.enum_type(0), "name")); 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) { TEST_F(SourceInfoTest, NestedEnums) {
EXPECT_TRUE( EXPECT_TRUE(
Parse("message Foo {\n" Parse("message Foo {\n"

View File

@ -67,7 +67,7 @@ constexpr CodeGeneratorResponse::CodeGeneratorResponse(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: file_() : file_()
, error_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) , error_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
, supported_features_(PROTOBUF_ULONGLONG(0)){} , supported_features_(uint64_t{0u}){}
struct CodeGeneratorResponseDefaultTypeInternal { struct CodeGeneratorResponseDefaultTypeInternal {
constexpr CodeGeneratorResponseDefaultTypeInternal() constexpr CodeGeneratorResponseDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
@ -243,7 +243,7 @@ Version::Version(const Version& from)
suffix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); suffix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_suffix()) { if (from._internal_has_suffix()) {
suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_suffix(), suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_suffix(),
GetArena()); GetArenaForAllocation());
} }
::memcpy(&major_, &from.major_, ::memcpy(&major_, &from.major_,
static_cast<size_t>(reinterpret_cast<char*>(&patch_) - static_cast<size_t>(reinterpret_cast<char*>(&patch_) -
@ -266,7 +266,7 @@ Version::~Version() {
} }
void Version::SharedDtor() { void Version::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
suffix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); suffix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
} }
@ -518,7 +518,11 @@ void Version::InternalSwap(Version* other) {
using std::swap; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); 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_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(Version, patch_) PROTOBUF_FIELD_OFFSET(Version, patch_)
+ sizeof(Version::patch_) + sizeof(Version::patch_)
@ -571,7 +575,7 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)
parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_parameter()) { if (from._internal_has_parameter()) {
parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_parameter(), parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_parameter(),
GetArena()); GetArenaForAllocation());
} }
if (from._internal_has_compiler_version()) { if (from._internal_has_compiler_version()) {
compiler_version_ = new PROTOBUF_NAMESPACE_ID::compiler::Version(*from.compiler_version_); compiler_version_ = new PROTOBUF_NAMESPACE_ID::compiler::Version(*from.compiler_version_);
@ -593,7 +597,7 @@ CodeGeneratorRequest::~CodeGeneratorRequest() {
} }
void CodeGeneratorRequest::SharedDtor() { void CodeGeneratorRequest::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
parameter_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); parameter_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete compiler_version_; 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]); swap(_has_bits_[0], other->_has_bits_[0]);
file_to_generate_.InternalSwap(&other->file_to_generate_); file_to_generate_.InternalSwap(&other->file_to_generate_);
proto_file_.InternalSwap(&other->proto_file_); 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(),
&parameter_, GetArenaForAllocation(),
&other->parameter_, other->GetArenaForAllocation()
);
swap(compiler_version_, other->compiler_version_); swap(compiler_version_, other->compiler_version_);
} }
@ -918,17 +926,17 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_insertion_point()) { if (from._internal_has_insertion_point()) {
insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_insertion_point(), insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_insertion_point(),
GetArena()); GetArenaForAllocation());
} }
content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_content()) { if (from._internal_has_content()) {
content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_content(), content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_content(),
GetArena()); GetArenaForAllocation());
} }
if (from._internal_has_generated_code_info()) { if (from._internal_has_generated_code_info()) {
generated_code_info_ = new PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo(*from.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() { void CodeGeneratorResponse_File::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
insertion_point_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); insertion_point_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
content_.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; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
insertion_point_.Swap(&other->insertion_point_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
content_.Swap(&other->content_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &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_); swap(generated_code_info_, other->generated_code_info_);
} }
@ -1268,7 +1288,7 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_error()) { if (from._internal_has_error()) {
error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_error(), error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_error(),
GetArena()); GetArenaForAllocation());
} }
supported_features_ = from.supported_features_; supported_features_ = from.supported_features_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse) // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse)
@ -1276,7 +1296,7 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
void CodeGeneratorResponse::SharedCtor() { void CodeGeneratorResponse::SharedCtor() {
error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
supported_features_ = PROTOBUF_ULONGLONG(0); supported_features_ = uint64_t{0u};
} }
CodeGeneratorResponse::~CodeGeneratorResponse() { CodeGeneratorResponse::~CodeGeneratorResponse() {
@ -1286,7 +1306,7 @@ CodeGeneratorResponse::~CodeGeneratorResponse() {
} }
void CodeGeneratorResponse::SharedDtor() { void CodeGeneratorResponse::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
error_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); error_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
} }
@ -1311,7 +1331,7 @@ void CodeGeneratorResponse::Clear() {
if (cached_has_bits & 0x00000001u) { if (cached_has_bits & 0x00000001u) {
error_.ClearNonDefaultToEmpty(); error_.ClearNonDefaultToEmpty();
} }
supported_features_ = PROTOBUF_ULONGLONG(0); supported_features_ = uint64_t{0u};
_has_bits_.Clear(); _has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
} }
@ -1516,7 +1536,11 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
file_.InternalSwap(&other->file_); 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_); swap(supported_features_, other->supported_features_);
} }

View File

@ -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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ {
public: public:
inline Version() : Version(nullptr) {} inline Version() : Version(nullptr) {}
@ -129,8 +129,9 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL :
return *this; return *this;
} }
inline Version& operator=(Version&& from) noexcept { inline Version& operator=(Version&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -168,7 +169,7 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL :
} }
inline void Swap(Version* other) { inline void Swap(Version* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -176,14 +177,14 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Version* other) { void UnsafeArenaSwap(Version* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Version* New() const final { inline Version* New() const final {
return CreateMaybeMessage<Version>(nullptr); return new Version();
} }
Version* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { Version* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -240,11 +241,11 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_suffix(ArgT0&& arg0, ArgT... args); void set_suffix(ArgT0&& arg0, ArgT... args);
std::string* mutable_suffix(); std::string* mutable_suffix();
std::string* release_suffix(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_suffix();
void set_allocated_suffix(std::string* suffix); void set_allocated_suffix(std::string* suffix);
private: private:
const std::string& _internal_suffix() const; 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(); std::string* _internal_mutable_suffix();
public: 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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorRequest) */ {
public: public:
inline CodeGeneratorRequest() : CodeGeneratorRequest(nullptr) {} inline CodeGeneratorRequest() : CodeGeneratorRequest(nullptr) {}
@ -322,8 +323,9 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL :
return *this; return *this;
} }
inline CodeGeneratorRequest& operator=(CodeGeneratorRequest&& from) noexcept { inline CodeGeneratorRequest& operator=(CodeGeneratorRequest&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -361,7 +363,7 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL :
} }
inline void Swap(CodeGeneratorRequest* other) { inline void Swap(CodeGeneratorRequest* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -369,14 +371,14 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(CodeGeneratorRequest* other) { void UnsafeArenaSwap(CodeGeneratorRequest* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline CodeGeneratorRequest* New() const final { inline CodeGeneratorRequest* New() const final {
return CreateMaybeMessage<CodeGeneratorRequest>(nullptr); return new CodeGeneratorRequest();
} }
CodeGeneratorRequest* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { CodeGeneratorRequest* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -475,11 +477,11 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_parameter(ArgT0&& arg0, ArgT... args); void set_parameter(ArgT0&& arg0, ArgT... args);
std::string* mutable_parameter(); std::string* mutable_parameter();
std::string* release_parameter(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_parameter();
void set_allocated_parameter(std::string* parameter); void set_allocated_parameter(std::string* parameter);
private: private:
const std::string& _internal_parameter() const; 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(); std::string* _internal_mutable_parameter();
public: 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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ {
public: public:
inline CodeGeneratorResponse_File() : CodeGeneratorResponse_File(nullptr) {} inline CodeGeneratorResponse_File() : CodeGeneratorResponse_File(nullptr) {}
@ -536,8 +538,9 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
return *this; return *this;
} }
inline CodeGeneratorResponse_File& operator=(CodeGeneratorResponse_File&& from) noexcept { inline CodeGeneratorResponse_File& operator=(CodeGeneratorResponse_File&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -575,7 +578,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
} }
inline void Swap(CodeGeneratorResponse_File* other) { inline void Swap(CodeGeneratorResponse_File* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -583,14 +586,14 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(CodeGeneratorResponse_File* other) { void UnsafeArenaSwap(CodeGeneratorResponse_File* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline CodeGeneratorResponse_File* New() const final { inline CodeGeneratorResponse_File* New() const final {
return CreateMaybeMessage<CodeGeneratorResponse_File>(nullptr); return new CodeGeneratorResponse_File();
} }
CodeGeneratorResponse_File* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { CodeGeneratorResponse_File* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -647,11 +650,11 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_name(ArgT0&& arg0, ArgT... args); void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name(); std::string* mutable_name();
std::string* release_name(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name); void set_allocated_name(std::string* name);
private: private:
const std::string& _internal_name() const; 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(); std::string* _internal_mutable_name();
public: public:
@ -665,11 +668,11 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_insertion_point(ArgT0&& arg0, ArgT... args); void set_insertion_point(ArgT0&& arg0, ArgT... args);
std::string* mutable_insertion_point(); 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); void set_allocated_insertion_point(std::string* insertion_point);
private: private:
const std::string& _internal_insertion_point() const; 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(); std::string* _internal_mutable_insertion_point();
public: public:
@ -683,11 +686,11 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_content(ArgT0&& arg0, ArgT... args); void set_content(ArgT0&& arg0, ArgT... args);
std::string* mutable_content(); std::string* mutable_content();
std::string* release_content(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_content();
void set_allocated_content(std::string* content); void set_allocated_content(std::string* content);
private: private:
const std::string& _internal_content() const; 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(); std::string* _internal_mutable_content();
public: 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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ {
public: public:
inline CodeGeneratorResponse() : CodeGeneratorResponse(nullptr) {} inline CodeGeneratorResponse() : CodeGeneratorResponse(nullptr) {}
@ -744,8 +747,9 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL :
return *this; return *this;
} }
inline CodeGeneratorResponse& operator=(CodeGeneratorResponse&& from) noexcept { inline CodeGeneratorResponse& operator=(CodeGeneratorResponse&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -783,7 +787,7 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL :
} }
inline void Swap(CodeGeneratorResponse* other) { inline void Swap(CodeGeneratorResponse* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -791,14 +795,14 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(CodeGeneratorResponse* other) { void UnsafeArenaSwap(CodeGeneratorResponse* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline CodeGeneratorResponse* New() const final { inline CodeGeneratorResponse* New() const final {
return CreateMaybeMessage<CodeGeneratorResponse>(nullptr); return new CodeGeneratorResponse();
} }
CodeGeneratorResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { CodeGeneratorResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -904,11 +908,11 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_error(ArgT0&& arg0, ArgT... args); void set_error(ArgT0&& arg0, ArgT... args);
std::string* mutable_error(); std::string* mutable_error();
std::string* release_error(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_error();
void set_allocated_error(std::string* error); void set_allocated_error(std::string* error);
private: private:
const std::string& _internal_error() const; 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(); std::string* _internal_mutable_error();
public: public:
@ -1051,10 +1055,10 @@ inline const std::string& Version::suffix() const {
return _internal_suffix(); return _internal_suffix();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Version::set_suffix(ArgT0&& arg0, ArgT... args) { void Version::set_suffix(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix) // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix)
} }
inline std::string* Version::mutable_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) { inline void Version::_internal_set_suffix(const std::string& value) {
_has_bits_[0] |= 0x00000001u; _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() { inline std::string* Version::_internal_mutable_suffix() {
_has_bits_[0] |= 0x00000001u; _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() { inline std::string* Version::release_suffix() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix) // @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix)
@ -1078,7 +1082,7 @@ inline std::string* Version::release_suffix() {
return nullptr; return nullptr;
} }
_has_bits_[0] &= ~0x00000001u; _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) { inline void Version::set_allocated_suffix(std::string* suffix) {
if (suffix != nullptr) { if (suffix != nullptr) {
@ -1087,7 +1091,7 @@ inline void Version::set_allocated_suffix(std::string* suffix) {
_has_bits_[0] &= ~0x00000001u; _has_bits_[0] &= ~0x00000001u;
} }
suffix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), suffix, suffix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), suffix,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix) // @@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(); return _internal_parameter();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void CodeGeneratorRequest::set_parameter(ArgT0&& arg0, ArgT... args) { void CodeGeneratorRequest::set_parameter(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter) // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter)
} }
inline std::string* CodeGeneratorRequest::mutable_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) { inline void CodeGeneratorRequest::_internal_set_parameter(const std::string& value) {
_has_bits_[0] |= 0x00000001u; _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() { inline std::string* CodeGeneratorRequest::_internal_mutable_parameter() {
_has_bits_[0] |= 0x00000001u; _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() { inline std::string* CodeGeneratorRequest::release_parameter() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter) // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter)
@ -1213,7 +1217,7 @@ inline std::string* CodeGeneratorRequest::release_parameter() {
return nullptr; return nullptr;
} }
_has_bits_[0] &= ~0x00000001u; _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) { inline void CodeGeneratorRequest::set_allocated_parameter(std::string* parameter) {
if (parameter != nullptr) { if (parameter != nullptr) {
@ -1222,7 +1226,7 @@ inline void CodeGeneratorRequest::set_allocated_parameter(std::string* parameter
_has_bits_[0] &= ~0x00000001u; _has_bits_[0] &= ~0x00000001u;
} }
parameter_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), parameter, parameter_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), parameter,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter) // @@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( inline void CodeGeneratorRequest::unsafe_arena_set_allocated_compiler_version(
PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version) { PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version) {
if (GetArena() == nullptr) { if (GetArenaForAllocation() == nullptr) {
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(compiler_version_); delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(compiler_version_);
} }
compiler_version_ = compiler_version; compiler_version_ = compiler_version;
@ -1301,7 +1305,7 @@ inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::release_c
_has_bits_[0] &= ~0x00000002u; _has_bits_[0] &= ~0x00000002u;
PROTOBUF_NAMESPACE_ID::compiler::Version* temp = compiler_version_; PROTOBUF_NAMESPACE_ID::compiler::Version* temp = compiler_version_;
compiler_version_ = nullptr; compiler_version_ = nullptr;
if (GetArena() != nullptr) { if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
} }
return 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() { inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::_internal_mutable_compiler_version() {
_has_bits_[0] |= 0x00000002u; _has_bits_[0] |= 0x00000002u;
if (compiler_version_ == nullptr) { if (compiler_version_ == nullptr) {
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::compiler::Version>(GetArena()); auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::compiler::Version>(GetArenaForAllocation());
compiler_version_ = p; compiler_version_ = p;
} }
return compiler_version_; return compiler_version_;
@ -1326,13 +1330,13 @@ inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::mutable_c
return _internal_mutable_compiler_version(); return _internal_mutable_compiler_version();
} }
inline void CodeGeneratorRequest::set_allocated_compiler_version(PROTOBUF_NAMESPACE_ID::compiler::Version* 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) { if (message_arena == nullptr) {
delete compiler_version_; delete compiler_version_;
} }
if (compiler_version) { if (compiler_version) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
::PROTOBUF_NAMESPACE_ID::Arena::GetArena(compiler_version); ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<PROTOBUF_NAMESPACE_ID::compiler::Version>::GetOwningArena(compiler_version);
if (message_arena != submessage_arena) { if (message_arena != submessage_arena) {
compiler_version = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( compiler_version = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, compiler_version, submessage_arena); message_arena, compiler_version, submessage_arena);
@ -1366,10 +1370,10 @@ inline const std::string& CodeGeneratorResponse_File::name() const {
return _internal_name(); return _internal_name();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void CodeGeneratorResponse_File::set_name(ArgT0&& arg0, ArgT... args) { void CodeGeneratorResponse_File::set_name(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name) // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name)
} }
inline std::string* CodeGeneratorResponse_File::mutable_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) { inline void CodeGeneratorResponse_File::_internal_set_name(const std::string& value) {
_has_bits_[0] |= 0x00000001u; _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() { inline std::string* CodeGeneratorResponse_File::_internal_mutable_name() {
_has_bits_[0] |= 0x00000001u; _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() { inline std::string* CodeGeneratorResponse_File::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.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; return nullptr;
} }
_has_bits_[0] &= ~0x00000001u; _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) { inline void CodeGeneratorResponse_File::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -1402,7 +1406,7 @@ inline void CodeGeneratorResponse_File::set_allocated_name(std::string* name) {
_has_bits_[0] &= ~0x00000001u; _has_bits_[0] &= ~0x00000001u;
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name) // @@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(); return _internal_insertion_point();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void CodeGeneratorResponse_File::set_insertion_point(ArgT0&& arg0, ArgT... args) { void CodeGeneratorResponse_File::set_insertion_point(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000002u; _has_bits_[0] |= 0x00000002u;
insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
} }
inline std::string* CodeGeneratorResponse_File::mutable_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) { inline void CodeGeneratorResponse_File::_internal_set_insertion_point(const std::string& value) {
_has_bits_[0] |= 0x00000002u; _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() { inline std::string* CodeGeneratorResponse_File::_internal_mutable_insertion_point() {
_has_bits_[0] |= 0x00000002u; _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() { inline std::string* CodeGeneratorResponse_File::release_insertion_point() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.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; return nullptr;
} }
_has_bits_[0] &= ~0x00000002u; _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) { inline void CodeGeneratorResponse_File::set_allocated_insertion_point(std::string* insertion_point) {
if (insertion_point != nullptr) { if (insertion_point != nullptr) {
@ -1459,7 +1463,7 @@ inline void CodeGeneratorResponse_File::set_allocated_insertion_point(std::strin
_has_bits_[0] &= ~0x00000002u; _has_bits_[0] &= ~0x00000002u;
} }
insertion_point_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), insertion_point, 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) // @@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(); return _internal_content();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void CodeGeneratorResponse_File::set_content(ArgT0&& arg0, ArgT... args) { void CodeGeneratorResponse_File::set_content(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000004u; _has_bits_[0] |= 0x00000004u;
content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content) // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content)
} }
inline std::string* CodeGeneratorResponse_File::mutable_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) { inline void CodeGeneratorResponse_File::_internal_set_content(const std::string& value) {
_has_bits_[0] |= 0x00000004u; _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() { inline std::string* CodeGeneratorResponse_File::_internal_mutable_content() {
_has_bits_[0] |= 0x00000004u; _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() { inline std::string* CodeGeneratorResponse_File::release_content() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.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; return nullptr;
} }
_has_bits_[0] &= ~0x00000004u; _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) { inline void CodeGeneratorResponse_File::set_allocated_content(std::string* content) {
if (content != nullptr) { if (content != nullptr) {
@ -1516,7 +1520,7 @@ inline void CodeGeneratorResponse_File::set_allocated_content(std::string* conte
_has_bits_[0] &= ~0x00000004u; _has_bits_[0] &= ~0x00000004u;
} }
content_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), content, content_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), content,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) // @@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( inline void CodeGeneratorResponse_File::unsafe_arena_set_allocated_generated_code_info(
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* 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_); delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info_);
} }
generated_code_info_ = 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; _has_bits_[0] &= ~0x00000008u;
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* temp = generated_code_info_; PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* temp = generated_code_info_;
generated_code_info_ = nullptr; generated_code_info_ = nullptr;
if (GetArena() != nullptr) { if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
} }
return 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() { inline PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::_internal_mutable_generated_code_info() {
_has_bits_[0] |= 0x00000008u; _has_bits_[0] |= 0x00000008u;
if (generated_code_info_ == nullptr) { if (generated_code_info_ == nullptr) {
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo>(GetArena()); auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo>(GetArenaForAllocation());
generated_code_info_ = p; generated_code_info_ = p;
} }
return generated_code_info_; return generated_code_info_;
@ -1580,13 +1584,15 @@ inline PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::mut
return _internal_mutable_generated_code_info(); return _internal_mutable_generated_code_info();
} }
inline void CodeGeneratorResponse_File::set_allocated_generated_code_info(PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* 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) { if (message_arena == nullptr) {
delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info_); delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info_);
} }
if (generated_code_info) { if (generated_code_info) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::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) { if (message_arena != submessage_arena) {
generated_code_info = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( generated_code_info = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, generated_code_info, submessage_arena); message_arena, generated_code_info, submessage_arena);
@ -1620,10 +1626,10 @@ inline const std::string& CodeGeneratorResponse::error() const {
return _internal_error(); return _internal_error();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void CodeGeneratorResponse::set_error(ArgT0&& arg0, ArgT... args) { void CodeGeneratorResponse::set_error(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error) // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error)
} }
inline std::string* CodeGeneratorResponse::mutable_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) { inline void CodeGeneratorResponse::_internal_set_error(const std::string& value) {
_has_bits_[0] |= 0x00000001u; _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() { inline std::string* CodeGeneratorResponse::_internal_mutable_error() {
_has_bits_[0] |= 0x00000001u; _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() { inline std::string* CodeGeneratorResponse::release_error() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error) // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error)
@ -1647,7 +1653,7 @@ inline std::string* CodeGeneratorResponse::release_error() {
return nullptr; return nullptr;
} }
_has_bits_[0] &= ~0x00000001u; _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) { inline void CodeGeneratorResponse::set_allocated_error(std::string* error) {
if (error != nullptr) { if (error != nullptr) {
@ -1656,7 +1662,7 @@ inline void CodeGeneratorResponse::set_allocated_error(std::string* error) {
_has_bits_[0] &= ~0x00000001u; _has_bits_[0] &= ~0x00000001u;
} }
error_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), error, error_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), error,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error) // @@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(); return _internal_has_supported_features();
} }
inline void CodeGeneratorResponse::clear_supported_features() { inline void CodeGeneratorResponse::clear_supported_features() {
supported_features_ = PROTOBUF_ULONGLONG(0); supported_features_ = uint64_t{0u};
_has_bits_[0] &= ~0x00000002u; _has_bits_[0] &= ~0x00000002u;
} }
inline ::PROTOBUF_NAMESPACE_ID::uint64 CodeGeneratorResponse::_internal_supported_features() const { inline ::PROTOBUF_NAMESPACE_ID::uint64 CodeGeneratorResponse::_internal_supported_features() const {

View File

@ -378,8 +378,8 @@ constexpr UninterpretedOption::UninterpretedOption(
, identifier_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) , identifier_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
, string_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) , aggregate_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
, positive_int_value_(PROTOBUF_ULONGLONG(0)) , positive_int_value_(uint64_t{0u})
, negative_int_value_(PROTOBUF_LONGLONG(0)) , negative_int_value_(int64_t{0})
, double_value_(0){} , double_value_(0){}
struct UninterpretedOptionDefaultTypeInternal { struct UninterpretedOptionDefaultTypeInternal {
constexpr UninterpretedOptionDefaultTypeInternal() constexpr UninterpretedOptionDefaultTypeInternal()
@ -1262,7 +1262,7 @@ FileDescriptorSet::~FileDescriptorSet() {
} }
void FileDescriptorSet::SharedDtor() { void FileDescriptorSet::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void FileDescriptorSet::ArenaDtor(void* object) { void FileDescriptorSet::ArenaDtor(void* object) {
@ -1487,17 +1487,17 @@ FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from)
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_package()) { if (from._internal_has_package()) {
package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_package(), package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_package(),
GetArena()); GetArenaForAllocation());
} }
syntax_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); syntax_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_syntax()) { if (from._internal_has_syntax()) {
syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_syntax(), syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_syntax(),
GetArena()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
options_ = new PROTOBUF_NAMESPACE_ID::FileOptions(*from.options_); options_ = new PROTOBUF_NAMESPACE_ID::FileOptions(*from.options_);
@ -1529,7 +1529,7 @@ FileDescriptorProto::~FileDescriptorProto() {
} }
void FileDescriptorProto::SharedDtor() { void FileDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
syntax_.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_); extension_.InternalSwap(&other->extension_);
public_dependency_.InternalSwap(&other->public_dependency_); public_dependency_.InternalSwap(&other->public_dependency_);
weak_dependency_.InternalSwap(&other->weak_dependency_); weak_dependency_.InternalSwap(&other->weak_dependency_);
name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
package_.Swap(&other->package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
syntax_.Swap(&other->syntax_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &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_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(FileDescriptorProto, source_code_info_) PROTOBUF_FIELD_OFFSET(FileDescriptorProto, source_code_info_)
+ sizeof(FileDescriptorProto::source_code_info_) + sizeof(FileDescriptorProto::source_code_info_)
@ -2138,7 +2150,7 @@ DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() {
} }
void DescriptorProto_ExtensionRange::SharedDtor() { void DescriptorProto_ExtensionRange::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
if (this != internal_default_instance()) delete options_; if (this != internal_default_instance()) delete options_;
} }
@ -2421,7 +2433,7 @@ DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() {
} }
void DescriptorProto_ReservedRange::SharedDtor() { void DescriptorProto_ReservedRange::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void DescriptorProto_ReservedRange::ArenaDtor(void* object) { void DescriptorProto_ReservedRange::ArenaDtor(void* object) {
@ -2675,7 +2687,7 @@ DescriptorProto::DescriptorProto(const DescriptorProto& from)
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
options_ = new PROTOBUF_NAMESPACE_ID::MessageOptions(*from.options_); options_ = new PROTOBUF_NAMESPACE_ID::MessageOptions(*from.options_);
@ -2697,7 +2709,7 @@ DescriptorProto::~DescriptorProto() {
} }
void DescriptorProto::SharedDtor() { void DescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete options_; if (this != internal_default_instance()) delete options_;
} }
@ -3159,7 +3171,11 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) {
oneof_decl_.InternalSwap(&other->oneof_decl_); oneof_decl_.InternalSwap(&other->oneof_decl_);
reserved_range_.InternalSwap(&other->reserved_range_); reserved_range_.InternalSwap(&other->reserved_range_);
reserved_name_.InternalSwap(&other->reserved_name_); 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_); swap(options_, other->options_);
} }
@ -3201,7 +3217,7 @@ ExtensionRangeOptions::~ExtensionRangeOptions() {
} }
void ExtensionRangeOptions::SharedDtor() { void ExtensionRangeOptions::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void ExtensionRangeOptions::ArenaDtor(void* object) { void ExtensionRangeOptions::ArenaDtor(void* object) {
@ -3444,27 +3460,27 @@ FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from)
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
extendee_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); extendee_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_extendee()) { if (from._internal_has_extendee()) {
extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_extendee(), extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_extendee(),
GetArena()); GetArenaForAllocation());
} }
type_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); type_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_type_name()) { if (from._internal_has_type_name()) {
type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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()); default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_default_value()) { if (from._internal_has_default_value()) {
default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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()); json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_json_name()) { if (from._internal_has_json_name()) {
json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_json_name(), json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_json_name(),
GetArena()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
options_ = new PROTOBUF_NAMESPACE_ID::FieldOptions(*from.options_); options_ = new PROTOBUF_NAMESPACE_ID::FieldOptions(*from.options_);
@ -3498,7 +3514,7 @@ FieldDescriptorProto::~FieldDescriptorProto() {
} }
void FieldDescriptorProto::SharedDtor() { void FieldDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
extendee_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); extendee_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
type_name_.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; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
extendee_.Swap(&other->extendee_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
type_name_.Swap(&other->type_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &name_, GetArenaForAllocation(),
default_value_.Swap(&other->default_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &other->name_, other->GetArenaForAllocation()
json_name_.Swap(&other->json_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); );
::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_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(FieldDescriptorProto, proto3_optional_) PROTOBUF_FIELD_OFFSET(FieldDescriptorProto, proto3_optional_)
+ sizeof(FieldDescriptorProto::proto3_optional_) + sizeof(FieldDescriptorProto::proto3_optional_)
@ -4041,7 +4077,7 @@ OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from)
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
options_ = new PROTOBUF_NAMESPACE_ID::OneofOptions(*from.options_); options_ = new PROTOBUF_NAMESPACE_ID::OneofOptions(*from.options_);
@ -4063,7 +4099,7 @@ OneofDescriptorProto::~OneofDescriptorProto() {
} }
void OneofDescriptorProto::SharedDtor() { void OneofDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete options_; if (this != internal_default_instance()) delete options_;
} }
@ -4272,7 +4308,11 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) {
using std::swap; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); 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_); swap(options_, other->options_);
} }
@ -4325,7 +4365,7 @@ EnumDescriptorProto_EnumReservedRange::~EnumDescriptorProto_EnumReservedRange()
} }
void EnumDescriptorProto_EnumReservedRange::SharedDtor() { void EnumDescriptorProto_EnumReservedRange::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void EnumDescriptorProto_EnumReservedRange::ArenaDtor(void* object) { void EnumDescriptorProto_EnumReservedRange::ArenaDtor(void* object) {
@ -4569,7 +4609,7 @@ EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from)
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
options_ = new PROTOBUF_NAMESPACE_ID::EnumOptions(*from.options_); options_ = new PROTOBUF_NAMESPACE_ID::EnumOptions(*from.options_);
@ -4591,7 +4631,7 @@ EnumDescriptorProto::~EnumDescriptorProto() {
} }
void EnumDescriptorProto::SharedDtor() { void EnumDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete options_; if (this != internal_default_instance()) delete options_;
} }
@ -4898,7 +4938,11 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) {
value_.InternalSwap(&other->value_); value_.InternalSwap(&other->value_);
reserved_range_.InternalSwap(&other->reserved_range_); reserved_range_.InternalSwap(&other->reserved_range_);
reserved_name_.InternalSwap(&other->reserved_name_); 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_); swap(options_, other->options_);
} }
@ -4942,7 +4986,7 @@ EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProt
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
options_ = new PROTOBUF_NAMESPACE_ID::EnumValueOptions(*from.options_); options_ = new PROTOBUF_NAMESPACE_ID::EnumValueOptions(*from.options_);
@ -4968,7 +5012,7 @@ EnumValueDescriptorProto::~EnumValueDescriptorProto() {
} }
void EnumValueDescriptorProto::SharedDtor() { void EnumValueDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete options_; if (this != internal_default_instance()) delete options_;
} }
@ -5203,7 +5247,11 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) {
using std::swap; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); 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_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(EnumValueDescriptorProto, number_) PROTOBUF_FIELD_OFFSET(EnumValueDescriptorProto, number_)
+ sizeof(EnumValueDescriptorProto::number_) + sizeof(EnumValueDescriptorProto::number_)
@ -5251,7 +5299,7 @@ ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& fro
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
options_ = new PROTOBUF_NAMESPACE_ID::ServiceOptions(*from.options_); options_ = new PROTOBUF_NAMESPACE_ID::ServiceOptions(*from.options_);
@ -5273,7 +5321,7 @@ ServiceDescriptorProto::~ServiceDescriptorProto() {
} }
void ServiceDescriptorProto::SharedDtor() { void ServiceDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete options_; if (this != internal_default_instance()) delete options_;
} }
@ -5513,7 +5561,11 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
method_.InternalSwap(&other->method_); 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_); swap(options_, other->options_);
} }
@ -5566,17 +5618,17 @@ MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from)
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
input_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); input_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_input_type()) { if (from._internal_has_input_type()) {
input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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()); output_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_output_type()) { if (from._internal_has_output_type()) {
output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_output_type(), output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_output_type(),
GetArena()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
options_ = new PROTOBUF_NAMESPACE_ID::MethodOptions(*from.options_); options_ = new PROTOBUF_NAMESPACE_ID::MethodOptions(*from.options_);
@ -5606,7 +5658,7 @@ MethodDescriptorProto::~MethodDescriptorProto() {
} }
void MethodDescriptorProto::SharedDtor() { void MethodDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
input_type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); input_type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
output_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; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
input_type_.Swap(&other->input_type_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
output_type_.Swap(&other->output_type_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &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_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(MethodDescriptorProto, server_streaming_) PROTOBUF_FIELD_OFFSET(MethodDescriptorProto, server_streaming_)
+ sizeof(MethodDescriptorProto::server_streaming_) + sizeof(MethodDescriptorProto::server_streaming_)
@ -6034,52 +6098,52 @@ FileOptions::FileOptions(const FileOptions& from)
java_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); java_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_java_package()) { if (from._internal_has_java_package()) {
java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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()); java_outer_classname_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_java_outer_classname()) { if (from._internal_has_java_outer_classname()) {
java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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()); go_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_go_package()) { if (from._internal_has_go_package()) {
go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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()); objc_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_objc_class_prefix()) { if (from._internal_has_objc_class_prefix()) {
objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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()); csharp_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_csharp_namespace()) { if (from._internal_has_csharp_namespace()) {
csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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()); swift_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_swift_prefix()) { if (from._internal_has_swift_prefix()) {
swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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()); php_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_php_class_prefix()) { if (from._internal_has_php_class_prefix()) {
php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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()); php_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_php_namespace()) { if (from._internal_has_php_namespace()) {
php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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()); php_metadata_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_php_metadata_namespace()) { if (from._internal_has_php_metadata_namespace()) {
php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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()); ruby_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_ruby_package()) { if (from._internal_has_ruby_package()) {
ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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_, ::memcpy(&java_multiple_files_, &from.java_multiple_files_,
static_cast<size_t>(reinterpret_cast<char*>(&cc_enable_arenas_) - static_cast<size_t>(reinterpret_cast<char*>(&cc_enable_arenas_) -
@ -6113,7 +6177,7 @@ FileOptions::~FileOptions() {
} }
void FileOptions::SharedDtor() { void FileOptions::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
java_package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); java_package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
java_outer_classname_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); java_outer_classname_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
go_package_.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_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
java_package_.Swap(&other->java_package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
java_outer_classname_.Swap(&other->java_outer_classname_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
go_package_.Swap(&other->go_package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &java_package_, GetArenaForAllocation(),
objc_class_prefix_.Swap(&other->objc_class_prefix_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &other->java_package_, other->GetArenaForAllocation()
csharp_namespace_.Swap(&other->csharp_namespace_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); );
swift_prefix_.Swap(&other->swift_prefix_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
php_class_prefix_.Swap(&other->php_class_prefix_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
php_namespace_.Swap(&other->php_namespace_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &java_outer_classname_, GetArenaForAllocation(),
php_metadata_namespace_.Swap(&other->php_metadata_namespace_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &other->java_outer_classname_, other->GetArenaForAllocation()
ruby_package_.Swap(&other->ruby_package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); );
::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_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(FileOptions, deprecated_) PROTOBUF_FIELD_OFFSET(FileOptions, deprecated_)
+ sizeof(FileOptions::deprecated_) + sizeof(FileOptions::deprecated_)
@ -6983,7 +7087,7 @@ MessageOptions::~MessageOptions() {
} }
void MessageOptions::SharedDtor() { void MessageOptions::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void MessageOptions::ArenaDtor(void* object) { void MessageOptions::ArenaDtor(void* object) {
@ -7336,7 +7440,7 @@ FieldOptions::~FieldOptions() {
} }
void FieldOptions::SharedDtor() { void FieldOptions::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void FieldOptions::ArenaDtor(void* object) { void FieldOptions::ArenaDtor(void* object) {
@ -7721,7 +7825,7 @@ OneofOptions::~OneofOptions() {
} }
void OneofOptions::SharedDtor() { void OneofOptions::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void OneofOptions::ArenaDtor(void* object) { void OneofOptions::ArenaDtor(void* object) {
@ -7953,7 +8057,7 @@ EnumOptions::~EnumOptions() {
} }
void EnumOptions::SharedDtor() { void EnumOptions::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void EnumOptions::ArenaDtor(void* object) { void EnumOptions::ArenaDtor(void* object) {
@ -8242,7 +8346,7 @@ EnumValueOptions::~EnumValueOptions() {
} }
void EnumValueOptions::SharedDtor() { void EnumValueOptions::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void EnumValueOptions::ArenaDtor(void* object) { void EnumValueOptions::ArenaDtor(void* object) {
@ -8496,7 +8600,7 @@ ServiceOptions::~ServiceOptions() {
} }
void ServiceOptions::SharedDtor() { void ServiceOptions::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void ServiceOptions::ArenaDtor(void* object) { void ServiceOptions::ArenaDtor(void* object) {
@ -8758,7 +8862,7 @@ MethodOptions::~MethodOptions() {
} }
void MethodOptions::SharedDtor() { void MethodOptions::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void MethodOptions::ArenaDtor(void* object) { void MethodOptions::ArenaDtor(void* object) {
@ -9046,7 +9150,7 @@ UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOp
name_part_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_part_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_name_part()) { if (from._internal_has_name_part()) {
name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name_part(), name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name_part(),
GetArena()); GetArenaForAllocation());
} }
is_extension_ = from.is_extension_; is_extension_ = from.is_extension_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption.NamePart) // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption.NamePart)
@ -9064,7 +9168,7 @@ UninterpretedOption_NamePart::~UninterpretedOption_NamePart() {
} }
void UninterpretedOption_NamePart::SharedDtor() { void UninterpretedOption_NamePart::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_part_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_part_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
} }
@ -9278,7 +9382,11 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot
using std::swap; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); 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_); swap(is_extension_, other->is_extension_);
} }
@ -9328,17 +9436,17 @@ UninterpretedOption::UninterpretedOption(const UninterpretedOption& from)
identifier_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); identifier_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_identifier_value()) { if (from._internal_has_identifier_value()) {
identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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()); string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_string_value()) { if (from._internal_has_string_value()) {
string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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()); aggregate_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_aggregate_value()) { if (from._internal_has_aggregate_value()) {
aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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_, ::memcpy(&positive_int_value_, &from.positive_int_value_,
static_cast<size_t>(reinterpret_cast<char*>(&double_value_) - static_cast<size_t>(reinterpret_cast<char*>(&double_value_) -
@ -9363,7 +9471,7 @@ UninterpretedOption::~UninterpretedOption() {
} }
void UninterpretedOption::SharedDtor() { void UninterpretedOption::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
identifier_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); identifier_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
string_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); string_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
aggregate_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_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
name_.InternalSwap(&other->name_); name_.InternalSwap(&other->name_);
identifier_value_.Swap(&other->identifier_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
string_value_.Swap(&other->string_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
aggregate_value_.Swap(&other->aggregate_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &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_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(UninterpretedOption, double_value_) PROTOBUF_FIELD_OFFSET(UninterpretedOption, double_value_)
+ sizeof(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()); leading_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_leading_comments()) { if (from._internal_has_leading_comments()) {
leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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()); trailing_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_trailing_comments()) { if (from._internal_has_trailing_comments()) {
trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_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) // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location)
} }
@ -9780,7 +9900,7 @@ SourceCodeInfo_Location::~SourceCodeInfo_Location() {
} }
void SourceCodeInfo_Location::SharedDtor() { void SourceCodeInfo_Location::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
leading_comments_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); leading_comments_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
trailing_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_); path_.InternalSwap(&other->path_);
span_.InternalSwap(&other->span_); span_.InternalSwap(&other->span_);
leading_detached_comments_.InternalSwap(&other->leading_detached_comments_); leading_detached_comments_.InternalSwap(&other->leading_detached_comments_);
leading_comments_.Swap(&other->leading_comments_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
trailing_comments_.Swap(&other->trailing_comments_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &::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 { ::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo_Location::GetMetadata() const {
@ -10142,7 +10270,7 @@ SourceCodeInfo::~SourceCodeInfo() {
} }
void SourceCodeInfo::SharedDtor() { void SourceCodeInfo::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void SourceCodeInfo::ArenaDtor(void* object) { void SourceCodeInfo::ArenaDtor(void* object) {
@ -10338,7 +10466,7 @@ GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeIn
source_file_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); source_file_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_source_file()) { if (from._internal_has_source_file()) {
source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_source_file(), source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_source_file(),
GetArena()); GetArenaForAllocation());
} }
::memcpy(&begin_, &from.begin_, ::memcpy(&begin_, &from.begin_,
static_cast<size_t>(reinterpret_cast<char*>(&end_) - static_cast<size_t>(reinterpret_cast<char*>(&end_) -
@ -10361,7 +10489,7 @@ GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() {
} }
void GeneratedCodeInfo_Annotation::SharedDtor() { void GeneratedCodeInfo_Annotation::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
source_file_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); 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_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
path_.InternalSwap(&other->path_); 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_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(GeneratedCodeInfo_Annotation, end_) PROTOBUF_FIELD_OFFSET(GeneratedCodeInfo_Annotation, end_)
+ sizeof(GeneratedCodeInfo_Annotation::end_) + sizeof(GeneratedCodeInfo_Annotation::end_)
@ -10671,7 +10803,7 @@ GeneratedCodeInfo::~GeneratedCodeInfo() {
} }
void GeneratedCodeInfo::SharedDtor() { void GeneratedCodeInfo::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void GeneratedCodeInfo::ArenaDtor(void* object) { void GeneratedCodeInfo::ArenaDtor(void* object) {

File diff suppressed because it is too large Load Diff

View File

@ -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. // Test reserved fields.
class ReservedDescriptorTest : public testing::Test { class ReservedDescriptorTest : public testing::Test {
protected: protected:

View File

@ -19,7 +19,7 @@ PROTOBUF_PRAGMA_INIT_SEG
PROTOBUF_NAMESPACE_OPEN PROTOBUF_NAMESPACE_OPEN
constexpr Duration::Duration( constexpr Duration::Duration(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: seconds_(PROTOBUF_LONGLONG(0)) : seconds_(int64_t{0})
, nanos_(0){} , nanos_(0){}
struct DurationDefaultTypeInternal { struct DurationDefaultTypeInternal {
constexpr DurationDefaultTypeInternal() constexpr DurationDefaultTypeInternal()
@ -110,7 +110,7 @@ Duration::~Duration() {
} }
void Duration::SharedDtor() { void Duration::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void Duration::ArenaDtor(void* object) { void Duration::ArenaDtor(void* object) {

View File

@ -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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Duration) */ {
public: public:
inline Duration() : Duration(nullptr) {} inline Duration() : Duration(nullptr) {}
@ -83,8 +83,9 @@ class PROTOBUF_EXPORT Duration PROTOBUF_FINAL :
return *this; return *this;
} }
inline Duration& operator=(Duration&& from) noexcept { inline Duration& operator=(Duration&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -115,7 +116,7 @@ class PROTOBUF_EXPORT Duration PROTOBUF_FINAL :
} }
inline void Swap(Duration* other) { inline void Swap(Duration* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -123,14 +124,14 @@ class PROTOBUF_EXPORT Duration PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Duration* other) { void UnsafeArenaSwap(Duration* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Duration* New() const final { inline Duration* New() const final {
return CreateMaybeMessage<Duration>(nullptr); return new Duration();
} }
Duration* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { Duration* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -218,7 +219,7 @@ class PROTOBUF_EXPORT Duration PROTOBUF_FINAL :
// int64 seconds = 1; // int64 seconds = 1;
inline void Duration::clear_seconds() { inline void Duration::clear_seconds() {
seconds_ = PROTOBUF_LONGLONG(0); seconds_ = int64_t{0};
} }
inline ::PROTOBUF_NAMESPACE_ID::int64 Duration::_internal_seconds() const { inline ::PROTOBUF_NAMESPACE_ID::int64 Duration::_internal_seconds() const {
return seconds_; return seconds_;

View File

@ -355,7 +355,7 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
if (type_info_->extensions_offset != -1) { if (type_info_->extensions_offset != -1) {
new (OffsetToPointer(type_info_->extensions_offset)) new (OffsetToPointer(type_info_->extensions_offset))
ExtensionSet(GetArena()); ExtensionSet(GetArenaForAllocation());
} }
for (int i = 0; i < descriptor->field_count(); i++) { for (int i = 0; i < descriptor->field_count(); i++) {
const FieldDescriptor* field = descriptor->field(i); const FieldDescriptor* field = descriptor->field(i);
@ -364,13 +364,13 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
continue; continue;
} }
switch (field->cpp_type()) { switch (field->cpp_type()) {
#define HANDLE_TYPE(CPPTYPE, TYPE) \ #define HANDLE_TYPE(CPPTYPE, TYPE) \
case FieldDescriptor::CPPTYPE_##CPPTYPE: \ case FieldDescriptor::CPPTYPE_##CPPTYPE: \
if (!field->is_repeated()) { \ if (!field->is_repeated()) { \
new (field_ptr) TYPE(field->default_value_##TYPE()); \ new (field_ptr) TYPE(field->default_value_##TYPE()); \
} else { \ } else { \
new (field_ptr) RepeatedField<TYPE>(GetArena()); \ new (field_ptr) RepeatedField<TYPE>(GetArenaForAllocation()); \
} \ } \
break; break;
HANDLE_TYPE(INT32, int32); HANDLE_TYPE(INT32, int32);
@ -386,7 +386,7 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
if (!field->is_repeated()) { if (!field->is_repeated()) {
new (field_ptr) int(field->default_value_enum()->number()); new (field_ptr) int(field->default_value_enum()->number());
} else { } else {
new (field_ptr) RepeatedField<int>(GetArena()); new (field_ptr) RepeatedField<int>(GetArenaForAllocation());
} }
break; break;
@ -402,7 +402,8 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
ArenaStringPtr* asp = new (field_ptr) ArenaStringPtr(); ArenaStringPtr* asp = new (field_ptr) ArenaStringPtr();
asp->UnsafeSetDefault(default_value); asp->UnsafeSetDefault(default_value);
} else { } else {
new (field_ptr) RepeatedPtrField<std::string>(GetArena()); new (field_ptr)
RepeatedPtrField<std::string>(GetArenaForAllocation());
} }
break; break;
} }
@ -417,20 +418,30 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
// when the constructor is called inside GetPrototype(), in which // when the constructor is called inside GetPrototype(), in which
// case we have already locked the factory. // case we have already locked the factory.
if (lock_factory) { if (lock_factory) {
if (GetArena() != nullptr) { if (GetArenaForAllocation() != nullptr) {
new (field_ptr) DynamicMapField( new (field_ptr) DynamicMapField(
type_info_->factory->GetPrototype(field->message_type()), type_info_->factory->GetPrototype(field->message_type()),
GetArena()); GetArenaForAllocation());
if (GetOwningArena() != nullptr) {
// Needs to destroy the mutex member.
GetOwningArena()->OwnDestructor(
static_cast<DynamicMapField*>(field_ptr));
}
} else { } else {
new (field_ptr) DynamicMapField( new (field_ptr) DynamicMapField(
type_info_->factory->GetPrototype(field->message_type())); type_info_->factory->GetPrototype(field->message_type()));
} }
} else { } else {
if (GetArena() != nullptr) { if (GetArenaForAllocation() != nullptr) {
new (field_ptr) new (field_ptr)
DynamicMapField(type_info_->factory->GetPrototypeNoLock( DynamicMapField(type_info_->factory->GetPrototypeNoLock(
field->message_type()), field->message_type()),
GetArena()); GetArenaForAllocation());
if (GetOwningArena() != nullptr) {
// Needs to destroy the mutex member.
GetOwningArena()->OwnDestructor(
static_cast<DynamicMapField*>(field_ptr));
}
} else { } else {
new (field_ptr) new (field_ptr)
DynamicMapField(type_info_->factory->GetPrototypeNoLock( DynamicMapField(type_info_->factory->GetPrototypeNoLock(
@ -438,7 +449,7 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
} }
} }
} else { } else {
new (field_ptr) RepeatedPtrField<Message>(GetArena()); new (field_ptr) RepeatedPtrField<Message>(GetArenaForAllocation());
} }
} }
break; break;

View File

@ -286,6 +286,7 @@ TEST_F(DynamicMessageTest, Arena) {
// Return without freeing: should not leak. // Return without freeing: should not leak.
} }
TEST_F(DynamicMessageTest, Proto3) { TEST_F(DynamicMessageTest, Proto3) {
Message* message = proto3_prototype_->New(); Message* message = proto3_prototype_->New();
const Reflection* refl = message->GetReflection(); const Reflection* refl = message->GetReflection();

View File

@ -98,7 +98,7 @@ Empty::~Empty() {
} }
void Empty::SharedDtor() { void Empty::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void Empty::ArenaDtor(void* object) { void Empty::ArenaDtor(void* object) {

View File

@ -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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Empty) */ {
public: public:
inline Empty() : Empty(nullptr) {} inline Empty() : Empty(nullptr) {}
@ -83,8 +83,9 @@ class PROTOBUF_EXPORT Empty PROTOBUF_FINAL :
return *this; return *this;
} }
inline Empty& operator=(Empty&& from) noexcept { inline Empty& operator=(Empty&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -115,7 +116,7 @@ class PROTOBUF_EXPORT Empty PROTOBUF_FINAL :
} }
inline void Swap(Empty* other) { inline void Swap(Empty* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -123,14 +124,14 @@ class PROTOBUF_EXPORT Empty PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Empty* other) { void UnsafeArenaSwap(Empty* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Empty* New() const final { inline Empty* New() const final {
return CreateMaybeMessage<Empty>(nullptr); return new Empty();
} }
Empty* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { Empty* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {

View File

@ -616,7 +616,7 @@ void ExtensionSet::SetAllocatedMessage(int number, FieldType type,
ClearExtension(number); ClearExtension(number);
return; return;
} }
Arena* message_arena = message->GetArena(); Arena* message_arena = message->GetOwningArena();
Extension* extension; Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) { if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type; extension->type = type;
@ -1071,6 +1071,7 @@ void ExtensionSet::Swap(ExtensionSet* x) {
void ExtensionSet::InternalSwap(ExtensionSet* other) { void ExtensionSet::InternalSwap(ExtensionSet* other) {
using std::swap; using std::swap;
swap(arena_, other->arena_);
swap(flat_capacity_, other->flat_capacity_); swap(flat_capacity_, other->flat_capacity_);
swap(flat_size_, other->flat_size_); swap(flat_size_, other->flat_size_);
swap(map_, other->map_); swap(map_, other->map_);

View File

@ -282,12 +282,13 @@ class PROTOBUF_EXPORT ExtensionSet {
void UnsafeArenaSetAllocatedMessage(int number, FieldType type, void UnsafeArenaSetAllocatedMessage(int number, FieldType type,
const FieldDescriptor* descriptor, const FieldDescriptor* descriptor,
MessageLite* message); 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, MessageLite* UnsafeArenaReleaseMessage(int number,
const MessageLite& prototype); const MessageLite& prototype);
MessageLite* ReleaseMessage(const FieldDescriptor* descriptor, PROTOBUF_FUTURE_MUST_USE_RESULT MessageLite* ReleaseMessage(
MessageFactory* factory); const FieldDescriptor* descriptor, MessageFactory* factory);
MessageLite* UnsafeArenaReleaseMessage(const FieldDescriptor* descriptor, MessageLite* UnsafeArenaReleaseMessage(const FieldDescriptor* descriptor,
MessageFactory* factory); MessageFactory* factory);
#undef desc #undef desc
@ -354,7 +355,7 @@ class PROTOBUF_EXPORT ExtensionSet {
#undef desc #undef desc
void RemoveLast(int number); 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); void SwapElements(int number, int index1, int index2);
// ----------------------------------------------------------------- // -----------------------------------------------------------------
@ -534,7 +535,8 @@ class PROTOBUF_EXPORT ExtensionSet {
virtual MessageLite* MutableMessage(const MessageLite& prototype) = 0; virtual MessageLite* MutableMessage(const MessageLite& prototype) = 0;
virtual void SetAllocatedMessage(MessageLite* message) = 0; virtual void SetAllocatedMessage(MessageLite* message) = 0;
virtual void UnsafeArenaSetAllocatedMessage(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( virtual MessageLite* UnsafeArenaReleaseMessage(
const MessageLite& prototype) = 0; const MessageLite& prototype) = 0;
@ -1260,8 +1262,8 @@ class MessageTypeTraits {
ExtensionSet* set) { ExtensionSet* set) {
set->UnsafeArenaSetAllocatedMessage(number, field_type, NULL, message); set->UnsafeArenaSetAllocatedMessage(number, field_type, NULL, message);
} }
static inline MutableType Release(int number, FieldType /* field_type */, static inline PROTOBUF_FUTURE_MUST_USE_RESULT MutableType
ExtensionSet* set) { Release(int number, FieldType /* field_type */, ExtensionSet* set) {
return static_cast<Type*>( return static_cast<Type*>(
set->ReleaseMessage(number, Type::default_instance())); set->ReleaseMessage(number, Type::default_instance()));
} }
@ -1476,9 +1478,11 @@ class ExtensionIdentifier {
template <typename _proto_TypeTraits, \ template <typename _proto_TypeTraits, \
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \ bool _is_packed> \
inline typename _proto_TypeTraits::Singular::MutableType ReleaseExtension( \ inline PROTOBUF_FUTURE_MUST_USE_RESULT \
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \ typename _proto_TypeTraits::Singular::MutableType \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \ ReleaseExtension( \
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \
return _proto_TypeTraits::Release(id.number(), _field_type, \ return _proto_TypeTraits::Release(id.number(), _field_type, \
&_extensions_); \ &_extensions_); \
} \ } \

View File

@ -103,7 +103,7 @@ FieldMask::~FieldMask() {
} }
void FieldMask::SharedDtor() { void FieldMask::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void FieldMask::ArenaDtor(void* object) { void FieldMask::ArenaDtor(void* object) {

View File

@ -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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldMask) */ {
public: public:
inline FieldMask() : FieldMask(nullptr) {} inline FieldMask() : FieldMask(nullptr) {}
@ -83,8 +83,9 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL :
return *this; return *this;
} }
inline FieldMask& operator=(FieldMask&& from) noexcept { inline FieldMask& operator=(FieldMask&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -115,7 +116,7 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL :
} }
inline void Swap(FieldMask* other) { inline void Swap(FieldMask* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -123,14 +124,14 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(FieldMask* other) { void UnsafeArenaSwap(FieldMask* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline FieldMask* New() const final { inline FieldMask* New() const final {
return CreateMaybeMessage<FieldMask>(nullptr); return new FieldMask();
} }
FieldMask* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { FieldMask* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {

View File

@ -235,6 +235,16 @@ UnknownFieldSet* Reflection::MutableUnknownFields(Message* message) const {
->mutable_unknown_fields<UnknownFieldSet>(); ->mutable_unknown_fields<UnknownFieldSet>();
} }
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 { size_t Reflection::SpaceUsedLong(const Message& message) const {
// object_size_ already includes the in-memory representation of each field // 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 // 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); SWAP_VALUES(ENUM, int);
#undef SWAP_VALUES #undef SWAP_VALUES
case FieldDescriptor::CPPTYPE_MESSAGE: case FieldDescriptor::CPPTYPE_MESSAGE:
if (GetArena(message1) == GetArena(message2)) { if (message1->GetArenaForAllocation() ==
message2->GetArenaForAllocation()) {
std::swap(*MutableRaw<Message*>(message1, field), std::swap(*MutableRaw<Message*>(message1, field),
*MutableRaw<Message*>(message2, field)); *MutableRaw<Message*>(message2, field));
} else { } else {
@ -423,13 +434,17 @@ void Reflection::SwapField(Message* message1, Message* message2,
break; break;
} }
if (*sub_msg1 == nullptr) { if (*sub_msg1 == nullptr) {
*sub_msg1 = (*sub_msg2)->New(message1->GetArena()); *sub_msg1 = (*sub_msg2)->New(message1->GetArenaForAllocation());
(*sub_msg1)->CopyFrom(**sub_msg2); (*sub_msg1)->CopyFrom(**sub_msg2);
ClearField(message2, field); ClearField(message2, field);
// Ensures has bit is unchanged after ClearField.
SetBit(message2, field);
} else { } else {
*sub_msg2 = (*sub_msg1)->New(message2->GetArena()); *sub_msg2 = (*sub_msg1)->New(message2->GetArenaForAllocation());
(*sub_msg2)->CopyFrom(**sub_msg1); (*sub_msg2)->CopyFrom(**sub_msg1);
ClearField(message1, field); ClearField(message1, field);
// Ensures has bit is unchanged after ClearField.
SetBit(message1, field);
} }
} }
break; break;
@ -438,25 +453,30 @@ void Reflection::SwapField(Message* message1, Message* message2,
switch (field->options().ctype()) { switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps. default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: { case FieldOptions::STRING: {
Arena* arena1 = GetArena(message1); const std::string* default_ptr =
Arena* arena2 = GetArena(message2); DefaultRaw<ArenaStringPtr>(field).GetPointer();
Arena* arena1 = message1->GetArenaForAllocation();
Arena* arena2 = message2->GetArenaForAllocation();
ArenaStringPtr* string1 = ArenaStringPtr* string1 =
MutableRaw<ArenaStringPtr>(message1, field); MutableRaw<ArenaStringPtr>(message1, field);
ArenaStringPtr* string2 = ArenaStringPtr* string2 =
MutableRaw<ArenaStringPtr>(message2, field); MutableRaw<ArenaStringPtr>(message2, field);
const std::string* default_ptr = if (message1->GetOwningArena() == message2->GetOwningArena()) {
DefaultRaw<ArenaStringPtr>(field).GetPointer(); ArenaStringPtr::InternalSwap(default_ptr, string1, arena1,
if (arena1 == arena2) { string2, arena2);
string1->Swap(string2, default_ptr, arena1);
} else if (string1->IsDefault(default_ptr) && } else if (string1->IsDefault(default_ptr) &&
string2->IsDefault(default_ptr)) { string2->IsDefault(default_ptr)) {
// Nothing to do. // Nothing to do.
} else if (string1->IsDefault(default_ptr)) { } else if (string1->IsDefault(default_ptr)) {
string1->Set(default_ptr, string2->Get(), arena1); string1->Set(default_ptr, string2->Get(), arena1);
// string2 needs to be destroyed before overwritten.
string2->Destroy(default_ptr, arena2);
string2->UnsafeSetDefault(default_ptr); string2->UnsafeSetDefault(default_ptr);
} else if (string2->IsDefault(default_ptr)) { } else if (string2->IsDefault(default_ptr)) {
string2->Set(default_ptr, string1->Get(), arena2); string2->Set(default_ptr, string1->Get(), arena2);
// string1 needs to be destroyed before overwritten.
string1->Destroy(default_ptr, arena1);
string1->UnsafeSetDefault(default_ptr); string1->UnsafeSetDefault(default_ptr);
} else { } else {
std::string temp = string1->Get(); 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 // 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. // need to copy all data if not, due to ownership semantics.
if (GetArena(message1) != GetArena(message2)) { if (message1->GetOwningArena() != message2->GetOwningArena()) {
// Slow copy path. // One of the two is guaranteed to have an arena. Switch things around
// Use our arena as temp space, if available. // to guarantee that message1 has an arena.
Message* temp = message1->New(GetArena(message1)); 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); temp->MergeFrom(*message2);
message2->CopyFrom(*message1); message2->CopyFrom(*message1);
Swap(message1, temp); Swap(message1, temp);
if (GetArena(message1) == nullptr) {
delete temp;
}
return; 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()) { if (schema_.HasHasbits()) {
uint32* has_bits1 = MutableHasBits(message1); uint32* has_bits1 = MutableHasBits(message1);
uint32* has_bits2 = MutableHasBits(message2); 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()) { if (schema_.HasExtensionSet()) {
MutableExtensionSet(message1)->Swap(MutableExtensionSet(message2)); MutableExtensionSet(message1)->Swap(MutableExtensionSet(message2));
} }
@ -708,13 +733,14 @@ void Reflection::SwapFields(
swapped_oneof.insert(oneof_index); swapped_oneof.insert(oneof_index);
SwapOneofField(message1, message2, field->containing_oneof()); SwapOneofField(message1, message2, field->containing_oneof());
} else { } else {
// Swap field.
SwapField(message1, message2, field);
// Swap has bit for non-repeated fields. We have already checked for // 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()) { if (!field->is_repeated()) {
SwapBit(message1, message2, field); SwapBit(message1, message2, field);
} }
// Swap field.
SwapField(message1, message2, field);
} }
} }
} }
@ -828,7 +854,8 @@ void Reflection::ClearField(Message* message,
const std::string* default_ptr = const std::string* default_ptr =
DefaultRaw<ArenaStringPtr>(field).GetPointer(); DefaultRaw<ArenaStringPtr>(field).GetPointer();
MutableRaw<ArenaStringPtr>(message, field) MutableRaw<ArenaStringPtr>(message, field)
->SetAllocated(default_ptr, nullptr, GetArena(message)); ->SetAllocated(default_ptr, nullptr,
message->GetArenaForAllocation());
break; break;
} }
} }
@ -839,7 +866,7 @@ void Reflection::ClearField(Message* message,
if (schema_.HasBitIndex(field) == static_cast<uint32>(-1)) { if (schema_.HasBitIndex(field) == static_cast<uint32>(-1)) {
// Proto3 does not have has-bits and we need to set a message field // Proto3 does not have has-bits and we need to set a message field
// to nullptr in order to indicate its un-presence. // to nullptr in order to indicate its un-presence.
if (GetArena(message) == nullptr) { if (message->GetArenaForAllocation() == nullptr) {
delete *MutableRaw<Message*>(message, field); delete *MutableRaw<Message*>(message, field);
} }
*MutableRaw<Message*>(message, field) = nullptr; *MutableRaw<Message*>(message, field) = nullptr;
@ -1242,7 +1269,8 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
->UnsafeSetDefault(default_ptr); ->UnsafeSetDefault(default_ptr);
} }
MutableField<ArenaStringPtr>(message, field) MutableField<ArenaStringPtr>(message, field)
->Set(default_ptr, std::move(value), GetArena(message)); ->Set(default_ptr, std::move(value),
message->GetArenaForAllocation());
break; break;
} }
} }
@ -1494,7 +1522,7 @@ const Message* Reflection::GetDefaultMessageInstance(
// This is an optimization to avoid going to GetPrototype() below, as that // This is an optimization to avoid going to GetPrototype() below, as that
// requires a lock and a map lookup. // requires a lock and a map lookup.
if (!field->is_extension() && !field->options().weak() && if (!field->is_extension() && !field->options().weak() &&
!field->options().lazy() && !schema_.InRealOneof(field)) { !IsLazyField(field) && !schema_.InRealOneof(field)) {
auto* res = DefaultRaw<const Message*>(field); auto* res = DefaultRaw<const Message*>(field);
if (res != nullptr) { if (res != nullptr) {
return res; return res;
@ -1548,7 +1576,7 @@ Message* Reflection::MutableMessage(Message* message,
ClearOneof(message, field->containing_oneof()); ClearOneof(message, field->containing_oneof());
result_holder = MutableField<Message*>(message, field); result_holder = MutableField<Message*>(message, field);
const Message* default_message = GetDefaultMessageInstance(field); const Message* default_message = GetDefaultMessageInstance(field);
*result_holder = default_message->New(message->GetArena()); *result_holder = default_message->New(message->GetArenaForAllocation());
} }
} else { } else {
SetBit(message, field); SetBit(message, field);
@ -1556,7 +1584,7 @@ Message* Reflection::MutableMessage(Message* message,
if (*result_holder == nullptr) { if (*result_holder == nullptr) {
const Message* default_message = GetDefaultMessageInstance(field); const Message* default_message = GetDefaultMessageInstance(field);
*result_holder = default_message->New(message->GetArena()); *result_holder = default_message->New(message->GetArenaForAllocation());
} }
result = *result_holder; result = *result_holder;
return result; return result;
@ -1590,7 +1618,7 @@ void Reflection::UnsafeArenaSetAllocatedMessage(
SetBit(message, field); SetBit(message, field);
} }
Message** sub_message_holder = MutableRaw<Message*>(message, field); Message** sub_message_holder = MutableRaw<Message*>(message, field);
if (GetArena(message) == nullptr) { if (message->GetArenaForAllocation() == nullptr) {
delete *sub_message_holder; delete *sub_message_holder;
} }
*sub_message_holder = sub_message; *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 // (different arenas, or one is on heap and one is not), then we may need to
// do a copy. // do a copy.
if (sub_message != nullptr && if (sub_message != nullptr &&
sub_message->GetArena() != message->GetArena()) { sub_message->GetOwningArena() != message->GetArenaForAllocation()) {
if (sub_message->GetArena() == nullptr && message->GetArena() != nullptr) { if (sub_message->GetOwningArena() == nullptr &&
message->GetArenaForAllocation() != nullptr) {
// Case 1: parent is on an arena and child is heap-allocated. We can add // 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 // the child to the arena's Own() list to free on arena destruction, then
// set our pointer. // set our pointer.
message->GetArena()->Own(sub_message); message->GetArenaForAllocation()->Own(sub_message);
UnsafeArenaSetAllocatedMessage(message, sub_message, field); UnsafeArenaSetAllocatedMessage(message, sub_message, field);
} else { } else {
// Case 2: all other cases. We need to make a copy. MutableMessage() will // 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); CheckInvalidAccess(schema_, field);
Message* released = UnsafeArenaReleaseMessage(message, field, factory); Message* released = UnsafeArenaReleaseMessage(message, field, factory);
if (GetArena(message) != nullptr && released != nullptr) { if (message->GetArenaForAllocation() != nullptr && released != nullptr) {
Message* copy_from_arena = released->New(); Message* copy_from_arena = released->New();
copy_from_arena->CopyFrom(*released); copy_from_arena->CopyFrom(*released);
released = copy_from_arena; released = copy_from_arena;
@ -1743,7 +1772,7 @@ Message* Reflection::AddMessage(Message* message, const FieldDescriptor* field,
} else { } else {
prototype = &repeated->Get<GenericTypeHandler<Message> >(0); prototype = &repeated->Get<GenericTypeHandler<Message> >(0);
} }
result = prototype->New(message->GetArena()); result = prototype->New(message->GetArenaForAllocation());
// We can guarantee here that repeated and result are either both heap // 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 // allocated or arena owned. So it is safe to call the unsafe version
// of AddAllocated. // of AddAllocated.
@ -1988,10 +2017,6 @@ ExtensionSet* Reflection::MutableExtensionSet(Message* message) const {
schema_.GetExtensionSetOffset()); schema_.GetExtensionSetOffset());
} }
Arena* Reflection::GetArena(Message* message) const {
return GetInternalMetadata(*message).arena();
}
const InternalMetadata& Reflection::GetInternalMetadata( const InternalMetadata& Reflection::GetInternalMetadata(
const Message& message) const { const Message& message) const {
return GetConstRefAtOffset<InternalMetadata>(message, return GetConstRefAtOffset<InternalMetadata>(message,
@ -2137,7 +2162,7 @@ void Reflection::ClearOneof(Message* message,
uint32 oneof_case = GetOneofCase(*message, oneof_descriptor); uint32 oneof_case = GetOneofCase(*message, oneof_descriptor);
if (oneof_case > 0) { if (oneof_case > 0) {
const FieldDescriptor* field = descriptor_->FindFieldByNumber(oneof_case); const FieldDescriptor* field = descriptor_->FindFieldByNumber(oneof_case);
if (GetArena(message) == nullptr) { if (message->GetArenaForAllocation() == nullptr) {
switch (field->cpp_type()) { switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_STRING: { case FieldDescriptor::CPPTYPE_STRING: {
switch (field->options().ctype()) { switch (field->options().ctype()) {
@ -2148,7 +2173,7 @@ void Reflection::ClearOneof(Message* message,
// work. This allows us to not have the real default accessible // work. This allows us to not have the real default accessible
// from reflection. // from reflection.
MutableField<ArenaStringPtr>(message, field) MutableField<ArenaStringPtr>(message, field)
->Destroy(nullptr, GetArena(message)); ->Destroy(nullptr, message->GetArenaForAllocation());
break; break;
} }
} }

View File

@ -198,6 +198,13 @@ struct ReflectionSchema {
OffsetValue(offsets_[field->index()], field->type()); 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, // Returns true if the field's accessor is called by any external code (aka,
// non proto library code). // non proto library code).
bool IsFieldUsed(const FieldDescriptor* field) const { bool IsFieldUsed(const FieldDescriptor* field) const {
@ -235,8 +242,11 @@ struct ReflectionSchema {
int weak_field_map_offset_; int weak_field_map_offset_;
// We tag offset values to provide additional data about fields (such as // We tag offset values to provide additional data about fields (such as
// "unused"). // "unused" or "lazy").
static uint32 OffsetValue(uint32 v, FieldDescriptor::Type /* type */) { static uint32 OffsetValue(uint32 v, FieldDescriptor::Type type) {
if (type == FieldDescriptor::TYPE_MESSAGE) {
return v & 0x7FFFFFFEu;
}
return v & 0x7FFFFFFFu; return v & 0x7FFFFFFFu;
} }
}; };

View File

@ -266,6 +266,39 @@ TEST(GeneratedMessageReflectionTest, SwapFieldsAll) {
TestUtil::ExpectClear(message2); TestUtil::ExpectClear(message2);
} }
TEST(GeneratedMessageReflectionTest, SwapFieldsAllOnDifferentArena) {
Arena arena1, arena2;
auto* message1 = Arena::CreateMessage<unittest::TestAllTypes>(&arena1);
auto* message2 = Arena::CreateMessage<unittest::TestAllTypes>(&arena2);
TestUtil::SetAllFields(message2);
std::vector<const FieldDescriptor*> 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<unittest::TestAllTypes>(&arena);
std::unique_ptr<unittest::TestAllTypes> message2(
Arena::CreateMessage<unittest::TestAllTypes>(nullptr));
TestUtil::SetAllFields(message2.get());
std::vector<const FieldDescriptor*> 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) { TEST(GeneratedMessageReflectionTest, SwapFieldsAllExtension) {
unittest::TestAllExtensions message1; unittest::TestAllExtensions message1;
unittest::TestAllExtensions message2; unittest::TestAllExtensions message2;

View File

@ -718,7 +718,8 @@ void GenericSwap(MessageLite* m1, MessageLite* m2) {
MessageLite* GetOwnedMessageInternal(Arena* message_arena, MessageLite* GetOwnedMessageInternal(Arena* message_arena,
MessageLite* submessage, MessageLite* submessage,
Arena* submessage_arena) { Arena* submessage_arena) {
GOOGLE_DCHECK(submessage->GetArena() == submessage_arena); GOOGLE_DCHECK(Arena::InternalHelper<MessageLite>::GetOwningArena(submessage) ==
submessage_arena);
GOOGLE_DCHECK(message_arena != submessage_arena); GOOGLE_DCHECK(message_arena != submessage_arena);
if (message_arena != NULL && submessage_arena == NULL) { if (message_arena != NULL && submessage_arena == NULL) {
message_arena->Own(submessage); message_arena->Own(submessage);

View File

@ -47,17 +47,17 @@ namespace internal {
template <size_t doublewords> template <size_t doublewords>
class HasBits { class HasBits {
public: 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_)); 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]; 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]; return has_bits_[index];
} }

View File

@ -51,11 +51,6 @@
#include <google/protobuf/port_def.inc> #include <google/protobuf/port_def.inc>
// 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 google {
namespace protobuf { namespace protobuf {
@ -168,24 +163,25 @@ VarintCase kVarintCases[] = {
{{0xbe, 0xf7, 0x92, 0x84, 0x0b}, {{0xbe, 0xf7, 0x92, 0x84, 0x0b},
5, // 2961488830 5, // 2961488830
(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
(ULL(0x0b) << 28)}, (uint64_t{0x0bu} << 28)},
// 64-bit // 64-bit
{{0xbe, 0xf7, 0x92, 0x84, 0x1b}, {{0xbe, 0xf7, 0x92, 0x84, 0x1b},
5, // 7256456126 5, // 7256456126
(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
(ULL(0x1b) << 28)}, (uint64_t{0x1bu} << 28)},
{{0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49}, {{0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49},
8, // 41256202580718336 8, // 41256202580718336
(0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) |
(ULL(0x43) << 28) | (ULL(0x49) << 35) | (ULL(0x24) << 42) | (uint64_t{0x43u} << 28) | (uint64_t{0x49u} << 35) |
(ULL(0x49) << 49)}, (uint64_t{0x24u} << 42) | (uint64_t{0x49u} << 49)},
// 11964378330978735131 // 11964378330978735131
{{0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01}, {{0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01},
10, 10,
(0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | (0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) |
(ULL(0x3b) << 28) | (ULL(0x56) << 35) | (ULL(0x00) << 42) | (uint64_t{0x3bu} << 28) | (uint64_t{0x56u} << 35) |
(ULL(0x05) << 49) | (ULL(0x26) << 56) | (ULL(0x01) << 63)}, (uint64_t{0x00u} << 42) | (uint64_t{0x05u} << 49) |
(uint64_t{0x26u} << 56) | (uint64_t{0x01u} << 63)},
}; };
TEST_2D(CodedStreamTest, ReadVarint32, kVarintCases, kBlockSizes) { TEST_2D(CodedStreamTest, ReadVarint32, kVarintCases, kBlockSizes) {
@ -313,7 +309,7 @@ TEST_2D(CodedStreamTest, ReadVarint64, kVarintCases, kBlockSizes) {
} }
TEST_2D(CodedStreamTest, WriteVarint32, 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. // Skip this test for the 64-bit values.
return; return;
} }
@ -500,8 +496,8 @@ VarintSizeCase kVarintSizeCases[] = {
{128u, 2}, {128u, 2},
{758923u, 3}, {758923u, 3},
{4000000000u, 5}, {4000000000u, 5},
{ULL(41256202580718336), 8}, {uint64_t{41256202580718336u}, 8},
{ULL(11964378330978735131), 10}, {uint64_t{11964378330978735131u}, 10},
}; };
TEST_1D(CodedStreamTest, VarintSize32, kVarintSizeCases) { TEST_1D(CodedStreamTest, VarintSize32, kVarintSizeCases) {
@ -569,8 +565,10 @@ Fixed32Case kFixed32Cases[] = {
}; };
Fixed64Case kFixed64Cases[] = { Fixed64Case kFixed64Cases[] = {
{{0xef, 0xcd, 0xab, 0x90, 0x12, 0x34, 0x56, 0x78}, ULL(0x7856341290abcdef)}, {{0xef, 0xcd, 0xab, 0x90, 0x12, 0x34, 0x56, 0x78},
{{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}, ULL(0x8877665544332211)}, uint64_t{0x7856341290abcdefu}},
{{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88},
uint64_t{0x8877665544332211u}},
}; };
TEST_2D(CodedStreamTest, ReadLittleEndian32, kFixed32Cases, kBlockSizes) { TEST_2D(CodedStreamTest, ReadLittleEndian32, kFixed32Cases, kBlockSizes) {

View File

@ -194,7 +194,7 @@ class MapEntryImpl : public Base {
_has_bits_{} {} _has_bits_{} {}
~MapEntryImpl() { ~MapEntryImpl() {
if (Base::GetArena() != NULL) return; if (Base::GetArenaForAllocation() != NULL) return;
KeyTypeHandler::DeleteNoArena(key_); KeyTypeHandler::DeleteNoArena(key_);
ValueTypeHandler::DeleteNoArena(value_); ValueTypeHandler::DeleteNoArena(value_);
} }
@ -209,11 +209,12 @@ class MapEntryImpl : public Base {
} }
inline KeyMapEntryAccessorType* mutable_key() { inline KeyMapEntryAccessorType* mutable_key() {
set_has_key(); set_has_key();
return KeyTypeHandler::EnsureMutable(&key_, Base::GetArena()); return KeyTypeHandler::EnsureMutable(&key_, Base::GetArenaForAllocation());
} }
inline ValueMapEntryAccessorType* mutable_value() { inline ValueMapEntryAccessorType* mutable_value() {
set_has_value(); set_has_value();
return ValueTypeHandler::EnsureMutable(&value_, Base::GetArena()); return ValueTypeHandler::EnsureMutable(&value_,
Base::GetArenaForAllocation());
} }
// implements MessageLite ========================================= // implements MessageLite =========================================
@ -301,13 +302,14 @@ class MapEntryImpl : public Base {
void MergeFromInternal(const MapEntryImpl& from) { void MergeFromInternal(const MapEntryImpl& from) {
if (from._has_bits_[0]) { if (from._has_bits_[0]) {
if (from.has_key()) { if (from.has_key()) {
KeyTypeHandler::EnsureMutable(&key_, Base::GetArena()); KeyTypeHandler::EnsureMutable(&key_, Base::GetArenaForAllocation());
KeyTypeHandler::Merge(from.key(), &key_, Base::GetArena()); KeyTypeHandler::Merge(from.key(), &key_, Base::GetArenaForAllocation());
set_has_key(); set_has_key();
} }
if (from.has_value()) { if (from.has_value()) {
ValueTypeHandler::EnsureMutable(&value_, Base::GetArena()); ValueTypeHandler::EnsureMutable(&value_, Base::GetArenaForAllocation());
ValueTypeHandler::Merge(from.value(), &value_, Base::GetArena()); ValueTypeHandler::Merge(from.value(), &value_,
Base::GetArenaForAllocation());
set_has_value(); set_has_value();
} }
} }
@ -315,8 +317,8 @@ class MapEntryImpl : public Base {
public: public:
void Clear() override { void Clear() override {
KeyTypeHandler::Clear(&key_, Base::GetArena()); KeyTypeHandler::Clear(&key_, Base::GetArenaForAllocation());
ValueTypeHandler::Clear(&value_, Base::GetArena()); ValueTypeHandler::Clear(&value_, Base::GetArenaForAllocation());
clear_has_key(); clear_has_key();
clear_has_value(); clear_has_value();
} }
@ -328,7 +330,8 @@ class MapEntryImpl : public Base {
public: public:
explicit Parser(MapField* mf) : mf_(mf), map_(mf->MutableMap()) {} explicit Parser(MapField* mf) : mf_(mf), map_(mf->MutableMap()) {}
~Parser() { ~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 // This does what the typical MergePartialFromCodedStream() is expected to

View File

@ -62,6 +62,7 @@ void MapFieldBase::Swap(MapFieldBase* other) {
} }
void MapFieldBase::InternalSwap(MapFieldBase* other) { void MapFieldBase::InternalSwap(MapFieldBase* other) {
std::swap(arena_, other->arena_);
std::swap(repeated_field_, other->repeated_field_); std::swap(repeated_field_, other->repeated_field_);
// a relaxed swap of the atomic // a relaxed swap of the atomic
auto other_state = other->state_.load(std::memory_order_relaxed); auto other_state = other->state_.load(std::memory_order_relaxed);
@ -136,12 +137,8 @@ void MapFieldBase::SyncRepeatedFieldWithMap() const {
// Double check state // Double check state
if (state_.load(std::memory_order_relaxed) == CLEAN) { if (state_.load(std::memory_order_relaxed) == CLEAN) {
if (repeated_field_ == nullptr) { if (repeated_field_ == nullptr) {
if (arena_ == nullptr) { repeated_field_ =
repeated_field_ = new RepeatedPtrField<Message>(); Arena::CreateMessage<RepeatedPtrField<Message> >(arena_);
} else {
repeated_field_ =
Arena::CreateMessage<RepeatedPtrField<Message> >(arena_);
}
} }
state_.store(CLEAN, std::memory_order_release); state_.store(CLEAN, std::memory_order_release);
} }
@ -186,11 +183,11 @@ DynamicMapField::DynamicMapField(const Message* default_entry, Arena* arena)
default_entry_(default_entry) {} default_entry_(default_entry) {}
DynamicMapField::~DynamicMapField() { DynamicMapField::~DynamicMapField() {
// DynamicMapField owns map values. Need to delete them before clearing if (arena_ != nullptr) return;
// the map. // DynamicMapField owns map values. Need to delete them before clearing the
for (Map<MapKey, MapValueRef>::iterator iter = map_.begin(); // map.
iter != map_.end(); ++iter) { for (auto& kv : map_) {
iter->second.DeleteData(); kv.second.DeleteData();
} }
map_.clear(); map_.clear();
} }
@ -402,13 +399,8 @@ void DynamicMapField::SyncRepeatedFieldWithMapNoLock() const {
const FieldDescriptor* key_des = default_entry_->GetDescriptor()->map_key(); const FieldDescriptor* key_des = default_entry_->GetDescriptor()->map_key();
const FieldDescriptor* val_des = default_entry_->GetDescriptor()->map_value(); const FieldDescriptor* val_des = default_entry_->GetDescriptor()->map_value();
if (MapFieldBase::repeated_field_ == NULL) { if (MapFieldBase::repeated_field_ == NULL) {
if (MapFieldBase::arena_ == NULL) { MapFieldBase::repeated_field_ =
MapFieldBase::repeated_field_ = new RepeatedPtrField<Message>(); Arena::CreateMessage<RepeatedPtrField<Message> >(MapFieldBase::arena_);
} else {
MapFieldBase::repeated_field_ =
Arena::CreateMessage<RepeatedPtrField<Message> >(
MapFieldBase::arena_);
}
} }
MapFieldBase::repeated_field_->Clear(); MapFieldBase::repeated_field_->Clear();

View File

@ -336,13 +336,7 @@ class PROTOBUF_EXPORT MapFieldBase {
mutex_(GOOGLE_PROTOBUF_LINKER_INITIALIZED), mutex_(GOOGLE_PROTOBUF_LINKER_INITIALIZED),
state_(STATE_MODIFIED_MAP) {} state_(STATE_MODIFIED_MAP) {}
explicit MapFieldBase(Arena* arena) explicit MapFieldBase(Arena* arena)
: arena_(arena), repeated_field_(NULL), state_(STATE_MODIFIED_MAP) { : arena_(arena), repeated_field_(nullptr), state_(STATE_MODIFIED_MAP) {}
// Mutex's destructor needs to be called explicitly to release resources
// acquired in its constructor.
if (arena) {
arena->OwnDestructor(&mutex_);
}
}
virtual ~MapFieldBase(); virtual ~MapFieldBase();
// Returns reference to internal repeated field. Data written using // Returns reference to internal repeated field. Data written using

View File

@ -297,13 +297,9 @@ template <typename Derived, typename Key, typename T,
void MapField<Derived, Key, T, kKeyFieldType, void MapField<Derived, Key, T, kKeyFieldType,
kValueFieldType>::SyncRepeatedFieldWithMapNoLock() const { kValueFieldType>::SyncRepeatedFieldWithMapNoLock() const {
if (this->MapFieldBase::repeated_field_ == NULL) { if (this->MapFieldBase::repeated_field_ == NULL) {
if (this->MapFieldBase::arena_ == NULL) { this->MapFieldBase::repeated_field_ =
this->MapFieldBase::repeated_field_ = new RepeatedPtrField<Message>(); Arena::CreateMessage<RepeatedPtrField<Message> >(
} else { this->MapFieldBase::arena_);
this->MapFieldBase::repeated_field_ =
Arena::CreateMessage<RepeatedPtrField<Message> >(
this->MapFieldBase::arena_);
}
} }
const Map<Key, T>& map = impl_.GetMap(); const Map<Key, T>& map = impl_.GetMap();
RepeatedPtrField<EntryType>* repeated_field = RepeatedPtrField<EntryType>* repeated_field =

View File

@ -100,6 +100,11 @@ class MapFieldBaseStub : public MapFieldBase {
void CopyIterator(MapIterator* this_iterator, void CopyIterator(MapIterator* this_iterator,
const MapIterator& other_iterator) const override {} const MapIterator& other_iterator) const override {}
void IncreaseIterator(MapIterator* map_iter) const override {} void IncreaseIterator(MapIterator* map_iter) const override {}
Arena* GetArenaForInternalRepeatedField() {
auto* repeated_field = MutableRepeatedField();
return repeated_field->GetArena();
}
}; };
class MapFieldBasePrimitiveTest : public testing::TestWithParam<bool> { class MapFieldBasePrimitiveTest : public testing::TestWithParam<bool> {
@ -205,9 +210,17 @@ TEST_P(MapFieldBasePrimitiveTest, Arena) {
// Trigger conversion to repeated field. // Trigger conversion to repeated field.
EXPECT_TRUE(map_field->MutableRepeatedField() != NULL); EXPECT_TRUE(map_field->MutableRepeatedField() != NULL);
EXPECT_EQ(map_field->GetArenaForInternalRepeatedField(), &arena);
} }
} }
TEST_P(MapFieldBasePrimitiveTest, EnforceNoArena) {
std::unique_ptr<MapFieldBaseStub> map_field(
Arena::CreateMessage<MapFieldBaseStub>(nullptr));
EXPECT_EQ(map_field->GetArenaForInternalRepeatedField(), nullptr);
}
namespace { namespace {
enum State { CLEAN, MAP_DIRTY, REPEATED_DIRTY }; enum State { CLEAN, MAP_DIRTY, REPEATED_DIRTY };
} // anonymous namespace } // anonymous namespace

View File

@ -3754,6 +3754,22 @@ TEST(ArenaTest, DynamicMapFieldOnArena) {
MapTestUtil::ExpectMapFieldsSet(message2); 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) { TEST(MoveTest, MoveConstructorWorks) {
Map<int32, TestAllTypes> original_map; Map<int32, TestAllTypes> original_map;
original_map[42].mutable_optional_nested_message()->set_bb(42); original_map[42].mutable_optional_nested_message()->set_bb(42);

View File

@ -346,18 +346,8 @@ template <>
PROTOBUF_NOINLINE PROTOBUF_NOINLINE
#endif #endif
Arena* Arena*
GenericTypeHandler<Message>::GetArena(Message* value) { GenericTypeHandler<Message>::GetOwningArena(Message* value) {
return value->GetArena(); return value->GetOwningArena();
}
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<Message>::GetMaybeArenaPointer(Message* value) {
return value->GetMaybeArenaPointer();
} }
} // namespace internal } // namespace internal

View File

@ -951,6 +951,24 @@ class PROTOBUF_EXPORT Reflection final {
const Message& message, bool should_fail, const Message& message, bool should_fail,
std::vector<const FieldDescriptor*>* output) const; std::vector<const FieldDescriptor*>* 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 Descriptor* const descriptor_;
const internal::ReflectionSchema schema_; const internal::ReflectionSchema schema_;
const DescriptorPool* const descriptor_pool_; const DescriptorPool* const descriptor_pool_;
@ -1067,7 +1085,6 @@ class PROTOBUF_EXPORT Reflection final {
} }
const internal::ExtensionSet& GetExtensionSet(const Message& message) const; const internal::ExtensionSet& GetExtensionSet(const Message& message) const;
internal::ExtensionSet* MutableExtensionSet(Message* message) const; internal::ExtensionSet* MutableExtensionSet(Message* message) const;
inline Arena* GetArena(Message* message) const;
inline const internal::InternalMetadata& GetInternalMetadata( inline const internal::InternalMetadata& GetInternalMetadata(
const Message& message) const; const Message& message) const;

View File

@ -64,6 +64,10 @@ namespace protobuf {
template <typename T> template <typename T>
class RepeatedPtrField; class RepeatedPtrField;
class FastReflectionMessageMutator;
class FastReflectionStringSetter;
class Reflection;
namespace io { namespace io {
class CodedInputStream; class CodedInputStream;
@ -83,10 +87,15 @@ struct ConstantInitialized {
// See parse_context.h for explanation // See parse_context.h for explanation
class ParseContext; class ParseContext;
class ExtensionSet;
class LazyField;
class RepeatedPtrFieldBase; class RepeatedPtrFieldBase;
class WireFormatLite; class WireFormatLite;
class WeakFieldMap; class WeakFieldMap;
template <typename Type>
class GenericTypeHandler; // defined in repeated_field.h
// We compute sizes as size_t but cache them as int. This function converts a // 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 // 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 // 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. // if arena is a NULL. Default implementation for backwards compatibility.
virtual MessageLite* New(Arena* arena) const; virtual MessageLite* New(Arena* arena) const;
// Get the arena, if any, associated with this message. Virtual method // Same as GetOwningArena.
// required for generic operations but most arena-related operations should Arena* GetArena() const { return GetOwningArena(); }
// 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(); }
// Get a pointer that may be equal to this message's arena, or may not be. // 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 // 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) {} 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_; internal::InternalMetadata _internal_metadata_;
public: public:
@ -502,9 +518,19 @@ class PROTOBUF_EXPORT MessageLite {
// TODO(gerbens) make this a pure abstract function // TODO(gerbens) make this a pure abstract function
virtual const void* InternalGetTable() const { return NULL; } virtual const void* InternalGetTable() const { return NULL; }
friend class internal::WireFormatLite; friend class FastReflectionMessageMutator;
friend class FastReflectionStringSetter;
friend class Message; friend class Message;
friend class Reflection;
friend class internal::ExtensionSet;
friend class internal::LazyField;
friend class internal::WeakFieldMap; friend class internal::WeakFieldMap;
friend class internal::WireFormatLite;
template <typename Type>
friend class Arena::InternalHelper;
template <typename Type>
friend class internal::GenericTypeHandler;
void LogInitializationErrorMessage() const; void LogInitializationErrorMessage() const;

View File

@ -548,8 +548,9 @@ TEST(MESSAGE_TEST_NAME, ReleaseMustUseResult) {
message.set_allocated_optional_foreign_message(f); message.set_allocated_optional_foreign_message(f);
auto* mf = message.mutable_optional_foreign_message(); auto* mf = message.mutable_optional_foreign_message();
EXPECT_EQ(mf, f); EXPECT_EQ(mf, f);
EXPECT_NE(message.release_optional_foreign_message(), nullptr); std::unique_ptr<UNITTEST::ForeignMessage> rf(
delete f; message.release_optional_foreign_message());
EXPECT_NE(rf.get(), nullptr);
} }
TEST(MESSAGE_TEST_NAME, ParseFailsOnInvalidMessageEnd) { TEST(MESSAGE_TEST_NAME, ParseFailsOnInvalidMessageEnd) {

View File

@ -48,129 +48,85 @@
// detect/prohibit anytime it is #included twice without a corresponding // detect/prohibit anytime it is #included twice without a corresponding
// #undef. // #undef.
// These macros are private and should always be #undef'd from headers. // The definitions in this file are intended to be portable across Clang,
// If any of these errors fire, you should either properly #include // GCC, and MSVC. Function-like macros are usable without an #ifdef guard.
// port_undef.h at the end of your header that #includes port.h, or // Syntax macros (for example, attributes) are always defined, although
// don't #include port.h twice in a .cc file. // they may be empty.
#ifdef PROTOBUF_NAMESPACE
#error PROTOBUF_NAMESPACE was previously defined // 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 #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 #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 #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 #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 #endif
#ifdef PROTOBUF_NOINLINE
#error PROTOBUF_NOINLINE was previously defined // Portable check for GCC minimum version:
#endif // https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
#ifdef PROTOBUF_SECTION_VARIABLE #if defined(__GNUC__) && defined(__GNUC_MINOR__) \
#error PROTOBUF_SECTION_VARIABLE was previously defined && defined(__GNUC_PATCHLEVEL__)
#endif # define PROTOBUF_GNUC_MIN(x, y) \
#ifdef PROTOBUF_DEPRECATED (__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y))
#error PROTOBUF_DEPRECATED was previously defined #else
#endif # define PROTOBUF_GNUC_MIN(x, y) 0
#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
#endif #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 #ifdef PROTOBUF_VERSION
#error PROTOBUF_VERSION was previously defined #error PROTOBUF_VERSION was previously defined
#endif #endif
#ifdef PROTOBUF_VERSION_SUFFIX #define PROTOBUF_VERSION 3015008
#error PROTOBUF_VERSION_SUFFIX was previously defined
#endif
#ifdef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC #ifdef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC
#error PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC was previously defined #error PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC was previously defined
#endif #endif
#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3015000
#ifdef PROTOBUF_MIN_PROTOC_VERSION #ifdef PROTOBUF_MIN_PROTOC_VERSION
#error PROTOBUF_MIN_PROTOC_VERSION was previously defined #error PROTOBUF_MIN_PROTOC_VERSION was previously defined
#endif #endif
#ifdef PROTOBUF_PREDICT_TRUE #define PROTOBUF_MIN_PROTOC_VERSION 3015000
#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
#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 "google::protobuf"
#define PROTOBUF_NAMESPACE_ID google::protobuf #define PROTOBUF_NAMESPACE_ID google::protobuf
#define PROTOBUF_NAMESPACE_OPEN \ #define PROTOBUF_NAMESPACE_OPEN \
@ -180,193 +136,170 @@
} /* namespace protobuf */ \ } /* namespace protobuf */ \
} /* namespace google */ } /* namespace google */
#if defined(__clang__) #ifdef PROTOBUF_ALWAYS_INLINE
#define PROTOBUF_DEPRECATED __attribute__((deprecated)) #error PROTOBUF_ALWAYS_INLINE was previously defined
#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
#endif #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. // For functions we want to force inline.
// Introduced in gcc 3.1. #if defined(PROTOBUF_NO_INLINE)
#define PROTOBUF_ALWAYS_INLINE __attribute__((always_inline)) # define PROTOBUF_ALWAYS_INLINE
#define PROTOBUF_NDEBUG_INLINE __attribute__((always_inline)) #elif PROTOBUF_GNUC_MIN(3, 1)
#endif # define PROTOBUF_ALWAYS_INLINE __attribute__((always_inline))
#endif #elif defined(_MSC_VER)
# define PROTOBUF_ALWAYS_INLINE __forceinline
#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
#else #else
#if defined(__GNUC__) && \ # define PROTOBUF_ALWAYS_INLINE
(__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) #endif
// For functions we want to force not inline.
// Introduced in gcc 3.1. #ifdef PROTOBUF_NDEBUG_INLINE
#define PROTOBUF_NOINLINE __attribute__((noinline)) #error PROTOBUF_NDEBUG_INLINE was previously defined
#elif defined(_MSC_VER) && (_MSC_VER >= 1400) #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 // Seems to have been around since at least Visual Studio 2005
#define PROTOBUF_NOINLINE __declspec(noinline) # define PROTOBUF_NOINLINE __declspec(noinline)
#else
// Other compilers will have to figure it out for themselves.
#define PROTOBUF_NOINLINE
#endif
#endif #endif
#ifdef GOOGLE_ATTRIBUTE_FUNC_ALIGN #ifdef PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED
#define PROTOBUF_FUNC_ALIGN GOOGLE_ATTRIBUTE_FUNC_ALIGN #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 #else
#if defined(__clang__) || \ #define PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED(...)
defined(__GNUC__) && \ #endif
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
// Function alignment attribute introduced in gcc 4.3 #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))) #define PROTOBUF_FUNC_ALIGN(bytes) __attribute__((aligned(bytes)))
#else #else
#define PROTOBUF_FUNC_ALIGN(bytes) #define PROTOBUF_FUNC_ALIGN(bytes)
#endif #endif
#endif
#ifdef GOOGLE_PREDICT_TRUE #ifdef PROTOBUF_RETURNS_NONNULL
#define PROTOBUF_PREDICT_TRUE GOOGLE_PREDICT_TRUE #error PROTOBUF_RETURNS_NONNULL was previously defined
#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)
#endif #endif
#endif #if __has_attribute(returns_nonnull) || PROTOBUF_GNUC_MIN(4, 9)
#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)
#define PROTOBUF_RETURNS_NONNULL __attribute__((returns_nonnull)) #define PROTOBUF_RETURNS_NONNULL __attribute__((returns_nonnull))
#endif #else
#endif
#endif
#ifndef PROTOBUF_RETURNS_NONNULL
#define PROTOBUF_RETURNS_NONNULL #define PROTOBUF_RETURNS_NONNULL
#endif #endif
#if defined(__has_cpp_attribute) #ifdef PROTOBUF_ATTRIBUTE_REINITIALIZES
#error PROTOBUF_ATTRIBUTE_REINITIALIZES was previously defined
#endif
#if __has_cpp_attribute(clang::reinitializes) #if __has_cpp_attribute(clang::reinitializes)
#define PROTOBUF_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]] #define PROTOBUF_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]]
#endif #else
#endif
#ifndef PROTOBUF_ATTRIBUTE_REINITIALIZES
#define PROTOBUF_ATTRIBUTE_REINITIALIZES #define PROTOBUF_ATTRIBUTE_REINITIALIZES
#endif #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 // The minimum library version which works with the current version of the
// headers. // headers.
#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3015000 #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 #if defined(GOOGLE_PROTOBUF_NO_RTTI) && GOOGLE_PROTOBUF_NO_RTTI
#define PROTOBUF_RTTI 0 #define PROTOBUF_RTTI 0
#elif defined(__has_feature) #elif __has_feature(cxx_rtti)
// 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
#define PROTOBUF_RTTI 1 #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 #endif
// Returns the offset of the given field within the given aggregate type. // 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. // which the offsets of the direct fields of a class are non-constant.
// Fields inherited from superclasses *can* have non-constant offsets, // Fields inherited from superclasses *can* have non-constant offsets,
// but that's not what this macro will be used for. // 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__) #if defined(__clang__)
// For Clang we use __builtin_offsetof() and suppress the warning, // For Clang we use __builtin_offsetof() and suppress the warning,
// to avoid Control Flow Integrity and UBSan vptr sanitizers from // to avoid Control Flow Integrity and UBSan vptr sanitizers from
@ -386,8 +322,7 @@
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(TYPE, FIELD) \ __builtin_offsetof(TYPE, FIELD) \
_Pragma("clang diagnostic pop") _Pragma("clang diagnostic pop")
#elif defined(__GNUC__) && \ #elif PROTOBUF_GNUC_MIN(4, 8)
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
#define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) __builtin_offsetof(TYPE, FIELD) #define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) __builtin_offsetof(TYPE, FIELD)
#else // defined(__clang__) #else // defined(__clang__)
// Note that we calculate relative to the pointer value 16 here since if we // Note that we calculate relative to the pointer value 16 here since if we
@ -400,43 +335,234 @@
reinterpret_cast<const char*>(16)) reinterpret_cast<const char*>(16))
#endif #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) #if defined(_MSC_VER)
#ifdef LIBPROTOBUF_EXPORTS #define PROTOBUF_ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
#define PROTOBUF_EXPORT __declspec(dllexport) #elif PROTOBUF_GNUC_MIN(3, 0)
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE #define PROTOBUF_ALIGNAS(byte_alignment) \
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllexport) __attribute__((aligned(byte_alignment)))
#else #else
#define PROTOBUF_EXPORT __declspec(dllimport) #define PROTOBUF_ALIGNAS(byte_alignment) alignas(byte_alignment)
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllimport)
#endif #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 #else
#define PROTOC_EXPORT __declspec(dllimport) #define PROTOBUF_THREAD_LOCAL __thread
#endif #endif
#else // defined(_MSC_VER)
#ifdef LIBPROTOBUF_EXPORTS // For enabling message owned arena, one major blocker is semantic change from
#define PROTOBUF_EXPORT __attribute__((visibility("default"))) // moving to copying when there is ownership transfer (e.g., move ctor, swap,
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default"))) // set allocated, release). This change not only causes performance regression
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE // 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 #else
#define PROTOBUF_EXPORT #define PROTOBUF_CONSTINIT
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE
#endif #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 #else
#define PROTOC_EXPORT #define PROTOBUF_ATTRIBUTE_NO_DESTROY
#endif #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 #endif
#else // defined(PROTOBUF_USE_DLLS) #if PROTOBUF_GNUC_MIN(3, 0)
#define PROTOBUF_EXPORT #define PROTOBUF_ATTRIBUTE_INIT_PRIORITY __attribute__((init_priority((102))))
#define PROTOC_EXPORT #else
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE #define PROTOBUF_ATTRIBUTE_INIT_PRIORITY
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE #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 #endif
// Windows declares several inconvenient macro names. We #undef them and then // Windows declares several inconvenient macro names. We #undef them and then
@ -490,19 +616,19 @@
#undef timezone #undef timezone
#endif // _MSC_VER #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 // Don't let Objective-C Macros interfere with proto identifiers with the same
// name. // name.
#pragma push_macro("DEBUG") #pragma push_macro("DEBUG")
#undef 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__) #if defined(__clang__)
#pragma clang diagnostic push #pragma clang diagnostic push
// TODO(gerbens) ideally we cleanup the code. But a cursory try shows many // TODO(gerbens) ideally we cleanup the code. But a cursory try shows many
// violations. So let's ignore for now. // violations. So let's ignore for now.
#pragma clang diagnostic ignored "-Wshorten-64-to-32" #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: // GCC does not allow disabling diagnostics within an expression:
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60875, so we disable this one // 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. // globally even though it's only used for PROTOBUF_FIELD_OFFSET.
@ -510,141 +636,6 @@
#pragma GCC diagnostic ignored "-Winvalid-offsetof" #pragma GCC diagnostic ignored "-Winvalid-offsetof"
#endif #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. // Silence some MSVC warnings in all our code.
#if _MSC_VER #if _MSC_VER
#pragma warning(push) #pragma warning(push)
@ -656,3 +647,28 @@
// To silence the fact that we will pop this push from another file // To silence the fact that we will pop this push from another file
#pragma warning(disable : 5031) #pragma warning(disable : 5031)
#endif #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

View File

@ -55,10 +55,6 @@
#undef PROTOBUF_MIN_PROTOC_VERSION #undef PROTOBUF_MIN_PROTOC_VERSION
#undef PROTOBUF_PREDICT_TRUE #undef PROTOBUF_PREDICT_TRUE
#undef PROTOBUF_PREDICT_FALSE #undef PROTOBUF_PREDICT_FALSE
#undef PROTOBUF_LONGLONG
#undef PROTOBUF_ULONGLONG
#undef PROTOBUF_LL_FORMAT
#undef PROTOBUF_GUARDED_BY
#undef PROTOBUF_FALLTHROUGH_INTENDED #undef PROTOBUF_FALLTHROUGH_INTENDED
#undef PROTOBUF_EXPORT #undef PROTOBUF_EXPORT
#undef PROTOC_EXPORT #undef PROTOC_EXPORT
@ -70,7 +66,6 @@
#undef PROTOBUF_EXPORT_TEMPLATE_DECLARE #undef PROTOBUF_EXPORT_TEMPLATE_DECLARE
#undef PROTOBUF_EXPORT_TEMPLATE_DEFINE #undef PROTOBUF_EXPORT_TEMPLATE_DEFINE
#undef PROTOBUF_ALIGNAS #undef PROTOBUF_ALIGNAS
#undef PROTOBUF_FINAL
#undef PROTOBUF_THREAD_LOCAL #undef PROTOBUF_THREAD_LOCAL
#undef PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT #undef PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT
#undef PROTOBUF_CONSTINIT #undef PROTOBUF_CONSTINIT
@ -81,6 +76,10 @@
#undef PROTOBUF_ASAN #undef PROTOBUF_ASAN
#undef PROTOBUF_MSAN #undef PROTOBUF_MSAN
#undef PROTOBUF_TSAN #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 #ifdef PROTOBUF_FUTURE_BREAKING_CHANGES
#undef PROTOBUF_FUTURE_BREAKING_CHANGES #undef PROTOBUF_FUTURE_BREAKING_CHANGES

View File

@ -418,19 +418,24 @@ void ReflectionOps::FindInitializationErrors(const Message& message,
} }
} }
void GenericSwap(Message* m1, Message* m2) { void GenericSwap(Message* lhs, Message* rhs) {
Arena* m2_arena = m2->GetArena(); GOOGLE_DCHECK(Arena::InternalHelper<Message>::GetOwningArena(lhs) !=
GOOGLE_DCHECK(m1->GetArena() != m2_arena); Arena::InternalHelper<Message>::GetOwningArena(rhs));
// At least one of these must have an arena, so make `rhs` point to it.
Arena* arena = Arena::InternalHelper<Message>::GetOwningArena(rhs);
if (arena == nullptr) {
std::swap(lhs, rhs);
arena = Arena::InternalHelper<Message>::GetOwningArena(rhs);
}
// Copy semantics in this case. We try to improve efficiency by placing the // Improve efficiency by placing the temporary on an arena so that messages
// temporary on |m2|'s arena so that messages are copied twice rather than // are copied twice rather than three times.
// three times. GOOGLE_DCHECK(arena != nullptr);
Message* tmp = m2->New(m2_arena); Message* tmp = rhs->New(arena);
std::unique_ptr<Message> tmp_deleter(m2_arena == nullptr ? tmp : nullptr); tmp->CheckTypeAndMergeFrom(*lhs);
tmp->CheckTypeAndMergeFrom(*m1); lhs->Clear();
m1->Clear(); lhs->CheckTypeAndMergeFrom(*rhs);
m1->CheckTypeAndMergeFrom(*m2); rhs->GetReflection()->Swap(tmp, rhs);
m2->GetReflection()->Swap(tmp, m2);
} }
} // namespace internal } // namespace internal

View File

@ -535,8 +535,8 @@ TEST(ReflectionOpsTest, GenericSwap) {
TestUtil::ExpectAllFieldsSet(message); TestUtil::ExpectAllFieldsSet(message);
TestUtil::ExpectClear(*arena_message); TestUtil::ExpectClear(*arena_message);
// The temp shouldn't be allocated on the arena in this case. // The temp should be allocated on the arena in this case.
EXPECT_EQ(arena.SpaceUsed(), initial_arena_size); EXPECT_GT(arena.SpaceUsed(), initial_arena_size);
} }
} }

View File

@ -595,12 +595,10 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
#endif #endif
} }
public:
// Must be called from destructor. // Must be called from destructor.
template <typename TypeHandler> template <typename TypeHandler>
void Destroy(); void Destroy();
protected:
bool empty() const; bool empty() const;
int size() const; int size() const;
@ -800,6 +798,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
// reinterpreting pointers as being to Message instead of a specific Message // reinterpreting pointers as being to Message instead of a specific Message
// subclass. // subclass.
friend class MapFieldBase; friend class MapFieldBase;
friend class MapFieldBaseStub;
// The table-driven MergePartialFromCodedStream implementation needs to // The table-driven MergePartialFromCodedStream implementation needs to
// operate on RepeatedPtrField<MessageLite>. // operate on RepeatedPtrField<MessageLite>.
@ -830,11 +829,8 @@ class GenericTypeHandler {
delete value; delete value;
} }
} }
static inline Arena* GetArena(GenericType* value) { static inline Arena* GetOwningArena(GenericType* value) {
return Arena::GetArena<Type>(value); return Arena::GetOwningArena<Type>(value);
}
static inline void* GetMaybeArenaPointer(GenericType* value) {
return Arena::GetArena<Type>(value);
} }
static inline void Clear(GenericType* value) { value->Clear(); } static inline void Clear(GenericType* value) { value->Clear(); }
@ -863,13 +859,9 @@ template <>
MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype( MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype(
const MessageLite* prototype, Arena* arena); const MessageLite* prototype, Arena* arena);
template <> template <>
inline Arena* GenericTypeHandler<MessageLite>::GetArena(MessageLite* value) { inline Arena* GenericTypeHandler<MessageLite>::GetOwningArena(
return value->GetArena();
}
template <>
inline void* GenericTypeHandler<MessageLite>::GetMaybeArenaPointer(
MessageLite* value) { MessageLite* value) {
return value->GetMaybeArenaPointer(); return value->GetOwningArena();
} }
template <> template <>
void GenericTypeHandler<MessageLite>::Merge(const MessageLite& from, void GenericTypeHandler<MessageLite>::Merge(const MessageLite& from,
@ -889,9 +881,7 @@ template <>
PROTOBUF_EXPORT Message* GenericTypeHandler<Message>::NewFromPrototype( PROTOBUF_EXPORT Message* GenericTypeHandler<Message>::NewFromPrototype(
const Message* prototype, Arena* arena); const Message* prototype, Arena* arena);
template <> template <>
PROTOBUF_EXPORT Arena* GenericTypeHandler<Message>::GetArena(Message* value); PROTOBUF_EXPORT Arena* GenericTypeHandler<Message>::GetOwningArena(
template <>
PROTOBUF_EXPORT void* GenericTypeHandler<Message>::GetMaybeArenaPointer(
Message* value); Message* value);
class StringTypeHandler { class StringTypeHandler {
@ -909,10 +899,7 @@ class StringTypeHandler {
Arena* arena) { Arena* arena) {
return New(arena); return New(arena);
} }
static inline Arena* GetArena(std::string*) { return NULL; } static inline Arena* GetOwningArena(std::string*) { return nullptr; }
static inline void* GetMaybeArenaPointer(std::string* /* value */) {
return NULL;
}
static inline void Delete(std::string* value, Arena* arena) { static inline void Delete(std::string* value, Arena* arena) {
if (arena == NULL) { if (arena == NULL) {
delete value; delete value;
@ -1496,7 +1483,6 @@ inline const Element* RepeatedField<Element>::data() const {
template <typename Element> template <typename Element>
inline void RepeatedField<Element>::InternalSwap(RepeatedField* other) { inline void RepeatedField<Element>::InternalSwap(RepeatedField* other) {
GOOGLE_DCHECK(this != other); GOOGLE_DCHECK(this != other);
GOOGLE_DCHECK(GetArena() == other->GetArena());
// Swap all fields at once. // Swap all fields at once.
static_assert(std::is_standard_layout<RepeatedField<Element>>::value, static_assert(std::is_standard_layout<RepeatedField<Element>>::value,
@ -1944,7 +1930,7 @@ template <typename TypeHandler>
void RepeatedPtrFieldBase::AddAllocatedInternal( void RepeatedPtrFieldBase::AddAllocatedInternal(
typename TypeHandler::Type* value, std::true_type) { typename TypeHandler::Type* value, std::true_type) {
Arena* element_arena = Arena* element_arena =
reinterpret_cast<Arena*>(TypeHandler::GetMaybeArenaPointer(value)); reinterpret_cast<Arena*>(TypeHandler::GetOwningArena(value));
Arena* arena = GetArena(); Arena* arena = GetArena();
if (arena == element_arena && rep_ && rep_->allocated_size < total_size_) { if (arena == element_arena && rep_ && rep_->allocated_size < total_size_) {
// Fast path: underlying arena representation (tagged pointer) is equal to // Fast path: underlying arena representation (tagged pointer) is equal to
@ -1960,8 +1946,7 @@ void RepeatedPtrFieldBase::AddAllocatedInternal(
current_size_ = current_size_ + 1; current_size_ = current_size_ + 1;
rep_->allocated_size = rep_->allocated_size + 1; rep_->allocated_size = rep_->allocated_size + 1;
} else { } else {
AddAllocatedSlowWithCopy<TypeHandler>(value, TypeHandler::GetArena(value), AddAllocatedSlowWithCopy<TypeHandler>(value, element_arena, arena);
arena);
} }
} }
@ -2093,7 +2078,7 @@ inline void RepeatedPtrFieldBase::AddCleared(
typename TypeHandler::Type* value) { typename TypeHandler::Type* value) {
GOOGLE_DCHECK(GetArena() == NULL) GOOGLE_DCHECK(GetArena() == NULL)
<< "AddCleared() can only be used on a RepeatedPtrField not on an arena."; << "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."; << "AddCleared() can only accept values not on an arena.";
if (!rep_ || rep_->allocated_size == total_size_) { if (!rep_ || rep_->allocated_size == total_size_) {
Reserve(total_size_ + 1); Reserve(total_size_ + 1);
@ -2635,17 +2620,14 @@ class RepeatedPtrOverPtrsIterator {
void RepeatedPtrFieldBase::InternalSwap(RepeatedPtrFieldBase* other) { void RepeatedPtrFieldBase::InternalSwap(RepeatedPtrFieldBase* other) {
GOOGLE_DCHECK(this != other); GOOGLE_DCHECK(this != other);
GOOGLE_DCHECK(GetArena() == other->GetArena());
// Swap all fields at once. // Swap all fields at once.
static_assert(std::is_standard_layout<RepeatedPtrFieldBase>::value, static_assert(std::is_standard_layout<RepeatedPtrFieldBase>::value,
"offsetof() requires standard layout before c++17"); "offsetof() requires standard layout before c++17");
internal::memswap<offsetof(RepeatedPtrFieldBase, rep_) + sizeof(this->rep_) - internal::memswap<offsetof(RepeatedPtrFieldBase, rep_) + sizeof(this->rep_) -
offsetof(RepeatedPtrFieldBase, current_size_)>( offsetof(RepeatedPtrFieldBase, arena_)>(
reinterpret_cast<char*>(this) + reinterpret_cast<char*>(this) + offsetof(RepeatedPtrFieldBase, arena_),
offsetof(RepeatedPtrFieldBase, current_size_), reinterpret_cast<char*>(other) + offsetof(RepeatedPtrFieldBase, arena_));
reinterpret_cast<char*>(other) +
offsetof(RepeatedPtrFieldBase, current_size_));
} }
} // namespace internal } // namespace internal

View File

@ -91,7 +91,7 @@ SourceContext::SourceContext(const SourceContext& from)
file_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); file_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_file_name().empty()) { if (!from._internal_file_name().empty()) {
file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_file_name(), file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_file_name(),
GetArena()); GetArenaForAllocation());
} }
// @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext) // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext)
} }
@ -107,7 +107,7 @@ SourceContext::~SourceContext() {
} }
void SourceContext::SharedDtor() { void SourceContext::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
file_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); file_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
} }
@ -176,7 +176,7 @@ failure:
(void) cached_has_bits; (void) cached_has_bits;
// string file_name = 1; // string file_name = 1;
if (this->file_name().size() > 0) { if (!this->file_name().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_file_name().data(), static_cast<int>(this->_internal_file_name().length()), this->_internal_file_name().data(), static_cast<int>(this->_internal_file_name().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -202,7 +202,7 @@ size_t SourceContext::ByteSizeLong() const {
(void) cached_has_bits; (void) cached_has_bits;
// string file_name = 1; // string file_name = 1;
if (this->file_name().size() > 0) { if (!this->file_name().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_file_name()); this->_internal_file_name());
@ -239,7 +239,7 @@ void SourceContext::MergeFrom(const SourceContext& from) {
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits; (void) cached_has_bits;
if (from.file_name().size() > 0) { if (!from.file_name().empty()) {
_internal_set_file_name(from._internal_file_name()); _internal_set_file_name(from._internal_file_name());
} }
} }
@ -265,7 +265,11 @@ bool SourceContext::IsInitialized() const {
void SourceContext::InternalSwap(SourceContext* other) { void SourceContext::InternalSwap(SourceContext* other) {
using std::swap; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _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 { ::PROTOBUF_NAMESPACE_ID::Metadata SourceContext::GetMetadata() const {

View File

@ -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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceContext) */ {
public: public:
inline SourceContext() : SourceContext(nullptr) {} inline SourceContext() : SourceContext(nullptr) {}
@ -83,8 +83,9 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL :
return *this; return *this;
} }
inline SourceContext& operator=(SourceContext&& from) noexcept { inline SourceContext& operator=(SourceContext&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -115,7 +116,7 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL :
} }
inline void Swap(SourceContext* other) { inline void Swap(SourceContext* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -123,14 +124,14 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(SourceContext* other) { void UnsafeArenaSwap(SourceContext* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline SourceContext* New() const final { inline SourceContext* New() const final {
return CreateMaybeMessage<SourceContext>(nullptr); return new SourceContext();
} }
SourceContext* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { SourceContext* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -180,11 +181,11 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_file_name(ArgT0&& arg0, ArgT... args); void set_file_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_file_name(); 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); void set_allocated_file_name(std::string* file_name);
private: private:
const std::string& _internal_file_name() const; 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(); std::string* _internal_mutable_file_name();
public: public:
@ -219,10 +220,10 @@ inline const std::string& SourceContext::file_name() const {
return _internal_file_name(); return _internal_file_name();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void SourceContext::set_file_name(ArgT0&& arg0, ArgT... args) { void SourceContext::set_file_name(ArgT0&& arg0, ArgT... args) {
file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name) // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name)
} }
inline std::string* SourceContext::mutable_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) { 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() { 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() { inline std::string* SourceContext::release_file_name() {
// @@protoc_insertion_point(field_release:google.protobuf.SourceContext.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) { inline void SourceContext::set_allocated_file_name(std::string* file_name) {
if (file_name != nullptr) { 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, file_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), file_name,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name)
} }

View File

@ -213,14 +213,18 @@ Struct::~Struct() {
} }
void Struct::SharedDtor() { void Struct::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void Struct::ArenaDtor(void* object) { void Struct::ArenaDtor(void* object) {
Struct* _this = reinterpret_cast< Struct* >(object); Struct* _this = reinterpret_cast< Struct* >(object);
(void)_this; (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 { void Struct::SetCachedSize(int size) const {
_cached_size_.Set(size); _cached_size_.Set(size);
@ -291,6 +295,7 @@ failure:
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByDerefFirst<SortItem> Less; typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByDerefFirst<SortItem> Less;
struct Utf8Check { struct Utf8Check {
static void Check(ConstPtr p) { static void Check(ConstPtr p) {
(void)p;
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
p->first.data(), static_cast<int>(p->first.length()), p->first.data(), static_cast<int>(p->first.length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -430,11 +435,11 @@ Value::_Internal::list_value(const Value* msg) {
return *msg->kind_.list_value_; return *msg->kind_.list_value_;
} }
void Value::set_allocated_struct_value(PROTOBUF_NAMESPACE_ID::Struct* struct_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(); clear_kind();
if (struct_value) { if (struct_value) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
::PROTOBUF_NAMESPACE_ID::Arena::GetArena(struct_value); ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<PROTOBUF_NAMESPACE_ID::Struct>::GetOwningArena(struct_value);
if (message_arena != submessage_arena) { if (message_arena != submessage_arena) {
struct_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( struct_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, struct_value, submessage_arena); 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) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.struct_value)
} }
void Value::set_allocated_list_value(PROTOBUF_NAMESPACE_ID::ListValue* list_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(); clear_kind();
if (list_value) { if (list_value) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
::PROTOBUF_NAMESPACE_ID::Arena::GetArena(list_value); ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<PROTOBUF_NAMESPACE_ID::ListValue>::GetOwningArena(list_value);
if (message_arena != submessage_arena) { if (message_arena != submessage_arena) {
list_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( list_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, list_value, submessage_arena); message_arena, list_value, submessage_arena);
@ -512,7 +517,7 @@ Value::~Value() {
} }
void Value::SharedDtor() { void Value::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
if (has_kind()) { if (has_kind()) {
clear_kind(); clear_kind();
} }
@ -540,7 +545,7 @@ void Value::clear_kind() {
break; break;
} }
case kStringValue: { 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; break;
} }
case kBoolValue: { case kBoolValue: {
@ -548,13 +553,13 @@ void Value::clear_kind() {
break; break;
} }
case kStructValue: { case kStructValue: {
if (GetArena() == nullptr) { if (GetArenaForAllocation() == nullptr) {
delete kind_.struct_value_; delete kind_.struct_value_;
} }
break; break;
} }
case kListValue: { case kListValue: {
if (GetArena() == nullptr) { if (GetArenaForAllocation() == nullptr) {
delete kind_.list_value_; delete kind_.list_value_;
} }
break; break;
@ -883,7 +888,7 @@ ListValue::~ListValue() {
} }
void ListValue::SharedDtor() { void ListValue::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void ListValue::ArenaDtor(void* object) { void ListValue::ArenaDtor(void* object) {

View File

@ -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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Struct) */ {
public: public:
inline Struct() : Struct(nullptr) {} inline Struct() : Struct(nullptr) {}
@ -148,8 +148,9 @@ class PROTOBUF_EXPORT Struct PROTOBUF_FINAL :
return *this; return *this;
} }
inline Struct& operator=(Struct&& from) noexcept { inline Struct& operator=(Struct&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -180,7 +181,7 @@ class PROTOBUF_EXPORT Struct PROTOBUF_FINAL :
} }
inline void Swap(Struct* other) { inline void Swap(Struct* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -188,14 +189,14 @@ class PROTOBUF_EXPORT Struct PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Struct* other) { void UnsafeArenaSwap(Struct* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Struct* New() const final { inline Struct* New() const final {
return CreateMaybeMessage<Struct>(nullptr); return new Struct();
} }
Struct* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { 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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Value) */ {
public: public:
inline Value() : Value(nullptr) {} inline Value() : Value(nullptr) {}
@ -292,8 +293,9 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL :
return *this; return *this;
} }
inline Value& operator=(Value&& from) noexcept { inline Value& operator=(Value&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -334,7 +336,7 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL :
} }
inline void Swap(Value* other) { inline void Swap(Value* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -342,14 +344,14 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Value* other) { void UnsafeArenaSwap(Value* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Value* New() const final { inline Value* New() const final {
return CreateMaybeMessage<Value>(nullptr); return new Value();
} }
Value* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { Value* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -434,11 +436,11 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_string_value(ArgT0&& arg0, ArgT... args); void set_string_value(ArgT0&& arg0, ArgT... args);
std::string* mutable_string_value(); 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); void set_allocated_string_value(std::string* string_value);
private: private:
const std::string& _internal_string_value() const; 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(); std::string* _internal_mutable_string_value();
public: 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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ListValue) */ {
public: public:
inline ListValue() : ListValue(nullptr) {} inline ListValue() : ListValue(nullptr) {}
@ -544,8 +546,9 @@ class PROTOBUF_EXPORT ListValue PROTOBUF_FINAL :
return *this; return *this;
} }
inline ListValue& operator=(ListValue&& from) noexcept { inline ListValue& operator=(ListValue&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -576,7 +579,7 @@ class PROTOBUF_EXPORT ListValue PROTOBUF_FINAL :
} }
inline void Swap(ListValue* other) { inline void Swap(ListValue* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -584,14 +587,14 @@ class PROTOBUF_EXPORT ListValue PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(ListValue* other) { void UnsafeArenaSwap(ListValue* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline ListValue* New() const final { inline ListValue* New() const final {
return CreateMaybeMessage<ListValue>(nullptr); return new ListValue();
} }
ListValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { 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() { inline void Value::clear_string_value() {
if (_internal_has_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(); clear_has_kind();
} }
} }
@ -813,7 +816,7 @@ inline void Value::set_string_value(ArgT0&& arg0, ArgT... args) {
set_has_string_value(); set_has_string_value();
kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
} }
kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value)
} }
inline std::string* Value::mutable_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(); set_has_string_value();
kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); 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() { inline std::string* Value::_internal_mutable_string_value() {
if (!_internal_has_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()); kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
} }
return kind_.string_value_.Mutable( 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() { inline std::string* Value::release_string_value() {
// @@protoc_insertion_point(field_release:google.protobuf.Value.string_value) // @@protoc_insertion_point(field_release:google.protobuf.Value.string_value)
if (_internal_has_string_value()) { if (_internal_has_string_value()) {
clear_has_kind(); 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 { } else {
return nullptr; return nullptr;
} }
@ -859,7 +862,7 @@ inline void Value::set_allocated_string_value(std::string* string_value) {
if (string_value != nullptr) { if (string_value != nullptr) {
set_has_string_value(); set_has_string_value();
kind_.string_value_.UnsafeSetDefault(string_value); kind_.string_value_.UnsafeSetDefault(string_value);
::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaForAllocation();
if (arena != nullptr) { if (arena != nullptr) {
arena->Own(string_value); arena->Own(string_value);
} }
@ -917,7 +920,7 @@ inline void Value::set_has_struct_value() {
} }
inline void Value::clear_struct_value() { inline void Value::clear_struct_value() {
if (_internal_has_struct_value()) { if (_internal_has_struct_value()) {
if (GetArena() == nullptr) { if (GetArenaForAllocation() == nullptr) {
delete kind_.struct_value_; delete kind_.struct_value_;
} }
clear_has_kind(); clear_has_kind();
@ -928,7 +931,7 @@ inline PROTOBUF_NAMESPACE_ID::Struct* Value::release_struct_value() {
if (_internal_has_struct_value()) { if (_internal_has_struct_value()) {
clear_has_kind(); clear_has_kind();
PROTOBUF_NAMESPACE_ID::Struct* temp = kind_.struct_value_; PROTOBUF_NAMESPACE_ID::Struct* temp = kind_.struct_value_;
if (GetArena() != nullptr) { if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
} }
kind_.struct_value_ = nullptr; kind_.struct_value_ = nullptr;
@ -969,7 +972,7 @@ inline PROTOBUF_NAMESPACE_ID::Struct* Value::_internal_mutable_struct_value() {
if (!_internal_has_struct_value()) { if (!_internal_has_struct_value()) {
clear_kind(); clear_kind();
set_has_struct_value(); 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_; return kind_.struct_value_;
} }
@ -990,7 +993,7 @@ inline void Value::set_has_list_value() {
} }
inline void Value::clear_list_value() { inline void Value::clear_list_value() {
if (_internal_has_list_value()) { if (_internal_has_list_value()) {
if (GetArena() == nullptr) { if (GetArenaForAllocation() == nullptr) {
delete kind_.list_value_; delete kind_.list_value_;
} }
clear_has_kind(); clear_has_kind();
@ -1001,7 +1004,7 @@ inline PROTOBUF_NAMESPACE_ID::ListValue* Value::release_list_value() {
if (_internal_has_list_value()) { if (_internal_has_list_value()) {
clear_has_kind(); clear_has_kind();
PROTOBUF_NAMESPACE_ID::ListValue* temp = kind_.list_value_; PROTOBUF_NAMESPACE_ID::ListValue* temp = kind_.list_value_;
if (GetArena() != nullptr) { if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
} }
kind_.list_value_ = nullptr; kind_.list_value_ = nullptr;
@ -1042,7 +1045,7 @@ inline PROTOBUF_NAMESPACE_ID::ListValue* Value::_internal_mutable_list_value() {
if (!_internal_has_list_value()) { if (!_internal_has_list_value()) {
clear_kind(); clear_kind();
set_has_list_value(); 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_; return kind_.list_value_;
} }

View File

@ -211,32 +211,29 @@ LogMessage& LogMessage::operator<<(const uint128& value) {
return *this; return *this;
} }
// Since this is just for logging, we don't care if the current locale changes LogMessage& LogMessage::operator<<(char value) {
// the results -- in fact, we probably prefer that. So we use snprintf() return *this << StringPiece(&value, 1);
// instead of Simple*toa(). }
LogMessage& LogMessage::operator<<(void* value) {
StrAppend(&message_, strings::Hex(reinterpret_cast<uintptr_t>(value)));
return *this;
}
#undef DECLARE_STREAM_OPERATOR #undef DECLARE_STREAM_OPERATOR
#define DECLARE_STREAM_OPERATOR(TYPE, FORMAT) \ #define DECLARE_STREAM_OPERATOR(TYPE) \
LogMessage& LogMessage::operator<<(TYPE value) { \ LogMessage& LogMessage::operator<<(TYPE value) { \
/* 128 bytes should be big enough for any of the primitive */ \ StrAppend(&message_, value); \
/* values which we print with this, but well use snprintf() */ \ return *this; \
/* 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; \
} }
DECLARE_STREAM_OPERATOR(char , "%c" ) DECLARE_STREAM_OPERATOR(int)
DECLARE_STREAM_OPERATOR(int , "%d" ) DECLARE_STREAM_OPERATOR(unsigned int)
DECLARE_STREAM_OPERATOR(unsigned int , "%u" ) DECLARE_STREAM_OPERATOR(long) // NOLINT(runtime/int)
DECLARE_STREAM_OPERATOR(long , "%ld") DECLARE_STREAM_OPERATOR(unsigned long) // NOLINT(runtime/int)
DECLARE_STREAM_OPERATOR(unsigned long, "%lu") DECLARE_STREAM_OPERATOR(double)
DECLARE_STREAM_OPERATOR(double , "%g" ) DECLARE_STREAM_OPERATOR(long long) // NOLINT(runtime/int)
DECLARE_STREAM_OPERATOR(void* , "%p" ) DECLARE_STREAM_OPERATOR(unsigned long long) // NOLINT(runtime/int)
DECLARE_STREAM_OPERATOR(long long , "%" PROTOBUF_LL_FORMAT "d")
DECLARE_STREAM_OPERATOR(unsigned long long, "%" PROTOBUF_LL_FORMAT "u")
#undef DECLARE_STREAM_OPERATOR #undef DECLARE_STREAM_OPERATOR
LogMessage::LogMessage(LogLevel level, const char* filename, int line) LogMessage::LogMessage(LogLevel level, const char* filename, int line)

View File

@ -41,10 +41,8 @@
namespace google { namespace google {
namespace protobuf { namespace protobuf {
const uint128_pod kuint128max = { const uint128_pod kuint128max = {uint64_t{0xFFFFFFFFFFFFFFFFu},
static_cast<uint64>(PROTOBUF_LONGLONG(0xFFFFFFFFFFFFFFFF)), uint64_t{0xFFFFFFFFFFFFFFFFu}};
static_cast<uint64>(PROTOBUF_LONGLONG(0xFFFFFFFFFFFFFFFF))
};
// Returns the 0-based position of the last set bit (i.e., most significant bit) // 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. // 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, 0x10);
STEP(uint32, n32, pos, 0x08); STEP(uint32, n32, pos, 0x08);
STEP(uint32, n32, pos, 0x04); STEP(uint32, n32, pos, 0x04);
return pos + ((PROTOBUF_ULONGLONG(0x3333333322221100) >> (n32 << 2)) & 0x3); return pos + ((uint64_t{0x3333333322221100u} >> (n32 << 2)) & 0x3);
} }
#undef STEP #undef STEP
@ -134,17 +132,17 @@ std::ostream& operator<<(std::ostream& o, const uint128& b) {
switch (flags & std::ios::basefield) { switch (flags & std::ios::basefield) {
case std::ios::hex: case std::ios::hex:
div = div =
static_cast<uint64>(PROTOBUF_ULONGLONG(0x1000000000000000)); // 16^15 static_cast<uint64>(uint64_t{0x1000000000000000u}); // 16^15
div_base_log = 15; div_base_log = 15;
break; break;
case std::ios::oct: case std::ios::oct:
div = static_cast<uint64>( div = static_cast<uint64>(
PROTOBUF_ULONGLONG(01000000000000000000000)); // 8^21 uint64_t{01000000000000000000000u}); // 8^21
div_base_log = 21; div_base_log = 21;
break; break;
default: // std::ios::dec default: // std::ios::dec
div = static_cast<uint64>( div = static_cast<uint64>(
PROTOBUF_ULONGLONG(10000000000000000000)); // 10^19 uint64_t{10000000000000000000u}); // 10^19
div_base_log = 19; div_base_log = 19;
break; break;
} }

View File

@ -293,26 +293,20 @@ TEST(Int128, Multiply) {
} }
// Verified with dc. // Verified with dc.
a = uint128(PROTOBUF_ULONGLONG(0xffffeeeeddddcccc), a = uint128(uint64_t{0xffffeeeeddddccccu}, uint64_t{0xbbbbaaaa99998888u});
PROTOBUF_ULONGLONG(0xbbbbaaaa99998888)); b = uint128(uint64_t{0x7777666655554444u}, uint64_t{0x3333222211110000u});
b = uint128(PROTOBUF_ULONGLONG(0x7777666655554444),
PROTOBUF_ULONGLONG(0x3333222211110000));
c = a * b; c = a * b;
EXPECT_EQ(uint128(PROTOBUF_ULONGLONG(0x530EDA741C71D4C3), EXPECT_EQ(
PROTOBUF_ULONGLONG(0xBF25975319080000)), uint128(uint64_t{0x530EDA741C71D4C3u}, uint64_t{0xBF25975319080000u}), c);
c);
EXPECT_EQ(0, c - b * a); EXPECT_EQ(0, c - b * a);
EXPECT_EQ(a * a - b * b, (a + b) * (a - b)); EXPECT_EQ(a * a - b * b, (a + b) * (a - b));
// Verified with dc. // Verified with dc.
a = uint128(PROTOBUF_ULONGLONG(0x0123456789abcdef), a = uint128(uint64_t{0x0123456789abcdefu}, uint64_t{0xfedcba9876543210u});
PROTOBUF_ULONGLONG(0xfedcba9876543210)); b = uint128(uint64_t{0x02468ace13579bdfu}, uint64_t{0xfdb97531eca86420u});
b = uint128(PROTOBUF_ULONGLONG(0x02468ace13579bdf),
PROTOBUF_ULONGLONG(0xfdb97531eca86420));
c = a * b; c = a * b;
EXPECT_EQ(uint128(PROTOBUF_ULONGLONG(0x97a87f4f261ba3f2), EXPECT_EQ(
PROTOBUF_ULONGLONG(0x342d0bbf48948200)), uint128(uint64_t{0x97a87f4f261ba3f2u}, uint64_t{0x342d0bbf48948200u}), c);
c);
EXPECT_EQ(0, c - b * a); EXPECT_EQ(0, c - b * a);
EXPECT_EQ(a*a - b*b, (a+b) * (a-b)); EXPECT_EQ(a*a - b*b, (a+b) * (a-b));
} }
@ -359,10 +353,8 @@ TEST(Int128, DivideAndMod) {
EXPECT_EQ(0, q); EXPECT_EQ(0, q);
EXPECT_EQ(0, r); EXPECT_EQ(0, r);
a = uint128(PROTOBUF_ULONGLONG(0x530eda741c71d4c3), a = uint128(uint64_t{0x530eda741c71d4c3u}, uint64_t{0xbf25975319080000u});
PROTOBUF_ULONGLONG(0xbf25975319080000)); q = uint128(uint64_t{0x4de2cab081u}, uint64_t{0x14c34ab4676e4babu});
q = uint128(PROTOBUF_ULONGLONG(0x4de2cab081),
PROTOBUF_ULONGLONG(0x14c34ab4676e4bab));
b = uint128(0x1110001); b = uint128(0x1110001);
r = uint128(0x3eb455); r = uint128(0x3eb455);
ASSERT_EQ(a, q * b + r); // Sanity-check. ASSERT_EQ(a, q * b + r); // Sanity-check.
@ -400,8 +392,8 @@ TEST(Int128, DivideAndMod) {
// Try a large remainder. // Try a large remainder.
b = a / 2 + 1; b = a / 2 + 1;
uint128 expected_r(PROTOBUF_ULONGLONG(0x29876d3a0e38ea61), uint128 expected_r(uint64_t{0x29876d3a0e38ea61u},
PROTOBUF_ULONGLONG(0xdf92cba98c83ffff)); uint64_t{0xdf92cba98c83ffffu});
// Sanity checks. // Sanity checks.
ASSERT_EQ(a / 2 - 1, expected_r); ASSERT_EQ(a / 2 - 1, expected_r);
ASSERT_EQ(a, b + 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::oct, 0, '_', "2000000000000000000000"},
{uint128(1, 0), std::ios::hex, 0, '_', "10000000000000000"}, {uint128(1, 0), std::ios::hex, 0, '_', "10000000000000000"},
// just the top bit // just the top bit
{uint128(PROTOBUF_ULONGLONG(0x8000000000000000), 0), std::ios::dec, 0, {uint128(uint64_t{0x8000000000000000u}, 0), std::ios::dec, 0, '_',
'_', "170141183460469231731687303715884105728"}, "170141183460469231731687303715884105728"},
{uint128(PROTOBUF_ULONGLONG(0x8000000000000000), 0), std::ios::oct, 0, {uint128(uint64_t{0x8000000000000000u}, 0), std::ios::oct, 0, '_',
'_', "2000000000000000000000000000000000000000000"}, "2000000000000000000000000000000000000000000"},
{uint128(PROTOBUF_ULONGLONG(0x8000000000000000), 0), std::ios::hex, 0, {uint128(uint64_t{0x8000000000000000u}, 0), std::ios::hex, 0, '_',
'_', "80000000000000000000000000000000"}, "80000000000000000000000000000000"},
// maximum uint128 value // maximum uint128 value
{uint128(-1, -1), std::ios::dec, 0, '_', {uint128(-1, -1), std::ios::dec, 0, '_',
"340282366920938463463374607431768211455"}, "340282366920938463463374607431768211455"},

View File

@ -35,8 +35,8 @@ namespace google {
namespace protobuf { namespace protobuf {
#undef GOOGLE_DISALLOW_EVIL_CONSTRUCTORS #undef GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName) \ #define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName) \
TypeName(const TypeName&) = delete; \ TypeName(const TypeName&) = delete; \
void operator=(const TypeName&) = delete void operator=(const TypeName&) = delete
#undef GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS #undef GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS

View File

@ -136,10 +136,10 @@ typedef uint64_t uint64;
static const int32 kint32max = 0x7FFFFFFF; static const int32 kint32max = 0x7FFFFFFF;
static const int32 kint32min = -kint32max - 1; 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 int64 kint64min = -kint64max - 1;
static const uint32 kuint32max = 0xFFFFFFFFu; 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) ||\ #if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) ||\
defined(MEMORY_SANITIZER) defined(MEMORY_SANITIZER)
@ -263,14 +263,14 @@ static inline uint32 bswap_32(uint32 x) {
#ifndef bswap_64 #ifndef bswap_64
static inline uint64 bswap_64(uint64 x) { static inline uint64 bswap_64(uint64 x) {
return (((x & PROTOBUF_ULONGLONG(0xFF)) << 56) | return (((x & uint64_t{0xFFu)) << 56) |
((x & PROTOBUF_ULONGLONG(0xFF00)) << 40) | ((x & uint64_t{0xFF00u)) << 40) |
((x & PROTOBUF_ULONGLONG(0xFF0000)) << 24) | ((x & uint64_t{0xFF0000u)) << 24) |
((x & PROTOBUF_ULONGLONG(0xFF000000)) << 8) | ((x & uint64_t{0xFF000000u)) << 8) |
((x & PROTOBUF_ULONGLONG(0xFF00000000)) >> 8) | ((x & uint64_t{0xFF00000000u)) >> 8) |
((x & PROTOBUF_ULONGLONG(0xFF0000000000)) >> 24) | ((x & uint64_t{0xFF0000000000u)) >> 24) |
((x & PROTOBUF_ULONGLONG(0xFF000000000000)) >> 40) | ((x & uint64_t{0xFF000000000000u)) >> 40) |
((x & PROTOBUF_ULONGLONG(0xFF00000000000000)) >> 56)); ((x & uint64_t{0xFF00000000000000u)) >> 56));
} }
#define bswap_64(x) bswap_64(x) #define bswap_64(x) bswap_64(x)
#endif #endif

View File

@ -46,6 +46,10 @@ std::ostream& operator<<(std::ostream& o, StringPiece piece) {
return o; 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 { void StringPiece::CopyToString(std::string* target) const {
target->assign(ptr_, length_); target->assign(ptr_, length_);
} }
@ -71,8 +75,8 @@ bool StringPiece::ConsumeFromEnd(StringPiece x) {
return false; return false;
} }
StringPiece::size_type StringPiece::copy( StringPiece::size_type StringPiece::copy(char* buf, size_type n,
char* buf, size_type n, size_type pos) const { size_type pos) const {
size_type ret = std::min(length_ - pos, n); size_type ret = std::min(length_ - pos, n);
memcpy(buf, ptr_ + pos, ret); memcpy(buf, ptr_ + pos, ret);
return ret; return ret;
@ -82,8 +86,7 @@ bool StringPiece::contains(StringPiece s) const {
return find(s, 0) != npos; return find(s, 0) != npos;
} }
StringPiece::size_type StringPiece::find( StringPiece::size_type StringPiece::find(StringPiece s, size_type pos) const {
StringPiece s, size_type pos) const {
if (length_ <= 0 || pos > static_cast<size_type>(length_)) { if (length_ <= 0 || pos > static_cast<size_type>(length_)) {
if (length_ == 0 && pos == 0 && s.length_ == 0) return 0; if (length_ == 0 && pos == 0 && s.length_ == 0) return 0;
return npos; 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 { StringPiece::size_type StringPiece::rfind(char c, size_type pos) const {
// Note: memrchr() is not available on Windows. // Note: memrchr() is not available on Windows.
if (empty()) return npos; if (empty()) return npos;
for (difference_type i = for (size_type i = std::min(pos, length_ - 1);; --i) {
std::min(pos, static_cast<size_type>(length_ - 1));
i >= 0; --i) {
if (ptr_[i] == c) { if (ptr_[i] == c) {
return i; return i;
} }
if (i == 0) break;
} }
return npos; return npos;
} }
@ -143,8 +145,8 @@ static inline void BuildLookupTable(StringPiece characters_wanted,
} }
} }
StringPiece::size_type StringPiece::find_first_of( StringPiece::size_type StringPiece::find_first_of(StringPiece s,
StringPiece s, size_type pos) const { size_type pos) const {
if (empty() || s.empty()) { if (empty() || s.empty()) {
return npos; return npos;
} }
@ -161,8 +163,8 @@ StringPiece::size_type StringPiece::find_first_of(
return npos; return npos;
} }
StringPiece::size_type StringPiece::find_first_not_of( StringPiece::size_type StringPiece::find_first_not_of(StringPiece s,
StringPiece s, size_type pos) const { size_type pos) const {
if (empty()) return npos; if (empty()) return npos;
if (s.empty()) return 0; if (s.empty()) return 0;
// Avoid the cost of BuildLookupTable() for a single-character search. // Avoid the cost of BuildLookupTable() for a single-character search.
@ -178,8 +180,8 @@ StringPiece::size_type StringPiece::find_first_not_of(
return npos; return npos;
} }
StringPiece::size_type StringPiece::find_first_not_of( StringPiece::size_type StringPiece::find_first_not_of(char c,
char c, size_type pos) const { size_type pos) const {
if (empty()) return npos; if (empty()) return npos;
for (; pos < static_cast<size_type>(length_); ++pos) { for (; pos < static_cast<size_type>(length_); ++pos) {
@ -190,28 +192,28 @@ StringPiece::size_type StringPiece::find_first_not_of(
return npos; return npos;
} }
StringPiece::size_type StringPiece::find_last_of( StringPiece::size_type StringPiece::find_last_of(StringPiece s,
StringPiece s, size_type pos) const { size_type pos) const {
if (empty() || s.empty()) return npos; if (empty() || s.empty()) return npos;
// Avoid the cost of BuildLookupTable() for a single-character search. // Avoid the cost of BuildLookupTable() for a single-character search.
if (s.length_ == 1) return find_last_of(s.ptr_[0], pos); if (s.length_ == 1) return find_last_of(s.ptr_[0], pos);
bool lookup[UCHAR_MAX + 1] = { false }; bool lookup[UCHAR_MAX + 1] = { false };
BuildLookupTable(s, lookup); BuildLookupTable(s, lookup);
for (difference_type i = for (size_type i = std::min(pos, length_ - 1);; --i) {
std::min(pos, static_cast<size_type>(length_ - 1)); i >= 0; --i) {
if (lookup[static_cast<unsigned char>(ptr_[i])]) { if (lookup[static_cast<unsigned char>(ptr_[i])]) {
return i; return i;
} }
if (i == 0) break;
} }
return npos; return npos;
} }
StringPiece::size_type StringPiece::find_last_not_of( StringPiece::size_type StringPiece::find_last_not_of(StringPiece s,
StringPiece s, size_type pos) const { size_type pos) const {
if (empty()) return npos; 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; if (s.empty()) return i;
// Avoid the cost of BuildLookupTable() for a single-character search. // 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 }; bool lookup[UCHAR_MAX + 1] = { false };
BuildLookupTable(s, lookup); BuildLookupTable(s, lookup);
for (; i >= 0; --i) { for (;; --i) {
if (!lookup[static_cast<unsigned char>(ptr_[i])]) { if (!lookup[static_cast<unsigned char>(ptr_[i])]) {
return i; return i;
} }
if (i == 0) break;
} }
return npos; return npos;
} }
StringPiece::size_type StringPiece::find_last_not_of( StringPiece::size_type StringPiece::find_last_not_of(char c,
char c, size_type pos) const { size_type pos) const {
if (empty()) return npos; if (empty()) return npos;
size_type i = std::min(pos, length_ - 1);
for (difference_type i = for (;; --i) {
std::min(pos, static_cast<size_type>(length_ - 1)); i >= 0; --i) {
if (ptr_[i] != c) { if (ptr_[i] != c) {
return i; return i;
} }
if (i == 0) break;
} }
return npos; return npos;
} }

View File

@ -175,6 +175,23 @@ class PROTOBUF_EXPORT StringPiece {
const char* ptr_; const char* ptr_;
size_type length_; size_type length_;
static constexpr size_type kMaxSize =
(std::numeric_limits<difference_type>::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: public:
// We provide non-explicit singleton constructors so users can pass // We provide non-explicit singleton constructors so users can pass
// in a "const char*" or a "string" wherever a "StringPiece" is // 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) StringPiece(const char* str) // NOLINT(runtime/explicit)
: ptr_(str), length_(0) { : ptr_(str), length_(0) {
if (str != nullptr) { if (str != nullptr) {
length_ = strlen(str); length_ = CheckSize(strlen(str));
} }
} }
@ -195,11 +212,11 @@ class PROTOBUF_EXPORT StringPiece {
StringPiece( // NOLINT(runtime/explicit) StringPiece( // NOLINT(runtime/explicit)
const std::basic_string<char, std::char_traits<char>, Allocator>& str) const std::basic_string<char, std::char_traits<char>, Allocator>& str)
: ptr_(str.data()), length_(0) { : ptr_(str.data()), length_(0) {
length_ = str.size(); length_ = CheckSize(str.size());
} }
StringPiece(const char* offset, size_type len) 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 // 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 // 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 { size_type find_last_of(char c, size_type pos = npos) const {
return rfind(c, pos); return rfind(c, pos);
} }
size_type find_last_not_of(StringPiece s, size_type find_last_not_of(StringPiece s, size_type pos = npos) const;
size_type pos = npos) const;
size_type find_last_not_of(char c, 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; StringPiece substr(size_type pos, size_type n = npos) const;

View File

@ -590,13 +590,13 @@ TEST(StringPiece, Custom) {
} }
{ {
StringPiece str("foobar"); StringPiece str("foobar");
EXPECT_TRUE(str.ConsumeFromEnd("bar")); EXPECT_TRUE(str.ConsumeFromEnd("bar"));
EXPECT_EQ(str, "foo"); EXPECT_EQ(str, "foo");
EXPECT_FALSE(str.ConsumeFromEnd("bar")); EXPECT_FALSE(str.ConsumeFromEnd("bar"));
EXPECT_FALSE(str.ConsumeFromEnd("foofoo")); EXPECT_FALSE(str.ConsumeFromEnd("foofoo"));
EXPECT_FALSE(str.ConsumeFromEnd("fo")); EXPECT_FALSE(str.ConsumeFromEnd("fo"));
EXPECT_EQ(str, "foo"); EXPECT_EQ(str, "foo");
} }
} }
@ -685,7 +685,7 @@ TEST(FindOneCharTest, EdgeCases) {
#ifdef PROTOBUF_HAS_DEATH_TEST #ifdef PROTOBUF_HAS_DEATH_TEST
#ifndef NDEBUG #ifndef NDEBUG
TEST(NonNegativeLenTest, NonNegativeLen) { TEST(NonNegativeLenTest, NonNegativeLen) {
EXPECT_DEATH(StringPiece("xyz", -1), "len >= 0"); EXPECT_DEATH(StringPiece("xyz", -1), "string length exceeds max size");
} }
#endif // ndef DEBUG #endif // ndef DEBUG
#endif // PROTOBUF_HAS_DEATH_TEST #endif // PROTOBUF_HAS_DEATH_TEST

View File

@ -1622,7 +1622,8 @@ int GlobalReplaceSubstring(const std::string &substring,
for (StringPiece::size_type match_pos = for (StringPiece::size_type match_pos =
s->find(substring.data(), pos, substring.length()); s->find(substring.data(), pos, substring.length());
match_pos != std::string::npos; pos = match_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; ++num_replacements;
// Append the original content before the match. // Append the original content before the match.
tmp.append(*s, pos, match_pos - pos); tmp.append(*s, pos, match_pos - pos);

View File

@ -1069,13 +1069,8 @@ static std::string RemoveRedundantZeros(std::string text) {
TEST_F(TextFormatTest, PrintExotic) { TEST_F(TextFormatTest, PrintExotic) {
unittest::TestAllTypes message; unittest::TestAllTypes message;
// Note: In C, a negative integer literal is actually the unary negation message.add_repeated_int64(int64_t{-9223372036854775807} - 1);
// operator being applied to a positive integer literal, and message.add_repeated_uint64(uint64_t{18446744073709551615u});
// 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_double(123.456); message.add_repeated_double(123.456);
message.add_repeated_double(1.23e21); message.add_repeated_double(1.23e21);
message.add_repeated_double(1.23e-18); message.add_repeated_double(1.23e-18);
@ -1240,32 +1235,19 @@ TEST_F(TextFormatTest, ParseExotic) {
ASSERT_EQ(2, message.repeated_int32_size()); ASSERT_EQ(2, message.repeated_int32_size());
EXPECT_EQ(-1, message.repeated_int32(0)); EXPECT_EQ(-1, message.repeated_int32(0));
// Note: In C, a negative integer literal is actually the unary negation EXPECT_EQ(-2147483648, message.repeated_int32(1));
// 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));
ASSERT_EQ(2, message.repeated_int64_size()); ASSERT_EQ(2, message.repeated_int64_size());
EXPECT_EQ(-1, message.repeated_int64(0)); EXPECT_EQ(-1, message.repeated_int64(0));
// Note: In C, a negative integer literal is actually the unary negation EXPECT_EQ(int64_t{-9223372036854775807} - 1, message.repeated_int64(1));
// 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));
ASSERT_EQ(2, message.repeated_uint32_size()); ASSERT_EQ(2, message.repeated_uint32_size());
EXPECT_EQ(4294967295u, message.repeated_uint32(0)); EXPECT_EQ(4294967295u, message.repeated_uint32(0));
EXPECT_EQ(2147483648u, message.repeated_uint32(1)); EXPECT_EQ(2147483648u, message.repeated_uint32(1));
ASSERT_EQ(2, message.repeated_uint64_size()); ASSERT_EQ(2, message.repeated_uint64_size());
EXPECT_EQ(PROTOBUF_ULONGLONG(18446744073709551615), EXPECT_EQ(uint64_t{18446744073709551615u}, message.repeated_uint64(0));
message.repeated_uint64(0)); EXPECT_EQ(uint64_t{9223372036854775808u}, message.repeated_uint64(1));
EXPECT_EQ(PROTOBUF_ULONGLONG(9223372036854775808),
message.repeated_uint64(1));
ASSERT_EQ(13, message.repeated_double_size()); ASSERT_EQ(13, message.repeated_double_size());
EXPECT_EQ(123.0, message.repeated_double(0)); EXPECT_EQ(123.0, message.repeated_double(0));

View File

@ -19,7 +19,7 @@ PROTOBUF_PRAGMA_INIT_SEG
PROTOBUF_NAMESPACE_OPEN PROTOBUF_NAMESPACE_OPEN
constexpr Timestamp::Timestamp( constexpr Timestamp::Timestamp(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: seconds_(PROTOBUF_LONGLONG(0)) : seconds_(int64_t{0})
, nanos_(0){} , nanos_(0){}
struct TimestampDefaultTypeInternal { struct TimestampDefaultTypeInternal {
constexpr TimestampDefaultTypeInternal() constexpr TimestampDefaultTypeInternal()
@ -110,7 +110,7 @@ Timestamp::~Timestamp() {
} }
void Timestamp::SharedDtor() { void Timestamp::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void Timestamp::ArenaDtor(void* object) { void Timestamp::ArenaDtor(void* object) {

View File

@ -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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Timestamp) */ {
public: public:
inline Timestamp() : Timestamp(nullptr) {} inline Timestamp() : Timestamp(nullptr) {}
@ -83,8 +83,9 @@ class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL :
return *this; return *this;
} }
inline Timestamp& operator=(Timestamp&& from) noexcept { inline Timestamp& operator=(Timestamp&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -115,7 +116,7 @@ class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL :
} }
inline void Swap(Timestamp* other) { inline void Swap(Timestamp* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -123,14 +124,14 @@ class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Timestamp* other) { void UnsafeArenaSwap(Timestamp* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Timestamp* New() const final { inline Timestamp* New() const final {
return CreateMaybeMessage<Timestamp>(nullptr); return new Timestamp();
} }
Timestamp* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { Timestamp* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -218,7 +219,7 @@ class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL :
// int64 seconds = 1; // int64 seconds = 1;
inline void Timestamp::clear_seconds() { inline void Timestamp::clear_seconds() {
seconds_ = PROTOBUF_LONGLONG(0); seconds_ = int64_t{0};
} }
inline ::PROTOBUF_NAMESPACE_ID::int64 Timestamp::_internal_seconds() const { inline ::PROTOBUF_NAMESPACE_ID::int64 Timestamp::_internal_seconds() const {
return seconds_; return seconds_;

View File

@ -343,7 +343,7 @@ Type::_Internal::source_context(const Type* msg) {
return *msg->source_context_; return *msg->source_context_;
} }
void Type::clear_source_context() { void Type::clear_source_context() {
if (GetArena() == nullptr && source_context_ != nullptr) { if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) {
delete source_context_; delete source_context_;
} }
source_context_ = nullptr; source_context_ = nullptr;
@ -366,7 +366,7 @@ Type::Type(const Type& from)
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
if (from._internal_has_source_context()) { if (from._internal_has_source_context()) {
source_context_ = new PROTOBUF_NAMESPACE_ID::SourceContext(*from.source_context_); source_context_ = new PROTOBUF_NAMESPACE_ID::SourceContext(*from.source_context_);
@ -392,7 +392,7 @@ Type::~Type() {
} }
void Type::SharedDtor() { void Type::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete source_context_; if (this != internal_default_instance()) delete source_context_;
} }
@ -417,7 +417,7 @@ void Type::Clear() {
oneofs_.Clear(); oneofs_.Clear();
options_.Clear(); options_.Clear();
name_.ClearToEmpty(); name_.ClearToEmpty();
if (GetArena() == nullptr && source_context_ != nullptr) { if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) {
delete source_context_; delete source_context_;
} }
source_context_ = nullptr; source_context_ = nullptr;
@ -523,7 +523,7 @@ failure:
(void) cached_has_bits; (void) cached_has_bits;
// string name = 1; // string name = 1;
if (this->name().size() > 0) { if (!this->name().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()), this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -612,7 +612,7 @@ size_t Type::ByteSizeLong() const {
} }
// string name = 1; // string name = 1;
if (this->name().size() > 0) { if (!this->name().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_name()); this->_internal_name());
@ -665,7 +665,7 @@ void Type::MergeFrom(const Type& from) {
fields_.MergeFrom(from.fields_); fields_.MergeFrom(from.fields_);
oneofs_.MergeFrom(from.oneofs_); oneofs_.MergeFrom(from.oneofs_);
options_.MergeFrom(from.options_); options_.MergeFrom(from.options_);
if (from.name().size() > 0) { if (!from.name().empty()) {
_internal_set_name(from._internal_name()); _internal_set_name(from._internal_name());
} }
if (from.has_source_context()) { if (from.has_source_context()) {
@ -700,7 +700,11 @@ void Type::InternalSwap(Type* other) {
fields_.InternalSwap(&other->fields_); fields_.InternalSwap(&other->fields_);
oneofs_.InternalSwap(&other->oneofs_); oneofs_.InternalSwap(&other->oneofs_);
options_.InternalSwap(&other->options_); 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_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(Type, syntax_) PROTOBUF_FIELD_OFFSET(Type, syntax_)
+ sizeof(Type::syntax_) + sizeof(Type::syntax_)
@ -735,22 +739,22 @@ Field::Field(const Field& from)
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_type_url().empty()) { if (!from._internal_type_url().empty()) {
type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_url(), type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_url(),
GetArena()); GetArenaForAllocation());
} }
json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_json_name().empty()) { if (!from._internal_json_name().empty()) {
json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_json_name(), json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_json_name(),
GetArena()); GetArenaForAllocation());
} }
default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_default_value().empty()) { if (!from._internal_default_value().empty()) {
default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_default_value(), default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_default_value(),
GetArena()); GetArenaForAllocation());
} }
::memcpy(&kind_, &from.kind_, ::memcpy(&kind_, &from.kind_,
static_cast<size_t>(reinterpret_cast<char*>(&packed_) - static_cast<size_t>(reinterpret_cast<char*>(&packed_) -
@ -776,7 +780,7 @@ Field::~Field() {
} }
void Field::SharedDtor() { void Field::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
json_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); json_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
@ -951,7 +955,7 @@ failure:
} }
// string name = 4; // string name = 4;
if (this->name().size() > 0) { if (!this->name().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()), this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -961,7 +965,7 @@ failure:
} }
// string type_url = 6; // string type_url = 6;
if (this->type_url().size() > 0) { if (!this->type_url().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_type_url().data(), static_cast<int>(this->_internal_type_url().length()), this->_internal_type_url().data(), static_cast<int>(this->_internal_type_url().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -991,7 +995,7 @@ failure:
} }
// string json_name = 10; // string json_name = 10;
if (this->json_name().size() > 0) { if (!this->json_name().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_json_name().data(), static_cast<int>(this->_internal_json_name().length()), this->_internal_json_name().data(), static_cast<int>(this->_internal_json_name().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -1001,7 +1005,7 @@ failure:
} }
// string default_value = 11; // string default_value = 11;
if (this->default_value().size() > 0) { if (!this->default_value().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_default_value().data(), static_cast<int>(this->_internal_default_value().length()), this->_internal_default_value().data(), static_cast<int>(this->_internal_default_value().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -1034,28 +1038,28 @@ size_t Field::ByteSizeLong() const {
} }
// string name = 4; // string name = 4;
if (this->name().size() > 0) { if (!this->name().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_name()); this->_internal_name());
} }
// string type_url = 6; // string type_url = 6;
if (this->type_url().size() > 0) { if (!this->type_url().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_type_url()); this->_internal_type_url());
} }
// string json_name = 10; // string json_name = 10;
if (this->json_name().size() > 0) { if (!this->json_name().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_json_name()); this->_internal_json_name());
} }
// string default_value = 11; // string default_value = 11;
if (this->default_value().size() > 0) { if (!this->default_value().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_default_value()); this->_internal_default_value());
@ -1124,16 +1128,16 @@ void Field::MergeFrom(const Field& from) {
(void) cached_has_bits; (void) cached_has_bits;
options_.MergeFrom(from.options_); options_.MergeFrom(from.options_);
if (from.name().size() > 0) { if (!from.name().empty()) {
_internal_set_name(from._internal_name()); _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()); _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()); _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()); _internal_set_default_value(from._internal_default_value());
} }
if (from.kind() != 0) { if (from.kind() != 0) {
@ -1175,10 +1179,26 @@ void Field::InternalSwap(Field* other) {
using std::swap; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
options_.InternalSwap(&other->options_); options_.InternalSwap(&other->options_);
name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
type_url_.Swap(&other->type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
json_name_.Swap(&other->json_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &name_, GetArenaForAllocation(),
default_value_.Swap(&other->default_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); &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_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(Field, packed_) PROTOBUF_FIELD_OFFSET(Field, packed_)
+ sizeof(Field::packed_) + sizeof(Field::packed_)
@ -1205,7 +1225,7 @@ Enum::_Internal::source_context(const Enum* msg) {
return *msg->source_context_; return *msg->source_context_;
} }
void Enum::clear_source_context() { void Enum::clear_source_context() {
if (GetArena() == nullptr && source_context_ != nullptr) { if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) {
delete source_context_; delete source_context_;
} }
source_context_ = nullptr; source_context_ = nullptr;
@ -1226,7 +1246,7 @@ Enum::Enum(const Enum& from)
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
if (from._internal_has_source_context()) { if (from._internal_has_source_context()) {
source_context_ = new PROTOBUF_NAMESPACE_ID::SourceContext(*from.source_context_); source_context_ = new PROTOBUF_NAMESPACE_ID::SourceContext(*from.source_context_);
@ -1252,7 +1272,7 @@ Enum::~Enum() {
} }
void Enum::SharedDtor() { void Enum::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete source_context_; if (this != internal_default_instance()) delete source_context_;
} }
@ -1276,7 +1296,7 @@ void Enum::Clear() {
enumvalue_.Clear(); enumvalue_.Clear();
options_.Clear(); options_.Clear();
name_.ClearToEmpty(); name_.ClearToEmpty();
if (GetArena() == nullptr && source_context_ != nullptr) { if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) {
delete source_context_; delete source_context_;
} }
source_context_ = nullptr; source_context_ = nullptr;
@ -1368,7 +1388,7 @@ failure:
(void) cached_has_bits; (void) cached_has_bits;
// string name = 1; // string name = 1;
if (this->name().size() > 0) { if (!this->name().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()), this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -1439,7 +1459,7 @@ size_t Enum::ByteSizeLong() const {
} }
// string name = 1; // string name = 1;
if (this->name().size() > 0) { if (!this->name().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_name()); this->_internal_name());
@ -1491,7 +1511,7 @@ void Enum::MergeFrom(const Enum& from) {
enumvalue_.MergeFrom(from.enumvalue_); enumvalue_.MergeFrom(from.enumvalue_);
options_.MergeFrom(from.options_); options_.MergeFrom(from.options_);
if (from.name().size() > 0) { if (!from.name().empty()) {
_internal_set_name(from._internal_name()); _internal_set_name(from._internal_name());
} }
if (from.has_source_context()) { if (from.has_source_context()) {
@ -1525,7 +1545,11 @@ void Enum::InternalSwap(Enum* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
enumvalue_.InternalSwap(&other->enumvalue_); enumvalue_.InternalSwap(&other->enumvalue_);
options_.InternalSwap(&other->options_); 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_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(Enum, syntax_) PROTOBUF_FIELD_OFFSET(Enum, syntax_)
+ sizeof(Enum::syntax_) + sizeof(Enum::syntax_)
@ -1560,7 +1584,7 @@ EnumValue::EnumValue(const EnumValue& from)
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
number_ = from.number_; number_ = from.number_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValue) // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValue)
@ -1578,7 +1602,7 @@ EnumValue::~EnumValue() {
} }
void EnumValue::SharedDtor() { void EnumValue::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
} }
@ -1668,7 +1692,7 @@ failure:
(void) cached_has_bits; (void) cached_has_bits;
// string name = 1; // string name = 1;
if (this->name().size() > 0) { if (!this->name().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()), this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -1715,7 +1739,7 @@ size_t EnumValue::ByteSizeLong() const {
} }
// string name = 1; // string name = 1;
if (this->name().size() > 0) { if (!this->name().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_name()); this->_internal_name());
@ -1760,7 +1784,7 @@ void EnumValue::MergeFrom(const EnumValue& from) {
(void) cached_has_bits; (void) cached_has_bits;
options_.MergeFrom(from.options_); options_.MergeFrom(from.options_);
if (from.name().size() > 0) { if (!from.name().empty()) {
_internal_set_name(from._internal_name()); _internal_set_name(from._internal_name());
} }
if (from.number() != 0) { if (from.number() != 0) {
@ -1790,7 +1814,11 @@ void EnumValue::InternalSwap(EnumValue* other) {
using std::swap; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
options_.InternalSwap(&other->options_); 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_); swap(number_, other->number_);
} }
@ -1812,7 +1840,7 @@ Option::_Internal::value(const Option* msg) {
return *msg->value_; return *msg->value_;
} }
void Option::clear_value() { void Option::clear_value() {
if (GetArena() == nullptr && value_ != nullptr) { if (GetArenaForAllocation() == nullptr && value_ != nullptr) {
delete value_; delete value_;
} }
value_ = nullptr; value_ = nullptr;
@ -1829,7 +1857,7 @@ Option::Option(const Option& from)
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(),
GetArena()); GetArenaForAllocation());
} }
if (from._internal_has_value()) { if (from._internal_has_value()) {
value_ = new PROTOBUF_NAMESPACE_ID::Any(*from.value_); value_ = new PROTOBUF_NAMESPACE_ID::Any(*from.value_);
@ -1851,7 +1879,7 @@ Option::~Option() {
} }
void Option::SharedDtor() { void Option::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete value_; if (this != internal_default_instance()) delete value_;
} }
@ -1873,7 +1901,7 @@ void Option::Clear() {
(void) cached_has_bits; (void) cached_has_bits;
name_.ClearToEmpty(); name_.ClearToEmpty();
if (GetArena() == nullptr && value_ != nullptr) { if (GetArenaForAllocation() == nullptr && value_ != nullptr) {
delete value_; delete value_;
} }
value_ = nullptr; value_ = nullptr;
@ -1932,7 +1960,7 @@ failure:
(void) cached_has_bits; (void) cached_has_bits;
// string name = 1; // string name = 1;
if (this->name().size() > 0) { if (!this->name().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()), this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -1966,7 +1994,7 @@ size_t Option::ByteSizeLong() const {
(void) cached_has_bits; (void) cached_has_bits;
// string name = 1; // string name = 1;
if (this->name().size() > 0) { if (!this->name().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_name()); this->_internal_name());
@ -2010,7 +2038,7 @@ void Option::MergeFrom(const Option& from) {
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits; (void) cached_has_bits;
if (from.name().size() > 0) { if (!from.name().empty()) {
_internal_set_name(from._internal_name()); _internal_set_name(from._internal_name());
} }
if (from.has_value()) { if (from.has_value()) {
@ -2039,7 +2067,11 @@ bool Option::IsInitialized() const {
void Option::InternalSwap(Option* other) { void Option::InternalSwap(Option* other) {
using std::swap; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _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_); swap(value_, other->value_);
} }

View File

@ -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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Type) */ {
public: public:
inline Type() : Type(nullptr) {} inline Type() : Type(nullptr) {}
@ -196,8 +196,9 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL :
return *this; return *this;
} }
inline Type& operator=(Type&& from) noexcept { inline Type& operator=(Type&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -228,7 +229,7 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL :
} }
inline void Swap(Type* other) { inline void Swap(Type* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -236,14 +237,14 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Type* other) { void UnsafeArenaSwap(Type* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Type* New() const final { inline Type* New() const final {
return CreateMaybeMessage<Type>(nullptr); return new Type();
} }
Type* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { Type* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -358,11 +359,11 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_name(ArgT0&& arg0, ArgT... args); void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name(); std::string* mutable_name();
std::string* release_name(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name); void set_allocated_name(std::string* name);
private: private:
const std::string& _internal_name() const; 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(); std::string* _internal_mutable_name();
public: 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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Field) */ {
public: public:
inline Field() : Field(nullptr) {} inline Field() : Field(nullptr) {}
@ -429,8 +430,9 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
return *this; return *this;
} }
inline Field& operator=(Field&& from) noexcept { inline Field& operator=(Field&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -461,7 +463,7 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
} }
inline void Swap(Field* other) { inline void Swap(Field* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -469,14 +471,14 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Field* other) { void UnsafeArenaSwap(Field* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Field* New() const final { inline Field* New() const final {
return CreateMaybeMessage<Field>(nullptr); return new Field();
} }
Field* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { Field* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -651,11 +653,11 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_name(ArgT0&& arg0, ArgT... args); void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name(); std::string* mutable_name();
std::string* release_name(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name); void set_allocated_name(std::string* name);
private: private:
const std::string& _internal_name() const; 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(); std::string* _internal_mutable_name();
public: public:
@ -665,11 +667,11 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_type_url(ArgT0&& arg0, ArgT... args); void set_type_url(ArgT0&& arg0, ArgT... args);
std::string* mutable_type_url(); 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); void set_allocated_type_url(std::string* type_url);
private: private:
const std::string& _internal_type_url() const; 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(); std::string* _internal_mutable_type_url();
public: public:
@ -679,11 +681,11 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_json_name(ArgT0&& arg0, ArgT... args); void set_json_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_json_name(); 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); void set_allocated_json_name(std::string* json_name);
private: private:
const std::string& _internal_json_name() const; 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(); std::string* _internal_mutable_json_name();
public: public:
@ -693,11 +695,11 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_default_value(ArgT0&& arg0, ArgT... args); void set_default_value(ArgT0&& arg0, ArgT... args);
std::string* mutable_default_value(); 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); void set_allocated_default_value(std::string* default_value);
private: private:
const std::string& _internal_default_value() const; 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(); std::string* _internal_mutable_default_value();
public: 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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Enum) */ {
public: public:
inline Enum() : Enum(nullptr) {} inline Enum() : Enum(nullptr) {}
@ -786,8 +788,9 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL :
return *this; return *this;
} }
inline Enum& operator=(Enum&& from) noexcept { inline Enum& operator=(Enum&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -818,7 +821,7 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL :
} }
inline void Swap(Enum* other) { inline void Swap(Enum* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -826,14 +829,14 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Enum* other) { void UnsafeArenaSwap(Enum* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Enum* New() const final { inline Enum* New() const final {
return CreateMaybeMessage<Enum>(nullptr); return new Enum();
} }
Enum* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { Enum* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -923,11 +926,11 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_name(ArgT0&& arg0, ArgT... args); void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name(); std::string* mutable_name();
std::string* release_name(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name); void set_allocated_name(std::string* name);
private: private:
const std::string& _internal_name() const; 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(); std::string* _internal_mutable_name();
public: 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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValue) */ {
public: public:
inline EnumValue() : EnumValue(nullptr) {} inline EnumValue() : EnumValue(nullptr) {}
@ -993,8 +996,9 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL :
return *this; return *this;
} }
inline EnumValue& operator=(EnumValue&& from) noexcept { inline EnumValue& operator=(EnumValue&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -1025,7 +1029,7 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL :
} }
inline void Swap(EnumValue* other) { inline void Swap(EnumValue* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -1033,14 +1037,14 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(EnumValue* other) { void UnsafeArenaSwap(EnumValue* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline EnumValue* New() const final { inline EnumValue* New() const final {
return CreateMaybeMessage<EnumValue>(nullptr); return new EnumValue();
} }
EnumValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { EnumValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -1110,11 +1114,11 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_name(ArgT0&& arg0, ArgT... args); void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name(); std::string* mutable_name();
std::string* release_name(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name); void set_allocated_name(std::string* name);
private: private:
const std::string& _internal_name() const; 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(); std::string* _internal_mutable_name();
public: 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 ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Option) */ {
public: public:
inline Option() : Option(nullptr) {} inline Option() : Option(nullptr) {}
@ -1160,8 +1164,9 @@ class PROTOBUF_EXPORT Option PROTOBUF_FINAL :
return *this; return *this;
} }
inline Option& operator=(Option&& from) noexcept { inline Option& operator=(Option&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -1192,7 +1197,7 @@ class PROTOBUF_EXPORT Option PROTOBUF_FINAL :
} }
inline void Swap(Option* other) { inline void Swap(Option* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -1200,14 +1205,14 @@ class PROTOBUF_EXPORT Option PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Option* other) { void UnsafeArenaSwap(Option* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Option* New() const final { inline Option* New() const final {
return CreateMaybeMessage<Option>(nullptr); return new Option();
} }
Option* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { Option* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -1258,11 +1263,11 @@ class PROTOBUF_EXPORT Option PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_name(ArgT0&& arg0, ArgT... args); void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name(); std::string* mutable_name();
std::string* release_name(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name); void set_allocated_name(std::string* name);
private: private:
const std::string& _internal_name() const; 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(); std::string* _internal_mutable_name();
public: public:
@ -1316,10 +1321,10 @@ inline const std::string& Type::name() const {
return _internal_name(); return _internal_name();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Type::set_name(ArgT0&& arg0, ArgT... args) { void Type::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Type.name) // @@protoc_insertion_point(field_set:google.protobuf.Type.name)
} }
inline std::string* Type::mutable_name() { inline std::string* Type::mutable_name() {
@ -1331,15 +1336,15 @@ inline const std::string& Type::_internal_name() const {
} }
inline void Type::_internal_set_name(const std::string& value) { inline void Type::_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* Type::_internal_mutable_name() { inline std::string* Type::_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* Type::release_name() { inline std::string* Type::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Type.name) // @@protoc_insertion_point(field_release:google.protobuf.Type.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
} }
inline void Type::set_allocated_name(std::string* name) { inline void Type::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -1348,7 +1353,7 @@ inline void Type::set_allocated_name(std::string* name) {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.name)
} }
@ -1522,7 +1527,7 @@ inline const PROTOBUF_NAMESPACE_ID::SourceContext& Type::source_context() const
} }
inline void Type::unsafe_arena_set_allocated_source_context( inline void Type::unsafe_arena_set_allocated_source_context(
PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { PROTOBUF_NAMESPACE_ID::SourceContext* source_context) {
if (GetArena() == nullptr) { if (GetArenaForAllocation() == nullptr) {
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_);
} }
source_context_ = source_context; source_context_ = source_context;
@ -1537,7 +1542,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Type::release_source_context() {
PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_; PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_;
source_context_ = nullptr; source_context_ = nullptr;
if (GetArena() != nullptr) { if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
} }
return temp; return temp;
@ -1552,7 +1557,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Type::unsafe_arena_release_source_c
inline PROTOBUF_NAMESPACE_ID::SourceContext* Type::_internal_mutable_source_context() { inline PROTOBUF_NAMESPACE_ID::SourceContext* Type::_internal_mutable_source_context() {
if (source_context_ == nullptr) { if (source_context_ == nullptr) {
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::SourceContext>(GetArena()); auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::SourceContext>(GetArenaForAllocation());
source_context_ = p; source_context_ = p;
} }
return source_context_; return source_context_;
@ -1562,13 +1567,15 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Type::mutable_source_context() {
return _internal_mutable_source_context(); return _internal_mutable_source_context();
} }
inline void Type::set_allocated_source_context(PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { inline void Type::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) { if (message_arena == nullptr) {
delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_);
} }
if (source_context) { if (source_context) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::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) { if (message_arena != submessage_arena) {
source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, source_context, submessage_arena); message_arena, source_context, submessage_arena);
@ -1674,10 +1681,10 @@ inline const std::string& Field::name() const {
return _internal_name(); return _internal_name();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Field::set_name(ArgT0&& arg0, ArgT... args) { void Field::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.name) // @@protoc_insertion_point(field_set:google.protobuf.Field.name)
} }
inline std::string* Field::mutable_name() { inline std::string* Field::mutable_name() {
@ -1689,15 +1696,15 @@ inline const std::string& Field::_internal_name() const {
} }
inline void Field::_internal_set_name(const std::string& value) { inline void Field::_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* Field::_internal_mutable_name() { inline std::string* Field::_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* Field::release_name() { inline std::string* Field::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.name) // @@protoc_insertion_point(field_release:google.protobuf.Field.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
} }
inline void Field::set_allocated_name(std::string* name) { inline void Field::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -1706,7 +1713,7 @@ inline void Field::set_allocated_name(std::string* name) {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.name)
} }
@ -1719,10 +1726,10 @@ inline const std::string& Field::type_url() const {
return _internal_type_url(); return _internal_type_url();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Field::set_type_url(ArgT0&& arg0, ArgT... args) { void Field::set_type_url(ArgT0&& arg0, ArgT... args) {
type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.type_url) // @@protoc_insertion_point(field_set:google.protobuf.Field.type_url)
} }
inline std::string* Field::mutable_type_url() { inline std::string* Field::mutable_type_url() {
@ -1734,15 +1741,15 @@ inline const std::string& Field::_internal_type_url() const {
} }
inline void Field::_internal_set_type_url(const std::string& value) { inline void Field::_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* Field::_internal_mutable_type_url() { inline std::string* Field::_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* Field::release_type_url() { inline std::string* Field::release_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.type_url) // @@protoc_insertion_point(field_release:google.protobuf.Field.type_url)
return type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); return type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
} }
inline void Field::set_allocated_type_url(std::string* type_url) { inline void Field::set_allocated_type_url(std::string* type_url) {
if (type_url != nullptr) { if (type_url != nullptr) {
@ -1751,7 +1758,7 @@ inline void Field::set_allocated_type_url(std::string* type_url) {
} }
type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_url, type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_url,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.type_url) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.type_url)
} }
@ -1843,10 +1850,10 @@ inline const std::string& Field::json_name() const {
return _internal_json_name(); return _internal_json_name();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Field::set_json_name(ArgT0&& arg0, ArgT... args) { void Field::set_json_name(ArgT0&& arg0, ArgT... args) {
json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.json_name) // @@protoc_insertion_point(field_set:google.protobuf.Field.json_name)
} }
inline std::string* Field::mutable_json_name() { inline std::string* Field::mutable_json_name() {
@ -1858,15 +1865,15 @@ inline const std::string& Field::_internal_json_name() const {
} }
inline void Field::_internal_set_json_name(const std::string& value) { inline void Field::_internal_set_json_name(const std::string& value) {
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* Field::_internal_mutable_json_name() { inline std::string* Field::_internal_mutable_json_name() {
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* Field::release_json_name() { inline std::string* Field::release_json_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.json_name) // @@protoc_insertion_point(field_release:google.protobuf.Field.json_name)
return json_name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); return json_name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
} }
inline void Field::set_allocated_json_name(std::string* json_name) { inline void Field::set_allocated_json_name(std::string* json_name) {
if (json_name != nullptr) { if (json_name != nullptr) {
@ -1875,7 +1882,7 @@ inline void Field::set_allocated_json_name(std::string* json_name) {
} }
json_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), json_name, json_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), json_name,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name)
} }
@ -1888,10 +1895,10 @@ inline const std::string& Field::default_value() const {
return _internal_default_value(); return _internal_default_value();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Field::set_default_value(ArgT0&& arg0, ArgT... args) { void Field::set_default_value(ArgT0&& arg0, ArgT... args) {
default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.default_value) // @@protoc_insertion_point(field_set:google.protobuf.Field.default_value)
} }
inline std::string* Field::mutable_default_value() { inline std::string* Field::mutable_default_value() {
@ -1903,15 +1910,15 @@ inline const std::string& Field::_internal_default_value() const {
} }
inline void Field::_internal_set_default_value(const std::string& value) { inline void Field::_internal_set_default_value(const std::string& value) {
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* Field::_internal_mutable_default_value() { inline std::string* Field::_internal_mutable_default_value() {
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* Field::release_default_value() { inline std::string* Field::release_default_value() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.default_value) // @@protoc_insertion_point(field_release:google.protobuf.Field.default_value)
return default_value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); return default_value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
} }
inline void Field::set_allocated_default_value(std::string* default_value) { inline void Field::set_allocated_default_value(std::string* default_value) {
if (default_value != nullptr) { if (default_value != nullptr) {
@ -1920,7 +1927,7 @@ inline void Field::set_allocated_default_value(std::string* default_value) {
} }
default_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), default_value, default_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), default_value,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.default_value) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.default_value)
} }
@ -1937,10 +1944,10 @@ inline const std::string& Enum::name() const {
return _internal_name(); return _internal_name();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Enum::set_name(ArgT0&& arg0, ArgT... args) { void Enum::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Enum.name) // @@protoc_insertion_point(field_set:google.protobuf.Enum.name)
} }
inline std::string* Enum::mutable_name() { inline std::string* Enum::mutable_name() {
@ -1952,15 +1959,15 @@ inline const std::string& Enum::_internal_name() const {
} }
inline void Enum::_internal_set_name(const std::string& value) { inline void Enum::_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* Enum::_internal_mutable_name() { inline std::string* Enum::_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* Enum::release_name() { inline std::string* Enum::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Enum.name) // @@protoc_insertion_point(field_release:google.protobuf.Enum.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
} }
inline void Enum::set_allocated_name(std::string* name) { inline void Enum::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -1969,7 +1976,7 @@ inline void Enum::set_allocated_name(std::string* name) {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.name)
} }
@ -2069,7 +2076,7 @@ inline const PROTOBUF_NAMESPACE_ID::SourceContext& Enum::source_context() const
} }
inline void Enum::unsafe_arena_set_allocated_source_context( inline void Enum::unsafe_arena_set_allocated_source_context(
PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { PROTOBUF_NAMESPACE_ID::SourceContext* source_context) {
if (GetArena() == nullptr) { if (GetArenaForAllocation() == nullptr) {
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_);
} }
source_context_ = source_context; source_context_ = source_context;
@ -2084,7 +2091,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Enum::release_source_context() {
PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_; PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_;
source_context_ = nullptr; source_context_ = nullptr;
if (GetArena() != nullptr) { if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
} }
return temp; return temp;
@ -2099,7 +2106,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Enum::unsafe_arena_release_source_c
inline PROTOBUF_NAMESPACE_ID::SourceContext* Enum::_internal_mutable_source_context() { inline PROTOBUF_NAMESPACE_ID::SourceContext* Enum::_internal_mutable_source_context() {
if (source_context_ == nullptr) { if (source_context_ == nullptr) {
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::SourceContext>(GetArena()); auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::SourceContext>(GetArenaForAllocation());
source_context_ = p; source_context_ = p;
} }
return source_context_; return source_context_;
@ -2109,13 +2116,15 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Enum::mutable_source_context() {
return _internal_mutable_source_context(); return _internal_mutable_source_context();
} }
inline void Enum::set_allocated_source_context(PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { inline void Enum::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) { if (message_arena == nullptr) {
delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_);
} }
if (source_context) { if (source_context) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::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) { if (message_arena != submessage_arena) {
source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, source_context, submessage_arena); message_arena, source_context, submessage_arena);
@ -2161,10 +2170,10 @@ inline const std::string& EnumValue::name() const {
return _internal_name(); return _internal_name();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void EnumValue::set_name(ArgT0&& arg0, ArgT... args) { void EnumValue::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name) // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name)
} }
inline std::string* EnumValue::mutable_name() { inline std::string* EnumValue::mutable_name() {
@ -2176,15 +2185,15 @@ inline const std::string& EnumValue::_internal_name() const {
} }
inline void EnumValue::_internal_set_name(const std::string& value) { inline void EnumValue::_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* EnumValue::_internal_mutable_name() { inline std::string* EnumValue::_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* EnumValue::release_name() { inline std::string* EnumValue::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.EnumValue.name) // @@protoc_insertion_point(field_release:google.protobuf.EnumValue.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
} }
inline void EnumValue::set_allocated_name(std::string* name) { inline void EnumValue::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -2193,7 +2202,7 @@ inline void EnumValue::set_allocated_name(std::string* name) {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name)
} }
@ -2269,10 +2278,10 @@ inline const std::string& Option::name() const {
return _internal_name(); return _internal_name();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void Option::set_name(ArgT0&& arg0, ArgT... args) { void Option::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Option.name) // @@protoc_insertion_point(field_set:google.protobuf.Option.name)
} }
inline std::string* Option::mutable_name() { inline std::string* Option::mutable_name() {
@ -2284,15 +2293,15 @@ inline const std::string& Option::_internal_name() const {
} }
inline void Option::_internal_set_name(const std::string& value) { inline void Option::_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* Option::_internal_mutable_name() { inline std::string* Option::_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* Option::release_name() { inline std::string* Option::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Option.name) // @@protoc_insertion_point(field_release:google.protobuf.Option.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
} }
inline void Option::set_allocated_name(std::string* name) { inline void Option::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -2301,7 +2310,7 @@ inline void Option::set_allocated_name(std::string* name) {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.name)
} }
@ -2323,7 +2332,7 @@ inline const PROTOBUF_NAMESPACE_ID::Any& Option::value() const {
} }
inline void Option::unsafe_arena_set_allocated_value( inline void Option::unsafe_arena_set_allocated_value(
PROTOBUF_NAMESPACE_ID::Any* value) { PROTOBUF_NAMESPACE_ID::Any* value) {
if (GetArena() == nullptr) { if (GetArenaForAllocation() == nullptr) {
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(value_); delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(value_);
} }
value_ = value; value_ = value;
@ -2338,7 +2347,7 @@ inline PROTOBUF_NAMESPACE_ID::Any* Option::release_value() {
PROTOBUF_NAMESPACE_ID::Any* temp = value_; PROTOBUF_NAMESPACE_ID::Any* temp = value_;
value_ = nullptr; value_ = nullptr;
if (GetArena() != nullptr) { if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
} }
return temp; return temp;
@ -2353,7 +2362,7 @@ inline PROTOBUF_NAMESPACE_ID::Any* Option::unsafe_arena_release_value() {
inline PROTOBUF_NAMESPACE_ID::Any* Option::_internal_mutable_value() { inline PROTOBUF_NAMESPACE_ID::Any* Option::_internal_mutable_value() {
if (value_ == nullptr) { if (value_ == nullptr) {
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::Any>(GetArena()); auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::Any>(GetArenaForAllocation());
value_ = p; value_ = p;
} }
return value_; return value_;
@ -2363,13 +2372,15 @@ inline PROTOBUF_NAMESPACE_ID::Any* Option::mutable_value() {
return _internal_mutable_value(); return _internal_mutable_value();
} }
inline void Option::set_allocated_value(PROTOBUF_NAMESPACE_ID::Any* value) { inline void Option::set_allocated_value(PROTOBUF_NAMESPACE_ID::Any* value) {
::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation();
if (message_arena == nullptr) { if (message_arena == nullptr) {
delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(value_); delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(value_);
} }
if (value) { if (value) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(value)->GetArena(); ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<
::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena(
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(value));
if (message_arena != submessage_arena) { if (message_arena != submessage_arena) {
value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, value, submessage_arena); message_arena, value, submessage_arena);

View File

@ -1238,6 +1238,19 @@ ProtoStreamObjectWriter* ProtoStreamObjectWriter::RenderDataPiece(
return this; return this;
} }
if (IsRepeated(*field) && !current_->is_list()) {
if (options_.disable_implicit_scalar_list) {
if (!options_.suppress_implicit_scalar_list_error) {
InvalidValue(
field->name(),
"Starting an primitive in a repeated field but the parent field "
"is not a list");
}
return this;
}
}
ProtoWriter::RenderDataPiece(name, data); ProtoWriter::RenderDataPiece(name, data);
return this; return this;
} }

View File

@ -108,6 +108,13 @@ class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
// is disabled. // is disabled.
bool suppress_implicit_message_list_error; bool suppress_implicit_message_list_error;
// If true, disable implicitly creating scalar list.
bool disable_implicit_scalar_list;
// If true, suppress the error of implicitly creating scalar list when it
// is disabled.
bool suppress_implicit_scalar_list_error;
// If true, suppress the error of rendering scalar field if the source is an // If true, suppress the error of rendering scalar field if the source is an
// object. // object.
bool suppress_object_to_scalar_error; bool suppress_object_to_scalar_error;
@ -125,6 +132,8 @@ class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
use_legacy_json_map_format(false), use_legacy_json_map_format(false),
disable_implicit_message_list(false), disable_implicit_message_list(false),
suppress_implicit_message_list_error(false), suppress_implicit_message_list_error(false),
disable_implicit_scalar_list(false),
suppress_implicit_scalar_list_error(false),
suppress_object_to_scalar_error(false), suppress_object_to_scalar_error(false),
use_json_name_in_missing_fields(false) {} use_json_name_in_missing_fields(false) {}

View File

@ -811,8 +811,8 @@ TEST(WireFormatTest, UnknownFieldRecursionLimit) {
TEST(WireFormatTest, ZigZag) { TEST(WireFormatTest, ZigZag) {
// avoid line-wrapping // avoid line-wrapping
#define LL(x) PROTOBUF_LONGLONG(x) #define LL(x) static_cast<int64_t>(ULL(x))
#define ULL(x) PROTOBUF_ULONGLONG(x) #define ULL(x) uint64_t{x##u}
#define ZigZagEncode32(x) WireFormatLite::ZigZagEncode32(x) #define ZigZagEncode32(x) WireFormatLite::ZigZagEncode32(x)
#define ZigZagDecode32(x) WireFormatLite::ZigZagDecode32(x) #define ZigZagDecode32(x) WireFormatLite::ZigZagDecode32(x)
#define ZigZagEncode64(x) WireFormatLite::ZigZagEncode64(x) #define ZigZagEncode64(x) WireFormatLite::ZigZagEncode64(x)

View File

@ -43,7 +43,7 @@ struct FloatValueDefaultTypeInternal {
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FloatValueDefaultTypeInternal _FloatValue_default_instance_; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FloatValueDefaultTypeInternal _FloatValue_default_instance_;
constexpr Int64Value::Int64Value( constexpr Int64Value::Int64Value(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: value_(PROTOBUF_LONGLONG(0)){} : value_(int64_t{0}){}
struct Int64ValueDefaultTypeInternal { struct Int64ValueDefaultTypeInternal {
constexpr Int64ValueDefaultTypeInternal() constexpr Int64ValueDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
@ -55,7 +55,7 @@ struct Int64ValueDefaultTypeInternal {
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT Int64ValueDefaultTypeInternal _Int64Value_default_instance_; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT Int64ValueDefaultTypeInternal _Int64Value_default_instance_;
constexpr UInt64Value::UInt64Value( constexpr UInt64Value::UInt64Value(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: value_(PROTOBUF_ULONGLONG(0)){} : value_(uint64_t{0u}){}
struct UInt64ValueDefaultTypeInternal { struct UInt64ValueDefaultTypeInternal {
constexpr UInt64ValueDefaultTypeInternal() constexpr UInt64ValueDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
@ -269,7 +269,7 @@ DoubleValue::~DoubleValue() {
} }
void DoubleValue::SharedDtor() { void DoubleValue::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void DoubleValue::ArenaDtor(void* object) { void DoubleValue::ArenaDtor(void* object) {
@ -457,7 +457,7 @@ FloatValue::~FloatValue() {
} }
void FloatValue::SharedDtor() { void FloatValue::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void FloatValue::ArenaDtor(void* object) { void FloatValue::ArenaDtor(void* object) {
@ -635,7 +635,7 @@ Int64Value::Int64Value(const Int64Value& from)
} }
void Int64Value::SharedCtor() { void Int64Value::SharedCtor() {
value_ = PROTOBUF_LONGLONG(0); value_ = int64_t{0};
} }
Int64Value::~Int64Value() { Int64Value::~Int64Value() {
@ -645,7 +645,7 @@ Int64Value::~Int64Value() {
} }
void Int64Value::SharedDtor() { void Int64Value::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void Int64Value::ArenaDtor(void* object) { void Int64Value::ArenaDtor(void* object) {
@ -664,7 +664,7 @@ void Int64Value::Clear() {
// Prevent compiler warnings about cached_has_bits being unused // Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits; (void) cached_has_bits;
value_ = PROTOBUF_LONGLONG(0); value_ = int64_t{0};
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
} }
@ -825,7 +825,7 @@ UInt64Value::UInt64Value(const UInt64Value& from)
} }
void UInt64Value::SharedCtor() { void UInt64Value::SharedCtor() {
value_ = PROTOBUF_ULONGLONG(0); value_ = uint64_t{0u};
} }
UInt64Value::~UInt64Value() { UInt64Value::~UInt64Value() {
@ -835,7 +835,7 @@ UInt64Value::~UInt64Value() {
} }
void UInt64Value::SharedDtor() { void UInt64Value::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void UInt64Value::ArenaDtor(void* object) { void UInt64Value::ArenaDtor(void* object) {
@ -854,7 +854,7 @@ void UInt64Value::Clear() {
// Prevent compiler warnings about cached_has_bits being unused // Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits; (void) cached_has_bits;
value_ = PROTOBUF_ULONGLONG(0); value_ = uint64_t{0u};
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
} }
@ -1025,7 +1025,7 @@ Int32Value::~Int32Value() {
} }
void Int32Value::SharedDtor() { void Int32Value::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void Int32Value::ArenaDtor(void* object) { void Int32Value::ArenaDtor(void* object) {
@ -1215,7 +1215,7 @@ UInt32Value::~UInt32Value() {
} }
void UInt32Value::SharedDtor() { void UInt32Value::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void UInt32Value::ArenaDtor(void* object) { void UInt32Value::ArenaDtor(void* object) {
@ -1405,7 +1405,7 @@ BoolValue::~BoolValue() {
} }
void BoolValue::SharedDtor() { void BoolValue::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
} }
void BoolValue::ArenaDtor(void* object) { void BoolValue::ArenaDtor(void* object) {
@ -1581,7 +1581,7 @@ StringValue::StringValue(const StringValue& from)
value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_value().empty()) { if (!from._internal_value().empty()) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(), value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(),
GetArena()); GetArenaForAllocation());
} }
// @@protoc_insertion_point(copy_constructor:google.protobuf.StringValue) // @@protoc_insertion_point(copy_constructor:google.protobuf.StringValue)
} }
@ -1597,7 +1597,7 @@ StringValue::~StringValue() {
} }
void StringValue::SharedDtor() { void StringValue::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
} }
@ -1666,7 +1666,7 @@ failure:
(void) cached_has_bits; (void) cached_has_bits;
// string value = 1; // string value = 1;
if (this->value().size() > 0) { if (!this->value().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_value().data(), static_cast<int>(this->_internal_value().length()), this->_internal_value().data(), static_cast<int>(this->_internal_value().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
@ -1692,7 +1692,7 @@ size_t StringValue::ByteSizeLong() const {
(void) cached_has_bits; (void) cached_has_bits;
// string value = 1; // string value = 1;
if (this->value().size() > 0) { if (!this->value().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_value()); this->_internal_value());
@ -1729,7 +1729,7 @@ void StringValue::MergeFrom(const StringValue& from) {
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits; (void) cached_has_bits;
if (from.value().size() > 0) { if (!from.value().empty()) {
_internal_set_value(from._internal_value()); _internal_set_value(from._internal_value());
} }
} }
@ -1755,7 +1755,11 @@ bool StringValue::IsInitialized() const {
void StringValue::InternalSwap(StringValue* other) { void StringValue::InternalSwap(StringValue* other) {
using std::swap; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
value_.Swap(&other->value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&value_, GetArenaForAllocation(),
&other->value_, other->GetArenaForAllocation()
);
} }
::PROTOBUF_NAMESPACE_ID::Metadata StringValue::GetMetadata() const { ::PROTOBUF_NAMESPACE_ID::Metadata StringValue::GetMetadata() const {
@ -1782,7 +1786,7 @@ BytesValue::BytesValue(const BytesValue& from)
value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_value().empty()) { if (!from._internal_value().empty()) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(), value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(),
GetArena()); GetArenaForAllocation());
} }
// @@protoc_insertion_point(copy_constructor:google.protobuf.BytesValue) // @@protoc_insertion_point(copy_constructor:google.protobuf.BytesValue)
} }
@ -1798,7 +1802,7 @@ BytesValue::~BytesValue() {
} }
void BytesValue::SharedDtor() { void BytesValue::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
} }
@ -1866,7 +1870,7 @@ failure:
(void) cached_has_bits; (void) cached_has_bits;
// bytes value = 1; // bytes value = 1;
if (this->value().size() > 0) { if (!this->value().empty()) {
target = stream->WriteBytesMaybeAliased( target = stream->WriteBytesMaybeAliased(
1, this->_internal_value(), target); 1, this->_internal_value(), target);
} }
@ -1888,7 +1892,7 @@ size_t BytesValue::ByteSizeLong() const {
(void) cached_has_bits; (void) cached_has_bits;
// bytes value = 1; // bytes value = 1;
if (this->value().size() > 0) { if (!this->value().empty()) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
this->_internal_value()); this->_internal_value());
@ -1925,7 +1929,7 @@ void BytesValue::MergeFrom(const BytesValue& from) {
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits; (void) cached_has_bits;
if (from.value().size() > 0) { if (!from.value().empty()) {
_internal_set_value(from._internal_value()); _internal_set_value(from._internal_value());
} }
} }
@ -1951,7 +1955,11 @@ bool BytesValue::IsInitialized() const {
void BytesValue::InternalSwap(BytesValue* other) { void BytesValue::InternalSwap(BytesValue* other) {
using std::swap; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
value_.Swap(&other->value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&value_, GetArenaForAllocation(),
&other->value_, other->GetArenaForAllocation()
);
} }
::PROTOBUF_NAMESPACE_ID::Metadata BytesValue::GetMetadata() const { ::PROTOBUF_NAMESPACE_ID::Metadata BytesValue::GetMetadata() const {

View File

@ -97,7 +97,7 @@ PROTOBUF_NAMESPACE_OPEN
// =================================================================== // ===================================================================
class PROTOBUF_EXPORT DoubleValue PROTOBUF_FINAL : class PROTOBUF_EXPORT DoubleValue final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DoubleValue) */ { public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DoubleValue) */ {
public: public:
inline DoubleValue() : DoubleValue(nullptr) {} inline DoubleValue() : DoubleValue(nullptr) {}
@ -115,8 +115,9 @@ class PROTOBUF_EXPORT DoubleValue PROTOBUF_FINAL :
return *this; return *this;
} }
inline DoubleValue& operator=(DoubleValue&& from) noexcept { inline DoubleValue& operator=(DoubleValue&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -147,7 +148,7 @@ class PROTOBUF_EXPORT DoubleValue PROTOBUF_FINAL :
} }
inline void Swap(DoubleValue* other) { inline void Swap(DoubleValue* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -155,14 +156,14 @@ class PROTOBUF_EXPORT DoubleValue PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(DoubleValue* other) { void UnsafeArenaSwap(DoubleValue* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline DoubleValue* New() const final { inline DoubleValue* New() const final {
return CreateMaybeMessage<DoubleValue>(nullptr); return new DoubleValue();
} }
DoubleValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { DoubleValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -228,7 +229,7 @@ class PROTOBUF_EXPORT DoubleValue PROTOBUF_FINAL :
}; };
// ------------------------------------------------------------------- // -------------------------------------------------------------------
class PROTOBUF_EXPORT FloatValue PROTOBUF_FINAL : class PROTOBUF_EXPORT FloatValue final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FloatValue) */ { public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FloatValue) */ {
public: public:
inline FloatValue() : FloatValue(nullptr) {} inline FloatValue() : FloatValue(nullptr) {}
@ -246,8 +247,9 @@ class PROTOBUF_EXPORT FloatValue PROTOBUF_FINAL :
return *this; return *this;
} }
inline FloatValue& operator=(FloatValue&& from) noexcept { inline FloatValue& operator=(FloatValue&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -278,7 +280,7 @@ class PROTOBUF_EXPORT FloatValue PROTOBUF_FINAL :
} }
inline void Swap(FloatValue* other) { inline void Swap(FloatValue* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -286,14 +288,14 @@ class PROTOBUF_EXPORT FloatValue PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(FloatValue* other) { void UnsafeArenaSwap(FloatValue* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline FloatValue* New() const final { inline FloatValue* New() const final {
return CreateMaybeMessage<FloatValue>(nullptr); return new FloatValue();
} }
FloatValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { FloatValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -359,7 +361,7 @@ class PROTOBUF_EXPORT FloatValue PROTOBUF_FINAL :
}; };
// ------------------------------------------------------------------- // -------------------------------------------------------------------
class PROTOBUF_EXPORT Int64Value PROTOBUF_FINAL : class PROTOBUF_EXPORT Int64Value final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int64Value) */ { public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int64Value) */ {
public: public:
inline Int64Value() : Int64Value(nullptr) {} inline Int64Value() : Int64Value(nullptr) {}
@ -377,8 +379,9 @@ class PROTOBUF_EXPORT Int64Value PROTOBUF_FINAL :
return *this; return *this;
} }
inline Int64Value& operator=(Int64Value&& from) noexcept { inline Int64Value& operator=(Int64Value&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -409,7 +412,7 @@ class PROTOBUF_EXPORT Int64Value PROTOBUF_FINAL :
} }
inline void Swap(Int64Value* other) { inline void Swap(Int64Value* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -417,14 +420,14 @@ class PROTOBUF_EXPORT Int64Value PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Int64Value* other) { void UnsafeArenaSwap(Int64Value* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Int64Value* New() const final { inline Int64Value* New() const final {
return CreateMaybeMessage<Int64Value>(nullptr); return new Int64Value();
} }
Int64Value* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { Int64Value* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -490,7 +493,7 @@ class PROTOBUF_EXPORT Int64Value PROTOBUF_FINAL :
}; };
// ------------------------------------------------------------------- // -------------------------------------------------------------------
class PROTOBUF_EXPORT UInt64Value PROTOBUF_FINAL : class PROTOBUF_EXPORT UInt64Value final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt64Value) */ { public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt64Value) */ {
public: public:
inline UInt64Value() : UInt64Value(nullptr) {} inline UInt64Value() : UInt64Value(nullptr) {}
@ -508,8 +511,9 @@ class PROTOBUF_EXPORT UInt64Value PROTOBUF_FINAL :
return *this; return *this;
} }
inline UInt64Value& operator=(UInt64Value&& from) noexcept { inline UInt64Value& operator=(UInt64Value&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -540,7 +544,7 @@ class PROTOBUF_EXPORT UInt64Value PROTOBUF_FINAL :
} }
inline void Swap(UInt64Value* other) { inline void Swap(UInt64Value* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -548,14 +552,14 @@ class PROTOBUF_EXPORT UInt64Value PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(UInt64Value* other) { void UnsafeArenaSwap(UInt64Value* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline UInt64Value* New() const final { inline UInt64Value* New() const final {
return CreateMaybeMessage<UInt64Value>(nullptr); return new UInt64Value();
} }
UInt64Value* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { UInt64Value* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -621,7 +625,7 @@ class PROTOBUF_EXPORT UInt64Value PROTOBUF_FINAL :
}; };
// ------------------------------------------------------------------- // -------------------------------------------------------------------
class PROTOBUF_EXPORT Int32Value PROTOBUF_FINAL : class PROTOBUF_EXPORT Int32Value final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int32Value) */ { public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int32Value) */ {
public: public:
inline Int32Value() : Int32Value(nullptr) {} inline Int32Value() : Int32Value(nullptr) {}
@ -639,8 +643,9 @@ class PROTOBUF_EXPORT Int32Value PROTOBUF_FINAL :
return *this; return *this;
} }
inline Int32Value& operator=(Int32Value&& from) noexcept { inline Int32Value& operator=(Int32Value&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -671,7 +676,7 @@ class PROTOBUF_EXPORT Int32Value PROTOBUF_FINAL :
} }
inline void Swap(Int32Value* other) { inline void Swap(Int32Value* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -679,14 +684,14 @@ class PROTOBUF_EXPORT Int32Value PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(Int32Value* other) { void UnsafeArenaSwap(Int32Value* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline Int32Value* New() const final { inline Int32Value* New() const final {
return CreateMaybeMessage<Int32Value>(nullptr); return new Int32Value();
} }
Int32Value* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { Int32Value* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -752,7 +757,7 @@ class PROTOBUF_EXPORT Int32Value PROTOBUF_FINAL :
}; };
// ------------------------------------------------------------------- // -------------------------------------------------------------------
class PROTOBUF_EXPORT UInt32Value PROTOBUF_FINAL : class PROTOBUF_EXPORT UInt32Value final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt32Value) */ { public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt32Value) */ {
public: public:
inline UInt32Value() : UInt32Value(nullptr) {} inline UInt32Value() : UInt32Value(nullptr) {}
@ -770,8 +775,9 @@ class PROTOBUF_EXPORT UInt32Value PROTOBUF_FINAL :
return *this; return *this;
} }
inline UInt32Value& operator=(UInt32Value&& from) noexcept { inline UInt32Value& operator=(UInt32Value&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -802,7 +808,7 @@ class PROTOBUF_EXPORT UInt32Value PROTOBUF_FINAL :
} }
inline void Swap(UInt32Value* other) { inline void Swap(UInt32Value* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -810,14 +816,14 @@ class PROTOBUF_EXPORT UInt32Value PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(UInt32Value* other) { void UnsafeArenaSwap(UInt32Value* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline UInt32Value* New() const final { inline UInt32Value* New() const final {
return CreateMaybeMessage<UInt32Value>(nullptr); return new UInt32Value();
} }
UInt32Value* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { UInt32Value* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -883,7 +889,7 @@ class PROTOBUF_EXPORT UInt32Value PROTOBUF_FINAL :
}; };
// ------------------------------------------------------------------- // -------------------------------------------------------------------
class PROTOBUF_EXPORT BoolValue PROTOBUF_FINAL : class PROTOBUF_EXPORT BoolValue final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BoolValue) */ { public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BoolValue) */ {
public: public:
inline BoolValue() : BoolValue(nullptr) {} inline BoolValue() : BoolValue(nullptr) {}
@ -901,8 +907,9 @@ class PROTOBUF_EXPORT BoolValue PROTOBUF_FINAL :
return *this; return *this;
} }
inline BoolValue& operator=(BoolValue&& from) noexcept { inline BoolValue& operator=(BoolValue&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -933,7 +940,7 @@ class PROTOBUF_EXPORT BoolValue PROTOBUF_FINAL :
} }
inline void Swap(BoolValue* other) { inline void Swap(BoolValue* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -941,14 +948,14 @@ class PROTOBUF_EXPORT BoolValue PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(BoolValue* other) { void UnsafeArenaSwap(BoolValue* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline BoolValue* New() const final { inline BoolValue* New() const final {
return CreateMaybeMessage<BoolValue>(nullptr); return new BoolValue();
} }
BoolValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { BoolValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -1014,7 +1021,7 @@ class PROTOBUF_EXPORT BoolValue PROTOBUF_FINAL :
}; };
// ------------------------------------------------------------------- // -------------------------------------------------------------------
class PROTOBUF_EXPORT StringValue PROTOBUF_FINAL : class PROTOBUF_EXPORT StringValue final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.StringValue) */ { public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.StringValue) */ {
public: public:
inline StringValue() : StringValue(nullptr) {} inline StringValue() : StringValue(nullptr) {}
@ -1032,8 +1039,9 @@ class PROTOBUF_EXPORT StringValue PROTOBUF_FINAL :
return *this; return *this;
} }
inline StringValue& operator=(StringValue&& from) noexcept { inline StringValue& operator=(StringValue&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -1064,7 +1072,7 @@ class PROTOBUF_EXPORT StringValue PROTOBUF_FINAL :
} }
inline void Swap(StringValue* other) { inline void Swap(StringValue* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -1072,14 +1080,14 @@ class PROTOBUF_EXPORT StringValue PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(StringValue* other) { void UnsafeArenaSwap(StringValue* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline StringValue* New() const final { inline StringValue* New() const final {
return CreateMaybeMessage<StringValue>(nullptr); return new StringValue();
} }
StringValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { StringValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -1129,11 +1137,11 @@ class PROTOBUF_EXPORT StringValue PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_value(ArgT0&& arg0, ArgT... args); void set_value(ArgT0&& arg0, ArgT... args);
std::string* mutable_value(); std::string* mutable_value();
std::string* release_value(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_value();
void set_allocated_value(std::string* value); void set_allocated_value(std::string* value);
private: private:
const std::string& _internal_value() const; 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(); std::string* _internal_mutable_value();
public: public:
@ -1150,7 +1158,7 @@ class PROTOBUF_EXPORT StringValue PROTOBUF_FINAL :
}; };
// ------------------------------------------------------------------- // -------------------------------------------------------------------
class PROTOBUF_EXPORT BytesValue PROTOBUF_FINAL : class PROTOBUF_EXPORT BytesValue final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BytesValue) */ { public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BytesValue) */ {
public: public:
inline BytesValue() : BytesValue(nullptr) {} inline BytesValue() : BytesValue(nullptr) {}
@ -1168,8 +1176,9 @@ class PROTOBUF_EXPORT BytesValue PROTOBUF_FINAL :
return *this; return *this;
} }
inline BytesValue& operator=(BytesValue&& from) noexcept { inline BytesValue& operator=(BytesValue&& from) noexcept {
if (GetArena() == from.GetArena()) { if (this == &from) return *this;
if (this != &from) InternalSwap(&from); if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else { } else {
CopyFrom(from); CopyFrom(from);
} }
@ -1200,7 +1209,7 @@ class PROTOBUF_EXPORT BytesValue PROTOBUF_FINAL :
} }
inline void Swap(BytesValue* other) { inline void Swap(BytesValue* other) {
if (other == this) return; if (other == this) return;
if (GetArena() == other->GetArena()) { if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -1208,14 +1217,14 @@ class PROTOBUF_EXPORT BytesValue PROTOBUF_FINAL :
} }
void UnsafeArenaSwap(BytesValue* other) { void UnsafeArenaSwap(BytesValue* other) {
if (other == this) return; if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena()); GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other); InternalSwap(other);
} }
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
inline BytesValue* New() const final { inline BytesValue* New() const final {
return CreateMaybeMessage<BytesValue>(nullptr); return new BytesValue();
} }
BytesValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { BytesValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
@ -1265,11 +1274,11 @@ class PROTOBUF_EXPORT BytesValue PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT> template <typename ArgT0 = const std::string&, typename... ArgT>
void set_value(ArgT0&& arg0, ArgT... args); void set_value(ArgT0&& arg0, ArgT... args);
std::string* mutable_value(); std::string* mutable_value();
std::string* release_value(); PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_value();
void set_allocated_value(std::string* value); void set_allocated_value(std::string* value);
private: private:
const std::string& _internal_value() const; 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(); std::string* _internal_mutable_value();
public: public:
@ -1345,7 +1354,7 @@ inline void FloatValue::set_value(float value) {
// int64 value = 1; // int64 value = 1;
inline void Int64Value::clear_value() { inline void Int64Value::clear_value() {
value_ = PROTOBUF_LONGLONG(0); value_ = int64_t{0};
} }
inline ::PROTOBUF_NAMESPACE_ID::int64 Int64Value::_internal_value() const { inline ::PROTOBUF_NAMESPACE_ID::int64 Int64Value::_internal_value() const {
return value_; return value_;
@ -1369,7 +1378,7 @@ inline void Int64Value::set_value(::PROTOBUF_NAMESPACE_ID::int64 value) {
// uint64 value = 1; // uint64 value = 1;
inline void UInt64Value::clear_value() { inline void UInt64Value::clear_value() {
value_ = PROTOBUF_ULONGLONG(0); value_ = uint64_t{0u};
} }
inline ::PROTOBUF_NAMESPACE_ID::uint64 UInt64Value::_internal_value() const { inline ::PROTOBUF_NAMESPACE_ID::uint64 UInt64Value::_internal_value() const {
return value_; return value_;
@ -1472,10 +1481,10 @@ inline const std::string& StringValue::value() const {
return _internal_value(); return _internal_value();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void StringValue::set_value(ArgT0&& arg0, ArgT... args) { void StringValue::set_value(ArgT0&& arg0, ArgT... args) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.StringValue.value) // @@protoc_insertion_point(field_set:google.protobuf.StringValue.value)
} }
inline std::string* StringValue::mutable_value() { inline std::string* StringValue::mutable_value() {
@ -1487,15 +1496,15 @@ inline const std::string& StringValue::_internal_value() const {
} }
inline void StringValue::_internal_set_value(const std::string& value) { inline void StringValue::_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* StringValue::_internal_mutable_value() { inline std::string* StringValue::_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* StringValue::release_value() { inline std::string* StringValue::release_value() {
// @@protoc_insertion_point(field_release:google.protobuf.StringValue.value) // @@protoc_insertion_point(field_release:google.protobuf.StringValue.value)
return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
} }
inline void StringValue::set_allocated_value(std::string* value) { inline void StringValue::set_allocated_value(std::string* value) {
if (value != nullptr) { if (value != nullptr) {
@ -1504,7 +1513,7 @@ inline void StringValue::set_allocated_value(std::string* value) {
} }
value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.StringValue.value) // @@protoc_insertion_point(field_set_allocated:google.protobuf.StringValue.value)
} }
@ -1521,10 +1530,10 @@ inline const std::string& BytesValue::value() const {
return _internal_value(); return _internal_value();
} }
template <typename ArgT0, typename... ArgT> template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
inline void BytesValue::set_value(ArgT0&& arg0, ArgT... args) { void BytesValue::set_value(ArgT0&& arg0, ArgT... args) {
value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena()); value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.BytesValue.value) // @@protoc_insertion_point(field_set:google.protobuf.BytesValue.value)
} }
inline std::string* BytesValue::mutable_value() { inline std::string* BytesValue::mutable_value() {
@ -1536,15 +1545,15 @@ inline const std::string& BytesValue::_internal_value() const {
} }
inline void BytesValue::_internal_set_value(const std::string& value) { inline void BytesValue::_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* BytesValue::_internal_mutable_value() { inline std::string* BytesValue::_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* BytesValue::release_value() { inline std::string* BytesValue::release_value() {
// @@protoc_insertion_point(field_release:google.protobuf.BytesValue.value) // @@protoc_insertion_point(field_release:google.protobuf.BytesValue.value)
return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
} }
inline void BytesValue::set_allocated_value(std::string* value) { inline void BytesValue::set_allocated_value(std::string* value) {
if (value != nullptr) { if (value != nullptr) {
@ -1553,7 +1562,7 @@ inline void BytesValue::set_allocated_value(std::string* value) {
} }
value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value,
GetArena()); GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.BytesValue.value) // @@protoc_insertion_point(field_set_allocated:google.protobuf.BytesValue.value)
} }