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",
"c29uLlBob25lVHlwZSIrCglQaG9uZVR5cGUSCgoGTU9CSUxFEAASCAoESE9N",
"RRABEggKBFdPUksQAiIvCgtBZGRyZXNzQm9vaxIgCgZwZW9wbGUYASADKAsy",
"EC50dXRvcmlhbC5QZXJzb25CWQobY29tLmV4YW1wbGUudHV0b3JpYWwucHJv",
"dG9zQhFBZGRyZXNzQm9va1Byb3Rvc1ABqgIkR29vZ2xlLlByb3RvYnVmLkV4",
"YW1wbGVzLkFkZHJlc3NCb29rYgZwcm90bzM="));
"EC50dXRvcmlhbC5QZXJzb25CZgobY29tLmV4YW1wbGUudHV0b3JpYWwucHJv",
"dG9zQhFBZGRyZXNzQm9va1Byb3Rvc1ABWgsuLi90dXRvcmlhbKoCJEdvb2ds",
"ZS5Qcm90b2J1Zi5FeGFtcGxlcy5BZGRyZXNzQm9va2IGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {

View File

@ -724,12 +724,12 @@ public final class Descriptors {
/** Determines if the given field number is an extension. */
public boolean isExtensionNumber(final int number) {
for (final DescriptorProto.ExtensionRange range : proto.getExtensionRangeList()) {
if (range.getStart() <= number && number < range.getEnd()) {
return true;
}
int index = Arrays.binarySearch(extensionRangeLowerBounds, number);
if (index < 0) {
index = ~index - 1;
}
return false;
// extensionRangeLowerBounds[index] is the biggest value <= number
return index >= 0 && number < extensionRangeUpperBounds[index];
}
/** Determines if the given field number is reserved. */
@ -831,6 +831,9 @@ public final class Descriptors {
private final OneofDescriptor[] oneofs;
private final int realOneofCount;
private final int[] extensionRangeLowerBounds;
private final int[] extensionRangeUpperBounds;
// Used to create a placeholder when the type cannot be found.
Descriptor(final String fullname) throws DescriptorValidationException {
String name = fullname;
@ -859,6 +862,9 @@ public final class Descriptors {
// Create a placeholder FileDescriptor to hold this message.
this.file = new FileDescriptor(packageName, this);
extensionRangeLowerBounds = new int[] {1};
extensionRangeUpperBounds = new int[] {536870912};
}
private Descriptor(
@ -922,6 +928,20 @@ public final class Descriptors {
this.realOneofCount = this.oneofs.length - syntheticOneofCount;
file.pool.addSymbol(this);
// NOTE: The defined extension ranges are guaranteed to be disjoint.
extensionRangeLowerBounds = new int[proto.getExtensionRangeCount()];
extensionRangeUpperBounds = new int[proto.getExtensionRangeCount()];
int i = 0;
for (final DescriptorProto.ExtensionRange range : proto.getExtensionRangeList()) {
extensionRangeLowerBounds[i] = range.getStart();
extensionRangeUpperBounds[i] = range.getEnd();
i++;
}
// Since the ranges are disjoint, sorting these independently must still produce the correct
// order.
Arrays.sort(extensionRangeLowerBounds);
Arrays.sort(extensionRangeUpperBounds);
}
/** Look up and cross-link all field types, etc. */

View File

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

View File

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

View File

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

View File

@ -42,6 +42,7 @@ except ImportError:
import unittest
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor
from google.protobuf import descriptor_pool
from google.protobuf import proto_builder
from google.protobuf import text_format
@ -91,6 +92,23 @@ class ProtoBuilderTest(unittest.TestCase):
pool=pool)
self.assertIs(proto_cls1.DESCRIPTOR, proto_cls2.DESCRIPTOR)
def testMakeLargeProtoClass(self):
"""Test that large created protos don't use reserved field numbers."""
num_fields = 123456
fields = {
'foo%d' % i: descriptor_pb2.FieldDescriptorProto.TYPE_INT64
for i in range(num_fields)
}
proto_cls = proto_builder.MakeSimpleProtoClass(
fields,
full_name='net.proto2.python.public.proto_builder_test.LargeProtoTest')
reserved_field_numbers = set(
range(descriptor.FieldDescriptor.FIRST_RESERVED_FIELD_NUMBER,
descriptor.FieldDescriptor.LAST_RESERVED_FIELD_NUMBER + 1))
proto_field_numbers = set(proto_cls.DESCRIPTOR.fields_by_number)
self.assertFalse(reserved_field_numbers.intersection(proto_field_numbers))
if __name__ == '__main__':
unittest.main()

View File

@ -31,13 +31,14 @@
"""Dynamic Protobuf class creator."""
try:
from collections import OrderedDict
from collections import OrderedDict
except ImportError:
from ordereddict import OrderedDict #PY26
from ordereddict import OrderedDict #PY26
import hashlib
import os
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor
from google.protobuf import message_factory
@ -124,6 +125,12 @@ def _MakeFileDescriptorProto(proto_file_name, full_name, field_items):
for f_number, (f_name, f_type) in enumerate(field_items, 1):
field_proto = desc_proto.field.add()
field_proto.name = f_name
# # If the number falls in the reserved range, reassign it to the correct
# # number after the range.
if f_number >= descriptor.FieldDescriptor.FIRST_RESERVED_FIELD_NUMBER:
f_number += (
descriptor.FieldDescriptor.LAST_RESERVED_FIELD_NUMBER -
descriptor.FieldDescriptor.FIRST_RESERVED_FIELD_NUMBER + 1)
field_proto.number = f_number
field_proto.label = descriptor_pb2.FieldDescriptorProto.LABEL_OPTIONAL
field_proto.type = f_type

View File

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

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.clean import clean as _clean
from distutils.command.build_ext import build_ext as _build_ext
from distutils.spawn import find_executable
# Find the Protocol Compiler.
@ -158,22 +157,6 @@ class build_py(_build_py):
if not any(fnmatch.fnmatchcase(fil, pat=pat) for pat in exclude)]
class build_ext(_build_ext):
def get_ext_filename(self, ext_name):
# since python3.5, python extensions' shared libraries use a suffix that corresponds to the value
# of sysconfig.get_config_var('EXT_SUFFIX') and contains info about the architecture the library targets.
# E.g. on x64 linux the suffix is ".cpython-XYZ-x86_64-linux-gnu.so"
# When crosscompiling python wheels, we need to be able to override this suffix
# so that the resulting file name matches the target architecture and we end up with a well-formed
# wheel.
filename = _build_ext.get_ext_filename(self, ext_name)
orig_ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
new_ext_suffix = os.getenv("PROTOCOL_BUFFERS_OVERRIDE_EXT_SUFFIX")
if new_ext_suffix and filename.endswith(orig_ext_suffix):
filename = filename[:-len(orig_ext_suffix)] + new_ext_suffix
return filename
class test_conformance(_build_py):
target = 'test_python'
def run(self):
@ -322,7 +305,6 @@ if __name__ == '__main__':
cmdclass={
'clean': clean,
'build_py': build_py,
'build_ext': build_ext,
'test_conformance': test_conformance,
},
install_requires=install_requires,

View File

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

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

View File

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

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:
inline Api() : Api(nullptr) {}
@ -93,8 +93,9 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
return *this;
}
inline Api& operator=(Api&& from) noexcept {
if (GetArena() == from.GetArena()) {
if (this != &from) InternalSwap(&from);
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
@ -125,7 +126,7 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
}
inline void Swap(Api* other) {
if (other == this) return;
if (GetArena() == other->GetArena()) {
if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -133,14 +134,14 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
}
void UnsafeArenaSwap(Api* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena());
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline Api* New() const final {
return CreateMaybeMessage<Api>(nullptr);
return new Api();
}
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>
void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name();
std::string* release_name();
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value);
std::string* _internal_mutable_name();
public:
@ -264,11 +265,11 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT>
void set_version(ArgT0&& arg0, ArgT... args);
std::string* mutable_version();
std::string* release_version();
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_version();
void set_allocated_version(std::string* version);
private:
const std::string& _internal_version() const;
void _internal_set_version(const std::string& value);
inline PROTOBUF_ALWAYS_INLINE void _internal_set_version(const std::string& value);
std::string* _internal_mutable_version();
public:
@ -318,7 +319,7 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
};
// -------------------------------------------------------------------
class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
class PROTOBUF_EXPORT Method final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Method) */ {
public:
inline Method() : Method(nullptr) {}
@ -336,8 +337,9 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
return *this;
}
inline Method& operator=(Method&& from) noexcept {
if (GetArena() == from.GetArena()) {
if (this != &from) InternalSwap(&from);
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
@ -368,7 +370,7 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
}
inline void Swap(Method* other) {
if (other == this) return;
if (GetArena() == other->GetArena()) {
if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -376,14 +378,14 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
}
void UnsafeArenaSwap(Method* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena());
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline Method* New() const final {
return CreateMaybeMessage<Method>(nullptr);
return new Method();
}
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>
void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name();
std::string* release_name();
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value);
std::string* _internal_mutable_name();
public:
@ -471,11 +473,11 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT>
void set_request_type_url(ArgT0&& arg0, ArgT... args);
std::string* mutable_request_type_url();
std::string* release_request_type_url();
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_request_type_url();
void set_allocated_request_type_url(std::string* request_type_url);
private:
const std::string& _internal_request_type_url() const;
void _internal_set_request_type_url(const std::string& value);
inline PROTOBUF_ALWAYS_INLINE void _internal_set_request_type_url(const std::string& value);
std::string* _internal_mutable_request_type_url();
public:
@ -485,11 +487,11 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT>
void set_response_type_url(ArgT0&& arg0, ArgT... args);
std::string* mutable_response_type_url();
std::string* release_response_type_url();
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_response_type_url();
void set_allocated_response_type_url(std::string* response_type_url);
private:
const std::string& _internal_response_type_url() const;
void _internal_set_response_type_url(const std::string& value);
inline PROTOBUF_ALWAYS_INLINE void _internal_set_response_type_url(const std::string& value);
std::string* _internal_mutable_response_type_url();
public:
@ -539,7 +541,7 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
};
// -------------------------------------------------------------------
class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
class PROTOBUF_EXPORT Mixin final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Mixin) */ {
public:
inline Mixin() : Mixin(nullptr) {}
@ -557,8 +559,9 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
return *this;
}
inline Mixin& operator=(Mixin&& from) noexcept {
if (GetArena() == from.GetArena()) {
if (this != &from) InternalSwap(&from);
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
@ -589,7 +592,7 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
}
inline void Swap(Mixin* other) {
if (other == this) return;
if (GetArena() == other->GetArena()) {
if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -597,14 +600,14 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
}
void UnsafeArenaSwap(Mixin* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena());
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline Mixin* New() const final {
return CreateMaybeMessage<Mixin>(nullptr);
return new Mixin();
}
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>
void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name();
std::string* release_name();
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value);
std::string* _internal_mutable_name();
public:
@ -669,11 +672,11 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT>
void set_root(ArgT0&& arg0, ArgT... args);
std::string* mutable_root();
std::string* release_root();
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_root();
void set_allocated_root(std::string* root);
private:
const std::string& _internal_root() const;
void _internal_set_root(const std::string& value);
inline PROTOBUF_ALWAYS_INLINE void _internal_set_root(const std::string& value);
std::string* _internal_mutable_root();
public:
@ -709,10 +712,10 @@ inline const std::string& Api::name() const {
return _internal_name();
}
template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE
inline void Api::set_name(ArgT0&& arg0, ArgT... args) {
inline PROTOBUF_ALWAYS_INLINE
void Api::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<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)
}
inline std::string* Api::mutable_name() {
@ -724,15 +727,15 @@ inline const std::string& Api::_internal_name() const {
}
inline void Api::_internal_set_name(const std::string& value) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
}
inline std::string* Api::_internal_mutable_name() {
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
}
inline std::string* Api::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Api.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
}
inline void Api::set_allocated_name(std::string* name) {
if (name != nullptr) {
@ -741,7 +744,7 @@ inline void Api::set_allocated_name(std::string* name) {
}
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena());
GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.name)
}
@ -829,10 +832,10 @@ inline const std::string& Api::version() const {
return _internal_version();
}
template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE
inline void Api::set_version(ArgT0&& arg0, ArgT... args) {
inline PROTOBUF_ALWAYS_INLINE
void Api::set_version(ArgT0&& arg0, ArgT... args) {
version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<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)
}
inline std::string* Api::mutable_version() {
@ -844,15 +847,15 @@ inline const std::string& Api::_internal_version() const {
}
inline void Api::_internal_set_version(const std::string& value) {
version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
}
inline std::string* Api::_internal_mutable_version() {
return version_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
return version_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
}
inline std::string* Api::release_version() {
// @@protoc_insertion_point(field_release:google.protobuf.Api.version)
return version_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
return version_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
}
inline void Api::set_allocated_version(std::string* version) {
if (version != nullptr) {
@ -861,7 +864,7 @@ inline void Api::set_allocated_version(std::string* version) {
}
version_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), version,
GetArena());
GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version)
}
@ -883,7 +886,7 @@ inline const PROTOBUF_NAMESPACE_ID::SourceContext& Api::source_context() const {
}
inline void Api::unsafe_arena_set_allocated_source_context(
PROTOBUF_NAMESPACE_ID::SourceContext* source_context) {
if (GetArena() == nullptr) {
if (GetArenaForAllocation() == nullptr) {
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_);
}
source_context_ = source_context;
@ -898,7 +901,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Api::release_source_context() {
PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_;
source_context_ = nullptr;
if (GetArena() != nullptr) {
if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
}
return temp;
@ -913,7 +916,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Api::unsafe_arena_release_source_co
inline PROTOBUF_NAMESPACE_ID::SourceContext* Api::_internal_mutable_source_context() {
if (source_context_ == nullptr) {
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::SourceContext>(GetArena());
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::SourceContext>(GetArenaForAllocation());
source_context_ = p;
}
return source_context_;
@ -923,13 +926,15 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Api::mutable_source_context() {
return _internal_mutable_source_context();
}
inline void Api::set_allocated_source_context(PROTOBUF_NAMESPACE_ID::SourceContext* source_context) {
::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena();
::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation();
if (message_arena == nullptr) {
delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_);
}
if (source_context) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context)->GetArena();
::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<
::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena(
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context));
if (message_arena != submessage_arena) {
source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, source_context, submessage_arena);
@ -1014,10 +1019,10 @@ inline const std::string& Method::name() const {
return _internal_name();
}
template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE
inline void Method::set_name(ArgT0&& arg0, ArgT... args) {
inline PROTOBUF_ALWAYS_INLINE
void Method::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<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)
}
inline std::string* Method::mutable_name() {
@ -1029,15 +1034,15 @@ inline const std::string& Method::_internal_name() const {
}
inline void Method::_internal_set_name(const std::string& value) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
}
inline std::string* Method::_internal_mutable_name() {
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
}
inline std::string* Method::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Method.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
}
inline void Method::set_allocated_name(std::string* name) {
if (name != nullptr) {
@ -1046,7 +1051,7 @@ inline void Method::set_allocated_name(std::string* name) {
}
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena());
GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name)
}
@ -1059,10 +1064,10 @@ inline const std::string& Method::request_type_url() const {
return _internal_request_type_url();
}
template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE
inline void Method::set_request_type_url(ArgT0&& arg0, ArgT... args) {
inline PROTOBUF_ALWAYS_INLINE
void Method::set_request_type_url(ArgT0&& arg0, ArgT... args) {
request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<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)
}
inline std::string* Method::mutable_request_type_url() {
@ -1074,15 +1079,15 @@ inline const std::string& Method::_internal_request_type_url() const {
}
inline void Method::_internal_set_request_type_url(const std::string& value) {
request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
}
inline std::string* Method::_internal_mutable_request_type_url() {
return request_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
return request_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
}
inline std::string* Method::release_request_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Method.request_type_url)
return request_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
return request_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
}
inline void Method::set_allocated_request_type_url(std::string* request_type_url) {
if (request_type_url != nullptr) {
@ -1091,7 +1096,7 @@ inline void Method::set_allocated_request_type_url(std::string* request_type_url
}
request_type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), request_type_url,
GetArena());
GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url)
}
@ -1124,10 +1129,10 @@ inline const std::string& Method::response_type_url() const {
return _internal_response_type_url();
}
template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE
inline void Method::set_response_type_url(ArgT0&& arg0, ArgT... args) {
inline PROTOBUF_ALWAYS_INLINE
void Method::set_response_type_url(ArgT0&& arg0, ArgT... args) {
response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<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)
}
inline std::string* Method::mutable_response_type_url() {
@ -1139,15 +1144,15 @@ inline const std::string& Method::_internal_response_type_url() const {
}
inline void Method::_internal_set_response_type_url(const std::string& value) {
response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
}
inline std::string* Method::_internal_mutable_response_type_url() {
return response_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
return response_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
}
inline std::string* Method::release_response_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Method.response_type_url)
return response_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
return response_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
}
inline void Method::set_allocated_response_type_url(std::string* response_type_url) {
if (response_type_url != nullptr) {
@ -1156,7 +1161,7 @@ inline void Method::set_allocated_response_type_url(std::string* response_type_u
}
response_type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), response_type_url,
GetArena());
GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url)
}
@ -1249,10 +1254,10 @@ inline const std::string& Mixin::name() const {
return _internal_name();
}
template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE
inline void Mixin::set_name(ArgT0&& arg0, ArgT... args) {
inline PROTOBUF_ALWAYS_INLINE
void Mixin::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<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)
}
inline std::string* Mixin::mutable_name() {
@ -1264,15 +1269,15 @@ inline const std::string& Mixin::_internal_name() const {
}
inline void Mixin::_internal_set_name(const std::string& value) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
}
inline std::string* Mixin::_internal_mutable_name() {
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
}
inline std::string* Mixin::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Mixin.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
}
inline void Mixin::set_allocated_name(std::string* name) {
if (name != nullptr) {
@ -1281,7 +1286,7 @@ inline void Mixin::set_allocated_name(std::string* name) {
}
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena());
GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name)
}
@ -1294,10 +1299,10 @@ inline const std::string& Mixin::root() const {
return _internal_root();
}
template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE
inline void Mixin::set_root(ArgT0&& arg0, ArgT... args) {
inline PROTOBUF_ALWAYS_INLINE
void Mixin::set_root(ArgT0&& arg0, ArgT... args) {
root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<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)
}
inline std::string* Mixin::mutable_root() {
@ -1309,15 +1314,15 @@ inline const std::string& Mixin::_internal_root() const {
}
inline void Mixin::_internal_set_root(const std::string& value) {
root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
}
inline std::string* Mixin::_internal_mutable_root() {
return root_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
return root_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
}
inline std::string* Mixin::release_root() {
// @@protoc_insertion_point(field_release:google.protobuf.Mixin.root)
return root_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
return root_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
}
inline void Mixin::set_allocated_root(std::string* root) {
if (root != nullptr) {
@ -1326,7 +1331,7 @@ inline void Mixin::set_allocated_root(std::string* root) {
}
root_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), root,
GetArena());
GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root)
}

View File

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

View File

@ -223,11 +223,11 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
}
// Basic accessors.
const std::string& Get() const PROTOBUF_NDEBUG_INLINE {
PROTOBUF_NDEBUG_INLINE const std::string& Get() const {
// Unconditionally mask away the tag.
return *tagged_ptr_.Get();
}
const std::string* GetPointer() const PROTOBUF_NDEBUG_INLINE {
PROTOBUF_NDEBUG_INLINE const std::string* GetPointer() const {
// Unconditionally mask away the tag.
return tagged_ptr_.Get();
}
@ -241,10 +241,10 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
// Own()'d by any arena. If the field is not set, this returns NULL. The
// caller retains ownership. Clears this field back to NULL state. Used to
// implement release_<field>() methods on generated classes.
std::string* Release(const std::string* default_value,
::google::protobuf::Arena* arena);
std::string* ReleaseNonDefault(const std::string* default_value,
::google::protobuf::Arena* arena);
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* Release(
const std::string* default_value, ::google::protobuf::Arena* arena);
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* ReleaseNonDefault(
const std::string* default_value, ::google::protobuf::Arena* arena);
// Takes a std::string that is heap-allocated, and takes ownership. The
// std::string's destructor is registered with the arena. Used to implement
@ -255,8 +255,9 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
// Swaps internal pointers. Arena-safety semantics: this is guarded by the
// logic in Swap()/UnsafeArenaSwap() at the message level, so this method is
// 'unsafe' if called directly.
inline void Swap(ArenaStringPtr* other, const std::string* default_value,
Arena* arena) PROTOBUF_NDEBUG_INLINE;
inline PROTOBUF_NDEBUG_INLINE static void InternalSwap(
const std::string* default_value, ArenaStringPtr* rhs, Arena* rhs_arena,
ArenaStringPtr* lhs, Arena* lhs_arena);
// Frees storage (if not on an arena).
void Destroy(const std::string* default_value, ::google::protobuf::Arena* arena);
@ -340,36 +341,28 @@ inline void ArenaStringPtr::UnsafeSetDefault(const std::string* value) {
tagged_ptr_.Set(const_cast<std::string*>(value));
}
inline void ArenaStringPtr::Swap(ArenaStringPtr* other,
const std::string* default_value,
Arena* arena) {
#ifndef NDEBUG
// For debug builds, we swap the contents of the string, rather than the
// std::string instances themselves. This invalidates previously taken const
// references that are (per our documentation) invalidated by calling Swap()
// on the message.
//
// If both strings are the default_value, swapping is uninteresting.
// Otherwise, we use ArenaStringPtr::Mutable() to access the std::string, to
// ensure that we do not try to mutate default_value itself.
if (IsDefault(default_value) && other->IsDefault(default_value)) {
return;
}
if (default_value == nullptr) {
// If we have non-empty default, then `default_value` is null and we can't
// call Mutable the same way. Just do the regular swap.
std::swap(tagged_ptr_, other->tagged_ptr_);
} else {
std::string* this_ptr = Mutable(EmptyDefault{}, arena);
std::string* other_ptr = other->Mutable(EmptyDefault{}, arena);
this_ptr->swap(*other_ptr);
}
#else
inline PROTOBUF_NDEBUG_INLINE void ArenaStringPtr::InternalSwap( //
const std::string* default_value, //
ArenaStringPtr* rhs, Arena* rhs_arena, //
ArenaStringPtr* lhs, Arena* lhs_arena) {
(void)default_value;
(void)arena;
std::swap(tagged_ptr_, other->tagged_ptr_);
std::swap(lhs_arena, rhs_arena);
std::swap(lhs->tagged_ptr_, rhs->tagged_ptr_);
#if 0 // TODO(b/186650244): renable this
#ifndef NDEBUG
auto force_realloc = [default_value](ArenaStringPtr* p, Arena* arena) {
if (p->IsDefault(default_value)) return;
std::string* old_value = p->tagged_ptr_.Get();
std::string* new_value =
p->IsDonatedString()
? Arena::Create<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
}

View File

@ -54,121 +54,100 @@ namespace protobuf {
using internal::ArenaStringPtr;
static std::string WrapString(const char* value) { return value; }
using EmptyDefault = ArenaStringPtr::EmptyDefault;
const internal::LazyString nonempty_default{{{"default", 7}}, {nullptr}};
const std::string* empty_default = &internal::GetEmptyString();
// Test ArenaStringPtr with arena == NULL.
TEST(ArenaStringPtrTest, ArenaStringPtrOnHeap) {
class SingleArena : public testing::TestWithParam<bool> {
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;
const std::string* empty_default = &internal::GetEmptyString();
field.UnsafeSetDefault(empty_default);
EXPECT_EQ(std::string(""), field.Get());
field.Set(empty_default, WrapString("Test short"), NULL);
EXPECT_EQ(std::string("Test short"), field.Get());
field.Set(empty_default, WrapString("Test long long long long value"), NULL);
EXPECT_EQ(std::string("Test long long long long value"), field.Get());
field.Set(empty_default, std::string(""), NULL);
field.Destroy(empty_default, NULL);
ArenaStringPtr field2;
field2.UnsafeSetDefault(empty_default);
std::string* mut = field2.Mutable(EmptyDefault{}, NULL);
EXPECT_EQ(mut, field2.Mutable(EmptyDefault{}, NULL));
EXPECT_EQ(mut, &field2.Get());
EXPECT_NE(empty_default, mut);
EXPECT_EQ(std::string(""), *mut);
*mut = "Test long long long long value"; // ensure string allocates storage
EXPECT_EQ(std::string("Test long long long long value"), field2.Get());
field2.Destroy(empty_default, NULL);
ArenaStringPtr field3;
field3.UnsafeSetDefault(nullptr);
mut = field3.Mutable(nonempty_default, NULL);
EXPECT_EQ(mut, field3.Mutable(nonempty_default, NULL));
EXPECT_EQ(mut, &field3.Get());
EXPECT_NE(nullptr, mut);
EXPECT_EQ(std::string("default"), *mut);
*mut = "Test long long long long value"; // ensure string allocates storage
EXPECT_EQ(std::string("Test long long long long value"), field3.Get());
field3.Destroy(nullptr, NULL);
EXPECT_EQ("", field.Get());
field.Set(empty_default, "Test short", arena.get());
EXPECT_EQ("Test short", field.Get());
field.Set(empty_default, "Test long long long long value", arena.get());
EXPECT_EQ("Test long long long long value", field.Get());
field.Set(empty_default, "", arena.get());
field.Destroy(empty_default, arena.get());
}
TEST(ArenaStringPtrTest, ArenaStringPtrOnArena) {
Arena arena;
TEST_P(SingleArena, MutableAccessor) {
auto arena = GetArena();
ArenaStringPtr field;
const std::string* empty_default = &internal::GetEmptyString();
field.UnsafeSetDefault(empty_default);
EXPECT_EQ(std::string(""), field.Get());
field.Set(empty_default, WrapString("Test short"), &arena);
EXPECT_EQ(std::string("Test short"), field.Get());
field.Set(empty_default, WrapString("Test long long long long value"),
&arena);
EXPECT_EQ(std::string("Test long long long long value"), field.Get());
field.Set(empty_default, std::string(""), &arena);
field.Destroy(empty_default, &arena);
ArenaStringPtr field2;
field2.UnsafeSetDefault(empty_default);
std::string* mut = field2.Mutable(EmptyDefault{}, &arena);
EXPECT_EQ(mut, field2.Mutable(EmptyDefault{}, &arena));
EXPECT_EQ(mut, &field2.Get());
std::string* mut = field.Mutable(EmptyDefault{}, arena.get());
EXPECT_EQ(mut, field.Mutable(EmptyDefault{}, arena.get()));
EXPECT_EQ(mut, &field.Get());
EXPECT_NE(empty_default, mut);
EXPECT_EQ(std::string(""), *mut);
EXPECT_EQ("", *mut);
*mut = "Test long long long long value"; // ensure string allocates storage
EXPECT_EQ(std::string("Test long long long long value"), field2.Get());
field2.Destroy(empty_default, &arena);
ArenaStringPtr field3;
field3.UnsafeSetDefault(nullptr);
mut = field3.Mutable(nonempty_default, &arena);
EXPECT_EQ(mut, field3.Mutable(nonempty_default, &arena));
EXPECT_EQ(mut, &field3.Get());
EXPECT_NE(nullptr, mut);
EXPECT_EQ(std::string("default"), *mut);
*mut = "Test long long long long value"; // ensure string allocates storage
EXPECT_EQ(std::string("Test long long long long value"), field3.Get());
field3.Destroy(nullptr, &arena);
EXPECT_EQ("Test long long long long value", field.Get());
field.Destroy(empty_default, arena.get());
}
TEST(ArenaStringPtrTest, ArenaStringPtrOnArenaNoSSO) {
Arena arena;
TEST_P(SingleArena, NullDefault) {
auto arena = GetArena();
ArenaStringPtr field;
const std::string* empty_default = &internal::GetEmptyString();
field.UnsafeSetDefault(empty_default);
EXPECT_EQ(std::string(""), field.Get());
// Avoid triggering the SSO optimization by setting the string to something
// larger than the internal buffer.
field.Set(empty_default, WrapString("Test long long long long value"),
&arena);
EXPECT_EQ(std::string("Test long long long long value"), field.Get());
field.Set(empty_default, std::string(""), &arena);
field.Destroy(empty_default, &arena);
ArenaStringPtr field2;
field2.UnsafeSetDefault(empty_default);
std::string* mut = field2.Mutable(EmptyDefault{}, &arena);
EXPECT_EQ(mut, field2.Mutable(EmptyDefault{}, &arena));
EXPECT_EQ(mut, &field2.Get());
EXPECT_NE(empty_default, mut);
EXPECT_EQ(std::string(""), *mut);
*mut = "Test long long long long value"; // ensure string allocates storage
EXPECT_EQ(std::string("Test long long long long value"), field2.Get());
field2.Destroy(empty_default, &arena);
ArenaStringPtr field3;
field3.UnsafeSetDefault(nullptr);
mut = field3.Mutable(nonempty_default, &arena);
EXPECT_EQ(mut, field3.Mutable(nonempty_default, &arena));
EXPECT_EQ(mut, &field3.Get());
field.UnsafeSetDefault(nullptr);
std::string* mut = field.Mutable(nonempty_default, arena.get());
EXPECT_EQ(mut, field.Mutable(nonempty_default, arena.get()));
EXPECT_EQ(mut, &field.Get());
EXPECT_NE(nullptr, mut);
EXPECT_EQ(std::string("default"), *mut);
EXPECT_EQ("default", *mut);
*mut = "Test long long long long value"; // ensure string allocates storage
EXPECT_EQ(std::string("Test long long long long value"), field3.Get());
field3.Destroy(nullptr, &arena);
EXPECT_EQ("Test long long long long value", field.Get());
field.Destroy(nullptr, arena.get());
}
class DualArena : public testing::TestWithParam<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;
} else if (options[i].first == "table_driven_serialization") {
file_options.table_driven_serialization = true;
} else if (options[i].first == "experimental_tail_call_table_mode") {
if (options[i].second == "never") {
file_options.tctable_mode = Options::kTCTableNever;
} else if (options[i].second == "guarded") {
file_options.tctable_mode = Options::kTCTableGuarded;
} else if (options[i].second == "always") {
file_options.tctable_mode = Options::kTCTableAlways;
} else {
*error = "Unknown value for experimental_tail_call_table_mode: " +
options[i].second;
return false;
}
} else {
*error = "Unknown generator option: " + options[i].first;
return false;

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

View File

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,20 +31,69 @@
#ifndef 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_options.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/wire_format_lite.h>
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
void GenerateParseFunction(const Descriptor* descriptor, int num_hasbits,
const Options& options,
MessageSCCAnalyzer* scc_analyzer,
io::Printer* printer);
// ParseFunctionGenerator generates the _InternalParse function for a message
// (and any associated supporting members).
class ParseFunctionGenerator {
public:
ParseFunctionGenerator(const Descriptor* descriptor, int num_hasbits,
const Options& options,
MessageSCCAnalyzer* scc_analyzer);
// Emits class-level method declarations to `printer`:
void GenerateMethodDecls(io::Printer* printer);
// Emits out-of-class method implementation definitions to `printer`:
void GenerateMethodImpls(io::Printer* printer);
private:
// Returns the proto runtime internal namespace.
std::string pi_ns();
// Generates a looping `_InternalParse` function.
void GenerateLoopingParseFunction(Formatter& format);
// Generates parsing code for an `ArenaString` field.
void GenerateArenaString(Formatter& format, const FieldDescriptor* field);
// Generates parsing code for a string-typed field.
void GenerateStrings(Formatter& format, const FieldDescriptor* field,
bool check_utf8);
// Generates parsing code for a length-delimited field (strings, messages,
// etc.).
void GenerateLengthDelim(Formatter& format, const FieldDescriptor* field);
// Generates the parsing code for a known field.
void GenerateFieldBody(Formatter& format,
google::protobuf::internal::WireFormatLite::WireType wiretype,
const FieldDescriptor* field);
// Generates code to parse the next field from the input stream.
void GenerateParseIterationBody(
Formatter& format, const Descriptor* descriptor,
const std::vector<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 compiler

View File

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

View File

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

View File

@ -211,9 +211,14 @@ void ImmutableMessageGenerator::GenerateFieldAccessorTable(
" com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\n"
" internal_$identifier$_fieldAccessorTable;\n");
// The following bytecode_estimate calculation logic must stay in sync with
// the similar logic in the GenerateFieldAccessorTableInitializer method below
// to make sure that the generated static final fields are initialized in the
// static initialization block directly.
//
// 6 bytes per field and oneof
*bytecode_estimate +=
10 + 6 * descriptor_->field_count() + 6 * oneofs_.size();
10 + 6 * descriptor_->field_count() + 6 * descriptor_->oneof_decl_count();
}
int ImmutableMessageGenerator::GenerateFieldAccessorTableInitializer(
@ -226,6 +231,10 @@ int ImmutableMessageGenerator::GenerateFieldAccessorTableInitializer(
" new java.lang.String[] { ",
"identifier", UniqueFileScopeIdentifier(descriptor_), "ver",
GeneratedCodeVersionSuffix());
// All the bytecode_estimate calculation logic in this method must stay in
// sync with the similar logic in the GenerateFieldAccessorTable method
// above. See the corresponding comment in GenerateFieldAccessorTable for
// details.
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i);
const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);

View File

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

View File

@ -3139,6 +3139,43 @@ TEST_F(SourceInfoTest, EnumValues) {
EXPECT_TRUE(HasSpan(file_.enum_type(0), "name"));
}
TEST_F(SourceInfoTest, EnumReservedRange) {
EXPECT_TRUE(
Parse("enum TestEnum {\n"
" $a$reserved $b$1$c$ to $d$10$e$;$f$\n"
"}"));
const EnumDescriptorProto::EnumReservedRange& bar =
file_.enum_type(0).reserved_range(0);
EXPECT_TRUE(HasSpan('a', 'f', file_.enum_type(0), "reserved_range"));
EXPECT_TRUE(HasSpan('b', 'e', bar));
EXPECT_TRUE(HasSpan('b', 'c', bar, "start"));
EXPECT_TRUE(HasSpan('d', 'e', bar, "end"));
// Ignore these.
EXPECT_TRUE(HasSpan(file_));
EXPECT_TRUE(HasSpan(file_.enum_type(0)));
EXPECT_TRUE(HasSpan(file_.enum_type(0), "name"));
}
TEST_F(SourceInfoTest, EnumReservedName) {
EXPECT_TRUE(
Parse("enum TestEnum {\n"
" $a$reserved $b$'foo'$c$;$d$\n"
"}"));
const EnumDescriptorProto& bar = file_.enum_type(0);
EXPECT_TRUE(HasSpan('a', 'd', bar, "reserved_name"));
EXPECT_TRUE(HasSpan('b', 'c', bar, "reserved_name", 0));
// Ignore these.
EXPECT_TRUE(HasSpan(file_));
EXPECT_TRUE(HasSpan(file_.enum_type(0)));
EXPECT_TRUE(HasSpan(file_.enum_type(0), "name"));
}
TEST_F(SourceInfoTest, NestedEnums) {
EXPECT_TRUE(
Parse("message Foo {\n"

View File

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

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

View File

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

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

View File

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -103,7 +103,7 @@ FieldMask::~FieldMask() {
}
void FieldMask::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr);
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
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:
inline FieldMask() : FieldMask(nullptr) {}
@ -83,8 +83,9 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL :
return *this;
}
inline FieldMask& operator=(FieldMask&& from) noexcept {
if (GetArena() == from.GetArena()) {
if (this != &from) InternalSwap(&from);
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
@ -115,7 +116,7 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL :
}
inline void Swap(FieldMask* other) {
if (other == this) return;
if (GetArena() == other->GetArena()) {
if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -123,14 +124,14 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL :
}
void UnsafeArenaSwap(FieldMask* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena());
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline FieldMask* New() const final {
return CreateMaybeMessage<FieldMask>(nullptr);
return new FieldMask();
}
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>();
}
bool Reflection::IsLazilyVerifiedLazyField(const FieldDescriptor* field) const {
return field->options().lazy();
}
bool Reflection::IsEagerlyVerifiedLazyField(
const FieldDescriptor* field) const {
return (field->type() == FieldDescriptor::TYPE_MESSAGE &&
schema_.IsEagerlyVerifiedLazyField(field));
}
size_t Reflection::SpaceUsedLong(const Message& message) const {
// object_size_ already includes the in-memory representation of each field
// in the message, so we only need to account for additional memory used by
@ -411,7 +421,8 @@ void Reflection::SwapField(Message* message1, Message* message2,
SWAP_VALUES(ENUM, int);
#undef SWAP_VALUES
case FieldDescriptor::CPPTYPE_MESSAGE:
if (GetArena(message1) == GetArena(message2)) {
if (message1->GetArenaForAllocation() ==
message2->GetArenaForAllocation()) {
std::swap(*MutableRaw<Message*>(message1, field),
*MutableRaw<Message*>(message2, field));
} else {
@ -423,13 +434,17 @@ void Reflection::SwapField(Message* message1, Message* message2,
break;
}
if (*sub_msg1 == nullptr) {
*sub_msg1 = (*sub_msg2)->New(message1->GetArena());
*sub_msg1 = (*sub_msg2)->New(message1->GetArenaForAllocation());
(*sub_msg1)->CopyFrom(**sub_msg2);
ClearField(message2, field);
// Ensures has bit is unchanged after ClearField.
SetBit(message2, field);
} else {
*sub_msg2 = (*sub_msg1)->New(message2->GetArena());
*sub_msg2 = (*sub_msg1)->New(message2->GetArenaForAllocation());
(*sub_msg2)->CopyFrom(**sub_msg1);
ClearField(message1, field);
// Ensures has bit is unchanged after ClearField.
SetBit(message1, field);
}
}
break;
@ -438,25 +453,30 @@ void Reflection::SwapField(Message* message1, Message* message2,
switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: {
Arena* arena1 = GetArena(message1);
Arena* arena2 = GetArena(message2);
const std::string* default_ptr =
DefaultRaw<ArenaStringPtr>(field).GetPointer();
Arena* arena1 = message1->GetArenaForAllocation();
Arena* arena2 = message2->GetArenaForAllocation();
ArenaStringPtr* string1 =
MutableRaw<ArenaStringPtr>(message1, field);
ArenaStringPtr* string2 =
MutableRaw<ArenaStringPtr>(message2, field);
const std::string* default_ptr =
DefaultRaw<ArenaStringPtr>(field).GetPointer();
if (arena1 == arena2) {
string1->Swap(string2, default_ptr, arena1);
if (message1->GetOwningArena() == message2->GetOwningArena()) {
ArenaStringPtr::InternalSwap(default_ptr, string1, arena1,
string2, arena2);
} else if (string1->IsDefault(default_ptr) &&
string2->IsDefault(default_ptr)) {
// Nothing to do.
} else if (string1->IsDefault(default_ptr)) {
string1->Set(default_ptr, string2->Get(), arena1);
// string2 needs to be destroyed before overwritten.
string2->Destroy(default_ptr, arena2);
string2->UnsafeSetDefault(default_ptr);
} else if (string2->IsDefault(default_ptr)) {
string2->Set(default_ptr, string1->Get(), arena2);
// string1 needs to be destroyed before overwritten.
string1->Destroy(default_ptr, arena1);
string1->UnsafeSetDefault(default_ptr);
} else {
std::string temp = string1->Get();
@ -612,19 +632,38 @@ void Reflection::Swap(Message* message1, Message* message2) const {
// Check that both messages are in the same arena (or both on the heap). We
// need to copy all data if not, due to ownership semantics.
if (GetArena(message1) != GetArena(message2)) {
// Slow copy path.
// Use our arena as temp space, if available.
Message* temp = message1->New(GetArena(message1));
if (message1->GetOwningArena() != message2->GetOwningArena()) {
// One of the two is guaranteed to have an arena. Switch things around
// to guarantee that message1 has an arena.
Arena* arena = message1->GetOwningArena();
if (arena == nullptr) {
arena = message2->GetOwningArena();
std::swap(message1, message2); // Swapping names for pointers!
}
Message* temp = message1->New(arena);
temp->MergeFrom(*message2);
message2->CopyFrom(*message1);
Swap(message1, temp);
if (GetArena(message1) == nullptr) {
delete temp;
}
return;
}
for (int i = 0; i <= last_non_weak_field_index_; i++) {
const FieldDescriptor* field = descriptor_->field(i);
if (schema_.InRealOneof(field)) continue;
if (schema_.IsFieldStripped(field)) continue;
SwapField(message1, message2, field);
}
const int oneof_decl_count = descriptor_->oneof_decl_count();
for (int i = 0; i < oneof_decl_count; i++) {
const OneofDescriptor* oneof = descriptor_->oneof_decl(i);
if (!oneof->is_synthetic()) {
SwapOneofField(message1, message2, oneof);
}
}
// Swapping bits need to happen after swapping fields, because the latter may
// depend on the has bit information.
if (schema_.HasHasbits()) {
uint32* has_bits1 = MutableHasBits(message1);
uint32* has_bits2 = MutableHasBits(message2);
@ -645,20 +684,6 @@ void Reflection::Swap(Message* message1, Message* message2) const {
}
}
for (int i = 0; i <= last_non_weak_field_index_; i++) {
const FieldDescriptor* field = descriptor_->field(i);
if (schema_.InRealOneof(field)) continue;
if (schema_.IsFieldStripped(field)) continue;
SwapField(message1, message2, field);
}
const int oneof_decl_count = descriptor_->oneof_decl_count();
for (int i = 0; i < oneof_decl_count; i++) {
const OneofDescriptor* oneof = descriptor_->oneof_decl(i);
if (!oneof->is_synthetic()) {
SwapOneofField(message1, message2, oneof);
}
}
if (schema_.HasExtensionSet()) {
MutableExtensionSet(message1)->Swap(MutableExtensionSet(message2));
}
@ -708,13 +733,14 @@ void Reflection::SwapFields(
swapped_oneof.insert(oneof_index);
SwapOneofField(message1, message2, field->containing_oneof());
} else {
// Swap field.
SwapField(message1, message2, field);
// Swap has bit for non-repeated fields. We have already checked for
// oneof already.
// oneof already. This has to be done after SwapField, because SwapField
// may depend on the information in has bits.
if (!field->is_repeated()) {
SwapBit(message1, message2, field);
}
// Swap field.
SwapField(message1, message2, field);
}
}
}
@ -828,7 +854,8 @@ void Reflection::ClearField(Message* message,
const std::string* default_ptr =
DefaultRaw<ArenaStringPtr>(field).GetPointer();
MutableRaw<ArenaStringPtr>(message, field)
->SetAllocated(default_ptr, nullptr, GetArena(message));
->SetAllocated(default_ptr, nullptr,
message->GetArenaForAllocation());
break;
}
}
@ -839,7 +866,7 @@ void Reflection::ClearField(Message* message,
if (schema_.HasBitIndex(field) == static_cast<uint32>(-1)) {
// Proto3 does not have has-bits and we need to set a message field
// to nullptr in order to indicate its un-presence.
if (GetArena(message) == nullptr) {
if (message->GetArenaForAllocation() == nullptr) {
delete *MutableRaw<Message*>(message, field);
}
*MutableRaw<Message*>(message, field) = nullptr;
@ -1242,7 +1269,8 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
->UnsafeSetDefault(default_ptr);
}
MutableField<ArenaStringPtr>(message, field)
->Set(default_ptr, std::move(value), GetArena(message));
->Set(default_ptr, std::move(value),
message->GetArenaForAllocation());
break;
}
}
@ -1494,7 +1522,7 @@ const Message* Reflection::GetDefaultMessageInstance(
// This is an optimization to avoid going to GetPrototype() below, as that
// requires a lock and a map lookup.
if (!field->is_extension() && !field->options().weak() &&
!field->options().lazy() && !schema_.InRealOneof(field)) {
!IsLazyField(field) && !schema_.InRealOneof(field)) {
auto* res = DefaultRaw<const Message*>(field);
if (res != nullptr) {
return res;
@ -1548,7 +1576,7 @@ Message* Reflection::MutableMessage(Message* message,
ClearOneof(message, field->containing_oneof());
result_holder = MutableField<Message*>(message, field);
const Message* default_message = GetDefaultMessageInstance(field);
*result_holder = default_message->New(message->GetArena());
*result_holder = default_message->New(message->GetArenaForAllocation());
}
} else {
SetBit(message, field);
@ -1556,7 +1584,7 @@ Message* Reflection::MutableMessage(Message* message,
if (*result_holder == nullptr) {
const Message* default_message = GetDefaultMessageInstance(field);
*result_holder = default_message->New(message->GetArena());
*result_holder = default_message->New(message->GetArenaForAllocation());
}
result = *result_holder;
return result;
@ -1590,7 +1618,7 @@ void Reflection::UnsafeArenaSetAllocatedMessage(
SetBit(message, field);
}
Message** sub_message_holder = MutableRaw<Message*>(message, field);
if (GetArena(message) == nullptr) {
if (message->GetArenaForAllocation() == nullptr) {
delete *sub_message_holder;
}
*sub_message_holder = sub_message;
@ -1605,12 +1633,13 @@ void Reflection::SetAllocatedMessage(Message* message, Message* sub_message,
// (different arenas, or one is on heap and one is not), then we may need to
// do a copy.
if (sub_message != nullptr &&
sub_message->GetArena() != message->GetArena()) {
if (sub_message->GetArena() == nullptr && message->GetArena() != nullptr) {
sub_message->GetOwningArena() != message->GetArenaForAllocation()) {
if (sub_message->GetOwningArena() == nullptr &&
message->GetArenaForAllocation() != nullptr) {
// Case 1: parent is on an arena and child is heap-allocated. We can add
// the child to the arena's Own() list to free on arena destruction, then
// set our pointer.
message->GetArena()->Own(sub_message);
message->GetArenaForAllocation()->Own(sub_message);
UnsafeArenaSetAllocatedMessage(message, sub_message, field);
} else {
// Case 2: all other cases. We need to make a copy. MutableMessage() will
@ -1661,7 +1690,7 @@ Message* Reflection::ReleaseMessage(Message* message,
CheckInvalidAccess(schema_, field);
Message* released = UnsafeArenaReleaseMessage(message, field, factory);
if (GetArena(message) != nullptr && released != nullptr) {
if (message->GetArenaForAllocation() != nullptr && released != nullptr) {
Message* copy_from_arena = released->New();
copy_from_arena->CopyFrom(*released);
released = copy_from_arena;
@ -1743,7 +1772,7 @@ Message* Reflection::AddMessage(Message* message, const FieldDescriptor* field,
} else {
prototype = &repeated->Get<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
// allocated or arena owned. So it is safe to call the unsafe version
// of AddAllocated.
@ -1988,10 +2017,6 @@ ExtensionSet* Reflection::MutableExtensionSet(Message* message) const {
schema_.GetExtensionSetOffset());
}
Arena* Reflection::GetArena(Message* message) const {
return GetInternalMetadata(*message).arena();
}
const InternalMetadata& Reflection::GetInternalMetadata(
const Message& message) const {
return GetConstRefAtOffset<InternalMetadata>(message,
@ -2137,7 +2162,7 @@ void Reflection::ClearOneof(Message* message,
uint32 oneof_case = GetOneofCase(*message, oneof_descriptor);
if (oneof_case > 0) {
const FieldDescriptor* field = descriptor_->FindFieldByNumber(oneof_case);
if (GetArena(message) == nullptr) {
if (message->GetArenaForAllocation() == nullptr) {
switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_STRING: {
switch (field->options().ctype()) {
@ -2148,7 +2173,7 @@ void Reflection::ClearOneof(Message* message,
// work. This allows us to not have the real default accessible
// from reflection.
MutableField<ArenaStringPtr>(message, field)
->Destroy(nullptr, GetArena(message));
->Destroy(nullptr, message->GetArenaForAllocation());
break;
}
}

View File

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

View File

@ -266,6 +266,39 @@ TEST(GeneratedMessageReflectionTest, SwapFieldsAll) {
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) {
unittest::TestAllExtensions message1;
unittest::TestAllExtensions message2;

View File

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

View File

@ -47,17 +47,17 @@ namespace internal {
template <size_t doublewords>
class HasBits {
public:
constexpr HasBits() PROTOBUF_NDEBUG_INLINE : has_bits_{} {}
PROTOBUF_NDEBUG_INLINE constexpr HasBits() : has_bits_{} {}
void Clear() PROTOBUF_NDEBUG_INLINE {
PROTOBUF_NDEBUG_INLINE void Clear() {
memset(has_bits_, 0, sizeof(has_bits_));
}
uint32& operator[](int index) PROTOBUF_NDEBUG_INLINE {
PROTOBUF_NDEBUG_INLINE uint32& operator[](int index) {
return has_bits_[index];
}
const uint32& operator[](int index) const PROTOBUF_NDEBUG_INLINE {
PROTOBUF_NDEBUG_INLINE const uint32& operator[](int index) const {
return has_bits_[index];
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3754,6 +3754,22 @@ TEST(ArenaTest, DynamicMapFieldOnArena) {
MapTestUtil::ExpectMapFieldsSet(message2);
}
TEST(ArenaTest, DynamicMapFieldOnArenaMemoryLeak) {
auto* desc = unittest::TestMap::descriptor();
auto* field = desc->FindFieldByName("map_int32_int32");
Arena arena;
DynamicMessageFactory factory;
auto* message = factory.GetPrototype(desc)->New(&arena);
auto* reflection = message->GetReflection();
reflection->AddMessage(message, field);
// Force internal syncing, which initializes the mutex.
MapReflectionTester reflection_tester(unittest::TestMap::descriptor());
int size = reflection_tester.MapSize(*message, "map_int32_int32");
EXPECT_EQ(size, 1);
}
TEST(MoveTest, MoveConstructorWorks) {
Map<int32, TestAllTypes> original_map;
original_map[42].mutable_optional_nested_message()->set_bb(42);

View File

@ -346,18 +346,8 @@ template <>
PROTOBUF_NOINLINE
#endif
Arena*
GenericTypeHandler<Message>::GetArena(Message* value) {
return value->GetArena();
}
template <>
#if defined(_MSC_VER) && (_MSC_VER >= 1800)
// Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue
// #240
PROTOBUF_NOINLINE
#endif
void*
GenericTypeHandler<Message>::GetMaybeArenaPointer(Message* value) {
return value->GetMaybeArenaPointer();
GenericTypeHandler<Message>::GetOwningArena(Message* value) {
return value->GetOwningArena();
}
} // namespace internal

View File

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

View File

@ -64,6 +64,10 @@ namespace protobuf {
template <typename T>
class RepeatedPtrField;
class FastReflectionMessageMutator;
class FastReflectionStringSetter;
class Reflection;
namespace io {
class CodedInputStream;
@ -83,10 +87,15 @@ struct ConstantInitialized {
// See parse_context.h for explanation
class ParseContext;
class ExtensionSet;
class LazyField;
class RepeatedPtrFieldBase;
class WireFormatLite;
class WeakFieldMap;
template <typename Type>
class GenericTypeHandler; // defined in repeated_field.h
// We compute sizes as size_t but cache them as int. This function converts a
// computed size to a cached size. Since we don't proceed with serialization
// if the total size was > INT_MAX, it is not important what this function
@ -209,12 +218,8 @@ class PROTOBUF_EXPORT MessageLite {
// if arena is a NULL. Default implementation for backwards compatibility.
virtual MessageLite* New(Arena* arena) const;
// Get the arena, if any, associated with this message. Virtual method
// required for generic operations but most arena-related operations should
// use the GetArena() generated-code method. Default implementation
// to reduce code size by avoiding the need for per-type implementations
// when types do not implement arena support.
Arena* GetArena() const { return _internal_metadata_.arena(); }
// Same as GetOwningArena.
Arena* GetArena() const { return GetOwningArena(); }
// Get a pointer that may be equal to this message's arena, or may not be.
// If the value returned by this method is equal to some arena pointer, then
@ -469,6 +474,17 @@ class PROTOBUF_EXPORT MessageLite {
inline explicit MessageLite(Arena* arena) : _internal_metadata_(arena) {}
// Returns the arena, if any, that directly owns this message and its internal
// memory (Arena::Own is different in that the arena doesn't directly own the
// internal memory). This method is used in proto's implementation for
// swapping, moving and setting allocated, for deciding whether the ownership
// of this message or its internal memory could be changed.
Arena* GetOwningArena() const { return _internal_metadata_.arena(); }
// Returns the arena, used for allocating internal objects(e.g., child
// messages, etc), or owning incoming objects (e.g., set allocated).
Arena* GetArenaForAllocation() const { return _internal_metadata_.arena(); }
internal::InternalMetadata _internal_metadata_;
public:
@ -502,9 +518,19 @@ class PROTOBUF_EXPORT MessageLite {
// TODO(gerbens) make this a pure abstract function
virtual const void* InternalGetTable() const { return NULL; }
friend class internal::WireFormatLite;
friend class FastReflectionMessageMutator;
friend class FastReflectionStringSetter;
friend class Message;
friend class Reflection;
friend class internal::ExtensionSet;
friend class internal::LazyField;
friend class internal::WeakFieldMap;
friend class internal::WireFormatLite;
template <typename Type>
friend class Arena::InternalHelper;
template <typename Type>
friend class internal::GenericTypeHandler;
void LogInitializationErrorMessage() const;

View File

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

View File

@ -48,129 +48,85 @@
// detect/prohibit anytime it is #included twice without a corresponding
// #undef.
// These macros are private and should always be #undef'd from headers.
// If any of these errors fire, you should either properly #include
// port_undef.h at the end of your header that #includes port.h, or
// don't #include port.h twice in a .cc file.
#ifdef PROTOBUF_NAMESPACE
#error PROTOBUF_NAMESPACE was previously defined
// The definitions in this file are intended to be portable across Clang,
// GCC, and MSVC. Function-like macros are usable without an #ifdef guard.
// Syntax macros (for example, attributes) are always defined, although
// they may be empty.
// Portable fallbacks for C++20 feature test macros:
// https://en.cppreference.com/w/cpp/feature_test
#ifndef __has_cpp_attribute
#define __has_cpp_attribute(x) 0
#define PROTOBUF_has_cpp_attribute_DEFINED_
#endif
#ifdef PROTOBUF_NAMESPACE_ID
#error PROTOBUF_NAMESPACE_ID was previously defined
// Portable fallback for Clang's __has_feature macro:
// https://clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension
#ifndef __has_feature
#define __has_feature(x) 0
#define PROTOBUF_has_feature_DEFINED_
#endif
#ifdef PROTOBUF_ALWAYS_INLINE
#error PROTOBUF_ALWAYS_INLINE was previously defined
// Portable fallback for Clang's __has_warning macro:
#ifndef __has_warning
#define __has_warning(x) 0
#define PROTOBUF_has_warning_DEFINED_
#endif
#ifdef PROTOBUF_NDEBUG_INLINE
#error PROTOBUF_NDEBUG_INLINE was previously defined
// Portable fallbacks for the __has_attribute macro (GCC and Clang):
// https://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
// https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html
#ifndef __has_attribute
#define __has_attribute(x) 0
#define PROTOBUF_has_attribute_DEFINED_
#endif
#ifdef PROTOBUF_COLD
#error PROTOBUF_COLD was previously defined
// Portable fallback for __has_builtin (GCC and Clang):
// https://clang.llvm.org/docs/LanguageExtensions.html#has-builtin
// https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fbuiltin.html
#ifndef __has_builtin
#define __has_builtin(x) 0
#define PROTOBUF_has_builtin_DEFINED_
#endif
#ifdef PROTOBUF_NOINLINE
#error PROTOBUF_NOINLINE was previously defined
#endif
#ifdef PROTOBUF_SECTION_VARIABLE
#error PROTOBUF_SECTION_VARIABLE was previously defined
#endif
#ifdef PROTOBUF_DEPRECATED
#error PROTOBUF_DEPRECATED was previously defined
#endif
#ifdef PROTOBUF_DEPRECATED_MSG
#error PROTOBUF_DEPRECATED_MSG was previously defined
#endif
#ifdef PROTOBUF_FUNC_ALIGN
#error PROTOBUF_FUNC_ALIGN was previously defined
#endif
#ifdef PROTOBUF_RETURNS_NONNULL
#error PROTOBUF_RETURNS_NONNULL was previously defined
#endif
#ifdef PROTOBUF_ATTRIBUTE_REINITIALIZES
#error PROTOBUF_ATTRIBUTE_REINITIALIZES was previously defined
#endif
#ifdef PROTOBUF_RTTI
#error PROTOBUF_RTTI was previously defined
// Portable check for GCC minimum version:
// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
#if defined(__GNUC__) && defined(__GNUC_MINOR__) \
&& defined(__GNUC_PATCHLEVEL__)
# define PROTOBUF_GNUC_MIN(x, y) \
(__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y))
#else
# define PROTOBUF_GNUC_MIN(x, y) 0
#endif
// Future versions of protobuf will include breaking changes to some APIs.
// This macro can be set to enable these API changes ahead of time, so that
// user code can be updated before upgrading versions of protobuf.
// #define PROTOBUF_FUTURE_BREAKING_CHANGES 1
#ifdef PROTOBUF_VERSION
#error PROTOBUF_VERSION was previously defined
#endif
#ifdef PROTOBUF_VERSION_SUFFIX
#error PROTOBUF_VERSION_SUFFIX was previously defined
#endif
#define PROTOBUF_VERSION 3015008
#ifdef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC
#error PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC was previously defined
#endif
#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3015000
#ifdef PROTOBUF_MIN_PROTOC_VERSION
#error PROTOBUF_MIN_PROTOC_VERSION was previously defined
#endif
#ifdef PROTOBUF_PREDICT_TRUE
#error PROTOBUF_PREDICT_TRUE was previously defined
#endif
#ifdef PROTOBUF_PREDICT_FALSE
#error PROTOBUF_PREDICT_FALSE was previously defined
#endif
#ifdef PROTOBUF_FIELD_OFFSET
#error PROTOBUF_FIELD_OFFSET was previously defined
#endif
#ifdef PROTOBUF_LL_FORMAT
#error PROTOBUF_LL_FORMAT was previously defined
#endif
#ifdef PROTOBUF_GUARDED_BY
#error PROTOBUF_GUARDED_BY was previously defined
#endif
#ifdef PROTOBUF_LONGLONG
#error PROTOBUF_LONGLONG was previously defined
#endif
#ifdef PROTOBUF_ULONGLONG
#error PROTOBUF_ULONGLONG was previously defined
#endif
#ifdef PROTOBUF_FALLTHROUGH_INTENDED
#error PROTOBUF_FALLTHROUGH_INTENDED was previously defined
#endif
#ifdef PROTOBUF_EXPORT
#error PROTOBUF_EXPORT was previously defined
#endif
#ifdef PROTOC_EXPORT
#error PROTOC_EXPORT was previously defined
#endif
#ifdef PROTOBUF_MUST_USE_RESULT
#error PROTOBUF_MUST_USE_RESULT was previously defined
#endif
#ifdef PROTOBUF_UNUSED
#error PROTOBUF_UNUSED was previously defined
#endif
#ifdef PROTOBUF_FINAL
#error PROTOBUF_FINAL was previously defined
#endif
#ifdef PROTOBUF_ENABLE_MSVC_UNION_WARNING
#error PROTOBUF_ENABLE_MSVC_UNION_WARNING was previously defined
#endif
#ifdef PROTOBUF_CONSTINIT
#error PROTOBUF_CONSTINIT was previously defined
#endif
#ifdef PROTOBUF_ATTRIBUTE_NO_DESTROY
#error PROTOBUF_ATTRIBUTE_NO_DESTROY was previously defined
#endif
#ifdef PROTOBUF_ATTRIBUTE_INIT_PRIORITY
#error PROTOBUF_ATTRIBUTE_INIT_PRIORITY was previously defined
#endif
#ifdef PROTOBUF_PRAGMA_INIT_SEG
#error PROTOBUF_PRAGMA_INIT_SEG was previously defined
#endif
#ifdef PROTOBUF_ATTRIBUTE_WEAK
#error PROTOBUF_ATTRIBUTE_WEAK was previously defined
#endif
#ifdef PROTOBUF_ASAN
#error PROTOBUF_ASAN was previously defined
#endif
#ifdef PROTOBUF_MSAN
#error PROTOBUF_MSAN was previously defined
#endif
#ifdef PROTOBUF_TSAN
#error PROTOBUF_TSAN was previously defined
#endif
#define PROTOBUF_MIN_PROTOC_VERSION 3015000
#ifdef PROTOBUF_VERSION_SUFFIX
#error PROTOBUF_VERSION_SUFFIX was previously defined
#endif
#define PROTOBUF_VERSION_SUFFIX ""
#if defined(PROTOBUF_NAMESPACE) || defined(PROTOBUF_NAMESPACE_ID)
#error PROTOBUF_NAMESPACE or PROTOBUF_NAMESPACE_ID was previously defined
#endif
#define PROTOBUF_NAMESPACE "google::protobuf"
#define PROTOBUF_NAMESPACE_ID google::protobuf
#define PROTOBUF_NAMESPACE_OPEN \
@ -180,193 +136,170 @@
} /* namespace protobuf */ \
} /* namespace google */
#if defined(__clang__)
#define PROTOBUF_DEPRECATED __attribute__((deprecated))
#define PROTOBUF_DEPRECATED_ENUM __attribute__((deprecated))
#define PROTOBUF_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
#elif defined(__GNUC__)
#define PROTOBUF_DEPRECATED __attribute__((deprecated))
#define PROTOBUF_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
#if __GNUC__ >= 6
#define PROTOBUF_DEPRECATED_ENUM __attribute__((deprecated))
#else
#define PROTOBUF_DEPRECATED_ENUM
#ifdef PROTOBUF_ALWAYS_INLINE
#error PROTOBUF_ALWAYS_INLINE was previously defined
#endif
#elif defined(_MSC_VER)
#define PROTOBUF_DEPRECATED __declspec(deprecated)
#define PROTOBUF_DEPRECATED_ENUM
#define PROTOBUF_DEPRECATED_MSG(msg) __declspec(deprecated(msg))
#endif
#define PROTOBUF_SECTION_VARIABLE(x)
#define PROTOBUF_MUST_USE_RESULT
#define PROTOBUF_FUTURE_MUST_USE_RESULT
// ----------------------------------------------------------------------------
// Annotations: Some parts of the code have been annotated in ways that might
// be useful to some compilers or tools, but are not supported universally.
// You can #define these annotations yourself if the default implementation
// is not right for you.
#ifndef PROTOBUF_NO_INLINE
#ifdef GOOGLE_ATTRIBUTE_ALWAYS_INLINE
#define PROTOBUF_ALWAYS_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE
#define PROTOBUF_NDEBUG_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE
#elif defined(__GNUC__) && \
(__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
// For functions we want to force inline.
// Introduced in gcc 3.1.
#define PROTOBUF_ALWAYS_INLINE __attribute__((always_inline))
#define PROTOBUF_NDEBUG_INLINE __attribute__((always_inline))
#endif
#endif
#ifndef PROTOBUF_ALWAYS_INLINE
// Other compilers will have to figure it out for themselves.
#define PROTOBUF_ALWAYS_INLINE
#define PROTOBUF_NDEBUG_INLINE
#endif
#ifdef GOOGLE_ATTRIBUTE_NOINLINE
#define PROTOBUF_NOINLINE GOOGLE_ATTRIBUTE_NOINLINE
#if defined(PROTOBUF_NO_INLINE)
# define PROTOBUF_ALWAYS_INLINE
#elif PROTOBUF_GNUC_MIN(3, 1)
# define PROTOBUF_ALWAYS_INLINE __attribute__((always_inline))
#elif defined(_MSC_VER)
# define PROTOBUF_ALWAYS_INLINE __forceinline
#else
#if defined(__GNUC__) && \
(__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
// For functions we want to force not inline.
// Introduced in gcc 3.1.
#define PROTOBUF_NOINLINE __attribute__((noinline))
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
# define PROTOBUF_ALWAYS_INLINE
#endif
#ifdef PROTOBUF_NDEBUG_INLINE
#error PROTOBUF_NDEBUG_INLINE was previously defined
#endif
// Avoid excessive inlining in non-optimized builds. Without other optimizations
// the inlining is not going to provide benefits anyway and the huge resulting
// functions, especially in the proto-generated serialization functions, produce
// stack frames so large that many tests run into stack overflows (b/32192897).
#if defined(NDEBUG) || (defined(_MSC_VER) && !defined(_DEBUG))
# define PROTOBUF_NDEBUG_INLINE PROTOBUF_ALWAYS_INLINE
#else
# define PROTOBUF_NDEBUG_INLINE
#endif
// Note that PROTOBUF_NOINLINE is an attribute applied to functions, to prevent
// them from being inlined by the compiler. This is different from
// PROTOBUF_NO_INLINE, which is a user-supplied macro that disables forced
// inlining by PROTOBUF_(ALWAYS|NDEBUG)_INLINE.
#ifdef PROTOBUF_NOINLINE
#error PROTOBUF_NOINLINE was previously defined
#endif
#if PROTOBUF_GNUC_MIN(3, 1)
# define PROTOBUF_NOINLINE __attribute__((noinline))
#elif defined(_MSC_VER)
// Seems to have been around since at least Visual Studio 2005
#define PROTOBUF_NOINLINE __declspec(noinline)
#else
// Other compilers will have to figure it out for themselves.
#define PROTOBUF_NOINLINE
#endif
# define PROTOBUF_NOINLINE __declspec(noinline)
#endif
#ifdef GOOGLE_ATTRIBUTE_FUNC_ALIGN
#define PROTOBUF_FUNC_ALIGN GOOGLE_ATTRIBUTE_FUNC_ALIGN
#ifdef PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED
#error PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED was previously defined
#endif
#if __has_attribute(exclusive_locks_required)
#define PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED(...) \
__attribute__((exclusive_locks_required(__VA_ARGS__)))
#else
#if defined(__clang__) || \
defined(__GNUC__) && \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
// Function alignment attribute introduced in gcc 4.3
#define PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED(...)
#endif
#ifdef PROTOBUF_NO_THREAD_SAFETY_ANALYSIS
#error PROTOBUF_NO_THREAD_SAFETY_ANALYSIS was previously defined
#endif
#if __has_attribute(no_thread_safety_analysis)
#define PROTOBUF_NO_THREAD_SAFETY_ANALYSIS \
__attribute__((no_thread_safety_analysis))
#else
#define PROTOBUF_NO_THREAD_SAFETY_ANALYSIS
#endif
#ifdef PROTOBUF_GUARDED_BY
#error PROTOBUF_GUARDED_BY was previously defined
#endif
#if __has_attribute(guarded_by)
#define PROTOBUF_GUARDED_BY(x) __attribute__((guarded_by(x)))
#else
#define PROTOBUF_GUARDED_BY(x)
#endif
#ifdef PROTOBUF_LOCKS_EXCLUDED
#error PROTOBUF_LOCKS_EXCLUDED was previously defined
#endif
#if __has_attribute(locks_excluded)
#define PROTOBUF_LOCKS_EXCLUDED(...) \
__attribute__((locks_excluded(__VA_ARGS__)))
#else
#define PROTOBUF_LOCKS_EXCLUDED(...)
#endif
#ifdef PROTOBUF_COLD
#error PROTOBUF_COLD was previously defined
#endif
#if __has_attribute(cold) || PROTOBUF_GNUC_MIN(4, 3)
# define PROTOBUF_COLD __attribute__((cold))
#else
# define PROTOBUF_COLD
#endif
#ifdef PROTOBUF_SECTION_VARIABLE
#error PROTOBUF_SECTION_VARIABLE was previously defined
#endif
#define PROTOBUF_SECTION_VARIABLE(x)
#if defined(PROTOBUF_DEPRECATED)
#error PROTOBUF_DEPRECATED was previously defined
#endif
#if defined(PROTOBUF_DEPRECATED_MSG)
#error PROTOBUF_DEPRECATED_MSG was previously defined
#endif
#if __has_attribute(deprecated) || PROTOBUF_GNUC_MIN(3, 0)
# define PROTOBUF_DEPRECATED __attribute__((deprecated))
# define PROTOBUF_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
#elif defined(_MSC_VER)
# define PROTOBUF_DEPRECATED __declspec(deprecated)
# define PROTOBUF_DEPRECATED_MSG(msg) __declspec(deprecated(msg))
#else
# define PROTOBUF_DEPRECATED
# define PROTOBUF_DEPRECATED_MSG(msg)
#endif
#if defined(PROTOBUF_DEPRECATED_ENUM)
#error PROTOBUF_DEPRECATED_ENUM was previously defined
#endif
#if defined(__clang__) || PROTOBUF_GNUC_MIN(6, 0)
// https://gcc.gnu.org/gcc-6/changes.html
# define PROTOBUF_DEPRECATED_ENUM __attribute__((deprecated))
#else
# define PROTOBUF_DEPRECATED_ENUM
#endif
#ifdef PROTOBUF_FUNC_ALIGN
#error PROTOBUF_FUNC_ALIGN was previously defined
#endif
#if __has_attribute(aligned) || PROTOBUF_GNUC_MIN(4, 3)
#define PROTOBUF_FUNC_ALIGN(bytes) __attribute__((aligned(bytes)))
#else
#define PROTOBUF_FUNC_ALIGN(bytes)
#endif
#endif
#ifdef GOOGLE_PREDICT_TRUE
#define PROTOBUF_PREDICT_TRUE GOOGLE_PREDICT_TRUE
#else
#ifdef __GNUC__
// Provided at least since GCC 3.0.
#define PROTOBUF_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
#else
#define PROTOBUF_PREDICT_TRUE(x) (x)
#ifdef PROTOBUF_RETURNS_NONNULL
#error PROTOBUF_RETURNS_NONNULL was previously defined
#endif
#endif
#ifdef GOOGLE_PREDICT_FALSE
#define PROTOBUF_PREDICT_FALSE GOOGLE_PREDICT_FALSE
#else
#ifdef __GNUC__
// Provided at least since GCC 3.0.
#define PROTOBUF_PREDICT_FALSE(x) (__builtin_expect(x, 0))
#else
#define PROTOBUF_PREDICT_FALSE(x) (x)
#endif
#endif
#ifdef GOOGLE_PROTOBUF_ATTRIBUTE_RETURNS_NONNULL
#define PROTOBUF_RETURNS_NONNULL GOOGLE_PROTOBUF_ATTRIBUTE_RETURNS_NONNULL
#else
#if defined(__has_attribute)
#if __has_attribute(returns_nonnull)
#if __has_attribute(returns_nonnull) || PROTOBUF_GNUC_MIN(4, 9)
#define PROTOBUF_RETURNS_NONNULL __attribute__((returns_nonnull))
#endif
#endif
#endif
#ifndef PROTOBUF_RETURNS_NONNULL
#else
#define PROTOBUF_RETURNS_NONNULL
#endif
#if defined(__has_cpp_attribute)
#ifdef PROTOBUF_ATTRIBUTE_REINITIALIZES
#error PROTOBUF_ATTRIBUTE_REINITIALIZES was previously defined
#endif
#if __has_cpp_attribute(clang::reinitializes)
#define PROTOBUF_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]]
#endif
#endif
#ifndef PROTOBUF_ATTRIBUTE_REINITIALIZES
#else
#define PROTOBUF_ATTRIBUTE_REINITIALIZES
#endif
#define PROTOBUF_GUARDED_BY(x)
#define PROTOBUF_COLD
// Copied from ABSL.
#if defined(__clang__) && defined(__has_warning)
#if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
#define PROTOBUF_FALLTHROUGH_INTENDED [[clang::fallthrough]]
#endif
#elif defined(__GNUC__) && __GNUC__ >= 7
#define PROTOBUF_FALLTHROUGH_INTENDED [[gnu::fallthrough]]
#endif
#ifndef PROTOBUF_FALLTHROUGH_INTENDED
#define PROTOBUF_FALLTHROUGH_INTENDED
#endif
#if defined(__has_cpp_attribute)
#define HAS_ATTRIBUTE(attr) __has_cpp_attribute(attr)
#else
#define HAS_ATTRIBUTE(attr) 0
#endif
#if HAS_ATTRIBUTE(unused) || (defined(__GNUC__) && !defined(__clang__))
#define PROTOBUF_UNUSED __attribute__((__unused__))
#else
#define PROTOBUF_UNUSED
#endif
#undef HAS_ATTRIBUTE
#ifdef _MSC_VER
#define PROTOBUF_LONGLONG(x) x##I64
#define PROTOBUF_ULONGLONG(x) x##UI64
#define PROTOBUF_LL_FORMAT "I64" // As in printf("%I64d", ...)
#else
// By long long, we actually mean int64.
#define PROTOBUF_LONGLONG(x) x##LL
#define PROTOBUF_ULONGLONG(x) x##ULL
// Used to format real long long integers.
#define PROTOBUF_LL_FORMAT \
"ll" // As in "%lld". Note that "q" is poor form also.
#endif
#define PROTOBUF_VERSION 3015008
#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3015000
#define PROTOBUF_MIN_PROTOC_VERSION 3015000
#define PROTOBUF_VERSION_SUFFIX ""
// The minimum library version which works with the current version of the
// headers.
#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3015000
#ifdef PROTOBUF_RTTI
#error PROTOBUF_RTTI was previously defined
#endif
#if defined(GOOGLE_PROTOBUF_NO_RTTI) && GOOGLE_PROTOBUF_NO_RTTI
#define PROTOBUF_RTTI 0
#elif defined(__has_feature)
// https://clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension
#define PROTOBUF_RTTI __has_feature(cxx_rtti)
#elif !defined(__cxx_rtti)
// https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros#C.2B.2B98
#define PROTOBUF_RTTI 0
#elif defined(__GNUC__) && !defined(__GXX_RTTI)
#https: // gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
#define PROTOBUF_RTTI 0
#else
#elif __has_feature(cxx_rtti)
#define PROTOBUF_RTTI 1
#elif defined(__cxx_rtti)
// https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros#C.2B.2B98
#define PROTOBUF_RTTI 1
#else
#define PROTOBUF_RTTI 0
#endif
// Returns the offset of the given field within the given aggregate type.
@ -377,6 +310,9 @@
// which the offsets of the direct fields of a class are non-constant.
// Fields inherited from superclasses *can* have non-constant offsets,
// but that's not what this macro will be used for.
#ifdef PROTOBUF_FIELD_OFFSET
#error PROTOBUF_FIELD_OFFSET was previously defined
#endif
#if defined(__clang__)
// For Clang we use __builtin_offsetof() and suppress the warning,
// to avoid Control Flow Integrity and UBSan vptr sanitizers from
@ -386,8 +322,7 @@
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(TYPE, FIELD) \
_Pragma("clang diagnostic pop")
#elif defined(__GNUC__) && \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
#elif PROTOBUF_GNUC_MIN(4, 8)
#define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) __builtin_offsetof(TYPE, FIELD)
#else // defined(__clang__)
// Note that we calculate relative to the pointer value 16 here since if we
@ -400,43 +335,234 @@
reinterpret_cast<const char*>(16))
#endif
#if defined(PROTOBUF_USE_DLLS)
#ifdef PROTOBUF_EXPORT
#error PROTOBUF_EXPORT was previously defined
#endif
#if defined(PROTOBUF_USE_DLLS) && defined(_MSC_VER)
# if defined(LIBPROTOBUF_EXPORTS)
# define PROTOBUF_EXPORT __declspec(dllexport)
# define PROTOBUF_EXPORT_TEMPLATE_DECLARE
# define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllexport)
# else
# define PROTOBUF_EXPORT __declspec(dllimport)
# define PROTOBUF_EXPORT_TEMPLATE_DECLARE
# define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllimport)
# endif // defined(LIBPROTOBUF_EXPORTS)
#elif defined(PROTOBUF_USE_DLLS) && defined(LIBPROTOBUF_EXPORTS)
# define PROTOBUF_EXPORT __attribute__((visibility("default")))
# define PROTOBUF_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default")))
# define PROTOBUF_EXPORT_TEMPLATE_DEFINE
#else
# define PROTOBUF_EXPORT
# define PROTOBUF_EXPORT_TEMPLATE_DECLARE
# define PROTOBUF_EXPORT_TEMPLATE_DEFINE
#endif
#ifdef PROTOC_EXPORT
#error PROTOC_EXPORT was previously defined
#endif
#if defined(PROTOBUF_USE_DLLS) && defined(_MSC_VER)
# if defined(LIBPROTOC_EXPORTS)
# define PROTOC_EXPORT __declspec(dllexport)
# else
# define PROTOC_EXPORT __declspec(dllimport)
# endif // defined(LIBPROTOC_EXPORTS)
#elif defined(PROTOBUF_USE_DLLS) && defined(LIBPROTOBUF_EXPORTS)
# define PROTOC_EXPORT __attribute__((visibility("default")))
#else
# define PROTOC_EXPORT
#endif
#if defined(PROTOBUF_PREDICT_TRUE) || defined(PROTOBUF_PREDICT_FALSE)
#error PROTOBUF_PREDICT_(TRUE|FALSE) was previously defined
#endif
#if PROTOBUF_GNUC_MIN(3, 0)
# define PROTOBUF_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
# define PROTOBUF_PREDICT_FALSE(x) (__builtin_expect((x), 0))
#else
# define PROTOBUF_PREDICT_TRUE(x) (x)
# define PROTOBUF_PREDICT_FALSE(x) (x)
#endif
#ifdef PROTOBUF_MUST_USE_RESULT
#error PROTOBUF_MUST_USE_RESULT was previously defined
#endif
# define PROTOBUF_FUTURE_MUST_USE_RESULT
# define PROTOBUF_MUST_USE_RESULT
#ifdef PROTOBUF_FALLTHROUGH_INTENDED
#error PROTOBUF_FALLTHROUGH_INTENDED was previously defined
#endif
#if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
#define PROTOBUF_FALLTHROUGH_INTENDED [[clang::fallthrough]]
#elif PROTOBUF_GNUC_MIN(7, 0)
#define PROTOBUF_FALLTHROUGH_INTENDED [[gnu::fallthrough]]
#else
#define PROTOBUF_FALLTHROUGH_INTENDED
#endif
// PROTOBUF_ASSUME(pred) tells the compiler that it can assume pred is true. To
// be safe, we also validate the assumption with a GOOGLE_DCHECK in unoptimized
// builds. The macro does not do anything useful if the compiler does not
// support __builtin_assume.
#ifdef PROTOBUF_ASSUME
#error PROTOBUF_ASSUME was previously defined
#endif
#if __has_builtin(__builtin_assume)
#define PROTOBUF_ASSUME(pred) \
GOOGLE_DCHECK(pred); \
__builtin_assume(pred)
#else
#define PROTOBUF_ASSUME(pred) GOOGLE_DCHECK(pred)
#endif
// Specify memory alignment for structs, classes, etc.
// Use like:
// class PROTOBUF_ALIGNAS(16) MyClass { ... }
// PROTOBUF_ALIGNAS(16) int array[4];
//
// In most places you can use the C++11 keyword "alignas", which is preferred.
//
// But compilers have trouble mixing __attribute__((...)) syntax with
// alignas(...) syntax.
//
// Doesn't work in clang or gcc:
// struct alignas(16) __attribute__((packed)) S { char c; };
// Works in clang but not gcc:
// struct __attribute__((packed)) alignas(16) S2 { char c; };
// Works in clang and gcc:
// struct alignas(16) S3 { char c; } __attribute__((packed));
//
// There are also some attributes that must be specified *before* a class
// definition: visibility (used for exporting functions/classes) is one of
// these attributes. This means that it is not possible to use alignas() with a
// class that is marked as exported.
#ifdef PROTOBUF_ALIGNAS
#error PROTOBUF_ALIGNAS was previously defined
#endif
#if defined(_MSC_VER)
#ifdef LIBPROTOBUF_EXPORTS
#define PROTOBUF_EXPORT __declspec(dllexport)
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllexport)
#define PROTOBUF_ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
#elif PROTOBUF_GNUC_MIN(3, 0)
#define PROTOBUF_ALIGNAS(byte_alignment) \
__attribute__((aligned(byte_alignment)))
#else
#define PROTOBUF_EXPORT __declspec(dllimport)
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllimport)
#define PROTOBUF_ALIGNAS(byte_alignment) alignas(byte_alignment)
#endif
#ifdef LIBPROTOC_EXPORTS
#define PROTOC_EXPORT __declspec(dllexport)
#ifdef PROTOBUF_THREAD_LOCAL
#error PROTOBUF_THREAD_LOCAL was previously defined
#endif
#if defined(_MSC_VER)
#define PROTOBUF_THREAD_LOCAL __declspec(thread)
#else
#define PROTOC_EXPORT __declspec(dllimport)
#define PROTOBUF_THREAD_LOCAL __thread
#endif
#else // defined(_MSC_VER)
#ifdef LIBPROTOBUF_EXPORTS
#define PROTOBUF_EXPORT __attribute__((visibility("default")))
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default")))
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE
// For enabling message owned arena, one major blocker is semantic change from
// moving to copying when there is ownership transfer (e.g., move ctor, swap,
// set allocated, release). This change not only causes performance regression
// but also breaks users code (e.g., dangling reference). For top-level
// messages, since it owns the arena, we can mitigate the issue by transferring
// ownership of arena. However, we cannot do that for nested messages. In order
// to tell how many usages of nested messages affected by message owned arena,
// we need to simulate the arena ownership.
// This experiment is purely for the purpose of gathering data. All code guarded
// by this flag is supposed to be removed after this experiment.
// #define PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT
#ifdef PROTOBUF_CONSTINIT
#error PROTOBUF_CONSTINIT was previously defined
#endif
#if defined(__cpp_constinit) && !PROTOBUF_GNUC_MIN(3, 0)
// Our use of constinit does not yet work with GCC:
// https://github.com/protocolbuffers/protobuf/issues/8310
#define PROTOBUF_CONSTINIT constinit
#elif __has_cpp_attribute(clang::require_constant_initialization)
#define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]]
#else
#define PROTOBUF_EXPORT
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE
#define PROTOBUF_CONSTINIT
#endif
#ifdef LIBPROTOC_EXPORTS
#define PROTOC_EXPORT __attribute__((visibility("default")))
// Some globals with an empty non-trivial destructor are annotated with
// no_destroy for performance reasons. It reduces the cost of these globals in
// non-opt mode and under sanitizers.
#ifdef PROTOBUF_ATTRIBUTE_NO_DESTROY
#error PROTOBUF_ATTRIBUTE_NO_DESTROY was previously defined
#endif
#if __has_cpp_attribute(clang::no_destroy)
#define PROTOBUF_ATTRIBUTE_NO_DESTROY [[clang::no_destroy]]
#else
#define PROTOC_EXPORT
#define PROTOBUF_ATTRIBUTE_NO_DESTROY
#endif
// Protobuf extensions and reflection require registration of the protos linked
// in the binary. Not until everything is registered does the runtime have a
// complete view on all protos. When code is using reflection or extensions
// in between registration calls this can lead to surprising behavior. By
// having the registration run first we mitigate this scenario.
// Highest priority is 101. We use 102 to allow code that really wants to
// higher priority to still beat us.
#ifdef PROTOBUF_ATTRIBUTE_INIT_PRIORITY
#error PROTOBUF_ATTRIBUTE_INIT_PRIORITY was previously defined
#endif
#else // defined(PROTOBUF_USE_DLLS)
#define PROTOBUF_EXPORT
#define PROTOC_EXPORT
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE
#if PROTOBUF_GNUC_MIN(3, 0)
#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY __attribute__((init_priority((102))))
#else
#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY
#endif
#ifdef PROTOBUF_PRAGMA_INIT_SEG
#error PROTOBUF_PRAGMA_INIT_SEG was previously defined
#endif
#if _MSC_VER
#define PROTOBUF_PRAGMA_INIT_SEG __pragma(init_seg(lib))
#else
#define PROTOBUF_PRAGMA_INIT_SEG
#endif
#ifdef PROTOBUF_ATTRIBUTE_WEAK
#error PROTOBUF_ATTRIBUTE_WEAK was previously defined
#endif
#if __has_attribute(weak) && !defined(__MINGW32__)
#define PROTOBUF_ATTRIBUTE_WEAK __attribute__((weak))
#else
#define PROTOBUF_ATTRIBUTE_WEAK
#endif
// Macros to detect sanitizers.
#ifdef PROTOBUF_ASAN
#error PROTOBUF_ASAN was previously defined
#endif
#ifdef PROTOBUF_MSAN
#error PROTOBUF_MSAN was previously defined
#endif
#ifdef PROTOBUF_TSAN
#error PROTOBUF_TSAN was previously defined
#endif
#if defined(__clang__)
# if __has_feature(address_sanitizer)
# define PROTOBUF_ASAN 1
# endif
# if __has_feature(thread_sanitizer)
# define PROTOBUF_TSAN 1
# endif
# if __has_feature(memory_sanitizer)
# define PROTOBUF_MSAN 1
# endif
#elif PROTOBUF_GNUC_MIN(3, 0)
# define PROTOBUF_ASAN __SANITIZE_ADDRESS__
# define PROTOBUF_TSAN __SANITIZE_THREAD__
#endif
#ifdef PROTOBUF_UNUSED
#error PROTOBUF_UNUSED was previously defined
#endif
#if __has_cpp_attribute(unused) || \
(PROTOBUF_GNUC_MIN(3, 0) && !defined(__clang__))
#define PROTOBUF_UNUSED __attribute__((__unused__))
#else
#define PROTOBUF_UNUSED
#endif
// Windows declares several inconvenient macro names. We #undef them and then
@ -490,19 +616,19 @@
#undef timezone
#endif // _MSC_VER
#if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER)
#if defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER)
// Don't let Objective-C Macros interfere with proto identifiers with the same
// name.
#pragma push_macro("DEBUG")
#undef DEBUG
#endif // defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER)
#endif // defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER)
#if defined(__clang__)
#pragma clang diagnostic push
// TODO(gerbens) ideally we cleanup the code. But a cursory try shows many
// violations. So let's ignore for now.
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
#elif defined(__GNUC__)
#elif PROTOBUF_GNUC_MIN(3, 0)
// GCC does not allow disabling diagnostics within an expression:
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60875, so we disable this one
// globally even though it's only used for PROTOBUF_FIELD_OFFSET.
@ -510,141 +636,6 @@
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
#endif
// PROTOBUF_ASSUME(pred) tells the compiler that it can assume pred is true. To
// be safe, we also validate the assumption with a GOOGLE_DCHECK in unoptimized
// builds. The macro does not do anything useful if the compiler does not
// support __builtin_assume.
#ifdef __has_builtin
#if __has_builtin(__builtin_assume)
#define PROTOBUF_ASSUME(pred) \
GOOGLE_DCHECK(pred); \
__builtin_assume(pred)
#else
#define PROTOBUF_ASSUME(pred) GOOGLE_DCHECK(pred)
#endif
#else
#define PROTOBUF_ASSUME(pred) GOOGLE_DCHECK(pred)
#endif
// Specify memory alignment for structs, classes, etc.
// Use like:
// class PROTOBUF_ALIGNAS(16) MyClass { ... }
// PROTOBUF_ALIGNAS(16) int array[4];
//
// In most places you can use the C++11 keyword "alignas", which is preferred.
//
// But compilers have trouble mixing __attribute__((...)) syntax with
// alignas(...) syntax.
//
// Doesn't work in clang or gcc:
// struct alignas(16) __attribute__((packed)) S { char c; };
// Works in clang but not gcc:
// struct __attribute__((packed)) alignas(16) S2 { char c; };
// Works in clang and gcc:
// struct alignas(16) S3 { char c; } __attribute__((packed));
//
// There are also some attributes that must be specified *before* a class
// definition: visibility (used for exporting functions/classes) is one of
// these attributes. This means that it is not possible to use alignas() with a
// class that is marked as exported.
#if defined(_MSC_VER)
#define PROTOBUF_ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
#elif defined(__GNUC__)
#define PROTOBUF_ALIGNAS(byte_alignment) \
__attribute__((aligned(byte_alignment)))
#else
#define PROTOBUF_ALIGNAS(byte_alignment) alignas(byte_alignment)
#endif
#define PROTOBUF_FINAL final
#if defined(_MSC_VER)
#define PROTOBUF_THREAD_LOCAL __declspec(thread)
#else
#define PROTOBUF_THREAD_LOCAL __thread
#endif
// For enabling message owned arena, one major blocker is semantic change from
// moving to copying when there is ownership transfer (e.g., move ctor, swap,
// set allocated, release). This change not only causes performance regression
// but also breaks users code (e.g., dangling reference). For top-level
// messages, since it owns the arena, we can mitigate the issue by transferring
// ownership of arena. However, we cannot do that for nested messages. In order
// to tell how many usages of nested messages affected by message owned arena,
// we need to simulate the arena ownership.
// This experiment is purely for the purpose of gathering data. All code guarded
// by this flag is supposed to be removed after this experiment.
// #define PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT
// Our use of constinit does not yet work with GCC:
// https://github.com/protocolbuffers/protobuf/issues/8310
#if defined(__cpp_constinit) && !defined(__GNUC__)
#define PROTOBUF_CONSTINIT constinit
#elif defined(__has_cpp_attribute)
#if __has_cpp_attribute(clang::require_constant_initialization)
#define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]]
#endif
#endif
#ifndef PROTOBUF_CONSTINIT
#define PROTOBUF_CONSTINIT
#endif
// Some globals with an empty non-trivial destructor are annotated with
// no_destroy for performance reasons. It reduces the cost of these globals in
// non-opt mode and under sanitizers.
#if defined(__has_cpp_attribute)
#if __has_cpp_attribute(clang::no_destroy)
#define PROTOBUF_ATTRIBUTE_NO_DESTROY [[clang::no_destroy]]
#endif
#endif
#if !defined(PROTOBUF_ATTRIBUTE_NO_DESTROY)
#define PROTOBUF_ATTRIBUTE_NO_DESTROY
#endif
#if defined(__GNUC__)
// Protobuf extensions and reflection require registration of the protos linked
// in the binary. Not until everything is registered does the runtime have a
// complete view on all protos. When code is using reflection or extensions
// in between registration calls this can lead to surprising behavior. By
// having the registration run first we mitigate this scenario.
// Highest priority is 101. We use 102 to allow code that really wants to
// higher priority to still beat us.
#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY __attribute__((init_priority((102))))
#else
#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY
#endif
#if _MSC_VER
#define PROTOBUF_PRAGMA_INIT_SEG __pragma(init_seg(lib))
#else
#define PROTOBUF_PRAGMA_INIT_SEG
#endif
#if defined(__has_attribute) && !defined(__MINGW32__)
#if __has_attribute(weak)
#define PROTOBUF_ATTRIBUTE_WEAK __attribute__((weak))
#endif
#endif
#if !defined(PROTOBUF_ATTRIBUTE_WEAK)
#define PROTOBUF_ATTRIBUTE_WEAK
#endif
// Macros to detect sanitizers.
#if defined(__clang__)
# if __has_feature(address_sanitizer)
# define PROTOBUF_ASAN 1
# endif
# if __has_feature(thread_sanitizer)
# define PROTOBUF_TSAN 1
# endif
# if __has_feature(memory_sanitizer)
# define PROTOBUF_MSAN 1
# endif
#elif defined(__GNUC__)
# define PROTOBUF_ASAN __SANITIZE_ADDRESS__
# define PROTOBUF_TSAN __SANITIZE_THREAD__
#endif
// Silence some MSVC warnings in all our code.
#if _MSC_VER
#pragma warning(push)
@ -656,3 +647,28 @@
// To silence the fact that we will pop this push from another file
#pragma warning(disable : 5031)
#endif
// We don't want code outside port_def doing complex testing, so
// remove our portable condition test macros to nudge folks away from
// using it themselves.
#ifdef PROTOBUF_has_cpp_attribute_DEFINED_
# undef __has_cpp_attribute
# undef PROTOBUF_has_cpp_attribute_DEFINED_
#endif
#ifdef PROTOBUF_has_feature_DEFINED_
# undef __has_feature
# undef PROTOBUF_has_feature_DEFINED_
#endif
#ifdef PROTOBUF_has_warning_DEFINED_
# undef __has_warning
# undef PROTOBUF_has_warning_DEFINED_
#endif
#ifdef PROTOBUF_has_attribute_DEFINED_
# undef __has_attribute
# undef PROTOBUF_has_attribute_DEFINED_
#endif
#ifdef PROTOBUF_has_builtin_DEFINED_
# undef __has_builtin
# undef PROTOBUF_has_builtin_DEFINED_
#endif
#undef PROTOBUF_GNUC_MIN

View File

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

View File

@ -418,19 +418,24 @@ void ReflectionOps::FindInitializationErrors(const Message& message,
}
}
void GenericSwap(Message* m1, Message* m2) {
Arena* m2_arena = m2->GetArena();
GOOGLE_DCHECK(m1->GetArena() != m2_arena);
void GenericSwap(Message* lhs, Message* rhs) {
GOOGLE_DCHECK(Arena::InternalHelper<Message>::GetOwningArena(lhs) !=
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
// temporary on |m2|'s arena so that messages are copied twice rather than
// three times.
Message* tmp = m2->New(m2_arena);
std::unique_ptr<Message> tmp_deleter(m2_arena == nullptr ? tmp : nullptr);
tmp->CheckTypeAndMergeFrom(*m1);
m1->Clear();
m1->CheckTypeAndMergeFrom(*m2);
m2->GetReflection()->Swap(tmp, m2);
// Improve efficiency by placing the temporary on an arena so that messages
// are copied twice rather than three times.
GOOGLE_DCHECK(arena != nullptr);
Message* tmp = rhs->New(arena);
tmp->CheckTypeAndMergeFrom(*lhs);
lhs->Clear();
lhs->CheckTypeAndMergeFrom(*rhs);
rhs->GetReflection()->Swap(tmp, rhs);
}
} // namespace internal

View File

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

View File

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

View File

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

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

View File

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -175,6 +175,23 @@ class PROTOBUF_EXPORT StringPiece {
const char* ptr_;
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:
// We provide non-explicit singleton constructors so users can pass
// in a "const char*" or a "string" wherever a "StringPiece" is
@ -187,7 +204,7 @@ class PROTOBUF_EXPORT StringPiece {
StringPiece(const char* str) // NOLINT(runtime/explicit)
: ptr_(str), length_(0) {
if (str != nullptr) {
length_ = strlen(str);
length_ = CheckSize(strlen(str));
}
}
@ -195,11 +212,11 @@ class PROTOBUF_EXPORT StringPiece {
StringPiece( // NOLINT(runtime/explicit)
const std::basic_string<char, std::char_traits<char>, Allocator>& str)
: ptr_(str.data()), length_(0) {
length_ = str.size();
length_ = CheckSize(str.size());
}
StringPiece(const char* offset, size_type len)
: ptr_(offset), length_(len) {}
: ptr_(offset), length_(CheckSize(len)) {}
// data() may return a pointer to a buffer with embedded NULs, and the
// returned buffer may or may not be null terminated. Therefore it is
@ -304,8 +321,7 @@ class PROTOBUF_EXPORT StringPiece {
size_type find_last_of(char c, size_type pos = npos) const {
return rfind(c, pos);
}
size_type find_last_not_of(StringPiece s,
size_type pos = npos) const;
size_type find_last_not_of(StringPiece s, size_type pos = npos) const;
size_type find_last_not_of(char c, size_type pos = npos) const;
StringPiece substr(size_type pos, size_type n = npos) const;

View File

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

View File

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

View File

@ -1069,13 +1069,8 @@ static std::string RemoveRedundantZeros(std::string text) {
TEST_F(TextFormatTest, PrintExotic) {
unittest::TestAllTypes message;
// Note: In C, a negative integer literal is actually the unary negation
// operator being applied to a positive integer literal, and
// 9223372036854775808 is outside the range of int64. However, it is not
// outside the range of uint64. Confusingly, this means that everything
// works if we make the literal unsigned, even though we are negating it.
message.add_repeated_int64(-PROTOBUF_ULONGLONG(9223372036854775808));
message.add_repeated_uint64(PROTOBUF_ULONGLONG(18446744073709551615));
message.add_repeated_int64(int64_t{-9223372036854775807} - 1);
message.add_repeated_uint64(uint64_t{18446744073709551615u});
message.add_repeated_double(123.456);
message.add_repeated_double(1.23e21);
message.add_repeated_double(1.23e-18);
@ -1240,32 +1235,19 @@ TEST_F(TextFormatTest, ParseExotic) {
ASSERT_EQ(2, message.repeated_int32_size());
EXPECT_EQ(-1, message.repeated_int32(0));
// Note: In C, a negative integer literal is actually the unary negation
// operator being applied to a positive integer literal, and 2147483648 is
// outside the range of int32. However, it is not outside the range of
// uint32. Confusingly, this means that everything works if we make the
// literal unsigned, even though we are negating it.
EXPECT_EQ(-2147483648u, message.repeated_int32(1));
EXPECT_EQ(-2147483648, message.repeated_int32(1));
ASSERT_EQ(2, message.repeated_int64_size());
EXPECT_EQ(-1, message.repeated_int64(0));
// Note: In C, a negative integer literal is actually the unary negation
// operator being applied to a positive integer literal, and
// 9223372036854775808 is outside the range of int64. However, it is not
// outside the range of uint64. Confusingly, this means that everything
// works if we make the literal unsigned, even though we are negating it.
EXPECT_EQ(-PROTOBUF_ULONGLONG(9223372036854775808),
message.repeated_int64(1));
EXPECT_EQ(int64_t{-9223372036854775807} - 1, message.repeated_int64(1));
ASSERT_EQ(2, message.repeated_uint32_size());
EXPECT_EQ(4294967295u, message.repeated_uint32(0));
EXPECT_EQ(2147483648u, message.repeated_uint32(1));
ASSERT_EQ(2, message.repeated_uint64_size());
EXPECT_EQ(PROTOBUF_ULONGLONG(18446744073709551615),
message.repeated_uint64(0));
EXPECT_EQ(PROTOBUF_ULONGLONG(9223372036854775808),
message.repeated_uint64(1));
EXPECT_EQ(uint64_t{18446744073709551615u}, message.repeated_uint64(0));
EXPECT_EQ(uint64_t{9223372036854775808u}, message.repeated_uint64(1));
ASSERT_EQ(13, message.repeated_double_size());
EXPECT_EQ(123.0, message.repeated_double(0));

View File

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

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

View File

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

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:
inline Type() : Type(nullptr) {}
@ -196,8 +196,9 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL :
return *this;
}
inline Type& operator=(Type&& from) noexcept {
if (GetArena() == from.GetArena()) {
if (this != &from) InternalSwap(&from);
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
@ -228,7 +229,7 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL :
}
inline void Swap(Type* other) {
if (other == this) return;
if (GetArena() == other->GetArena()) {
if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -236,14 +237,14 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL :
}
void UnsafeArenaSwap(Type* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena());
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline Type* New() const final {
return CreateMaybeMessage<Type>(nullptr);
return new Type();
}
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>
void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name();
std::string* release_name();
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value);
std::string* _internal_mutable_name();
public:
@ -411,7 +412,7 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL :
};
// -------------------------------------------------------------------
class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
class PROTOBUF_EXPORT Field final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Field) */ {
public:
inline Field() : Field(nullptr) {}
@ -429,8 +430,9 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
return *this;
}
inline Field& operator=(Field&& from) noexcept {
if (GetArena() == from.GetArena()) {
if (this != &from) InternalSwap(&from);
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
@ -461,7 +463,7 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
}
inline void Swap(Field* other) {
if (other == this) return;
if (GetArena() == other->GetArena()) {
if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -469,14 +471,14 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
}
void UnsafeArenaSwap(Field* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena());
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline Field* New() const final {
return CreateMaybeMessage<Field>(nullptr);
return new Field();
}
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>
void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name();
std::string* release_name();
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value);
std::string* _internal_mutable_name();
public:
@ -665,11 +667,11 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT>
void set_type_url(ArgT0&& arg0, ArgT... args);
std::string* mutable_type_url();
std::string* release_type_url();
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_type_url();
void set_allocated_type_url(std::string* type_url);
private:
const std::string& _internal_type_url() const;
void _internal_set_type_url(const std::string& value);
inline PROTOBUF_ALWAYS_INLINE void _internal_set_type_url(const std::string& value);
std::string* _internal_mutable_type_url();
public:
@ -679,11 +681,11 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT>
void set_json_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_json_name();
std::string* release_json_name();
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_json_name();
void set_allocated_json_name(std::string* json_name);
private:
const std::string& _internal_json_name() const;
void _internal_set_json_name(const std::string& value);
inline PROTOBUF_ALWAYS_INLINE void _internal_set_json_name(const std::string& value);
std::string* _internal_mutable_json_name();
public:
@ -693,11 +695,11 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
template <typename ArgT0 = const std::string&, typename... ArgT>
void set_default_value(ArgT0&& arg0, ArgT... args);
std::string* mutable_default_value();
std::string* release_default_value();
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_default_value();
void set_allocated_default_value(std::string* default_value);
private:
const std::string& _internal_default_value() const;
void _internal_set_default_value(const std::string& value);
inline PROTOBUF_ALWAYS_INLINE void _internal_set_default_value(const std::string& value);
std::string* _internal_mutable_default_value();
public:
@ -768,7 +770,7 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
};
// -------------------------------------------------------------------
class PROTOBUF_EXPORT Enum PROTOBUF_FINAL :
class PROTOBUF_EXPORT Enum final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Enum) */ {
public:
inline Enum() : Enum(nullptr) {}
@ -786,8 +788,9 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL :
return *this;
}
inline Enum& operator=(Enum&& from) noexcept {
if (GetArena() == from.GetArena()) {
if (this != &from) InternalSwap(&from);
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
@ -818,7 +821,7 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL :
}
inline void Swap(Enum* other) {
if (other == this) return;
if (GetArena() == other->GetArena()) {
if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -826,14 +829,14 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL :
}
void UnsafeArenaSwap(Enum* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena());
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline Enum* New() const final {
return CreateMaybeMessage<Enum>(nullptr);
return new Enum();
}
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>
void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name();
std::string* release_name();
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value);
std::string* _internal_mutable_name();
public:
@ -975,7 +978,7 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL :
};
// -------------------------------------------------------------------
class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL :
class PROTOBUF_EXPORT EnumValue final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValue) */ {
public:
inline EnumValue() : EnumValue(nullptr) {}
@ -993,8 +996,9 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL :
return *this;
}
inline EnumValue& operator=(EnumValue&& from) noexcept {
if (GetArena() == from.GetArena()) {
if (this != &from) InternalSwap(&from);
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
@ -1025,7 +1029,7 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL :
}
inline void Swap(EnumValue* other) {
if (other == this) return;
if (GetArena() == other->GetArena()) {
if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -1033,14 +1037,14 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL :
}
void UnsafeArenaSwap(EnumValue* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena());
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline EnumValue* New() const final {
return CreateMaybeMessage<EnumValue>(nullptr);
return new EnumValue();
}
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>
void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name();
std::string* release_name();
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value);
std::string* _internal_mutable_name();
public:
@ -1142,7 +1146,7 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL :
};
// -------------------------------------------------------------------
class PROTOBUF_EXPORT Option PROTOBUF_FINAL :
class PROTOBUF_EXPORT Option final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Option) */ {
public:
inline Option() : Option(nullptr) {}
@ -1160,8 +1164,9 @@ class PROTOBUF_EXPORT Option PROTOBUF_FINAL :
return *this;
}
inline Option& operator=(Option&& from) noexcept {
if (GetArena() == from.GetArena()) {
if (this != &from) InternalSwap(&from);
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
@ -1192,7 +1197,7 @@ class PROTOBUF_EXPORT Option PROTOBUF_FINAL :
}
inline void Swap(Option* other) {
if (other == this) return;
if (GetArena() == other->GetArena()) {
if (GetOwningArena() == other->GetOwningArena()) {
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
@ -1200,14 +1205,14 @@ class PROTOBUF_EXPORT Option PROTOBUF_FINAL :
}
void UnsafeArenaSwap(Option* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArena() == other->GetArena());
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline Option* New() const final {
return CreateMaybeMessage<Option>(nullptr);
return new Option();
}
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>
void set_name(ArgT0&& arg0, ArgT... args);
std::string* mutable_name();
std::string* release_name();
PROTOBUF_FUTURE_MUST_USE_RESULT std::string* release_name();
void set_allocated_name(std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value);
std::string* _internal_mutable_name();
public:
@ -1316,10 +1321,10 @@ inline const std::string& Type::name() const {
return _internal_name();
}
template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE
inline void Type::set_name(ArgT0&& arg0, ArgT... args) {
inline PROTOBUF_ALWAYS_INLINE
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)
}
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) {
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() {
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() {
// @@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) {
if (name != nullptr) {
@ -1348,7 +1353,7 @@ inline void Type::set_allocated_name(std::string* name) {
}
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena());
GetArenaForAllocation());
// @@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(
PROTOBUF_NAMESPACE_ID::SourceContext* source_context) {
if (GetArena() == nullptr) {
if (GetArenaForAllocation() == nullptr) {
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_);
}
source_context_ = source_context;
@ -1537,7 +1542,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Type::release_source_context() {
PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_;
source_context_ = nullptr;
if (GetArena() != nullptr) {
if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
}
return temp;
@ -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() {
if (source_context_ == nullptr) {
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::SourceContext>(GetArena());
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::SourceContext>(GetArenaForAllocation());
source_context_ = p;
}
return source_context_;
@ -1562,13 +1567,15 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Type::mutable_source_context() {
return _internal_mutable_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) {
delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_);
}
if (source_context) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context)->GetArena();
::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<
::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena(
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context));
if (message_arena != submessage_arena) {
source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, source_context, submessage_arena);
@ -1674,10 +1681,10 @@ inline const std::string& Field::name() const {
return _internal_name();
}
template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE
inline void Field::set_name(ArgT0&& arg0, ArgT... args) {
inline PROTOBUF_ALWAYS_INLINE
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)
}
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) {
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() {
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() {
// @@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) {
if (name != nullptr) {
@ -1706,7 +1713,7 @@ inline void Field::set_allocated_name(std::string* name) {
}
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena());
GetArenaForAllocation());
// @@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();
}
template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE
inline void Field::set_type_url(ArgT0&& arg0, ArgT... args) {
inline PROTOBUF_ALWAYS_INLINE
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)
}
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) {
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() {
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() {
// @@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) {
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,
GetArena());
GetArenaForAllocation());
// @@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();
}
template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE
inline void Field::set_json_name(ArgT0&& arg0, ArgT... args) {
inline PROTOBUF_ALWAYS_INLINE
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)
}
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) {
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() {
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() {
// @@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) {
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,
GetArena());
GetArenaForAllocation());
// @@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();
}
template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE
inline void Field::set_default_value(ArgT0&& arg0, ArgT... args) {
inline PROTOBUF_ALWAYS_INLINE
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)
}
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) {
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() {
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() {
// @@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) {
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,
GetArena());
GetArenaForAllocation());
// @@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();
}
template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE
inline void Enum::set_name(ArgT0&& arg0, ArgT... args) {
inline PROTOBUF_ALWAYS_INLINE
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)
}
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) {
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() {
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() {
// @@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) {
if (name != nullptr) {
@ -1969,7 +1976,7 @@ inline void Enum::set_allocated_name(std::string* name) {
}
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena());
GetArenaForAllocation());
// @@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(
PROTOBUF_NAMESPACE_ID::SourceContext* source_context) {
if (GetArena() == nullptr) {
if (GetArenaForAllocation() == nullptr) {
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_);
}
source_context_ = source_context;
@ -2084,7 +2091,7 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Enum::release_source_context() {
PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_;
source_context_ = nullptr;
if (GetArena() != nullptr) {
if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
}
return temp;
@ -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() {
if (source_context_ == nullptr) {
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::SourceContext>(GetArena());
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::SourceContext>(GetArenaForAllocation());
source_context_ = p;
}
return source_context_;
@ -2109,13 +2116,15 @@ inline PROTOBUF_NAMESPACE_ID::SourceContext* Enum::mutable_source_context() {
return _internal_mutable_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) {
delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_);
}
if (source_context) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context)->GetArena();
::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<
::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena(
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context));
if (message_arena != submessage_arena) {
source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, source_context, submessage_arena);
@ -2161,10 +2170,10 @@ inline const std::string& EnumValue::name() const {
return _internal_name();
}
template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE
inline void EnumValue::set_name(ArgT0&& arg0, ArgT... args) {
inline PROTOBUF_ALWAYS_INLINE
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)
}
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) {
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() {
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() {
// @@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) {
if (name != nullptr) {
@ -2193,7 +2202,7 @@ inline void EnumValue::set_allocated_name(std::string* name) {
}
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena());
GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name)
}
@ -2269,10 +2278,10 @@ inline const std::string& Option::name() const {
return _internal_name();
}
template <typename ArgT0, typename... ArgT>
PROTOBUF_ALWAYS_INLINE
inline void Option::set_name(ArgT0&& arg0, ArgT... args) {
inline PROTOBUF_ALWAYS_INLINE
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)
}
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) {
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() {
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() {
// @@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) {
if (name != nullptr) {
@ -2301,7 +2310,7 @@ inline void Option::set_allocated_name(std::string* name) {
}
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArena());
GetArenaForAllocation());
// @@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(
PROTOBUF_NAMESPACE_ID::Any* value) {
if (GetArena() == nullptr) {
if (GetArenaForAllocation() == nullptr) {
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(value_);
}
value_ = value;
@ -2338,7 +2347,7 @@ inline PROTOBUF_NAMESPACE_ID::Any* Option::release_value() {
PROTOBUF_NAMESPACE_ID::Any* temp = value_;
value_ = nullptr;
if (GetArena() != nullptr) {
if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(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() {
if (value_ == nullptr) {
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::Any>(GetArena());
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::Any>(GetArenaForAllocation());
value_ = p;
}
return value_;
@ -2363,13 +2372,15 @@ inline PROTOBUF_NAMESPACE_ID::Any* Option::mutable_value() {
return _internal_mutable_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) {
delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(value_);
}
if (value) {
::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) {
value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, value, submessage_arena);

View File

@ -1238,6 +1238,19 @@ ProtoStreamObjectWriter* ProtoStreamObjectWriter::RenderDataPiece(
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);
return this;
}

View File

@ -108,6 +108,13 @@ class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
// is disabled.
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
// object.
bool suppress_object_to_scalar_error;
@ -125,6 +132,8 @@ class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
use_legacy_json_map_format(false),
disable_implicit_message_list(false),
suppress_implicit_message_list_error(false),
disable_implicit_scalar_list(false),
suppress_implicit_scalar_list_error(false),
suppress_object_to_scalar_error(false),
use_json_name_in_missing_fields(false) {}

View File

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

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