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

This commit is contained in:
Adam Cozzette 2022-03-02 17:37:55 +00:00
commit 0ece18cf2e
69 changed files with 842 additions and 668 deletions

View File

@ -90,6 +90,7 @@ set(libprotobuf_includes
${protobuf_source_dir}/src/google/protobuf/util/delimited_message_util.h
${protobuf_source_dir}/src/google/protobuf/util/field_comparator.h
${protobuf_source_dir}/src/google/protobuf/util/field_mask_util.h
${protobuf_source_dir}/src/google/protobuf/util/internal/json_escaping.h
${protobuf_source_dir}/src/google/protobuf/util/json_util.h
${protobuf_source_dir}/src/google/protobuf/util/message_differencer.h
${protobuf_source_dir}/src/google/protobuf/util/time_util.h

View File

@ -59,6 +59,8 @@ public final class TextFormat {
private static final Logger logger = Logger.getLogger(TextFormat.class.getName());
private static final String DEBUG_STRING_SILENT_MARKER = "\t ";
/**
* Outputs a textual representation of the Protocol Message supplied into the parameter output.
@ -945,6 +947,14 @@ public final class TextFormat {
Pattern.compile("-?inf(inity)?f?", Pattern.CASE_INSENSITIVE);
private static final Pattern FLOAT_NAN = Pattern.compile("nanf?", Pattern.CASE_INSENSITIVE);
/**
* {@link containsSilentMarkerAfterCurrentToken} indicates if there is a silent marker after the
* current token. This value is moved to {@link containsSilentMarkerAfterPrevToken} every time
* the next token is parsed.
*/
private boolean containsSilentMarkerAfterCurrentToken = false;
private boolean containsSilentMarkerAfterPrevToken = false;
/** Construct a tokenizer that parses tokens from the given text. */
private Tokenizer(final CharSequence text) {
this.text = text;
@ -969,6 +979,14 @@ public final class TextFormat {
return column;
}
boolean getContainsSilentMarkerAfterCurrentToken() {
return containsSilentMarkerAfterCurrentToken;
}
boolean getContainsSilentMarkerAfterPrevToken() {
return containsSilentMarkerAfterPrevToken;
}
/** Are we at the end of the input? */
public boolean atEnd() {
return currentToken.length() == 0;
@ -1534,6 +1552,23 @@ public final class TextFormat {
* control the parser behavior.
*/
public static class Parser {
private int debugStringSilentMarker;
int getSilentMarkerCount() {
return debugStringSilentMarker;
}
/**
* A valid silent marker appears between a field name and its value. If there is a ":" in
* between, the silent marker will only appear after the colon. This is called after a field
* name is parsed, and before the ":" if it exists. If the current token is ":", then
* containsSilentMarkerAfterCurrentToken indicates if there is a valid silent marker. Otherwise,
* the current token is part of the field value, so the silent marker is indicated by
* containsSilentMarkerAfterPrevToken.
*/
private void detectSilentMarker(Tokenizer tokenizer) {
}
/**
* Determines if repeated values for non-repeated fields and oneofs are permitted. For example,
* given required/optional field "foo" and a oneof containing "baz" and "qux":
@ -1890,6 +1925,7 @@ public final class TextFormat {
// start with "{" or "<" which indicates the beginning of a message body.
// If there is no ":" or there is a "{" or "<" after ":", this field has
// to be a message or the input is ill-formed.
detectSilentMarker(tokenizer);
if (tokenizer.tryConsume(":") && !tokenizer.lookingAt("{") && !tokenizer.lookingAt("<")) {
skipFieldValue(tokenizer);
} else {
@ -1900,6 +1936,7 @@ public final class TextFormat {
// Handle potential ':'.
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
detectSilentMarker(tokenizer);
tokenizer.tryConsume(":"); // optional
if (parseTreeBuilder != null) {
TextFormatParseInfoTree.Builder childParseTreeBuilder =
@ -1923,6 +1960,7 @@ public final class TextFormat {
unknownFields);
}
} else {
detectSilentMarker(tokenizer);
tokenizer.consume(":"); // required
consumeFieldValues(
tokenizer,
@ -2184,6 +2222,7 @@ public final class TextFormat {
throw tokenizer.parseExceptionPreviousToken("Expected a valid type URL.");
}
}
detectSilentMarker(tokenizer);
tokenizer.tryConsume(":");
final String anyEndToken;
if (tokenizer.tryConsume("<")) {
@ -2220,7 +2259,7 @@ public final class TextFormat {
}
/** Skips the next field including the field's name and value. */
private static void skipField(Tokenizer tokenizer) throws ParseException {
private void skipField(Tokenizer tokenizer) throws ParseException {
if (tokenizer.tryConsume("[")) {
// Extension name.
do {
@ -2237,6 +2276,7 @@ public final class TextFormat {
// start with "{" or "<" which indicates the beginning of a message body.
// If there is no ":" or there is a "{" or "<" after ":", this field has
// to be a message or the input is ill-formed.
detectSilentMarker(tokenizer);
if (tokenizer.tryConsume(":") && !tokenizer.lookingAt("<") && !tokenizer.lookingAt("{")) {
skipFieldValue(tokenizer);
} else {
@ -2252,7 +2292,7 @@ public final class TextFormat {
/**
* Skips the whole body of a message including the beginning delimiter and the ending delimiter.
*/
private static void skipFieldMessage(Tokenizer tokenizer) throws ParseException {
private void skipFieldMessage(Tokenizer tokenizer) throws ParseException {
final String delimiter;
if (tokenizer.tryConsume("<")) {
delimiter = ">";
@ -2267,7 +2307,7 @@ public final class TextFormat {
}
/** Skips a field value. */
private static void skipFieldValue(Tokenizer tokenizer) throws ParseException {
private void skipFieldValue(Tokenizer tokenizer) throws ParseException {
if (tokenizer.tryConsumeString()) {
while (tokenizer.tryConsumeString()) {}
return;

View File

@ -764,6 +764,7 @@ public class CodedOutputStreamTest {
* Writes the given value using writeRawVarint32() and writeRawVarint64() and checks that the
* result matches the given bytes.
*/
@SuppressWarnings("UnnecessaryLongToIntConversion") // Intentionally tests 32-bit int values.
private static void assertWriteVarint(byte[] data, long value) throws Exception {
for (OutputType outputType : OutputType.values()) {
// Only test 32-bit write if the value fits into an int.

View File

@ -32,6 +32,8 @@ package com.google.protobuf;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.protobuf.Descriptors.FileDescriptor;
import com.google.protobuf.Descriptors.MethodDescriptor;
@ -46,145 +48,124 @@ import protobuf_unittest.UnittestProto.TestService;
import protobuf_unittest.no_generic_services_test.UnittestNoGenericServices;
import java.util.HashSet;
import java.util.Set;
import org.easymock.EasyMock;
import org.easymock.IArgumentMatcher;
import org.easymock.IMocksControl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.InOrder;
import org.mockito.Mockito;
/** Tests services and stubs. */
@RunWith(JUnit4.class)
public class ServiceTest {
private IMocksControl control;
private RpcController mockController;
private final Descriptors.MethodDescriptor fooDescriptor =
TestService.getDescriptor().getMethods().get(0);
private final Descriptors.MethodDescriptor barDescriptor =
TestService.getDescriptor().getMethods().get(1);
@Before
public void setUp() throws Exception {
control = EasyMock.createStrictControl();
mockController = control.createMock(RpcController.class);
}
// =================================================================
private static final FooRequest FOO_REQUEST = FooRequest.getDefaultInstance();
private static final BarRequest BAR_REQUEST = BarRequest.getDefaultInstance();
private static final RpcController MOCK_RPC_CONTROLLER = Mockito.mock(RpcController.class);
private static final FooResponse FOO_RESPONSE = FooResponse.getDefaultInstance();
private static final BarResponse BAR_RESPONSE = BarResponse.getDefaultInstance();
private static final MessageWithNoOuter MESSAGE_WITH_NO_OUTER =
MessageWithNoOuter.getDefaultInstance();
/** Tests Service.callMethod(). */
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void testCallMethod() throws Exception {
FooRequest fooRequest = FooRequest.newBuilder().build();
BarRequest barRequest = BarRequest.newBuilder().build();
MockCallback<Message> fooCallback = new MockCallback<Message>();
MockCallback<Message> barCallback = new MockCallback<Message>();
TestService mockService = EasyMock.createMock(TestService.class);
TestService mockService = Mockito.mock(TestService.class);
RpcCallback mockFooRpcCallback = Mockito.mock(RpcCallback.class);
RpcCallback mockBarRpcCallback = Mockito.mock(RpcCallback.class);
InOrder order = Mockito.inOrder(mockService);
mockService.foo(
EasyMock.same(mockController),
EasyMock.same(fooRequest),
this.<FooResponse>wrapsCallback(fooCallback));
mockService.bar(
EasyMock.same(mockController),
EasyMock.same(barRequest),
this.<BarResponse>wrapsCallback(barCallback));
control.replay();
mockService.callMethod(
fooDescriptor, mockController,
fooRequest, fooCallback);
mockService.callMethod(
barDescriptor, mockController,
barRequest, barCallback);
control.verify();
mockService.callMethod(fooDescriptor, MOCK_RPC_CONTROLLER, FOO_REQUEST, mockFooRpcCallback);
mockService.callMethod(barDescriptor, MOCK_RPC_CONTROLLER, BAR_REQUEST, mockBarRpcCallback);
order
.verify(mockService)
.foo(
Mockito.same(MOCK_RPC_CONTROLLER),
Mockito.same(FOO_REQUEST),
Mockito.same(mockFooRpcCallback));
order
.verify(mockService)
.bar(
Mockito.same(MOCK_RPC_CONTROLLER),
Mockito.same(BAR_REQUEST),
Mockito.same(mockBarRpcCallback));
}
/** Tests Service.get{Request,Response}Prototype(). */
@Test
public void testGetPrototype() throws Exception {
TestService mockService = EasyMock.createMock(TestService.class);
Descriptors.MethodDescriptor fooDescriptor = TestService.getDescriptor().getMethods().get(0);
Descriptors.MethodDescriptor barDescriptor = TestService.getDescriptor().getMethods().get(1);
TestService mockService = Mockito.mock(TestService.class);
assertThat(mockService.getRequestPrototype(fooDescriptor))
.isSameInstanceAs(FooRequest.getDefaultInstance());
assertThat(mockService.getResponsePrototype(fooDescriptor))
.isSameInstanceAs(FooResponse.getDefaultInstance());
assertThat(mockService.getRequestPrototype(barDescriptor))
.isSameInstanceAs(BarRequest.getDefaultInstance());
assertThat(mockService.getResponsePrototype(barDescriptor))
.isSameInstanceAs(BarResponse.getDefaultInstance());
assertThat(mockService.getRequestPrototype(fooDescriptor)).isSameInstanceAs(FOO_REQUEST);
assertThat(mockService.getResponsePrototype(fooDescriptor)).isSameInstanceAs(FOO_RESPONSE);
assertThat(mockService.getRequestPrototype(barDescriptor)).isSameInstanceAs(BAR_REQUEST);
assertThat(mockService.getResponsePrototype(barDescriptor)).isSameInstanceAs(BAR_RESPONSE);
}
/** Tests generated stubs. */
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void testStub() throws Exception {
FooRequest fooRequest = FooRequest.newBuilder().build();
BarRequest barRequest = BarRequest.newBuilder().build();
MockCallback<FooResponse> fooCallback = new MockCallback<FooResponse>();
MockCallback<BarResponse> barCallback = new MockCallback<BarResponse>();
RpcChannel mockChannel = control.createMock(RpcChannel.class);
TestService stub = TestService.newStub(mockChannel);
RpcCallback mockFooRpcCallback = Mockito.mock(RpcCallback.class);
RpcCallback mockBarRpcCallback = Mockito.mock(RpcCallback.class);
RpcChannel mockRpcChannel = Mockito.mock(RpcChannel.class);
InOrder order = Mockito.inOrder(mockRpcChannel);
TestService stub = TestService.newStub(mockRpcChannel);
mockChannel.callMethod(
EasyMock.same(fooDescriptor),
EasyMock.same(mockController),
EasyMock.same(fooRequest),
EasyMock.same(FooResponse.getDefaultInstance()),
this.<Message>wrapsCallback(fooCallback));
mockChannel.callMethod(
EasyMock.same(barDescriptor),
EasyMock.same(mockController),
EasyMock.same(barRequest),
EasyMock.same(BarResponse.getDefaultInstance()),
this.<Message>wrapsCallback(barCallback));
control.replay();
stub.foo(MOCK_RPC_CONTROLLER, FOO_REQUEST, mockFooRpcCallback);
stub.bar(MOCK_RPC_CONTROLLER, BAR_REQUEST, mockBarRpcCallback);
stub.foo(mockController, fooRequest, fooCallback);
stub.bar(mockController, barRequest, barCallback);
control.verify();
order
.verify(mockRpcChannel)
.callMethod(
Mockito.same(fooDescriptor),
Mockito.same(MOCK_RPC_CONTROLLER),
Mockito.same(FOO_REQUEST),
Mockito.same(FOO_RESPONSE),
Mockito.any(RpcCallback.class));
order
.verify(mockRpcChannel)
.callMethod(
Mockito.same(barDescriptor),
Mockito.same(MOCK_RPC_CONTROLLER),
Mockito.same(BAR_REQUEST),
Mockito.same(BAR_RESPONSE),
Mockito.any(RpcCallback.class));
}
/** Tests generated blocking stubs. */
@Test
public void testBlockingStub() throws Exception {
FooRequest fooRequest = FooRequest.newBuilder().build();
BarRequest barRequest = BarRequest.newBuilder().build();
BlockingRpcChannel mockChannel = control.createMock(BlockingRpcChannel.class);
TestService.BlockingInterface stub = TestService.newBlockingStub(mockChannel);
BlockingRpcChannel mockBlockingRpcChannel = Mockito.mock(BlockingRpcChannel.class);
TestService.BlockingInterface stub = TestService.newBlockingStub(mockBlockingRpcChannel);
FooResponse fooResponse = FooResponse.newBuilder().build();
BarResponse barResponse = BarResponse.newBuilder().build();
when(mockBlockingRpcChannel.callBlockingMethod(
Mockito.same(fooDescriptor),
Mockito.same(MOCK_RPC_CONTROLLER),
Mockito.same(FOO_REQUEST),
Mockito.same(FOO_RESPONSE)))
.thenReturn(FOO_RESPONSE);
when(mockBlockingRpcChannel.callBlockingMethod(
Mockito.same(barDescriptor),
Mockito.same(MOCK_RPC_CONTROLLER),
Mockito.same(BAR_REQUEST),
Mockito.same(BAR_RESPONSE)))
.thenReturn(BAR_RESPONSE);
EasyMock.expect(
mockChannel.callBlockingMethod(
EasyMock.same(fooDescriptor),
EasyMock.same(mockController),
EasyMock.same(fooRequest),
EasyMock.same(FooResponse.getDefaultInstance())))
.andReturn(fooResponse);
EasyMock.expect(
mockChannel.callBlockingMethod(
EasyMock.same(barDescriptor),
EasyMock.same(mockController),
EasyMock.same(barRequest),
EasyMock.same(BarResponse.getDefaultInstance())))
.andReturn(barResponse);
control.replay();
assertThat(fooResponse).isSameInstanceAs(stub.foo(mockController, fooRequest));
assertThat(barResponse).isSameInstanceAs(stub.bar(mockController, barRequest));
control.verify();
assertThat(FOO_RESPONSE).isSameInstanceAs(stub.foo(MOCK_RPC_CONTROLLER, FOO_REQUEST));
assertThat(BAR_RESPONSE).isSameInstanceAs(stub.bar(MOCK_RPC_CONTROLLER, BAR_REQUEST));
}
@Test
public void testNewReflectiveService() {
ServiceWithNoOuter.Interface impl = control.createMock(ServiceWithNoOuter.Interface.class);
RpcController controller = control.createMock(RpcController.class);
ServiceWithNoOuter.Interface impl = Mockito.mock(ServiceWithNoOuter.Interface.class);
Service service = ServiceWithNoOuter.newReflectiveService(impl);
MethodDescriptor fooMethod = ServiceWithNoOuter.getDescriptor().findMethodByName("Foo");
MessageWithNoOuter request = MessageWithNoOuter.getDefaultInstance();
RpcCallback<Message> callback =
new RpcCallback<Message>() {
@Override
@ -195,36 +176,30 @@ public class ServiceTest {
};
RpcCallback<TestAllTypes> specializedCallback = RpcUtil.specializeCallback(callback);
impl.foo(EasyMock.same(controller), EasyMock.same(request), EasyMock.same(specializedCallback));
EasyMock.expectLastCall();
control.replay();
service.callMethod(fooMethod, controller, request, callback);
control.verify();
service.callMethod(fooMethod, MOCK_RPC_CONTROLLER, MESSAGE_WITH_NO_OUTER, callback);
verify(impl)
.foo(
Mockito.same(MOCK_RPC_CONTROLLER),
Mockito.same(MESSAGE_WITH_NO_OUTER),
Mockito.same(specializedCallback));
}
@Test
public void testNewReflectiveBlockingService() throws ServiceException {
ServiceWithNoOuter.BlockingInterface impl =
control.createMock(ServiceWithNoOuter.BlockingInterface.class);
RpcController controller = control.createMock(RpcController.class);
Mockito.mock(ServiceWithNoOuter.BlockingInterface.class);
BlockingService service = ServiceWithNoOuter.newReflectiveBlockingService(impl);
MethodDescriptor fooMethod = ServiceWithNoOuter.getDescriptor().findMethodByName("Foo");
MessageWithNoOuter request = MessageWithNoOuter.getDefaultInstance();
TestAllTypes expectedResponse = TestAllTypes.getDefaultInstance();
EasyMock.expect(impl.foo(EasyMock.same(controller), EasyMock.same(request)))
.andReturn(expectedResponse);
control.replay();
Message response = service.callBlockingMethod(fooMethod, controller, request);
when(impl.foo(Mockito.same(MOCK_RPC_CONTROLLER), Mockito.same(MESSAGE_WITH_NO_OUTER)))
.thenReturn(expectedResponse);
Message response =
service.callBlockingMethod(fooMethod, MOCK_RPC_CONTROLLER, MESSAGE_WITH_NO_OUTER);
assertThat(response).isEqualTo(expectedResponse);
control.verify();
}
@Test
@ -243,7 +218,7 @@ public class ServiceTest {
"protobuf_unittest.no_generic_services_test.UnittestNoGenericServices";
Class<?> outerClass = Class.forName(outerName);
Set<String> innerClassNames = new HashSet<String>();
Set<String> innerClassNames = new HashSet<>();
for (Class<?> innerClass : outerClass.getClasses()) {
String fullName = innerClass.getName();
// Figure out the unqualified name of the inner class.
@ -279,57 +254,4 @@ public class ServiceTest {
// =================================================================
/**
* wrapsCallback() is an EasyMock argument predicate. wrapsCallback(c) matches a callback if
* calling that callback causes c to be called. In other words, c wraps the given callback.
*/
private <T extends Message> RpcCallback<T> wrapsCallback(MockCallback<?> callback) {
EasyMock.reportMatcher(new WrapsCallback(callback));
return null;
}
/** The parameter to wrapsCallback() must be a MockCallback. */
private static class MockCallback<T extends Message> implements RpcCallback<T> {
private boolean called = false;
public boolean isCalled() {
return called;
}
public void reset() {
called = false;
}
@Override
public void run(T message) {
called = true;
}
}
/** Implementation of the wrapsCallback() argument matcher. */
private static class WrapsCallback implements IArgumentMatcher {
private MockCallback<?> callback;
public WrapsCallback(MockCallback<?> callback) {
this.callback = callback;
}
@Override
public boolean matches(Object actual) {
if (!(actual instanceof RpcCallback)) {
return false;
}
RpcCallback<?> actualCallback = (RpcCallback<?>) actual;
callback.reset();
actualCallback.run(null);
return callback.isCalled();
}
@Override
public void appendTo(StringBuffer buffer) {
buffer.append("wrapsCallback(mockCallback)");
}
}
}

View File

@ -1831,4 +1831,5 @@ public class TextFormatTest {
assertThat(TextFormat.printer().printToString(message))
.isEqualTo("optional_float: -0.0\noptional_double: -0.0\n");
}
}

View File

@ -44,6 +44,7 @@ import proto3_unittest.UnittestProto3.TestAllTypes
import proto3_unittest.UnittestProto3.TestAllTypes.NestedEnum
import proto3_unittest.UnittestProto3.TestEmptyMessage
import proto3_unittest.copy
import proto3_unittest.optionalForeignMessageOrNull
import proto3_unittest.optionalNestedMessageOrNull
import proto3_unittest.testAllTypes
import proto3_unittest.testEmptyMessage
@ -347,5 +348,8 @@ class Proto3Test {
}
assertThat(someNestedMessage.optionalNestedMessageOrNull)
.isEqualTo(TestAllTypesKt.nestedMessage { bb = 118 })
// No optional keyword, OrNull should still be generated
assertThat(someNestedMessage.optionalForeignMessageOrNull).isEqualTo(null)
}
}

View File

@ -784,7 +784,6 @@ PyMessageFactory* GetFactoryForMessage(CMessage* message) {
static int MaybeReleaseOverlappingOneofField(
CMessage* cmessage,
const FieldDescriptor* field) {
#ifdef GOOGLE_PROTOBUF_HAS_ONEOF
Message* message = cmessage->message;
const Reflection* reflection = message->GetReflection();
if (!field->containing_oneof() ||
@ -804,7 +803,6 @@ static int MaybeReleaseOverlappingOneofField(
if (InternalReleaseFieldByDescriptor(cmessage, existing_field) < 0) {
return -1;
}
#endif
return 0;
}

View File

@ -172,6 +172,7 @@ nobase_include_HEADERS = \
google/protobuf/util/delimited_message_util.h \
google/protobuf/util/field_comparator.h \
google/protobuf/util/field_mask_util.h \
google/protobuf/util/internal/json_escaping.h \
google/protobuf/util/json_util.h \
google/protobuf/util/message_differencer.h \
google/protobuf/util/time_util.h \
@ -284,7 +285,6 @@ libprotobuf_la_SOURCES = \
google/protobuf/util/internal/field_mask_utility.cc \
google/protobuf/util/internal/field_mask_utility.h \
google/protobuf/util/internal/json_escaping.cc \
google/protobuf/util/internal/json_escaping.h \
google/protobuf/util/internal/json_objectwriter.cc \
google/protobuf/util/internal/json_objectwriter.h \
google/protobuf/util/internal/json_stream_parser.cc \
@ -803,12 +803,6 @@ protobuf_test_SOURCES = \
google/protobuf/util/delimited_message_util_test.cc \
google/protobuf/util/field_comparator_test.cc \
google/protobuf/util/field_mask_util_test.cc \
google/protobuf/util/internal/default_value_objectwriter_test.cc \
google/protobuf/util/internal/json_objectwriter_test.cc \
google/protobuf/util/internal/json_stream_parser_test.cc \
google/protobuf/util/internal/protostream_objectsource_test.cc \
google/protobuf/util/internal/protostream_objectwriter_test.cc \
google/protobuf/util/internal/type_info_test_helper.cc \
google/protobuf/util/json_util_test.cc \
google/protobuf/util/message_differencer_unittest.cc \
google/protobuf/util/time_util_test.cc \

View File

@ -25,13 +25,13 @@ namespace _pbi = _pb::internal;
#pragma clang diagnostic ignored "-Wuninitialized"
#endif // __llvm__
PROTOBUF_NAMESPACE_OPEN
constexpr Any::Any(
PROTOBUF_CONSTEXPR Any::Any(
::_pbi::ConstantInitialized)
: type_url_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, _any_metadata_(&type_url_, &value_){}
struct AnyDefaultTypeInternal {
constexpr AnyDefaultTypeInternal()
PROTOBUF_CONSTEXPR AnyDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~AnyDefaultTypeInternal() {}
union {

View File

@ -61,7 +61,7 @@ class PROTOBUF_EXPORT Any final :
public:
inline Any() : Any(nullptr) {}
~Any() override;
explicit constexpr Any(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Any(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Any(const Any& from);
Any(Any&& from) noexcept

View File

@ -21,7 +21,7 @@ namespace _pb = ::PROTOBUF_NAMESPACE_ID;
namespace _pbi = _pb::internal;
PROTOBUF_NAMESPACE_OPEN
constexpr Api::Api(
PROTOBUF_CONSTEXPR Api::Api(
::_pbi::ConstantInitialized)
: methods_()
, options_()
@ -32,7 +32,7 @@ constexpr Api::Api(
, syntax_(0)
{}
struct ApiDefaultTypeInternal {
constexpr ApiDefaultTypeInternal()
PROTOBUF_CONSTEXPR ApiDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~ApiDefaultTypeInternal() {}
union {
@ -40,7 +40,7 @@ struct ApiDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ApiDefaultTypeInternal _Api_default_instance_;
constexpr Method::Method(
PROTOBUF_CONSTEXPR Method::Method(
::_pbi::ConstantInitialized)
: options_()
, name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
@ -51,7 +51,7 @@ constexpr Method::Method(
, syntax_(0)
{}
struct MethodDefaultTypeInternal {
constexpr MethodDefaultTypeInternal()
PROTOBUF_CONSTEXPR MethodDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~MethodDefaultTypeInternal() {}
union {
@ -59,12 +59,12 @@ struct MethodDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodDefaultTypeInternal _Method_default_instance_;
constexpr Mixin::Mixin(
PROTOBUF_CONSTEXPR Mixin::Mixin(
::_pbi::ConstantInitialized)
: name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, root_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}){}
struct MixinDefaultTypeInternal {
constexpr MixinDefaultTypeInternal()
PROTOBUF_CONSTEXPR MixinDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~MixinDefaultTypeInternal() {}
union {

View File

@ -71,7 +71,7 @@ class PROTOBUF_EXPORT Api final :
public:
inline Api() : Api(nullptr) {}
~Api() override;
explicit constexpr Api(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Api(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Api(const Api& from);
Api(Api&& from) noexcept
@ -326,7 +326,7 @@ class PROTOBUF_EXPORT Method final :
public:
inline Method() : Method(nullptr) {}
~Method() override;
explicit constexpr Method(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Method(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Method(const Method& from);
Method(Method&& from) noexcept
@ -559,7 +559,7 @@ class PROTOBUF_EXPORT Mixin final :
public:
inline Mixin() : Mixin(nullptr) {}
~Mixin() override;
explicit constexpr Mixin(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Mixin(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Mixin(const Mixin& from);
Mixin(Mixin&& from) noexcept

View File

@ -175,6 +175,10 @@ template <typename... Lazy>
std::string* ArenaStringPtr::MutableSlow(::google::protobuf::Arena* arena,
const Lazy&... lazy_default) {
GOOGLE_DCHECK(IsDefault());
// For empty defaults, this ends up calling the default constructor which is
// more efficient than a copy construction from
// GetEmptyStringAlreadyInited().
return NewString(arena, lazy_default.get()...);
}

View File

@ -54,6 +54,9 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
(*variables)["type"] = QualifiedClassName(descriptor->enum_type(), options);
(*variables)["default"] = Int32ToString(default_value->number());
(*variables)["full_name"] = descriptor->full_name();
(*variables)["cached_byte_size_name"] = MakeVarintCachedSizeName(descriptor);
(*variables)["cached_byte_size_field"] =
MakeVarintCachedSizeFieldName(descriptor);
}
} // namespace
@ -235,7 +238,7 @@ void RepeatedEnumFieldGenerator::GeneratePrivateMembers(
format("::$proto_ns$::RepeatedField<int> $name$_;\n");
if (descriptor_->is_packed() &&
HasGeneratedMethods(descriptor_->file(), options_)) {
format("mutable std::atomic<int> _$name$_cached_byte_size_;\n");
format("mutable std::atomic<int> $cached_byte_size_name$;\n");
}
}
@ -341,7 +344,7 @@ void RepeatedEnumFieldGenerator::GenerateSerializeWithCachedSizesToArray(
format(
"{\n"
" int byte_size = "
"_$name$_cached_byte_size_.load(std::memory_order_relaxed);\n"
"$cached_byte_size_field$.load(std::memory_order_relaxed);\n"
" if (byte_size > 0) {\n"
" target = stream->WriteEnumPacked(\n"
" $number$, $field$, byte_size, target);\n"
@ -379,7 +382,7 @@ void RepeatedEnumFieldGenerator::GenerateByteSize(io::Printer* printer) const {
"::_pbi::WireFormatLite::Int32Size(static_cast<$int32$>(data_size));\n"
"}\n"
"int cached_size = ::_pbi::ToCachedSize(data_size);\n"
"_$name$_cached_byte_size_.store(cached_size,\n"
"$cached_byte_size_field$.store(cached_size,\n"
" std::memory_order_relaxed);\n"
"total_size += data_size;\n");
} else {
@ -395,7 +398,7 @@ void RepeatedEnumFieldGenerator::GenerateConstinitInitializer(
format("$name$_()");
if (descriptor_->is_packed() &&
HasGeneratedMethods(descriptor_->file(), options_)) {
format("\n, _$name$_cached_byte_size_(0)");
format("\n, $cached_byte_size_name$(0)");
}
}

View File

@ -78,6 +78,7 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
break;
}
SetCommonVars(options, &variables_);
SetCommonMessageDataVariables(&variables_);
variables_["extendee"] =
QualifiedClassName(descriptor_->containing_type(), options_);
variables_["type_traits"] = type_traits_;

View File

@ -154,7 +154,8 @@ void AddAccessorAnnotations(const FieldDescriptor* descriptor,
const google::protobuf::OneofDescriptor* oneof_member =
descriptor->real_containing_oneof();
const std::string proto_ns = (*variables)["proto_ns"];
const std::string substitute_template_prefix = " _tracker_.$1<$0>(this, ";
const std::string substitute_template_prefix =
StrCat(" ", (*variables)["tracker"], ".$1<$0>(this, ");
std::string prepared_template;
// Flat template is needed if the prepared one is introspecting the values
@ -235,6 +236,8 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
std::map<std::string, std::string>* variables,
const Options& options) {
SetCommonVars(options, variables);
SetCommonMessageDataVariables(variables);
(*variables)["ns"] = Namespace(descriptor, options);
(*variables)["name"] = FieldName(descriptor);
(*variables)["index"] = StrCat(descriptor->index());
@ -251,7 +254,8 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
(*variables)["clear_hasbit"] = "";
if (HasHasbit(descriptor)) {
(*variables)["set_hasbit_io"] =
"_Internal::set_has_" + FieldName(descriptor) + "(&_has_bits_);";
StrCat("_Internal::set_has_", FieldName(descriptor), "(&",
(*variables)["has_bits"], ");");
} else {
(*variables)["set_hasbit_io"] = "";
}
@ -272,10 +276,10 @@ void FieldGenerator::SetHasBitIndex(int32_t has_bit_index) {
return;
}
variables_["set_hasbit"] = StrCat(
"_has_bits_[", has_bit_index / 32, "] |= 0x",
variables_["has_bits"], "[", has_bit_index / 32, "] |= 0x",
strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8), "u;");
variables_["clear_hasbit"] = StrCat(
"_has_bits_[", has_bit_index / 32, "] &= ~0x",
variables_["has_bits"], "[", has_bit_index / 32, "] &= ~0x",
strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8), "u;");
}
@ -288,11 +292,13 @@ void FieldGenerator::SetInlinedStringIndex(int32_t inlined_string_index) {
GOOGLE_CHECK_GT(inlined_string_index, 0)
<< "_inlined_string_donated_'s bit 0 is reserved for arena dtor tracking";
variables_["inlined_string_donated"] = StrCat(
"(_inlined_string_donated_[", inlined_string_index / 32, "] & 0x",
"(", variables_["inlined_string_donated_array"], "[",
inlined_string_index / 32, "] & 0x",
strings::Hex(1u << (inlined_string_index % 32), strings::ZERO_PAD_8),
"u) != 0;");
variables_["donating_states_word"] =
StrCat("_inlined_string_donated_[", inlined_string_index / 32, "]");
StrCat(variables_["inlined_string_donated_array"], "[",
inlined_string_index / 32, "]");
variables_["mask_for_undonate"] = StrCat(
"~0x", strings::Hex(1u << (inlined_string_index % 32), strings::ZERO_PAD_8),
"u");

View File

@ -486,7 +486,7 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx,
// destructor that we need to elide.
format(
"struct $1$ {\n"
" constexpr $1$()\n"
" PROTOBUF_CONSTEXPR $1$()\n"
" : _instance(::_pbi::ConstantInitialized{}) {}\n"
" ~$1$() {}\n"
" union {\n"

View File

@ -229,6 +229,18 @@ void SetCommonVars(const Options& options,
(*variables)["string"] = "std::string";
}
void SetCommonMessageDataVariables(
std::map<std::string, std::string>* variables) {
(*variables)["any_metadata"] = "_any_metadata_";
(*variables)["cached_size"] = "_cached_size_";
(*variables)["extensions"] = "_extensions_";
(*variables)["has_bits"] = "_has_bits_";
(*variables)["inlined_string_donated_array"] = "_inlined_string_donated_";
(*variables)["oneof_case"] = "_oneof_case_";
(*variables)["tracker"] = "_tracker_";
(*variables)["weak_field_map"] = "_weak_field_map_";
}
void SetUnknownFieldsVariable(const Descriptor* descriptor,
const Options& options,
std::map<std::string, std::string>* variables) {

View File

@ -87,6 +87,10 @@ extern const char kThinSeparator[];
void SetCommonVars(const Options& options,
std::map<std::string, std::string>* variables);
// Variables to access message data from the message scope.
void SetCommonMessageDataVariables(
std::map<std::string, std::string>* variables);
void SetUnknownFieldsVariable(const Descriptor* descriptor,
const Options& options,
std::map<std::string, std::string>* variables);
@ -362,8 +366,7 @@ inline bool IsExplicitLazy(const FieldDescriptor* field) {
inline bool IsLazilyVerifiedLazy(const FieldDescriptor* field,
const Options& options) {
// TODO(b/211906113): Make lazy() imply eagerly verified lazy.
return IsExplicitLazy(field) &&
!field->is_repeated() &&
return IsExplicitLazy(field) && !field->is_repeated() &&
field->type() == FieldDescriptor::TYPE_MESSAGE &&
GetOptimizeFor(field->file(), options) != FileOptions::LITE_RUNTIME &&
!options.opensource_runtime;
@ -491,15 +494,34 @@ inline std::string MakeDefaultName(const FieldDescriptor* field) {
// variable name.
// For example, declarations of default variables should always use just
// MakeDefaultName to produce code like:
// Type _i_give_permission_to_break_this_code_default_field_;
// Type _i_give_permission_to_break_this_code_default_field_;
//
// Code that references these should use MakeDefaultFieldName, in case the field
// exists at some nested level like:
// internal_container_._i_give_permission_to_break_this_code_default_field_;
// internal_container_._i_give_permission_to_break_this_code_default_field_;
inline std::string MakeDefaultFieldName(const FieldDescriptor* field) {
return MakeDefaultName(field);
}
inline std::string MakeVarintCachedSizeName(const FieldDescriptor* field) {
return StrCat("_", FieldName(field), "_cached_byte_size_");
}
// Semantically distinct from MakeVarintCachedSizeName in that it gives the C++
// code referencing the object from the message scope, rather than just the
// variable name.
// For example, declarations of default variables should always use just
// MakeVarintCachedSizeName to produce code like:
// Type _field_cached_byte_size_;
//
// Code that references these variables should use
// MakeVarintCachedSizeFieldName, in case the field exists at some nested level
// like:
// internal_container_._field_cached_byte_size_;
inline std::string MakeVarintCachedSizeFieldName(const FieldDescriptor* field) {
return StrCat("_", FieldName(field), "_cached_byte_size_");
}
bool IsAnyMessage(const FileDescriptor* descriptor, const Options& options);
bool IsAnyMessage(const Descriptor* descriptor, const Options& options);

View File

@ -108,7 +108,7 @@ void PrintPresenceCheck(const Formatter& format, const FieldDescriptor* field,
int has_bit_index = has_bit_indices[field->index()];
if (*cached_has_word_index != (has_bit_index / 32)) {
*cached_has_word_index = (has_bit_index / 32);
format("cached_has_bits = _has_bits_[$1$];\n", *cached_has_word_index);
format("cached_has_bits = $has_bits$[$1$];\n", *cached_has_word_index);
}
const std::string mask =
StrCat(strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8));
@ -411,6 +411,7 @@ class ColdChunkSkipper {
access_info_map_(options.access_info_map),
cold_threshold_(cold_threshold) {
SetCommonVars(options, &variables_);
SetCommonMessageDataVariables(&variables_);
}
// May open an external if check for a batch of cold fields. "from" is the
@ -551,6 +552,8 @@ void GenerateExtensionAnnotations(
google::protobuf::FileOptions::LITE_RUNTIME) {
return;
}
StringPiece tracker = (*variables)["tracker"];
StringPiece extensions = (*variables)["extensions"];
for (const auto& annotation : accessor_annotations_to_hooks) {
const std::string& annotation_name = annotation.first;
const std::string& listener_call = annotation.second;
@ -560,29 +563,29 @@ void GenerateExtensionAnnotations(
// Primitive fields accessors.
// "Has" is here as users calling "has" on a repeated field is a mistake.
(*variables)[annotation_name] = StrCat(
" _tracker_.", listener_call,
"(this, id.number(), _proto_TypeTraits::GetPtr(id.number(), "
"_extensions_, id.default_value_ref()));");
" ", tracker, ".", listener_call,
"(this, id.number(), _proto_TypeTraits::GetPtr(id.number(), ",
extensions, ", id.default_value_ref()));");
} else if (StrContains(annotation_name, "repeated") &&
!StrContains(annotation_name, "list") &&
!StrContains(annotation_name, "size")) {
// Repeated index accessors.
std::string str_index = "index";
if (StrContains(annotation_name, "add")) {
str_index = "_extensions_.ExtensionSize(id.number()) - 1";
str_index = StrCat(extensions, ".ExtensionSize(id.number()) - 1");
}
(*variables)[annotation_name] =
StrCat(" _tracker_.", listener_call,
StrCat(" ", tracker, ".", listener_call,
"(this, id.number(), "
"_proto_TypeTraits::GetPtr(id.number(), _extensions_, ",
str_index, "));");
"_proto_TypeTraits::GetPtr(id.number(), ",
extensions, ", ", str_index, "));");
} else if (StrContains(annotation_name, "list") ||
StrContains(annotation_name, "size")) {
// Repeated full accessors.
(*variables)[annotation_name] = StrCat(
" _tracker_.", listener_call,
"(this, id.number(), _proto_TypeTraits::GetRepeatedPtr(id.number(), "
"_extensions_));");
" ", tracker, ".", listener_call,
"(this, id.number(), _proto_TypeTraits::GetRepeatedPtr(id.number(), ",
extensions, "));");
} else {
// Generic accessors such as "clear".
// TODO(b/190614678): Generalize clear from both repeated and non repeated
@ -614,6 +617,7 @@ MessageGenerator::MessageGenerator(
if (!message_layout_helper_) {
message_layout_helper_.reset(new PaddingOptimizer());
}
SetCommonMessageDataVariables(&variables_);
// Variables that apply to this class
variables_["classname"] = classname_;
@ -629,7 +633,8 @@ MessageGenerator::MessageGenerator(
if (options.field_listener_options.inject_field_listener_events &&
descriptor->file()->options().optimize_for() !=
google::protobuf::FileOptions::LITE_RUNTIME) {
const std::string injector_template = " _tracker_.";
const std::string injector_template =
StrCat(" ", variables_["tracker"], ".");
MaySetAnnotationVariable(options, "serialize", injector_template,
"OnSerialize(this);\n", &variables_);
@ -845,7 +850,7 @@ inline bool HasExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) const {
$annotate_extension_has$
return _extensions_.Has(id.number());
return $extensions$.Has(id.number());
}
template <typename _proto_TypeTraits,
@ -854,7 +859,7 @@ template <typename _proto_TypeTraits,
inline void ClearExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
_extensions_.ClearExtension(id.number());
$extensions$.ClearExtension(id.number());
$annotate_extension_clear$
}
@ -865,7 +870,7 @@ inline int ExtensionSize(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) const {
$annotate_extension_repeated_size$
return _extensions_.ExtensionSize(id.number());
return $extensions$.ExtensionSize(id.number());
}
template <typename _proto_TypeTraits,
@ -875,7 +880,7 @@ inline typename _proto_TypeTraits::Singular::ConstType GetExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) const {
$annotate_extension_get$
return _proto_TypeTraits::Get(id.number(), _extensions_,
return _proto_TypeTraits::Get(id.number(), $extensions$,
id.default_value());
}
@ -887,7 +892,7 @@ inline typename _proto_TypeTraits::Singular::MutableType MutableExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
$annotate_extension_mutable$
return _proto_TypeTraits::Mutable(id.number(), _field_type,
&_extensions_);
&$extensions$);
}
template <typename _proto_TypeTraits,
@ -897,7 +902,7 @@ inline void SetExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::ConstType value) {
_proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_);
_proto_TypeTraits::Set(id.number(), _field_type, value, &$extensions$);
$annotate_extension_set$
}
@ -909,7 +914,7 @@ inline void SetAllocatedExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::SetAllocated(id.number(), _field_type, value,
&_extensions_);
&$extensions$);
$annotate_extension_set$
}
template <typename _proto_TypeTraits,
@ -920,7 +925,7 @@ inline void UnsafeArenaSetAllocatedExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type,
value, &_extensions_);
value, &$extensions$);
$annotate_extension_set$
}
template <typename _proto_TypeTraits,
@ -933,7 +938,7 @@ PROTOBUF_NODISCARD inline
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
$annotate_extension_release$
return _proto_TypeTraits::Release(id.number(), _field_type,
&_extensions_);
&$extensions$);
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
@ -944,7 +949,7 @@ UnsafeArenaReleaseExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
$annotate_extension_release$
return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type,
&_extensions_);
&$extensions$);
}
template <typename _proto_TypeTraits,
@ -955,7 +960,7 @@ inline typename _proto_TypeTraits::Repeated::ConstType GetExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
int index) const {
$annotate_repeated_extension_get$
return _proto_TypeTraits::Get(id.number(), _extensions_, index);
return _proto_TypeTraits::Get(id.number(), $extensions$, index);
}
template <typename _proto_TypeTraits,
@ -966,7 +971,7 @@ inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
int index) {
$annotate_repeated_extension_mutable$
return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_);
return _proto_TypeTraits::Mutable(id.number(), index, &$extensions$);
}
template <typename _proto_TypeTraits,
@ -976,7 +981,7 @@ inline void SetExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
int index, typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Set(id.number(), index, value, &_extensions_);
_proto_TypeTraits::Set(id.number(), index, value, &$extensions$);
$annotate_repeated_extension_set$
}
@ -987,7 +992,7 @@ inline typename _proto_TypeTraits::Repeated::MutableType AddExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
typename _proto_TypeTraits::Repeated::MutableType to_add =
_proto_TypeTraits::Add(id.number(), _field_type, &_extensions_);
_proto_TypeTraits::Add(id.number(), _field_type, &$extensions$);
$annotate_repeated_extension_add_mutable$
return to_add;
}
@ -1000,7 +1005,7 @@ inline void AddExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value,
&_extensions_);
&$extensions$);
$annotate_repeated_extension_add$
}
@ -1012,7 +1017,7 @@ GetRepeatedExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) const {
$annotate_repeated_extension_list$
return _proto_TypeTraits::GetRepeated(id.number(), _extensions_);
return _proto_TypeTraits::GetRepeated(id.number(), $extensions$);
}
template <typename _proto_TypeTraits,
@ -1024,7 +1029,7 @@ MutableRepeatedExtension(
$classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
$annotate_repeated_extension_list_mutable$
return _proto_TypeTraits::MutableRepeated(id.number(), _field_type,
_is_packed, &_extensions_);
_is_packed, &$extensions$);
}
)");
@ -1061,7 +1066,7 @@ void MessageGenerator::GenerateSingularFieldHasBits(
format(
"inline bool $classname$::has_$name$() const {\n"
"$annotate_has$"
" return _weak_field_map_.Has($number$);\n"
" return $weak_field_map$.Has($number$);\n"
"}\n");
return;
}
@ -1075,7 +1080,7 @@ void MessageGenerator::GenerateSingularFieldHasBits(
format(
"inline bool $classname$::_internal_has_$name$() const {\n"
" bool value = "
"(_has_bits_[$has_array_index$] & 0x$has_mask$u) != 0;\n");
"($has_bits$[$has_array_index$] & 0x$has_mask$u) != 0;\n");
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
!IsLazy(field, options_, scc_analyzer_)) {
@ -1125,7 +1130,7 @@ void MessageGenerator::GenerateOneofHasBits(io::Printer* printer) {
" return $oneof_name$_case() != $cap_oneof_name$_NOT_SET;\n"
"}\n"
"inline void $classname$::clear_has_$oneof_name$() {\n"
" _oneof_case_[$oneof_index$] = $cap_oneof_name$_NOT_SET;\n"
" $oneof_case$[$oneof_index$] = $cap_oneof_name$_NOT_SET;\n"
"}\n");
}
}
@ -1171,7 +1176,7 @@ void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field,
// annotated.
format(
"inline void $classname$::set_has_$name$() {\n"
" _oneof_case_[$oneof_index$] = k$field_name$;\n"
" $oneof_case$[$oneof_index$] = k$field_name$;\n"
"}\n");
}
@ -1206,7 +1211,7 @@ void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field,
format.Set("has_array_index", has_bit_index / 32);
format.Set("has_mask",
strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8));
format("_has_bits_[$has_array_index$] &= ~0x$has_mask$u;\n");
format("$has_bits$[$has_array_index$] &= ~0x$has_mask$u;\n");
}
}
format("$annotate_clear$");
@ -1303,7 +1308,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" ::$proto_ns$::internal::WireFormatLite::$val_wire_type$> "
"SuperType;\n"
" $classname$();\n"
" explicit constexpr $classname$(\n"
" explicit PROTOBUF_CONSTEXPR $classname$(\n"
" ::$proto_ns$::internal::ConstantInitialized);\n"
" explicit $classname$(::$proto_ns$::Arena* arena);\n"
" void MergeFrom(const $classname$& other);\n"
@ -1400,7 +1405,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
format("~$classname$() override;\n");
}
format(
"explicit constexpr "
"explicit PROTOBUF_CONSTEXPR "
"$classname$(::$proto_ns$::internal::ConstantInitialized);\n"
"\n"
"$classname$(const $classname$& from);\n"
@ -1505,16 +1510,16 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
if (HasDescriptorMethods(descriptor_->file(), options_)) {
format(
"bool PackFrom(const ::$proto_ns$::Message& message) {\n"
" return _any_metadata_.PackFrom(GetArena(), message);\n"
" return $any_metadata$.PackFrom(GetArena(), message);\n"
"}\n"
"bool PackFrom(const ::$proto_ns$::Message& message,\n"
" ::PROTOBUF_NAMESPACE_ID::ConstStringParam "
"type_url_prefix) {\n"
" return _any_metadata_.PackFrom(GetArena(), message, "
" return $any_metadata$.PackFrom(GetArena(), message, "
"type_url_prefix);\n"
"}\n"
"bool UnpackTo(::$proto_ns$::Message* message) const {\n"
" return _any_metadata_.UnpackTo(message);\n"
" return $any_metadata$.UnpackTo(message);\n"
"}\n"
"static bool GetAnyFieldDescriptors(\n"
" const ::$proto_ns$::Message& message,\n"
@ -1524,7 +1529,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"!std::is_convertible<T, const ::$proto_ns$::Message&>"
"::value>::type>\n"
"bool PackFrom(const T& message) {\n"
" return _any_metadata_.PackFrom<T>(GetArena(), message);\n"
" return $any_metadata$.PackFrom<T>(GetArena(), message);\n"
"}\n"
"template <typename T, class = typename std::enable_if<"
"!std::is_convertible<T, const ::$proto_ns$::Message&>"
@ -1532,36 +1537,36 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"bool PackFrom(const T& message,\n"
" ::PROTOBUF_NAMESPACE_ID::ConstStringParam "
"type_url_prefix) {\n"
" return _any_metadata_.PackFrom<T>(GetArena(), message, "
" return $any_metadata$.PackFrom<T>(GetArena(), message, "
"type_url_prefix);"
"}\n"
"template <typename T, class = typename std::enable_if<"
"!std::is_convertible<T, const ::$proto_ns$::Message&>"
"::value>::type>\n"
"bool UnpackTo(T* message) const {\n"
" return _any_metadata_.UnpackTo<T>(message);\n"
" return $any_metadata$.UnpackTo<T>(message);\n"
"}\n");
} else {
format(
"template <typename T>\n"
"bool PackFrom(const T& message) {\n"
" return _any_metadata_.PackFrom(GetArena(), message);\n"
" return $any_metadata$.PackFrom(GetArena(), message);\n"
"}\n"
"template <typename T>\n"
"bool PackFrom(const T& message,\n"
" ::PROTOBUF_NAMESPACE_ID::ConstStringParam "
"type_url_prefix) {\n"
" return _any_metadata_.PackFrom(GetArena(), message, "
" return $any_metadata$.PackFrom(GetArena(), message, "
"type_url_prefix);\n"
"}\n"
"template <typename T>\n"
"bool UnpackTo(T* message) const {\n"
" return _any_metadata_.UnpackTo(message);\n"
" return $any_metadata$.UnpackTo(message);\n"
"}\n");
}
format(
"template<typename T> bool Is() const {\n"
" return _any_metadata_.Is<T>();\n"
" return $any_metadata$.Is<T>();\n"
"}\n"
"static bool ParseAnyTypeUrl(::PROTOBUF_NAMESPACE_ID::ConstStringParam "
"type_url,\n"
@ -1668,7 +1673,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
if (!HasSimpleBaseClass(descriptor_, options_)) {
format(
"int GetCachedSize() const final { return _cached_size_.Get(); }"
"int GetCachedSize() const final { return "
"$cached_size$.Get(); }"
"\n\nprivate:\n"
"void SharedCtor();\n"
"void SharedDtor();\n"
@ -1701,11 +1707,13 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"static void ArenaDtor(void* object);\n"
"inline void OnDemandRegisterArenaDtor(::$proto_ns$::Arena* arena) "
"override {\n"
" if (arena == nullptr || (_inlined_string_donated_[0] & 0x1u) == "
" if (arena == nullptr || ($inlined_string_donated_array$[0] & "
"0x1u) "
"== "
"0) {\n"
" return;\n"
" }\n"
" _inlined_string_donated_[0] &= 0xFFFFFFFEu;\n"
" $inlined_string_donated_array$[0] &= 0xFFFFFFFEu;\n"
" arena->OwnCustomDestructor(this, &$classname$::ArenaDtor);\n"
"}\n");
break;
@ -1956,7 +1964,7 @@ void MessageGenerator::GenerateInlineMethods(io::Printer* printer) {
"inline $classname$::$camel_oneof_name$Case $classname$::"
"${1$$oneof_name$_case$}$() const {\n"
" return $classname$::$camel_oneof_name$Case("
"_oneof_case_[$oneof_index$]);\n"
"$oneof_case$[$oneof_index$]);\n"
"}\n",
oneof);
}
@ -2040,7 +2048,8 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
format.Indent();
if (!has_bit_indices_.empty()) {
format(
"using HasBits = decltype(std::declval<$classname$>()._has_bits_);\n");
"using HasBits = "
"decltype(std::declval<$classname$>().$has_bits$);\n");
}
for (auto field : FieldRange(descriptor_)) {
field_generators_.get(field).GenerateInternalAccessorDeclarations(printer);
@ -2168,7 +2177,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
google::protobuf::FileOptions::LITE_RUNTIME) {
format(
"::$proto_ns$::AccessListener<$classtype$> "
"$1$::_tracker_(&FullMessageName);\n",
"$1$::$tracker$(&FullMessageName);\n",
ClassName(descriptor_));
}
}
@ -2178,28 +2187,30 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
Formatter format(printer, variables_);
if (!has_bit_indices_.empty() || IsMapEntryMessage(descriptor_)) {
format("PROTOBUF_FIELD_OFFSET($classtype$, _has_bits_),\n");
format("PROTOBUF_FIELD_OFFSET($classtype$, $has_bits$),\n");
} else {
format("~0u, // no _has_bits_\n");
}
format("PROTOBUF_FIELD_OFFSET($classtype$, _internal_metadata_),\n");
if (descriptor_->extension_range_count() > 0) {
format("PROTOBUF_FIELD_OFFSET($classtype$, _extensions_),\n");
format("PROTOBUF_FIELD_OFFSET($classtype$, $extensions$),\n");
} else {
format("~0u, // no _extensions_\n");
}
if (descriptor_->real_oneof_decl_count() > 0) {
format("PROTOBUF_FIELD_OFFSET($classtype$, _oneof_case_[0]),\n");
format("PROTOBUF_FIELD_OFFSET($classtype$, $oneof_case$[0]),\n");
} else {
format("~0u, // no _oneof_case_\n");
}
if (num_weak_fields_ > 0) {
format("PROTOBUF_FIELD_OFFSET($classtype$, _weak_field_map_),\n");
format("PROTOBUF_FIELD_OFFSET($classtype$, $weak_field_map$),\n");
} else {
format("~0u, // no _weak_field_map_\n");
}
if (!inlined_string_indices_.empty()) {
format("PROTOBUF_FIELD_OFFSET($classtype$, _inlined_string_donated_),\n");
format(
"PROTOBUF_FIELD_OFFSET($classtype$, "
"$inlined_string_donated_array$),\n");
} else {
format("~0u, // no _inlined_string_donated_\n");
}
@ -2310,7 +2321,7 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) {
}
if (num_weak_fields_) {
format("_weak_field_map_.ClearAll();\n");
format("$weak_field_map$.ClearAll();\n");
}
format.Outdent();
format(
@ -2368,7 +2379,7 @@ void MessageGenerator::GenerateConstexprConstructor(io::Printer* printer) {
Formatter format(printer, variables_);
format(
"constexpr $classname$::$classname$(\n"
"PROTOBUF_CONSTEXPR $classname$::$classname$(\n"
" ::_pbi::ConstantInitialized)");
format.Indent();
const char* field_sep = ":";
@ -2519,16 +2530,16 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
if (NeedsArenaDestructor() == ArenaDtorNeeds::kOnDemand) {
format(
" if (!is_message_owned) {\n"
" _inlined_string_donated_[0] = ~0u;\n"
" $inlined_string_donated_array$[0] = ~0u;\n"
" } else {\n"
// We should not register ArenaDtor for MOA.
" _inlined_string_donated_[0] = 0xFFFFFFFEu;\n"
" $inlined_string_donated_array$[0] = 0xFFFFFFFEu;\n"
" }\n");
} else {
format(" _inlined_string_donated_[0] = 0xFFFFFFFEu;\n");
format(" $inlined_string_donated_array$[0] = 0xFFFFFFFEu;\n");
}
for (size_t i = 1; i < InlinedStringDonatedSize(); ++i) {
format(" _inlined_string_donated_[$1$] = ~0u;\n", i);
format(" $inlined_string_donated_array$[$1$] = ~0u;\n", i);
}
format("}\n");
format.Outdent();
@ -2606,8 +2617,8 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
if (descriptor_->extension_range_count() > 0) {
format(
"_extensions_.MergeFrom(internal_default_instance(), "
"from._extensions_);\n");
"$extensions$.MergeFrom(internal_default_instance(), "
"from.$extensions$);\n");
}
GenerateConstructorBody(printer, processed, true);
@ -2687,7 +2698,7 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
// Generate SetCachedSize.
format(
"void $classname$::SetCachedSize(int size) const {\n"
" _cached_size_.Set(size);\n"
" $cached_size$.Set(size);\n"
"}\n");
}
}
@ -2723,7 +2734,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
"(void) cached_has_bits;\n\n");
if (descriptor_->extension_range_count() > 0) {
format("_extensions_.Clear();\n");
format("$extensions$.Clear();\n");
}
// Collect fields into chunks. Each chunk may have an if() condition that
@ -2796,7 +2807,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
if (cached_has_word_index != HasWordIndex(chunk.front())) {
cached_has_word_index = HasWordIndex(chunk.front());
format("cached_has_bits = _has_bits_[$1$];\n", cached_has_word_index);
format("cached_has_bits = $has_bits$[$1$];\n", cached_has_word_index);
}
format("if (cached_has_bits & 0x$1$u) {\n", chunk_mask_str);
format.Indent();
@ -2858,14 +2869,14 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
}
if (num_weak_fields_) {
format("_weak_field_map_.ClearAll();\n");
format("$weak_field_map$.ClearAll();\n");
}
// We don't clear donated status.
if (!has_bit_indices_.empty()) {
// Step 5: Everything else.
format("_has_bits_.Clear();\n");
format("$has_bits$.Clear();\n");
}
std::map<std::string, std::string> vars;
@ -2911,7 +2922,7 @@ void MessageGenerator::GenerateOneofClear(io::Printer* printer) {
format.Outdent();
format(
"}\n"
"_oneof_case_[$1$] = $2$_NOT_SET;\n",
"$oneof_case$[$1$] = $2$_NOT_SET;\n",
i, ToUpper(oneof->name()));
format.Outdent();
format(
@ -2931,7 +2942,9 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
if (HasGeneratedMethods(descriptor_->file(), options_)) {
if (descriptor_->extension_range_count() > 0) {
format("_extensions_.InternalSwap(&other->_extensions_);\n");
format(
"$extensions$.InternalSwap(&other->$extensions$);"
"\n");
}
std::map<std::string, std::string> vars;
@ -2946,7 +2959,7 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
if (!has_bit_indices_.empty()) {
for (int i = 0; i < HasBitsSize(); ++i) {
format("swap(_has_bits_[$1$], other->_has_bits_[$1$]);\n", i);
format("swap($has_bits$[$1$], other->$has_bits$[$1$]);\n", i);
}
}
@ -2993,18 +3006,23 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
}
for (int i = 0; i < descriptor_->real_oneof_decl_count(); i++) {
format("swap(_oneof_case_[$1$], other->_oneof_case_[$1$]);\n", i);
format(
"swap($oneof_case$[$1$], "
"other->$oneof_case$[$1$]);\n",
i);
}
if (num_weak_fields_) {
format("_weak_field_map_.UnsafeArenaSwap(&other->_weak_field_map_);\n");
format(
"$weak_field_map$.UnsafeArenaSwap(&other->$weak_field_map$)"
";\n");
}
if (!inlined_string_indices_.empty()) {
for (size_t i = 0; i < InlinedStringDonatedSize(); ++i) {
format(
"swap(_inlined_string_donated_[$1$], "
"other->_inlined_string_donated_[$1$]);\n",
"swap($inlined_string_donated_array$[$1$], "
"other->$inlined_string_donated_array$[$1$]);\n",
i);
}
}
@ -3119,7 +3137,7 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
if (cached_has_word_index != HasWordIndex(chunk.front())) {
cached_has_word_index = HasWordIndex(chunk.front());
format("cached_has_bits = from._has_bits_[$1$];\n",
format("cached_has_bits = from.$has_bits$[$1$];\n",
cached_has_word_index);
}
@ -3180,7 +3198,7 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
if (deferred_has_bit_changes) {
// Flush the has bits for the primitives we deferred.
GOOGLE_CHECK_LE(0, cached_has_word_index);
format("_has_bits_[$1$] |= cached_has_bits;\n", cached_has_word_index);
format("$has_bits$[$1$] |= cached_has_bits;\n", cached_has_word_index);
}
format.Outdent();
@ -3216,15 +3234,17 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
format("}\n");
}
if (num_weak_fields_) {
format("_weak_field_map_.MergeFrom(from._weak_field_map_);\n");
format(
"$weak_field_map$.MergeFrom(from.$weak_field_map$);"
"\n");
}
// Merging of extensions and unknown fields is done last, to maximize
// the opportunity for tail calls.
if (descriptor_->extension_range_count() > 0) {
format(
"_extensions_.MergeFrom(internal_default_instance(), "
"from._extensions_);\n");
"$extensions$.MergeFrom(internal_default_instance(), "
"from.$extensions$);\n");
}
format(
@ -3360,7 +3380,7 @@ void MessageGenerator::GenerateSerializeOneExtensionRange(
Formatter format(printer, vars);
format("// Extension range [$start$, $end$)\n");
format(
"target = _extensions_._InternalSerialize(\n"
"target = $extensions$._InternalSerialize(\n"
"internal_default_instance(), $start$, $end$, target, stream);\n\n");
}
@ -3375,7 +3395,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesToArray(
" $uint8$* target, ::$proto_ns$::io::EpsCopyOutputStream* stream) "
"const {\n"
"$annotate_serialize$"
" target = _extensions_."
" target = $extensions$."
"InternalSerializeMessageSetWithCachedSizesToArray(\n" //
"internal_default_instance(), target, stream);\n");
std::map<std::string, std::string> vars;
@ -3578,7 +3598,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
if (num_weak_fields_) {
format(
"::_pbi::WeakFieldMap::FieldWriter field_writer("
"_weak_field_map_);\n");
"$weak_field_map$);\n");
}
format(
@ -3668,7 +3688,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled(
if (num_weak_fields_) {
format(
"::_pbi::WeakFieldMap::FieldWriter field_writer("
"_weak_field_map_);\n");
"$weak_field_map$);\n");
}
format("for (int i = $1$; i >= 0; i-- ) {\n", num_fields - 1);
@ -3759,7 +3779,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
"size_t $classname$::ByteSizeLong() const {\n"
"$annotate_bytesize$"
"// @@protoc_insertion_point(message_set_byte_size_start:$full_name$)\n"
" size_t total_size = _extensions_.MessageSetByteSize();\n"
" size_t total_size = $extensions$.MessageSetByteSize();\n"
" if ($have_unknown_fields$) {\n"
" total_size += ::_pbi::\n"
" ComputeUnknownMessageSetItemsSize($unknown_fields$);\n"
@ -3812,7 +3832,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
if (descriptor_->extension_range_count() > 0) {
format(
"total_size += _extensions_.ByteSize();\n"
"total_size += $extensions$.ByteSize();\n"
"\n");
}
@ -3893,7 +3913,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
if (cached_has_word_index != HasWordIndex(chunk.front())) {
cached_has_word_index = HasWordIndex(chunk.front());
format("cached_has_bits = _has_bits_[$1$];\n", cached_has_word_index);
format("cached_has_bits = $has_bits$[$1$];\n", cached_has_word_index);
}
format("if (cached_has_bits & 0x$1$u) {\n", chunk_mask_str);
format.Indent();
@ -3973,7 +3993,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
if (num_weak_fields_) {
// TagSize + MessageSize
format("total_size += _weak_field_map_.ByteSizeLong();\n");
format("total_size += $weak_field_map$.ByteSizeLong();\n");
}
if (UseUnknownFieldSet(descriptor_->file(), options_)) {
@ -3981,7 +4001,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
// unknown fields in tail position. This allows for better code generation
// of this function for simple protos.
format(
"return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);\n");
"return MaybeComputeUnknownFieldsSize(total_size, &$cached_size$);\n");
} else {
format("if (PROTOBUF_PREDICT_FALSE($have_unknown_fields$)) {\n");
format(" total_size += $unknown_fields$.size();\n");
@ -4013,14 +4033,14 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) {
if (descriptor_->extension_range_count() > 0) {
format(
"if (!_extensions_.IsInitialized()) {\n"
"if (!$extensions$.IsInitialized()) {\n"
" return false;\n"
"}\n\n");
}
if (num_required_fields_ > 0) {
format(
"if (_Internal::MissingRequiredFields(_has_bits_))"
"if (_Internal::MissingRequiredFields($has_bits$))"
" return false;\n");
}
@ -4030,7 +4050,7 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) {
}
if (num_weak_fields_) {
// For Weak fields.
format("if (!_weak_field_map_.IsInitialized()) return false;\n");
format("if (!$weak_field_map$.IsInitialized()) return false;\n");
}
// Go through the oneof fields, emitting a switch if any might have required
// fields.

View File

@ -82,6 +82,7 @@ struct Options {
bool unverified_lazy_message_sets = true;
bool eagerly_verified_lazy = true;
bool profile_driven_inline_string = true;
bool force_split = false;
#ifdef PROTOBUF_STABLE_EXPERIMENTS
bool force_eagerly_verified_lazy = true;
bool force_inline_string = true;

View File

@ -450,6 +450,7 @@ ParseFunctionGenerator::ParseFunctionGenerator(
inlined_string_indices, scc_analyzer));
}
SetCommonVars(options_, &variables_);
SetCommonMessageDataVariables(&variables_);
SetUnknownFieldsVariable(descriptor_, options_, &variables_);
variables_["classname"] = ClassName(descriptor, false);
}
@ -491,7 +492,7 @@ void ParseFunctionGenerator::GenerateMethodImpls(io::Printer* printer) {
" ctx->set_lazy_eager_verify_func(&$classname$::InternalVerify);\n");
}
format(
" return _extensions_.ParseMessageSet(ptr, \n"
" return $extensions$.ParseMessageSet(ptr, \n"
" internal_default_instance(), &_internal_metadata_, ctx);\n"
"}\n");
}
@ -785,7 +786,7 @@ void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) {
}
if (descriptor_->extension_range_count() == 1) {
format(
"PROTOBUF_FIELD_OFFSET($classname$, _extensions_),\n"
"PROTOBUF_FIELD_OFFSET($classname$, $extensions$),\n"
"$1$, $2$, // extension_range_{low,high}\n",
descriptor_->extension_range(0)->start,
descriptor_->extension_range(0)->end);
@ -1131,7 +1132,7 @@ void ParseFunctionGenerator::GenerateArenaString(Formatter& format,
GOOGLE_DCHECK(!inlined_string_indices_.empty());
int inlined_string_index = inlined_string_indices_[field->index()];
GOOGLE_DCHECK_GT(inlined_string_index, 0);
format(", &$msg$_inlined_string_donated_[0], $1$, $this$",
format(", &$msg$$inlined_string_donated_array$[0], $1$, $this$",
inlined_string_index);
} else {
GOOGLE_DCHECK(field->default_value_string().empty());
@ -1318,7 +1319,7 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format,
format(
"{\n"
" auto* default_ = &reinterpret_cast<const Message&>($1$);\n"
" ptr = ctx->ParseMessage($msg$_weak_field_map_.MutableMessage("
" ptr = ctx->ParseMessage($msg$$weak_field_map$.MutableMessage("
"$2$, default_), ptr);\n"
"}\n",
QualifiedDefaultInstanceName(field->message_type(), options_),
@ -1533,7 +1534,7 @@ void ParseFunctionGenerator::GenerateParseIterationBody(
}
format(
") {\n"
" ptr = $msg$_extensions_.ParseField(tag, ptr, "
" ptr = $msg$$extensions$.ParseField(tag, ptr, "
"internal_default_instance(), &$msg$_internal_metadata_, ctx);\n"
" CHK_(ptr != nullptr);\n"
" $next_tag$;\n"

View File

@ -104,6 +104,9 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
SetCommonFieldVariables(descriptor, variables, options);
(*variables)["type"] = PrimitiveTypeName(options, descriptor->cpp_type());
(*variables)["default"] = DefaultValue(options, descriptor);
(*variables)["cached_byte_size_name"] = MakeVarintCachedSizeName(descriptor);
(*variables)["cached_byte_size_field"] =
MakeVarintCachedSizeFieldName(descriptor);
(*variables)["tag"] = StrCat(internal::WireFormat::MakeTag(descriptor));
int fixed_size = FixedSize(descriptor->type());
if (fixed_size != -1) {
@ -313,7 +316,7 @@ void RepeatedPrimitiveFieldGenerator::GeneratePrivateMembers(
format("::$proto_ns$::RepeatedField< $type$ > $name$_;\n");
if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 &&
HasGeneratedMethods(descriptor_->file(), options_)) {
format("mutable std::atomic<int> _$name$_cached_byte_size_;\n");
format("mutable std::atomic<int> $cached_byte_size_name$;\n");
}
}
@ -412,7 +415,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
format(
"{\n"
" int byte_size = "
"_$name$_cached_byte_size_.load(std::memory_order_relaxed);\n"
"$cached_byte_size_field$.load(std::memory_order_relaxed);\n"
" if (byte_size > 0) {\n"
" target = stream->Write$declared_type$Packed(\n"
" $number$, _internal_$name$(), byte_size, target);\n"
@ -462,7 +465,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateByteSize(
if (FixedSize(descriptor_->type()) == -1) {
format(
"int cached_size = ::_pbi::ToCachedSize(data_size);\n"
"_$name$_cached_byte_size_.store(cached_size,\n"
"$cached_byte_size_field$.store(cached_size,\n"
" std::memory_order_relaxed);\n");
}
format("total_size += data_size;\n");
@ -483,7 +486,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateConstinitInitializer(
format("$name$_()");
if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 &&
HasGeneratedMethods(descriptor_->file(), options_)) {
format("\n, _$name$_cached_byte_size_(0)");
format("\n, $cached_byte_size_name$(0)");
}
}

View File

@ -418,9 +418,9 @@ void StringFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
format(
"::$proto_ns$::internal::InlinedStringField::InternalSwap(\n"
" &$field$, lhs_arena, "
"(_inlined_string_donated_[0] & 0x1u) == 0, this,\n"
"($inlined_string_donated_array$[0] & 0x1u) == 0, this,\n"
" &other->$field$, rhs_arena, "
"(other->_inlined_string_donated_[0] & 0x1u) == 0, other);\n");
"(other->$inlined_string_donated_array$[0] & 0x1u) == 0, other);\n");
}
}

View File

@ -1505,8 +1505,7 @@ void ImmutableMessageGenerator::GenerateTopLevelKotlinMembers(
void ImmutableMessageGenerator::GenerateKotlinOrNull(io::Printer* printer) const {
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i);
if (field->has_optional_keyword() &&
GetJavaType(field) == JAVATYPE_MESSAGE) {
if (field->has_presence() && GetJavaType(field) == JAVATYPE_MESSAGE) {
printer->Print(
"val $full_classname$OrBuilder.$camelcase_name$OrNull: $full_name$?\n"
" get() = if (has$name$()) get$name$() else null\n\n",

View File

@ -825,8 +825,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinOrNull(io::Printer* printer) c
// Generate getFieldOrNull getters for all optional message fields.
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i);
if (field->has_optional_keyword() &&
GetJavaType(field) == JAVATYPE_MESSAGE) {
if (field->has_presence() && GetJavaType(field) == JAVATYPE_MESSAGE) {
printer->Print(
"val $full_classname$OrBuilder.$camelcase_name$OrNull: "
"$full_name$?\n"

View File

@ -941,7 +941,7 @@ bool Parser::ParseMessageField(FieldDescriptorProto* field,
const FileDescriptorProto* containing_file) {
{
FieldDescriptorProto::Label label;
if (ParseLabel(&label, field_location, containing_file)) {
if (ParseLabel(&label, field_location)) {
field->set_label(label);
if (label == FieldDescriptorProto::LABEL_OPTIONAL &&
syntax_identifier_ == "proto3") {
@ -2245,8 +2245,7 @@ bool Parser::ParseMethodOptions(const LocationRecorder& parent_location,
// -------------------------------------------------------------------
bool Parser::ParseLabel(FieldDescriptorProto::Label* label,
const LocationRecorder& field_location,
const FileDescriptorProto* containing_file) {
const LocationRecorder& field_location) {
if (!LookingAt("optional") && !LookingAt("repeated") &&
!LookingAt("required")) {
return false;

View File

@ -440,8 +440,7 @@ class PROTOBUF_EXPORT Parser {
// Parse "required", "optional", or "repeated" and fill in "label"
// with the value. Returns true if such a label is consumed.
bool ParseLabel(FieldDescriptorProto::Label* label,
const LocationRecorder& field_location,
const FileDescriptorProto* containing_file);
const LocationRecorder& field_location);
// Parse a type name and fill in "type" (if it is a primitive) or
// "type_name" (if it is not) with the type parsed.

View File

@ -22,14 +22,14 @@ namespace _pbi = _pb::internal;
PROTOBUF_NAMESPACE_OPEN
namespace compiler {
constexpr Version::Version(
PROTOBUF_CONSTEXPR Version::Version(
::_pbi::ConstantInitialized)
: suffix_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, major_(0)
, minor_(0)
, patch_(0){}
struct VersionDefaultTypeInternal {
constexpr VersionDefaultTypeInternal()
PROTOBUF_CONSTEXPR VersionDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~VersionDefaultTypeInternal() {}
union {
@ -37,14 +37,14 @@ struct VersionDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 VersionDefaultTypeInternal _Version_default_instance_;
constexpr CodeGeneratorRequest::CodeGeneratorRequest(
PROTOBUF_CONSTEXPR CodeGeneratorRequest::CodeGeneratorRequest(
::_pbi::ConstantInitialized)
: file_to_generate_()
, proto_file_()
, parameter_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, compiler_version_(nullptr){}
struct CodeGeneratorRequestDefaultTypeInternal {
constexpr CodeGeneratorRequestDefaultTypeInternal()
PROTOBUF_CONSTEXPR CodeGeneratorRequestDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~CodeGeneratorRequestDefaultTypeInternal() {}
union {
@ -52,14 +52,14 @@ struct CodeGeneratorRequestDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_;
constexpr CodeGeneratorResponse_File::CodeGeneratorResponse_File(
PROTOBUF_CONSTEXPR CodeGeneratorResponse_File::CodeGeneratorResponse_File(
::_pbi::ConstantInitialized)
: name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, insertion_point_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, content_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, generated_code_info_(nullptr){}
struct CodeGeneratorResponse_FileDefaultTypeInternal {
constexpr CodeGeneratorResponse_FileDefaultTypeInternal()
PROTOBUF_CONSTEXPR CodeGeneratorResponse_FileDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~CodeGeneratorResponse_FileDefaultTypeInternal() {}
union {
@ -67,13 +67,13 @@ struct CodeGeneratorResponse_FileDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_;
constexpr CodeGeneratorResponse::CodeGeneratorResponse(
PROTOBUF_CONSTEXPR CodeGeneratorResponse::CodeGeneratorResponse(
::_pbi::ConstantInitialized)
: file_()
, error_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, supported_features_(uint64_t{0u}){}
struct CodeGeneratorResponseDefaultTypeInternal {
constexpr CodeGeneratorResponseDefaultTypeInternal()
PROTOBUF_CONSTEXPR CodeGeneratorResponseDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~CodeGeneratorResponseDefaultTypeInternal() {}
union {

View File

@ -107,7 +107,7 @@ class PROTOC_EXPORT Version final :
public:
inline Version() : Version(nullptr) {}
~Version() override;
explicit constexpr Version(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Version(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Version(const Version& from);
Version(Version&& from) noexcept
@ -312,7 +312,7 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
public:
inline CodeGeneratorRequest() : CodeGeneratorRequest(nullptr) {}
~CodeGeneratorRequest() override;
explicit constexpr CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
CodeGeneratorRequest(const CodeGeneratorRequest& from);
CodeGeneratorRequest(CodeGeneratorRequest&& from) noexcept
@ -538,7 +538,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
public:
inline CodeGeneratorResponse_File() : CodeGeneratorResponse_File(nullptr) {}
~CodeGeneratorResponse_File() override;
explicit constexpr CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from);
CodeGeneratorResponse_File(CodeGeneratorResponse_File&& from) noexcept
@ -758,7 +758,7 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
public:
inline CodeGeneratorResponse() : CodeGeneratorResponse(nullptr) {}
~CodeGeneratorResponse() override;
explicit constexpr CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
CodeGeneratorResponse(const CodeGeneratorResponse& from);
CodeGeneratorResponse(CodeGeneratorResponse&& from) noexcept

View File

@ -143,7 +143,68 @@ struct ExpressionEater {
};
void Fold(std::initializer_list<ExpressionEater>) {}
constexpr size_t RoundUp(size_t n) { return (n + 7) & ~7; }
template <int R>
constexpr size_t RoundUpTo(size_t n) {
static_assert((R & (R - 1)) == 0, "Must be power of two");
return (n + (R - 1)) & ~(R - 1);
}
constexpr size_t Max(size_t a, size_t b) { return a > b ? a : b; }
template <typename T, typename... Ts>
constexpr size_t Max(T a, Ts... b) {
return Max(a, Max(b...));
}
template <typename T>
constexpr size_t EffectiveAlignof() {
// `char` is special in that it gets aligned to 8. It is where we drop the
// trivial structs.
return std::is_same<T, char>::value ? 8 : alignof(T);
}
// Metafunction to sort types in descending order of alignment.
// Useful for the flat allocator to ensure proper alignment of all elements
// without having to add padding.
// For simplicity we use a function pointer as a type list.
struct TypeListSorter {
template <int align, typename U, typename... T>
static auto AppendIfAlign(void (*)(T...)) ->
typename std::conditional<EffectiveAlignof<U>() == align,
void (*)(T..., U), void (*)(T...)>::type {
return nullptr;
}
template <typename... T16, typename... T8, typename... T4, typename... T2,
typename... T1>
static auto SortImpl(void (*)(), void (*)(T16...), void (*)(T8...),
void (*)(T4...), void (*)(T2...), void (*)(T1...))
-> void (*)(T16..., T8..., T4..., T2..., T1...) {
return nullptr;
}
template <typename T, typename... Ts, typename T16, typename T8, typename T4,
typename T2, typename T1, typename Self = TypeListSorter>
static auto SortImpl(void (*)(T, Ts...), T16 p16, T8 p8, T4 p4, T2 p2, T1 p1)
-> decltype(Self::template SortImpl(
static_cast<void (*)(Ts...)>(nullptr), AppendIfAlign<16, T>(p16),
AppendIfAlign<8, T>(p8), AppendIfAlign<4, T>(p4),
AppendIfAlign<2, T>(p2), AppendIfAlign<1, T>(p1))) {
return nullptr;
}
// Instead of implementing a proper sort metafunction we just do a
// filter+merge, which is much simpler to write as a metafunction.
// We have a fixed set of alignments we can filter on.
template <typename... T>
static auto SortByAlignment(void (*p)() = nullptr)
-> decltype(SortImpl(static_cast<void (*)(T...)>(nullptr), p, p, p, p,
p)) {
return nullptr;
}
};
template <template <typename...> class C, typename... T>
auto ApplyTypeList(void (*)(T...)) -> C<T...>;
template <typename T>
constexpr int FindTypeIndex() {
@ -190,9 +251,12 @@ using PointerT = T*;
template <typename... T>
class FlatAllocation {
public:
static constexpr size_t kMaxAlign = Max(alignof(T)...);
FlatAllocation(const TypeMap<IntT, T...>& ends) : ends_(ends) {
// The arrays start just after FlatAllocation, so adjust the ends.
Fold({(ends_.template Get<T>() += RoundUp(sizeof(FlatAllocation)))...});
Fold({(ends_.template Get<T>() +=
RoundUpTo<kMaxAlign>(sizeof(FlatAllocation)))...});
Fold({Init<T>()...});
}
@ -228,38 +292,42 @@ class FlatAllocation {
constexpr int prev_type_index = type_index == 0 ? 0 : type_index - 1;
using PrevType =
typename std::tuple_element<prev_type_index, std::tuple<T...>>::type;
return type_index == 0 ? RoundUp(sizeof(FlatAllocation))
// Ensure the types are properly aligned.
static_assert(EffectiveAlignof<PrevType>() >= EffectiveAlignof<U>(), "");
return type_index == 0 ? RoundUpTo<kMaxAlign>(sizeof(FlatAllocation))
: ends_.template Get<PrevType>();
}
template <typename U>
int EndOffset() const {
return ends_.template Get<U>();
}
// Avoid the reinterpret_cast if the array is empty.
// Clang's Control Flow Integrity does not like the cast pointing to memory
// that is not yet initialized to be of that type.
// (from -fsanitize=cfi-unrelated-cast)
template <typename U>
U* Begin() const {
auto begin = BeginOffset<U>();
// Avoid the reinterpret_cast if the array is empty.
// Clang's Control Flow Integrity does not like the cast pointing to memory
// that is not yet initialized to be of that type.
// (from -fsanitize=cfi-unrelated-cast)
if (begin == ends_.template Get<U>()) return nullptr;
int begin = BeginOffset<U>(), end = EndOffset<U>();
if (begin == end) return nullptr;
return reinterpret_cast<U*>(data() + begin);
}
// Due to alignment the end offset could contain some extra bytes that do not
// belong to any object.
// Calculate the actual size by dividing the space by sizeof(U) to drop the
// extra bytes. If we calculate end as `data + offset` we can have an invalid
// pointer.
template <typename U>
size_t Size() const {
return static_cast<size_t>(ends_.template Get<U>() - BeginOffset<U>()) /
sizeof(U);
U* End() const {
int begin = BeginOffset<U>(), end = EndOffset<U>();
if (begin == end) return nullptr;
return reinterpret_cast<U*>(data() + end);
}
template <typename U>
bool Init() {
// Skip for the `char` block. No need to zero initialize it.
if (std::is_same<U, char>::value) return true;
for (int i = 0, size = Size<U>(); i < size; ++i) {
::new (data() + BeginOffset<U>() + sizeof(U) * i) U{};
for (char *p = data() + BeginOffset<U>(), *end = data() + EndOffset<U>();
p != end; p += sizeof(U)) {
::new (p) U{};
}
return true;
}
@ -267,7 +335,7 @@ class FlatAllocation {
template <typename U>
bool Destroy() {
if (std::is_trivially_destructible<U>::value) return true;
for (U* it = Begin<U>(), *end = it + Size<U>(); it != end; ++it) {
for (U* it = Begin<U>(), *end = End<U>(); it != end; ++it) {
it->~U();
}
return true;
@ -285,7 +353,7 @@ TypeMap<IntT, T...> CalculateEnds(const TypeMap<IntT, T...>& sizes) {
int total = 0;
TypeMap<IntT, T...> out;
Fold({(out.template Get<T>() = total +=
RoundUp(sizeof(T) * sizes.template Get<T>()))...});
sizeof(T) * sizes.template Get<T>())...});
return out;
}
@ -302,7 +370,9 @@ class FlatAllocatorImpl {
// We can't call PlanArray after FinalizePlanning has been called.
GOOGLE_CHECK(!has_allocated());
if (std::is_trivially_destructible<U>::value) {
total_.template Get<char>() += RoundUp(array_size * sizeof(U));
// Trivial types are aligned to 8 bytes.
static_assert(alignof(U) <= 8, "");
total_.template Get<char>() += RoundUpTo<8>(array_size * sizeof(U));
} else {
// Since we can't use `if constexpr`, just make the expression compile
// when this path is not taken.
@ -324,7 +394,7 @@ class FlatAllocatorImpl {
TypeToUse*& data = pointers_.template Get<TypeToUse>();
int& used = used_.template Get<TypeToUse>();
U* res = reinterpret_cast<U*>(data + used);
used += trivial ? RoundUp(array_size * sizeof(U)) : array_size;
used += trivial ? RoundUpTo<8>(array_size * sizeof(U)) : array_size;
GOOGLE_CHECK_LE(used, total_.template Get<TypeToUse>());
return res;
}
@ -492,29 +562,6 @@ class FlatAllocatorImpl {
} // namespace
namespace internal {
// Small sequential allocator to be used within a single file.
// Most of the memory for a single FileDescriptor and everything under it is
// allocated in a single block of memory, with the FlatAllocator giving it out
// in parts later.
// The code first plans the total number of bytes needed by calling PlanArray
// with all the allocations that will happen afterwards, then calls
// FinalizePlanning passing the underlying allocator (the DescriptorPool::Tables
// instance), and then proceeds to get the memory via
// `AllocateArray`/`AllocateString` calls. The calls to PlanArray and
// The calls have to match between planning and allocating, though not
// necessarily in the same order.
class FlatAllocator
: public FlatAllocatorImpl<
char, std::string, SourceCodeInfo, FileDescriptorTables,
// Option types
MessageOptions, FieldOptions, EnumOptions, EnumValueOptions,
ExtensionRangeOptions, OneofOptions, ServiceOptions, MethodOptions,
FileOptions> {};
} // namespace internal
class Symbol {
public:
enum Type {
@ -1081,9 +1128,126 @@ bool AllowedExtendeeInProto3(const std::string& name) {
return allowed_proto3_extendees->find(name) !=
allowed_proto3_extendees->end();
}
} // anonymous namespace
// Contains tables specific to a particular file. These tables are not
// modified once the file has been constructed, so they need not be
// protected by a mutex. This makes operations that depend only on the
// contents of a single file -- e.g. Descriptor::FindFieldByName() --
// lock-free.
//
// For historical reasons, the definitions of the methods of
// FileDescriptorTables and DescriptorPool::Tables are interleaved below.
// These used to be a single class.
class FileDescriptorTables {
public:
FileDescriptorTables();
~FileDescriptorTables();
// Empty table, used with placeholder files.
inline static const FileDescriptorTables& GetEmptyInstance();
// -----------------------------------------------------------------
// Finding items.
// Returns a null Symbol (symbol.IsNull() is true) if not found.
inline Symbol FindNestedSymbol(const void* parent,
StringPiece name) const;
// These return nullptr if not found.
inline const FieldDescriptor* FindFieldByNumber(const Descriptor* parent,
int number) const;
inline const FieldDescriptor* FindFieldByLowercaseName(
const void* parent, StringPiece lowercase_name) const;
inline const FieldDescriptor* FindFieldByCamelcaseName(
const void* parent, StringPiece camelcase_name) const;
inline const EnumValueDescriptor* FindEnumValueByNumber(
const EnumDescriptor* parent, int number) const;
// This creates a new EnumValueDescriptor if not found, in a thread-safe way.
inline const EnumValueDescriptor* FindEnumValueByNumberCreatingIfUnknown(
const EnumDescriptor* parent, int number) const;
// -----------------------------------------------------------------
// Adding items.
// These add items to the corresponding tables. They return false if
// the key already exists in the table.
bool AddAliasUnderParent(const void* parent, const std::string& name,
Symbol symbol);
bool AddFieldByNumber(FieldDescriptor* field);
bool AddEnumValueByNumber(EnumValueDescriptor* value);
// Populates p->first->locations_by_path_ from p->second.
// Unusual signature dictated by internal::call_once.
static void BuildLocationsByPath(
std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p);
// Returns the location denoted by the specified path through info,
// or nullptr if not found.
// The value of info must be that of the corresponding FileDescriptor.
// (Conceptually a pure function, but stateful as an optimisation.)
const SourceCodeInfo_Location* GetSourceLocation(
const std::vector<int>& path, const SourceCodeInfo* info) const;
// Must be called after BuildFileImpl(), even if the build failed and
// we are going to roll back to the last checkpoint.
void FinalizeTables();
private:
const void* FindParentForFieldsByMap(const FieldDescriptor* field) const;
static void FieldsByLowercaseNamesLazyInitStatic(
const FileDescriptorTables* tables);
void FieldsByLowercaseNamesLazyInitInternal() const;
static void FieldsByCamelcaseNamesLazyInitStatic(
const FileDescriptorTables* tables);
void FieldsByCamelcaseNamesLazyInitInternal() const;
SymbolsByParentSet symbols_by_parent_;
mutable internal::once_flag fields_by_lowercase_name_once_;
mutable internal::once_flag fields_by_camelcase_name_once_;
// Make these fields atomic to avoid race conditions with
// GetEstimatedOwnedMemoryBytesSize. Once the pointer is set the map won't
// change anymore.
mutable std::atomic<const FieldsByNameMap*> fields_by_lowercase_name_{};
mutable std::atomic<const FieldsByNameMap*> fields_by_camelcase_name_{};
FieldsByNumberSet fields_by_number_; // Not including extensions.
EnumValuesByNumberSet enum_values_by_number_;
mutable EnumValuesByNumberSet unknown_enum_values_by_number_
PROTOBUF_GUARDED_BY(unknown_enum_values_mu_);
// Populated on first request to save space, hence constness games.
mutable internal::once_flag locations_by_path_once_;
mutable LocationsByPathMap locations_by_path_;
// Mutex to protect the unknown-enum-value map due to dynamic
// EnumValueDescriptor creation on unknown values.
mutable internal::WrappedMutex unknown_enum_values_mu_;
};
namespace internal {
// Small sequential allocator to be used within a single file.
// Most of the memory for a single FileDescriptor and everything under it is
// allocated in a single block of memory, with the FlatAllocator giving it out
// in parts later.
// The code first plans the total number of bytes needed by calling PlanArray
// with all the allocations that will happen afterwards, then calls
// FinalizePlanning passing the underlying allocator (the DescriptorPool::Tables
// instance), and then proceeds to get the memory via
// `AllocateArray`/`AllocateString` calls. The calls to PlanArray and
// The calls have to match between planning and allocating, though not
// necessarily in the same order.
class FlatAllocator
: public decltype(ApplyTypeList<FlatAllocatorImpl>(
TypeListSorter::SortByAlignment<
char, std::string, SourceCodeInfo, FileDescriptorTables,
// Option types
MessageOptions, FieldOptions, EnumOptions, EnumValueOptions,
ExtensionRangeOptions, OneofOptions, ServiceOptions,
MethodOptions, FileOptions>())) {};
} // namespace internal
// ===================================================================
// DescriptorPool::Tables
@ -1199,7 +1363,7 @@ class DescriptorPool::Tables {
Type* Allocate();
// Allocate some bytes which will be reclaimed when the pool is
// destroyed.
// destroyed. Memory is aligned to 8 bytes.
void* AllocateBytes(int size);
// Create a FlatAllocation for the corresponding sizes.
@ -1257,100 +1421,6 @@ class DescriptorPool::Tables {
std::vector<DescriptorIntPair> extensions_after_checkpoint_;
};
// Contains tables specific to a particular file. These tables are not
// modified once the file has been constructed, so they need not be
// protected by a mutex. This makes operations that depend only on the
// contents of a single file -- e.g. Descriptor::FindFieldByName() --
// lock-free.
//
// For historical reasons, the definitions of the methods of
// FileDescriptorTables and DescriptorPool::Tables are interleaved below.
// These used to be a single class.
class FileDescriptorTables {
public:
FileDescriptorTables();
~FileDescriptorTables();
// Empty table, used with placeholder files.
inline static const FileDescriptorTables& GetEmptyInstance();
// -----------------------------------------------------------------
// Finding items.
// Returns a null Symbol (symbol.IsNull() is true) if not found.
inline Symbol FindNestedSymbol(const void* parent,
StringPiece name) const;
// These return nullptr if not found.
inline const FieldDescriptor* FindFieldByNumber(const Descriptor* parent,
int number) const;
inline const FieldDescriptor* FindFieldByLowercaseName(
const void* parent, StringPiece lowercase_name) const;
inline const FieldDescriptor* FindFieldByCamelcaseName(
const void* parent, StringPiece camelcase_name) const;
inline const EnumValueDescriptor* FindEnumValueByNumber(
const EnumDescriptor* parent, int number) const;
// This creates a new EnumValueDescriptor if not found, in a thread-safe way.
inline const EnumValueDescriptor* FindEnumValueByNumberCreatingIfUnknown(
const EnumDescriptor* parent, int number) const;
// -----------------------------------------------------------------
// Adding items.
// These add items to the corresponding tables. They return false if
// the key already exists in the table.
bool AddAliasUnderParent(const void* parent, const std::string& name,
Symbol symbol);
bool AddFieldByNumber(FieldDescriptor* field);
bool AddEnumValueByNumber(EnumValueDescriptor* value);
// Populates p->first->locations_by_path_ from p->second.
// Unusual signature dictated by internal::call_once.
static void BuildLocationsByPath(
std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p);
// Returns the location denoted by the specified path through info,
// or nullptr if not found.
// The value of info must be that of the corresponding FileDescriptor.
// (Conceptually a pure function, but stateful as an optimisation.)
const SourceCodeInfo_Location* GetSourceLocation(
const std::vector<int>& path, const SourceCodeInfo* info) const;
// Must be called after BuildFileImpl(), even if the build failed and
// we are going to roll back to the last checkpoint.
void FinalizeTables();
private:
const void* FindParentForFieldsByMap(const FieldDescriptor* field) const;
static void FieldsByLowercaseNamesLazyInitStatic(
const FileDescriptorTables* tables);
void FieldsByLowercaseNamesLazyInitInternal() const;
static void FieldsByCamelcaseNamesLazyInitStatic(
const FileDescriptorTables* tables);
void FieldsByCamelcaseNamesLazyInitInternal() const;
SymbolsByParentSet symbols_by_parent_;
mutable internal::once_flag fields_by_lowercase_name_once_;
mutable internal::once_flag fields_by_camelcase_name_once_;
// Make these fields atomic to avoid race conditions with
// GetEstimatedOwnedMemoryBytesSize. Once the pointer is set the map won't
// change anymore.
mutable std::atomic<const FieldsByNameMap*> fields_by_lowercase_name_{};
mutable std::atomic<const FieldsByNameMap*> fields_by_camelcase_name_{};
FieldsByNumberSet fields_by_number_; // Not including extensions.
EnumValuesByNumberSet enum_values_by_number_;
mutable EnumValuesByNumberSet unknown_enum_values_by_number_
PROTOBUF_GUARDED_BY(unknown_enum_values_mu_);
// Populated on first request to save space, hence constness games.
mutable internal::once_flag locations_by_path_once_;
mutable LocationsByPathMap locations_by_path_;
// Mutex to protect the unknown-enum-value map due to dynamic
// EnumValueDescriptor creation on unknown values.
mutable internal::WrappedMutex unknown_enum_values_mu_;
};
DescriptorPool::Tables::Tables() {
well_known_types_.insert({
{"google.protobuf.DoubleValue", Descriptor::WELLKNOWNTYPE_DOUBLEVALUE},
@ -1738,16 +1808,17 @@ bool DescriptorPool::Tables::AddExtension(const FieldDescriptor* field) {
template <typename Type>
Type* DescriptorPool::Tables::Allocate() {
static_assert(std::is_trivially_destructible<Type>::value, "");
static_assert(alignof(Type) <= 8, "");
return ::new (AllocateBytes(sizeof(Type))) Type{};
}
void* DescriptorPool::Tables::AllocateBytes(int size) {
if (size == 0) return nullptr;
void* p = ::operator new(size + RoundUp(sizeof(int)));
void* p = ::operator new(size + RoundUpTo<8>(sizeof(int)));
int* sizep = static_cast<int*>(p);
misc_allocs_.emplace_back(sizep);
*sizep = size;
return static_cast<char*>(p) + RoundUp(sizeof(int));
return static_cast<char*>(p) + RoundUpTo<8>(sizeof(int));
}
template <typename... T>
@ -1758,7 +1829,8 @@ internal::FlatAllocator::Allocation* DescriptorPool::Tables::CreateFlatAlloc(
int last_end = ends.template Get<
typename std::tuple_element<sizeof...(T) - 1, std::tuple<T...>>::type>();
size_t total_size = last_end + RoundUp(sizeof(FlatAlloc));
size_t total_size =
last_end + RoundUpTo<FlatAlloc::kMaxAlign>(sizeof(FlatAlloc));
char* data = static_cast<char*>(::operator new(total_size));
auto* res = ::new (data) FlatAlloc(ends);
flat_allocs_.emplace_back(res);

View File

@ -21,11 +21,11 @@ namespace _pb = ::PROTOBUF_NAMESPACE_ID;
namespace _pbi = _pb::internal;
PROTOBUF_NAMESPACE_OPEN
constexpr FileDescriptorSet::FileDescriptorSet(
PROTOBUF_CONSTEXPR FileDescriptorSet::FileDescriptorSet(
::_pbi::ConstantInitialized)
: file_(){}
struct FileDescriptorSetDefaultTypeInternal {
constexpr FileDescriptorSetDefaultTypeInternal()
PROTOBUF_CONSTEXPR FileDescriptorSetDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~FileDescriptorSetDefaultTypeInternal() {}
union {
@ -33,7 +33,7 @@ struct FileDescriptorSetDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_;
constexpr FileDescriptorProto::FileDescriptorProto(
PROTOBUF_CONSTEXPR FileDescriptorProto::FileDescriptorProto(
::_pbi::ConstantInitialized)
: dependency_()
, message_type_()
@ -48,7 +48,7 @@ constexpr FileDescriptorProto::FileDescriptorProto(
, options_(nullptr)
, source_code_info_(nullptr){}
struct FileDescriptorProtoDefaultTypeInternal {
constexpr FileDescriptorProtoDefaultTypeInternal()
PROTOBUF_CONSTEXPR FileDescriptorProtoDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~FileDescriptorProtoDefaultTypeInternal() {}
union {
@ -56,13 +56,13 @@ struct FileDescriptorProtoDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_;
constexpr DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(
PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(
::_pbi::ConstantInitialized)
: options_(nullptr)
, start_(0)
, end_(0){}
struct DescriptorProto_ExtensionRangeDefaultTypeInternal {
constexpr DescriptorProto_ExtensionRangeDefaultTypeInternal()
PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRangeDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~DescriptorProto_ExtensionRangeDefaultTypeInternal() {}
union {
@ -70,12 +70,12 @@ struct DescriptorProto_ExtensionRangeDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_;
constexpr DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(
PROTOBUF_CONSTEXPR DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(
::_pbi::ConstantInitialized)
: start_(0)
, end_(0){}
struct DescriptorProto_ReservedRangeDefaultTypeInternal {
constexpr DescriptorProto_ReservedRangeDefaultTypeInternal()
PROTOBUF_CONSTEXPR DescriptorProto_ReservedRangeDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~DescriptorProto_ReservedRangeDefaultTypeInternal() {}
union {
@ -83,7 +83,7 @@ struct DescriptorProto_ReservedRangeDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_;
constexpr DescriptorProto::DescriptorProto(
PROTOBUF_CONSTEXPR DescriptorProto::DescriptorProto(
::_pbi::ConstantInitialized)
: field_()
, nested_type_()
@ -96,7 +96,7 @@ constexpr DescriptorProto::DescriptorProto(
, name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, options_(nullptr){}
struct DescriptorProtoDefaultTypeInternal {
constexpr DescriptorProtoDefaultTypeInternal()
PROTOBUF_CONSTEXPR DescriptorProtoDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~DescriptorProtoDefaultTypeInternal() {}
union {
@ -104,11 +104,11 @@ struct DescriptorProtoDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_;
constexpr ExtensionRangeOptions::ExtensionRangeOptions(
PROTOBUF_CONSTEXPR ExtensionRangeOptions::ExtensionRangeOptions(
::_pbi::ConstantInitialized)
: uninterpreted_option_(){}
struct ExtensionRangeOptionsDefaultTypeInternal {
constexpr ExtensionRangeOptionsDefaultTypeInternal()
PROTOBUF_CONSTEXPR ExtensionRangeOptionsDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~ExtensionRangeOptionsDefaultTypeInternal() {}
union {
@ -116,7 +116,7 @@ struct ExtensionRangeOptionsDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_;
constexpr FieldDescriptorProto::FieldDescriptorProto(
PROTOBUF_CONSTEXPR FieldDescriptorProto::FieldDescriptorProto(
::_pbi::ConstantInitialized)
: name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, extendee_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
@ -132,7 +132,7 @@ constexpr FieldDescriptorProto::FieldDescriptorProto(
, type_(1)
{}
struct FieldDescriptorProtoDefaultTypeInternal {
constexpr FieldDescriptorProtoDefaultTypeInternal()
PROTOBUF_CONSTEXPR FieldDescriptorProtoDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~FieldDescriptorProtoDefaultTypeInternal() {}
union {
@ -140,12 +140,12 @@ struct FieldDescriptorProtoDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_;
constexpr OneofDescriptorProto::OneofDescriptorProto(
PROTOBUF_CONSTEXPR OneofDescriptorProto::OneofDescriptorProto(
::_pbi::ConstantInitialized)
: name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, options_(nullptr){}
struct OneofDescriptorProtoDefaultTypeInternal {
constexpr OneofDescriptorProtoDefaultTypeInternal()
PROTOBUF_CONSTEXPR OneofDescriptorProtoDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~OneofDescriptorProtoDefaultTypeInternal() {}
union {
@ -153,12 +153,12 @@ struct OneofDescriptorProtoDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_;
constexpr EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(
PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(
::_pbi::ConstantInitialized)
: start_(0)
, end_(0){}
struct EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal {
constexpr EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal()
PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal() {}
union {
@ -166,7 +166,7 @@ struct EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_;
constexpr EnumDescriptorProto::EnumDescriptorProto(
PROTOBUF_CONSTEXPR EnumDescriptorProto::EnumDescriptorProto(
::_pbi::ConstantInitialized)
: value_()
, reserved_range_()
@ -174,7 +174,7 @@ constexpr EnumDescriptorProto::EnumDescriptorProto(
, name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, options_(nullptr){}
struct EnumDescriptorProtoDefaultTypeInternal {
constexpr EnumDescriptorProtoDefaultTypeInternal()
PROTOBUF_CONSTEXPR EnumDescriptorProtoDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~EnumDescriptorProtoDefaultTypeInternal() {}
union {
@ -182,13 +182,13 @@ struct EnumDescriptorProtoDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_;
constexpr EnumValueDescriptorProto::EnumValueDescriptorProto(
PROTOBUF_CONSTEXPR EnumValueDescriptorProto::EnumValueDescriptorProto(
::_pbi::ConstantInitialized)
: name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, options_(nullptr)
, number_(0){}
struct EnumValueDescriptorProtoDefaultTypeInternal {
constexpr EnumValueDescriptorProtoDefaultTypeInternal()
PROTOBUF_CONSTEXPR EnumValueDescriptorProtoDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~EnumValueDescriptorProtoDefaultTypeInternal() {}
union {
@ -196,13 +196,13 @@ struct EnumValueDescriptorProtoDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_;
constexpr ServiceDescriptorProto::ServiceDescriptorProto(
PROTOBUF_CONSTEXPR ServiceDescriptorProto::ServiceDescriptorProto(
::_pbi::ConstantInitialized)
: method_()
, name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, options_(nullptr){}
struct ServiceDescriptorProtoDefaultTypeInternal {
constexpr ServiceDescriptorProtoDefaultTypeInternal()
PROTOBUF_CONSTEXPR ServiceDescriptorProtoDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~ServiceDescriptorProtoDefaultTypeInternal() {}
union {
@ -210,7 +210,7 @@ struct ServiceDescriptorProtoDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_;
constexpr MethodDescriptorProto::MethodDescriptorProto(
PROTOBUF_CONSTEXPR MethodDescriptorProto::MethodDescriptorProto(
::_pbi::ConstantInitialized)
: name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, input_type_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
@ -219,7 +219,7 @@ constexpr MethodDescriptorProto::MethodDescriptorProto(
, client_streaming_(false)
, server_streaming_(false){}
struct MethodDescriptorProtoDefaultTypeInternal {
constexpr MethodDescriptorProtoDefaultTypeInternal()
PROTOBUF_CONSTEXPR MethodDescriptorProtoDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~MethodDescriptorProtoDefaultTypeInternal() {}
union {
@ -227,7 +227,7 @@ struct MethodDescriptorProtoDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_;
constexpr FileOptions::FileOptions(
PROTOBUF_CONSTEXPR FileOptions::FileOptions(
::_pbi::ConstantInitialized)
: uninterpreted_option_()
, java_package_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
@ -252,7 +252,7 @@ constexpr FileOptions::FileOptions(
, cc_enable_arenas_(true){}
struct FileOptionsDefaultTypeInternal {
constexpr FileOptionsDefaultTypeInternal()
PROTOBUF_CONSTEXPR FileOptionsDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~FileOptionsDefaultTypeInternal() {}
union {
@ -260,7 +260,7 @@ struct FileOptionsDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileOptionsDefaultTypeInternal _FileOptions_default_instance_;
constexpr MessageOptions::MessageOptions(
PROTOBUF_CONSTEXPR MessageOptions::MessageOptions(
::_pbi::ConstantInitialized)
: uninterpreted_option_()
, message_set_wire_format_(false)
@ -268,7 +268,7 @@ constexpr MessageOptions::MessageOptions(
, deprecated_(false)
, map_entry_(false){}
struct MessageOptionsDefaultTypeInternal {
constexpr MessageOptionsDefaultTypeInternal()
PROTOBUF_CONSTEXPR MessageOptionsDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~MessageOptionsDefaultTypeInternal() {}
union {
@ -276,7 +276,7 @@ struct MessageOptionsDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_;
constexpr FieldOptions::FieldOptions(
PROTOBUF_CONSTEXPR FieldOptions::FieldOptions(
::_pbi::ConstantInitialized)
: uninterpreted_option_()
, ctype_(0)
@ -289,7 +289,7 @@ constexpr FieldOptions::FieldOptions(
, deprecated_(false)
, weak_(false){}
struct FieldOptionsDefaultTypeInternal {
constexpr FieldOptionsDefaultTypeInternal()
PROTOBUF_CONSTEXPR FieldOptionsDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~FieldOptionsDefaultTypeInternal() {}
union {
@ -297,11 +297,11 @@ struct FieldOptionsDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_;
constexpr OneofOptions::OneofOptions(
PROTOBUF_CONSTEXPR OneofOptions::OneofOptions(
::_pbi::ConstantInitialized)
: uninterpreted_option_(){}
struct OneofOptionsDefaultTypeInternal {
constexpr OneofOptionsDefaultTypeInternal()
PROTOBUF_CONSTEXPR OneofOptionsDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~OneofOptionsDefaultTypeInternal() {}
union {
@ -309,13 +309,13 @@ struct OneofOptionsDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_;
constexpr EnumOptions::EnumOptions(
PROTOBUF_CONSTEXPR EnumOptions::EnumOptions(
::_pbi::ConstantInitialized)
: uninterpreted_option_()
, allow_alias_(false)
, deprecated_(false){}
struct EnumOptionsDefaultTypeInternal {
constexpr EnumOptionsDefaultTypeInternal()
PROTOBUF_CONSTEXPR EnumOptionsDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~EnumOptionsDefaultTypeInternal() {}
union {
@ -323,12 +323,12 @@ struct EnumOptionsDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_;
constexpr EnumValueOptions::EnumValueOptions(
PROTOBUF_CONSTEXPR EnumValueOptions::EnumValueOptions(
::_pbi::ConstantInitialized)
: uninterpreted_option_()
, deprecated_(false){}
struct EnumValueOptionsDefaultTypeInternal {
constexpr EnumValueOptionsDefaultTypeInternal()
PROTOBUF_CONSTEXPR EnumValueOptionsDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~EnumValueOptionsDefaultTypeInternal() {}
union {
@ -336,12 +336,12 @@ struct EnumValueOptionsDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_;
constexpr ServiceOptions::ServiceOptions(
PROTOBUF_CONSTEXPR ServiceOptions::ServiceOptions(
::_pbi::ConstantInitialized)
: uninterpreted_option_()
, deprecated_(false){}
struct ServiceOptionsDefaultTypeInternal {
constexpr ServiceOptionsDefaultTypeInternal()
PROTOBUF_CONSTEXPR ServiceOptionsDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~ServiceOptionsDefaultTypeInternal() {}
union {
@ -349,14 +349,14 @@ struct ServiceOptionsDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_;
constexpr MethodOptions::MethodOptions(
PROTOBUF_CONSTEXPR MethodOptions::MethodOptions(
::_pbi::ConstantInitialized)
: uninterpreted_option_()
, deprecated_(false)
, idempotency_level_(0)
{}
struct MethodOptionsDefaultTypeInternal {
constexpr MethodOptionsDefaultTypeInternal()
PROTOBUF_CONSTEXPR MethodOptionsDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~MethodOptionsDefaultTypeInternal() {}
union {
@ -364,12 +364,12 @@ struct MethodOptionsDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_;
constexpr UninterpretedOption_NamePart::UninterpretedOption_NamePart(
PROTOBUF_CONSTEXPR UninterpretedOption_NamePart::UninterpretedOption_NamePart(
::_pbi::ConstantInitialized)
: name_part_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, is_extension_(false){}
struct UninterpretedOption_NamePartDefaultTypeInternal {
constexpr UninterpretedOption_NamePartDefaultTypeInternal()
PROTOBUF_CONSTEXPR UninterpretedOption_NamePartDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~UninterpretedOption_NamePartDefaultTypeInternal() {}
union {
@ -377,7 +377,7 @@ struct UninterpretedOption_NamePartDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_;
constexpr UninterpretedOption::UninterpretedOption(
PROTOBUF_CONSTEXPR UninterpretedOption::UninterpretedOption(
::_pbi::ConstantInitialized)
: name_()
, identifier_value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
@ -387,7 +387,7 @@ constexpr UninterpretedOption::UninterpretedOption(
, negative_int_value_(int64_t{0})
, double_value_(0){}
struct UninterpretedOptionDefaultTypeInternal {
constexpr UninterpretedOptionDefaultTypeInternal()
PROTOBUF_CONSTEXPR UninterpretedOptionDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~UninterpretedOptionDefaultTypeInternal() {}
union {
@ -395,7 +395,7 @@ struct UninterpretedOptionDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_;
constexpr SourceCodeInfo_Location::SourceCodeInfo_Location(
PROTOBUF_CONSTEXPR SourceCodeInfo_Location::SourceCodeInfo_Location(
::_pbi::ConstantInitialized)
: path_()
, _path_cached_byte_size_(0)
@ -405,7 +405,7 @@ constexpr SourceCodeInfo_Location::SourceCodeInfo_Location(
, leading_comments_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, trailing_comments_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}){}
struct SourceCodeInfo_LocationDefaultTypeInternal {
constexpr SourceCodeInfo_LocationDefaultTypeInternal()
PROTOBUF_CONSTEXPR SourceCodeInfo_LocationDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~SourceCodeInfo_LocationDefaultTypeInternal() {}
union {
@ -413,11 +413,11 @@ struct SourceCodeInfo_LocationDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_;
constexpr SourceCodeInfo::SourceCodeInfo(
PROTOBUF_CONSTEXPR SourceCodeInfo::SourceCodeInfo(
::_pbi::ConstantInitialized)
: location_(){}
struct SourceCodeInfoDefaultTypeInternal {
constexpr SourceCodeInfoDefaultTypeInternal()
PROTOBUF_CONSTEXPR SourceCodeInfoDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~SourceCodeInfoDefaultTypeInternal() {}
union {
@ -425,7 +425,7 @@ struct SourceCodeInfoDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_;
constexpr GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(
PROTOBUF_CONSTEXPR GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(
::_pbi::ConstantInitialized)
: path_()
, _path_cached_byte_size_(0)
@ -433,7 +433,7 @@ constexpr GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(
, begin_(0)
, end_(0){}
struct GeneratedCodeInfo_AnnotationDefaultTypeInternal {
constexpr GeneratedCodeInfo_AnnotationDefaultTypeInternal()
PROTOBUF_CONSTEXPR GeneratedCodeInfo_AnnotationDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~GeneratedCodeInfo_AnnotationDefaultTypeInternal() {}
union {
@ -441,11 +441,11 @@ struct GeneratedCodeInfo_AnnotationDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_;
constexpr GeneratedCodeInfo::GeneratedCodeInfo(
PROTOBUF_CONSTEXPR GeneratedCodeInfo::GeneratedCodeInfo(
::_pbi::ConstantInitialized)
: annotation_(){}
struct GeneratedCodeInfoDefaultTypeInternal {
constexpr GeneratedCodeInfoDefaultTypeInternal()
PROTOBUF_CONSTEXPR GeneratedCodeInfoDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~GeneratedCodeInfoDefaultTypeInternal() {}
union {

View File

@ -325,7 +325,7 @@ class PROTOBUF_EXPORT FileDescriptorSet final :
public:
inline FileDescriptorSet() : FileDescriptorSet(nullptr) {}
~FileDescriptorSet() override;
explicit constexpr FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
FileDescriptorSet(const FileDescriptorSet& from);
FileDescriptorSet(FileDescriptorSet&& from) noexcept
@ -484,7 +484,7 @@ class PROTOBUF_EXPORT FileDescriptorProto final :
public:
inline FileDescriptorProto() : FileDescriptorProto(nullptr) {}
~FileDescriptorProto() override;
explicit constexpr FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
FileDescriptorProto(const FileDescriptorProto& from);
FileDescriptorProto(FileDescriptorProto&& from) noexcept
@ -878,7 +878,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final :
public:
inline DescriptorProto_ExtensionRange() : DescriptorProto_ExtensionRange(nullptr) {}
~DescriptorProto_ExtensionRange() override;
explicit constexpr DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from);
DescriptorProto_ExtensionRange(DescriptorProto_ExtensionRange&& from) noexcept
@ -1068,7 +1068,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final :
public:
inline DescriptorProto_ReservedRange() : DescriptorProto_ReservedRange(nullptr) {}
~DescriptorProto_ReservedRange() override;
explicit constexpr DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from);
DescriptorProto_ReservedRange(DescriptorProto_ReservedRange&& from) noexcept
@ -1238,7 +1238,7 @@ class PROTOBUF_EXPORT DescriptorProto final :
public:
inline DescriptorProto() : DescriptorProto(nullptr) {}
~DescriptorProto() override;
explicit constexpr DescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR DescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
DescriptorProto(const DescriptorProto& from);
DescriptorProto(DescriptorProto&& from) noexcept
@ -1587,7 +1587,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final :
public:
inline ExtensionRangeOptions() : ExtensionRangeOptions(nullptr) {}
~ExtensionRangeOptions() override;
explicit constexpr ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
ExtensionRangeOptions(const ExtensionRangeOptions& from);
ExtensionRangeOptions(ExtensionRangeOptions&& from) noexcept
@ -1938,7 +1938,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto final :
public:
inline FieldDescriptorProto() : FieldDescriptorProto(nullptr) {}
~FieldDescriptorProto() override;
explicit constexpr FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
FieldDescriptorProto(const FieldDescriptorProto& from);
FieldDescriptorProto(FieldDescriptorProto&& from) noexcept
@ -2367,7 +2367,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto final :
public:
inline OneofDescriptorProto() : OneofDescriptorProto(nullptr) {}
~OneofDescriptorProto() override;
explicit constexpr OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
OneofDescriptorProto(const OneofDescriptorProto& from);
OneofDescriptorProto(OneofDescriptorProto&& from) noexcept
@ -2547,7 +2547,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final :
public:
inline EnumDescriptorProto_EnumReservedRange() : EnumDescriptorProto_EnumReservedRange(nullptr) {}
~EnumDescriptorProto_EnumReservedRange() override;
explicit constexpr EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
EnumDescriptorProto_EnumReservedRange(const EnumDescriptorProto_EnumReservedRange& from);
EnumDescriptorProto_EnumReservedRange(EnumDescriptorProto_EnumReservedRange&& from) noexcept
@ -2717,7 +2717,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto final :
public:
inline EnumDescriptorProto() : EnumDescriptorProto(nullptr) {}
~EnumDescriptorProto() override;
explicit constexpr EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
EnumDescriptorProto(const EnumDescriptorProto& from);
EnumDescriptorProto(EnumDescriptorProto&& from) noexcept
@ -2965,7 +2965,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final :
public:
inline EnumValueDescriptorProto() : EnumValueDescriptorProto(nullptr) {}
~EnumValueDescriptorProto() override;
explicit constexpr EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
EnumValueDescriptorProto(const EnumValueDescriptorProto& from);
EnumValueDescriptorProto(EnumValueDescriptorProto&& from) noexcept
@ -3160,7 +3160,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final :
public:
inline ServiceDescriptorProto() : ServiceDescriptorProto(nullptr) {}
~ServiceDescriptorProto() override;
explicit constexpr ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
ServiceDescriptorProto(const ServiceDescriptorProto& from);
ServiceDescriptorProto(ServiceDescriptorProto&& from) noexcept
@ -3360,7 +3360,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto final :
public:
inline MethodDescriptorProto() : MethodDescriptorProto(nullptr) {}
~MethodDescriptorProto() override;
explicit constexpr MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
MethodDescriptorProto(const MethodDescriptorProto& from);
MethodDescriptorProto(MethodDescriptorProto&& from) noexcept
@ -3610,7 +3610,7 @@ class PROTOBUF_EXPORT FileOptions final :
public:
inline FileOptions() : FileOptions(nullptr) {}
~FileOptions() override;
explicit constexpr FileOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR FileOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
FileOptions(const FileOptions& from);
FileOptions(FileOptions&& from) noexcept
@ -4344,7 +4344,7 @@ class PROTOBUF_EXPORT MessageOptions final :
public:
inline MessageOptions() : MessageOptions(nullptr) {}
~MessageOptions() override;
explicit constexpr MessageOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR MessageOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
MessageOptions(const MessageOptions& from);
MessageOptions(MessageOptions&& from) noexcept
@ -4756,7 +4756,7 @@ class PROTOBUF_EXPORT FieldOptions final :
public:
inline FieldOptions() : FieldOptions(nullptr) {}
~FieldOptions() override;
explicit constexpr FieldOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR FieldOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
FieldOptions(const FieldOptions& from);
FieldOptions(FieldOptions&& from) noexcept
@ -5277,7 +5277,7 @@ class PROTOBUF_EXPORT OneofOptions final :
public:
inline OneofOptions() : OneofOptions(nullptr) {}
~OneofOptions() override;
explicit constexpr OneofOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR OneofOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
OneofOptions(const OneofOptions& from);
OneofOptions(OneofOptions&& from) noexcept
@ -5628,7 +5628,7 @@ class PROTOBUF_EXPORT EnumOptions final :
public:
inline EnumOptions() : EnumOptions(nullptr) {}
~EnumOptions() override;
explicit constexpr EnumOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR EnumOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
EnumOptions(const EnumOptions& from);
EnumOptions(EnumOptions&& from) noexcept
@ -6010,7 +6010,7 @@ class PROTOBUF_EXPORT EnumValueOptions final :
public:
inline EnumValueOptions() : EnumValueOptions(nullptr) {}
~EnumValueOptions() override;
explicit constexpr EnumValueOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR EnumValueOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
EnumValueOptions(const EnumValueOptions& from);
EnumValueOptions(EnumValueOptions&& from) noexcept
@ -6377,7 +6377,7 @@ class PROTOBUF_EXPORT ServiceOptions final :
public:
inline ServiceOptions() : ServiceOptions(nullptr) {}
~ServiceOptions() override;
explicit constexpr ServiceOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR ServiceOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
ServiceOptions(const ServiceOptions& from);
ServiceOptions(ServiceOptions&& from) noexcept
@ -6744,7 +6744,7 @@ class PROTOBUF_EXPORT MethodOptions final :
public:
inline MethodOptions() : MethodOptions(nullptr) {}
~MethodOptions() override;
explicit constexpr MethodOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR MethodOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
MethodOptions(const MethodOptions& from);
MethodOptions(MethodOptions&& from) noexcept
@ -7158,7 +7158,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final :
public:
inline UninterpretedOption_NamePart() : UninterpretedOption_NamePart(nullptr) {}
~UninterpretedOption_NamePart() override;
explicit constexpr UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from);
UninterpretedOption_NamePart(UninterpretedOption_NamePart&& from) noexcept
@ -7336,7 +7336,7 @@ class PROTOBUF_EXPORT UninterpretedOption final :
public:
inline UninterpretedOption() : UninterpretedOption(nullptr) {}
~UninterpretedOption() override;
explicit constexpr UninterpretedOption(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR UninterpretedOption(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
UninterpretedOption(const UninterpretedOption& from);
UninterpretedOption(UninterpretedOption&& from) noexcept
@ -7603,7 +7603,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final :
public:
inline SourceCodeInfo_Location() : SourceCodeInfo_Location(nullptr) {}
~SourceCodeInfo_Location() override;
explicit constexpr SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
SourceCodeInfo_Location(const SourceCodeInfo_Location& from);
SourceCodeInfo_Location(SourceCodeInfo_Location&& from) noexcept
@ -7859,7 +7859,7 @@ class PROTOBUF_EXPORT SourceCodeInfo final :
public:
inline SourceCodeInfo() : SourceCodeInfo(nullptr) {}
~SourceCodeInfo() override;
explicit constexpr SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
SourceCodeInfo(const SourceCodeInfo& from);
SourceCodeInfo(SourceCodeInfo&& from) noexcept
@ -8020,7 +8020,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final :
public:
inline GeneratedCodeInfo_Annotation() : GeneratedCodeInfo_Annotation(nullptr) {}
~GeneratedCodeInfo_Annotation() override;
explicit constexpr GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from);
GeneratedCodeInfo_Annotation(GeneratedCodeInfo_Annotation&& from) noexcept
@ -8235,7 +8235,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final :
public:
inline GeneratedCodeInfo() : GeneratedCodeInfo(nullptr) {}
~GeneratedCodeInfo() override;
explicit constexpr GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
GeneratedCodeInfo(const GeneratedCodeInfo& from);
GeneratedCodeInfo(GeneratedCodeInfo&& from) noexcept

View File

@ -21,12 +21,12 @@ namespace _pb = ::PROTOBUF_NAMESPACE_ID;
namespace _pbi = _pb::internal;
PROTOBUF_NAMESPACE_OPEN
constexpr Duration::Duration(
PROTOBUF_CONSTEXPR Duration::Duration(
::_pbi::ConstantInitialized)
: seconds_(int64_t{0})
, nanos_(0){}
struct DurationDefaultTypeInternal {
constexpr DurationDefaultTypeInternal()
PROTOBUF_CONSTEXPR DurationDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~DurationDefaultTypeInternal() {}
union {

View File

@ -61,7 +61,7 @@ class PROTOBUF_EXPORT Duration final :
public:
inline Duration() : Duration(nullptr) {}
~Duration() override;
explicit constexpr Duration(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Duration(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Duration(const Duration& from);
Duration(Duration&& from) noexcept

View File

@ -21,10 +21,10 @@ namespace _pb = ::PROTOBUF_NAMESPACE_ID;
namespace _pbi = _pb::internal;
PROTOBUF_NAMESPACE_OPEN
constexpr Empty::Empty(
PROTOBUF_CONSTEXPR Empty::Empty(
::_pbi::ConstantInitialized){}
struct EmptyDefaultTypeInternal {
constexpr EmptyDefaultTypeInternal()
PROTOBUF_CONSTEXPR EmptyDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~EmptyDefaultTypeInternal() {}
union {

View File

@ -61,7 +61,7 @@ class PROTOBUF_EXPORT Empty final :
public ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase /* @@protoc_insertion_point(class_definition:google.protobuf.Empty) */ {
public:
inline Empty() : Empty(nullptr) {}
explicit constexpr Empty(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Empty(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Empty(const Empty& from);
Empty(Empty&& from) noexcept

View File

@ -21,11 +21,11 @@ namespace _pb = ::PROTOBUF_NAMESPACE_ID;
namespace _pbi = _pb::internal;
PROTOBUF_NAMESPACE_OPEN
constexpr FieldMask::FieldMask(
PROTOBUF_CONSTEXPR FieldMask::FieldMask(
::_pbi::ConstantInitialized)
: paths_(){}
struct FieldMaskDefaultTypeInternal {
constexpr FieldMaskDefaultTypeInternal()
PROTOBUF_CONSTEXPR FieldMaskDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~FieldMaskDefaultTypeInternal() {}
union {

View File

@ -61,7 +61,7 @@ class PROTOBUF_EXPORT FieldMask final :
public:
inline FieldMask() : FieldMask(nullptr) {}
~FieldMask() override;
explicit constexpr FieldMask(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR FieldMask(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
FieldMask(const FieldMask& from);
FieldMask(FieldMask&& from) noexcept

View File

@ -483,6 +483,10 @@ class PROTOBUF_EXPORT TcParser final {
template <typename FieldType, typename TagType, bool zigzag = false>
static inline const char* PackedVarint(PROTOBUF_TC_PARAM_DECL);
// Helper for ints > 127:
template <typename FieldType, typename TagType, bool zigzag = false>
static const char* SingularVarBigint(PROTOBUF_TC_PARAM_DECL);
// Implementations for fast enum field parsing functions:
template <typename TagType, uint16_t xform_val>
static inline const char* SingularEnum(PROTOBUF_TC_PARAM_DECL);

View File

@ -212,7 +212,9 @@ const TcParseTableBase::FieldEntry* TcParser::FindFieldEntry(
skipmap &= skipmap - 1;
}
#endif
return field_entries + adj_fnum;
auto* entry = field_entries + adj_fnum;
PROTOBUF_ASSUME(entry != nullptr);
return entry;
}
const uint16_t* lookup_table = table->field_lookup_begin();
for (;;) {
@ -247,7 +249,9 @@ const TcParseTableBase::FieldEntry* TcParser::FindFieldEntry(
skipmap &= skipmap - 1;
}
#endif
return field_entries + adj_fnum;
auto* entry = field_entries + adj_fnum;
PROTOBUF_ASSUME(entry != nullptr);
return entry;
}
lookup_table +=
num_skip_entries * (sizeof(SkipEntry16) / sizeof(*lookup_table));
@ -736,9 +740,46 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularVarint(
}
ptr += sizeof(TagType); // Consume tag
hasbits |= (uint64_t{1} << data.hasbit_idx());
// clang isn't smart enough to be able to only conditionally save
// registers to the stack, so we turn the integer-greater-than-128
// case into a separate routine.
if (PROTOBUF_PREDICT_FALSE(static_cast<int8_t>(*ptr) < 0)) {
PROTOBUF_MUSTTAIL return SingularVarBigint<FieldType, TagType, zigzag>(
PROTOBUF_TC_PARAM_PASS);
}
RefAt<FieldType>(msg, data.offset()) =
ZigZagDecodeHelper<FieldType, zigzag>(static_cast<uint8_t>(*ptr++));
PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
}
template <typename FieldType, typename TagType, bool zigzag>
PROTOBUF_NOINLINE const char* TcParser::SingularVarBigint(
PROTOBUF_TC_PARAM_DECL) {
// For some reason clang wants to save 5 registers to the stack here,
// but we only need four for this code, so save the data we don't need
// to the stack. Happily, saving them this way uses regular store
// instructions rather than PUSH/POP, which saves time at the cost of greater
// code size, but for this heavily-used piece of code, that's fine.
struct Spill {
uint64_t field_data;
::google::protobuf::MessageLite* msg;
const ::google::protobuf::internal::TcParseTableBase* table;
uint64_t hasbits;
};
volatile Spill spill = {data.data, msg, table, hasbits};
uint64_t tmp;
PROTOBUF_ASSUME(static_cast<int8_t>(*ptr) < 0);
ptr = ParseVarint(ptr, &tmp);
if (ptr == nullptr) {
data.data = spill.field_data;
msg = spill.msg;
table = spill.table;
hasbits = spill.hasbits;
if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) {
return Error(PROTOBUF_TC_PARAM_PASS);
}
RefAt<FieldType>(msg, data.offset()) =

View File

@ -127,9 +127,6 @@
#include <google/protobuf/message_lite.h>
#define GOOGLE_PROTOBUF_HAS_ONEOF
#define GOOGLE_PROTOBUF_HAS_ARENAS
// Must be included last.
#include <google/protobuf/port_def.inc>

View File

@ -598,6 +598,7 @@
#endif
#if defined(__cpp_constinit)
#define PROTOBUF_CONSTINIT constinit
#define PROTOBUF_CONSTEXPR constexpr
// Some older Clang versions incorrectly raise an error about
// constant-initializing weak default instance pointers. Versions 12.0 and
// higher seem to work, except that XCode 12.5.1 shows the error even though it
@ -606,10 +607,13 @@
((defined(__APPLE__) && __clang_major__ >= 13) || \
(!defined(__APPLE__) && __clang_major__ >= 12))
#define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]]
#define PROTOBUF_CONSTEXPR constexpr
#elif PROTOBUF_GNUC_MIN(12, 0)
#define PROTOBUF_CONSTINIT __constinit
#define PROTOBUF_CONSTEXPR constexpr
#else
#define PROTOBUF_CONSTINIT
#define PROTOBUF_CONSTEXPR inline
#endif
// Some globals with an empty non-trivial destructor are annotated with

View File

@ -80,6 +80,7 @@
#undef PROTOBUF_THREAD_LOCAL
#undef PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT
#undef PROTOBUF_CONSTINIT
#undef PROTOBUF_CONSTEXPR
#undef PROTOBUF_ATTRIBUTE_WEAK
#undef PROTOBUF_HAVE_ATTRIBUTE_WEAK
#undef PROTOBUF_ATTRIBUTE_NO_DESTROY

View File

@ -626,15 +626,15 @@ inline Element* RepeatedField<Element>::AddAlreadyReserved() {
}
template <typename Element>
inline Element* RepeatedField<Element>::AddNAlreadyReserved(int n) {
GOOGLE_DCHECK_GE(total_size_ - current_size_, n)
inline Element* RepeatedField<Element>::AddNAlreadyReserved(int elements) {
GOOGLE_DCHECK_GE(total_size_ - current_size_, elements)
<< total_size_ << ", " << current_size_;
// Warning: sometimes people call this when n == 0 and total_size_ == 0. In
// this case the return pointer points to a zero size array (n == 0). Hence
// we can just use unsafe_elements(), because the user cannot dereference the
// pointer anyway.
// Warning: sometimes people call this when elements == 0 and
// total_size_ == 0. In this case the return pointer points to a zero size
// array (n == 0). Hence we can just use unsafe_elements(), because the user
// cannot dereference the pointer anyway.
Element* ret = unsafe_elements() + current_size_;
current_size_ += n;
current_size_ += elements;
return ret;
}
@ -847,6 +847,7 @@ void RepeatedField<Element>::Swap(RepeatedField* other) {
template <typename Element>
void RepeatedField<Element>::UnsafeArenaSwap(RepeatedField* other) {
if (this == other) return;
GOOGLE_DCHECK_EQ(GetArena(), other->GetArena());
InternalSwap(other);
}
@ -1142,7 +1143,6 @@ class RepeatedIterator {
friend class RepeatedIterator;
// Allow construction from RepeatedField.
friend class RepeatedField<Element>; // TODO(b/218695758) Remove this.
friend class RepeatedField<value_type>;
explicit RepeatedIterator(Element* it) noexcept : it_(it) {}

View File

@ -848,6 +848,7 @@ class StringTypeHandler {
// Messages.
template <typename Element>
class RepeatedPtrField final : private internal::RepeatedPtrFieldBase {
public:
constexpr RepeatedPtrField();
explicit RepeatedPtrField(Arena* arena);
@ -1429,6 +1430,7 @@ template <typename Element>
inline void RepeatedPtrField<Element>::UnsafeArenaSwap(
RepeatedPtrField* other) {
if (this == other) return;
GOOGLE_DCHECK_EQ(GetArena(), other->GetArena());
RepeatedPtrFieldBase::InternalSwap(other);
}

View File

@ -21,11 +21,11 @@ namespace _pb = ::PROTOBUF_NAMESPACE_ID;
namespace _pbi = _pb::internal;
PROTOBUF_NAMESPACE_OPEN
constexpr SourceContext::SourceContext(
PROTOBUF_CONSTEXPR SourceContext::SourceContext(
::_pbi::ConstantInitialized)
: file_name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}){}
struct SourceContextDefaultTypeInternal {
constexpr SourceContextDefaultTypeInternal()
PROTOBUF_CONSTEXPR SourceContextDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~SourceContextDefaultTypeInternal() {}
union {

View File

@ -61,7 +61,7 @@ class PROTOBUF_EXPORT SourceContext final :
public:
inline SourceContext() : SourceContext(nullptr) {}
~SourceContext() override;
explicit constexpr SourceContext(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR SourceContext(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
SourceContext(const SourceContext& from);
SourceContext(SourceContext&& from) noexcept

View File

@ -21,10 +21,10 @@ namespace _pb = ::PROTOBUF_NAMESPACE_ID;
namespace _pbi = _pb::internal;
PROTOBUF_NAMESPACE_OPEN
constexpr Struct_FieldsEntry_DoNotUse::Struct_FieldsEntry_DoNotUse(
PROTOBUF_CONSTEXPR Struct_FieldsEntry_DoNotUse::Struct_FieldsEntry_DoNotUse(
::_pbi::ConstantInitialized){}
struct Struct_FieldsEntry_DoNotUseDefaultTypeInternal {
constexpr Struct_FieldsEntry_DoNotUseDefaultTypeInternal()
PROTOBUF_CONSTEXPR Struct_FieldsEntry_DoNotUseDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~Struct_FieldsEntry_DoNotUseDefaultTypeInternal() {}
union {
@ -32,11 +32,11 @@ struct Struct_FieldsEntry_DoNotUseDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Struct_FieldsEntry_DoNotUseDefaultTypeInternal _Struct_FieldsEntry_DoNotUse_default_instance_;
constexpr Struct::Struct(
PROTOBUF_CONSTEXPR Struct::Struct(
::_pbi::ConstantInitialized)
: fields_(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}){}
struct StructDefaultTypeInternal {
constexpr StructDefaultTypeInternal()
PROTOBUF_CONSTEXPR StructDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~StructDefaultTypeInternal() {}
union {
@ -44,11 +44,11 @@ struct StructDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 StructDefaultTypeInternal _Struct_default_instance_;
constexpr Value::Value(
PROTOBUF_CONSTEXPR Value::Value(
::_pbi::ConstantInitialized)
: _oneof_case_{}{}
struct ValueDefaultTypeInternal {
constexpr ValueDefaultTypeInternal()
PROTOBUF_CONSTEXPR ValueDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~ValueDefaultTypeInternal() {}
union {
@ -56,11 +56,11 @@ struct ValueDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ValueDefaultTypeInternal _Value_default_instance_;
constexpr ListValue::ListValue(
PROTOBUF_CONSTEXPR ListValue::ListValue(
::_pbi::ConstantInitialized)
: values_(){}
struct ListValueDefaultTypeInternal {
constexpr ListValueDefaultTypeInternal()
PROTOBUF_CONSTEXPR ListValueDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~ListValueDefaultTypeInternal() {}
union {

View File

@ -106,7 +106,7 @@ public:
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING,
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE> SuperType;
Struct_FieldsEntry_DoNotUse();
explicit constexpr Struct_FieldsEntry_DoNotUse(
explicit PROTOBUF_CONSTEXPR Struct_FieldsEntry_DoNotUse(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit Struct_FieldsEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void MergeFrom(const Struct_FieldsEntry_DoNotUse& other);
@ -127,7 +127,7 @@ class PROTOBUF_EXPORT Struct final :
public:
inline Struct() : Struct(nullptr) {}
~Struct() override;
explicit constexpr Struct(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Struct(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Struct(const Struct& from);
Struct(Struct&& from) noexcept
@ -285,7 +285,7 @@ class PROTOBUF_EXPORT Value final :
public:
inline Value() : Value(nullptr) {}
~Value() override;
explicit constexpr Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Value(const Value& from);
Value(Value&& from) noexcept
@ -549,7 +549,7 @@ class PROTOBUF_EXPORT ListValue final :
public:
inline ListValue() : ListValue(nullptr) {}
~ListValue() override;
explicit constexpr ListValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR ListValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
ListValue(const ListValue& from);
ListValue(ListValue&& from) noexcept

View File

@ -21,12 +21,12 @@ namespace _pb = ::PROTOBUF_NAMESPACE_ID;
namespace _pbi = _pb::internal;
PROTOBUF_NAMESPACE_OPEN
constexpr Timestamp::Timestamp(
PROTOBUF_CONSTEXPR Timestamp::Timestamp(
::_pbi::ConstantInitialized)
: seconds_(int64_t{0})
, nanos_(0){}
struct TimestampDefaultTypeInternal {
constexpr TimestampDefaultTypeInternal()
PROTOBUF_CONSTEXPR TimestampDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~TimestampDefaultTypeInternal() {}
union {

View File

@ -61,7 +61,7 @@ class PROTOBUF_EXPORT Timestamp final :
public:
inline Timestamp() : Timestamp(nullptr) {}
~Timestamp() override;
explicit constexpr Timestamp(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Timestamp(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Timestamp(const Timestamp& from);
Timestamp(Timestamp&& from) noexcept

View File

@ -21,7 +21,7 @@ namespace _pb = ::PROTOBUF_NAMESPACE_ID;
namespace _pbi = _pb::internal;
PROTOBUF_NAMESPACE_OPEN
constexpr Type::Type(
PROTOBUF_CONSTEXPR Type::Type(
::_pbi::ConstantInitialized)
: fields_()
, oneofs_()
@ -31,7 +31,7 @@ constexpr Type::Type(
, syntax_(0)
{}
struct TypeDefaultTypeInternal {
constexpr TypeDefaultTypeInternal()
PROTOBUF_CONSTEXPR TypeDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~TypeDefaultTypeInternal() {}
union {
@ -39,7 +39,7 @@ struct TypeDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 TypeDefaultTypeInternal _Type_default_instance_;
constexpr Field::Field(
PROTOBUF_CONSTEXPR Field::Field(
::_pbi::ConstantInitialized)
: options_()
, name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
@ -54,7 +54,7 @@ constexpr Field::Field(
, oneof_index_(0)
, packed_(false){}
struct FieldDefaultTypeInternal {
constexpr FieldDefaultTypeInternal()
PROTOBUF_CONSTEXPR FieldDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~FieldDefaultTypeInternal() {}
union {
@ -62,7 +62,7 @@ struct FieldDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldDefaultTypeInternal _Field_default_instance_;
constexpr Enum::Enum(
PROTOBUF_CONSTEXPR Enum::Enum(
::_pbi::ConstantInitialized)
: enumvalue_()
, options_()
@ -71,7 +71,7 @@ constexpr Enum::Enum(
, syntax_(0)
{}
struct EnumDefaultTypeInternal {
constexpr EnumDefaultTypeInternal()
PROTOBUF_CONSTEXPR EnumDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~EnumDefaultTypeInternal() {}
union {
@ -79,13 +79,13 @@ struct EnumDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDefaultTypeInternal _Enum_default_instance_;
constexpr EnumValue::EnumValue(
PROTOBUF_CONSTEXPR EnumValue::EnumValue(
::_pbi::ConstantInitialized)
: options_()
, name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, number_(0){}
struct EnumValueDefaultTypeInternal {
constexpr EnumValueDefaultTypeInternal()
PROTOBUF_CONSTEXPR EnumValueDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~EnumValueDefaultTypeInternal() {}
union {
@ -93,12 +93,12 @@ struct EnumValueDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueDefaultTypeInternal _EnumValue_default_instance_;
constexpr Option::Option(
PROTOBUF_CONSTEXPR Option::Option(
::_pbi::ConstantInitialized)
: name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
, value_(nullptr){}
struct OptionDefaultTypeInternal {
constexpr OptionDefaultTypeInternal()
PROTOBUF_CONSTEXPR OptionDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~OptionDefaultTypeInternal() {}
union {

View File

@ -174,7 +174,7 @@ class PROTOBUF_EXPORT Type final :
public:
inline Type() : Type(nullptr) {}
~Type() override;
explicit constexpr Type(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Type(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Type(const Type& from);
Type(Type&& from) noexcept
@ -419,7 +419,7 @@ class PROTOBUF_EXPORT Field final :
public:
inline Field() : Field(nullptr) {}
~Field() override;
explicit constexpr Field(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Field(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Field(const Field& from);
Field(Field&& from) noexcept
@ -788,7 +788,7 @@ class PROTOBUF_EXPORT Enum final :
public:
inline Enum() : Enum(nullptr) {}
~Enum() override;
explicit constexpr Enum(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Enum(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Enum(const Enum& from);
Enum(Enum&& from) noexcept
@ -1007,7 +1007,7 @@ class PROTOBUF_EXPORT EnumValue final :
public:
inline EnumValue() : EnumValue(nullptr) {}
~EnumValue() override;
explicit constexpr EnumValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR EnumValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
EnumValue(const EnumValue& from);
EnumValue(EnumValue&& from) noexcept
@ -1186,7 +1186,7 @@ class PROTOBUF_EXPORT Option final :
public:
inline Option() : Option(nullptr) {}
~Option() override;
explicit constexpr Option(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Option(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Option(const Option& from);
Option(Option&& from) noexcept

View File

@ -558,8 +558,12 @@ message TestLazyMessage {
optional TestAllTypes sub_message = 1 [lazy=true];
}
message TestEagerMaybeLazy {
message NestedMessage {
optional TestPackedTypes packed = 1;
}
optional TestAllTypes message_foo = 1;
optional TestAllTypes message_bar = 2;
optional NestedMessage message_baz = 3;
}
// Needed for a Python test.
message TestNestedMessageHasBits {

View File

@ -32,8 +32,8 @@
#include <cstdint>
#include <google/protobuf/message.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/message.h>
#include <google/protobuf/stubs/map_util.h>
// Must be included last.

View File

@ -37,8 +37,8 @@
#include <string>
#include <google/protobuf/field_mask.pb.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/descriptor.h>
// Must be included last.
#include <google/protobuf/port_def.inc>

View File

@ -32,8 +32,8 @@
#include <google/protobuf/util/internal/expecting_objectwriter.h>
#include <google/protobuf/util/internal/testdata/default_value_test.pb.h>
#include <google/protobuf/util/internal/type_info_test_helper.h>
#include <google/protobuf/util/internal/constants.h>
#include <google/protobuf/util/internal/type_info_test_helper.h>
#include <gtest/gtest.h>
namespace google {

View File

@ -41,8 +41,8 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/status.h>
#include <google/protobuf/util/internal/json_escaping.h>
#include <google/protobuf/util/internal/object_writer.h>
#include <google/protobuf/util/internal/json_escaping.h>
namespace google {

View File

@ -35,9 +35,9 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/util/internal/expecting_objectwriter.h>
#include <google/protobuf/util/internal/object_writer.h>
#include <gtest/gtest.h>
#include <google/protobuf/stubs/time.h>
#include <google/protobuf/util/internal/object_writer.h>
#include <google/protobuf/stubs/status.h>

View File

@ -34,8 +34,8 @@
#include <cstdint>
#include <deque>
#include <string>
#include <vector>
#include <unordered_set>
#include <vector>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/type.pb.h>

View File

@ -46,11 +46,11 @@
#include <google/protobuf/util/internal/testdata/proto3.pb.h>
#include <google/protobuf/util/internal/testdata/struct.pb.h>
#include <google/protobuf/util/internal/testdata/timestamp_duration.pb.h>
#include <google/protobuf/util/internal/type_info_test_helper.h>
#include <google/protobuf/util/internal/constants.h>
#include <gtest/gtest.h>
#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/stubs/status.h>
#include <google/protobuf/util/internal/constants.h>
#include <google/protobuf/util/internal/type_info_test_helper.h>
namespace google {

View File

@ -57,9 +57,9 @@ namespace protobuf {
namespace util {
namespace converter {
using util::Status;
using ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite;
using std::placeholders::_1;
using util::Status;
ProtoStreamObjectWriter::ProtoStreamObjectWriter(

View File

@ -38,8 +38,6 @@
#include <google/protobuf/wrappers.pb.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/message.h>
#include <google/protobuf/util/internal/mock_error_listener.h>
#include <google/protobuf/util/internal/testdata/anys.pb.h>
@ -51,13 +49,15 @@
#include <google/protobuf/util/internal/testdata/struct.pb.h>
#include <google/protobuf/util/internal/testdata/timestamp_duration.pb.h>
#include <google/protobuf/util/internal/testdata/wrappers.pb.h>
#include <google/protobuf/util/internal/type_info_test_helper.h>
#include <google/protobuf/util/internal/constants.h>
#include <google/protobuf/util/message_differencer.h>
#include <google/protobuf/util/type_resolver_util.h>
#include <google/protobuf/stubs/bytestream.h>
#include <google/protobuf/stubs/strutil.h>
#include <gtest/gtest.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/util/internal/constants.h>
#include <google/protobuf/util/internal/type_info_test_helper.h>
#include <google/protobuf/util/message_differencer.h>
#include <google/protobuf/util/type_resolver_util.h>
namespace google {

View File

@ -36,11 +36,11 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/util/internal/default_value_objectwriter.h>
#include <google/protobuf/util/internal/type_info.h>
#include <google/protobuf/util/internal/constants.h>
#include <google/protobuf/util/internal/default_value_objectwriter.h>
#include <google/protobuf/util/internal/protostream_objectsource.h>
#include <google/protobuf/util/internal/protostream_objectwriter.h>
#include <google/protobuf/util/internal/type_info.h>
#include <google/protobuf/util/type_resolver.h>
#include <google/protobuf/util/type_resolver_util.h>

View File

@ -28,8 +28,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_TEST_HELPER_H__
#define GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_TEST_HELPER_H__
#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_TYPE_INFO_TEST_HELPER_H__
#define GOOGLE_PROTOBUF_UTIL_INTERNAL_TYPE_INFO_TEST_HELPER_H__
#include <memory>
#include <vector>
@ -37,9 +37,9 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/util/internal/default_value_objectwriter.h>
#include <google/protobuf/util/internal/type_info.h>
#include <google/protobuf/util/internal/protostream_objectsource.h>
#include <google/protobuf/util/internal/protostream_objectwriter.h>
#include <google/protobuf/util/internal/type_info.h>
#include <google/protobuf/util/type_resolver.h>
namespace google {
@ -93,4 +93,4 @@ class TypeInfoTestHelper {
} // namespace protobuf
} // namespace google
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_TEST_HELPER_H__
#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_TYPE_INFO_TEST_HELPER_H__

View File

@ -66,6 +66,26 @@ namespace protobuf {
namespace util {
namespace {
std::string PrintShortTextFormat(const google::protobuf::Message& message) {
std::string debug_string;
google::protobuf::TextFormat::Printer printer;
printer.SetSingleLineMode(true);
printer.SetExpandAny(true);
printer.PrintToString(message, &debug_string);
// Single line mode currently might have an extra space at the end.
if (!debug_string.empty() && debug_string[debug_string.size() - 1] == ' ') {
debug_string.resize(debug_string.size() - 1);
}
return debug_string;
}
} // namespace
// A reporter to report the total number of diffs.
// TODO(ykzhu): we can improve this to take into account the value differencers.
class NumDiffsReporter : public google::protobuf::util::MessageDifferencer::Reporter {
@ -2012,14 +2032,13 @@ void MessageDifferencer::StreamReporter::PrintValue(
if (field->is_map() && message1_ != nullptr && message2_ != nullptr) {
fd = field_message.GetDescriptor()->field(1);
if (fd->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
output = field_message.GetReflection()
->GetMessage(field_message, fd)
.ShortDebugString();
output = PrintShortTextFormat(
field_message.GetReflection()->GetMessage(field_message, fd));
} else {
TextFormat::PrintFieldValueToString(field_message, fd, -1, &output);
}
} else {
output = field_message.ShortDebugString();
output = PrintShortTextFormat(field_message);
}
if (output.empty()) {
printer_->Print("{ }");

View File

@ -21,11 +21,11 @@ namespace _pb = ::PROTOBUF_NAMESPACE_ID;
namespace _pbi = _pb::internal;
PROTOBUF_NAMESPACE_OPEN
constexpr DoubleValue::DoubleValue(
PROTOBUF_CONSTEXPR DoubleValue::DoubleValue(
::_pbi::ConstantInitialized)
: value_(0){}
struct DoubleValueDefaultTypeInternal {
constexpr DoubleValueDefaultTypeInternal()
PROTOBUF_CONSTEXPR DoubleValueDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~DoubleValueDefaultTypeInternal() {}
union {
@ -33,11 +33,11 @@ struct DoubleValueDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DoubleValueDefaultTypeInternal _DoubleValue_default_instance_;
constexpr FloatValue::FloatValue(
PROTOBUF_CONSTEXPR FloatValue::FloatValue(
::_pbi::ConstantInitialized)
: value_(0){}
struct FloatValueDefaultTypeInternal {
constexpr FloatValueDefaultTypeInternal()
PROTOBUF_CONSTEXPR FloatValueDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~FloatValueDefaultTypeInternal() {}
union {
@ -45,11 +45,11 @@ struct FloatValueDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FloatValueDefaultTypeInternal _FloatValue_default_instance_;
constexpr Int64Value::Int64Value(
PROTOBUF_CONSTEXPR Int64Value::Int64Value(
::_pbi::ConstantInitialized)
: value_(int64_t{0}){}
struct Int64ValueDefaultTypeInternal {
constexpr Int64ValueDefaultTypeInternal()
PROTOBUF_CONSTEXPR Int64ValueDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~Int64ValueDefaultTypeInternal() {}
union {
@ -57,11 +57,11 @@ struct Int64ValueDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Int64ValueDefaultTypeInternal _Int64Value_default_instance_;
constexpr UInt64Value::UInt64Value(
PROTOBUF_CONSTEXPR UInt64Value::UInt64Value(
::_pbi::ConstantInitialized)
: value_(uint64_t{0u}){}
struct UInt64ValueDefaultTypeInternal {
constexpr UInt64ValueDefaultTypeInternal()
PROTOBUF_CONSTEXPR UInt64ValueDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~UInt64ValueDefaultTypeInternal() {}
union {
@ -69,11 +69,11 @@ struct UInt64ValueDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_;
constexpr Int32Value::Int32Value(
PROTOBUF_CONSTEXPR Int32Value::Int32Value(
::_pbi::ConstantInitialized)
: value_(0){}
struct Int32ValueDefaultTypeInternal {
constexpr Int32ValueDefaultTypeInternal()
PROTOBUF_CONSTEXPR Int32ValueDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~Int32ValueDefaultTypeInternal() {}
union {
@ -81,11 +81,11 @@ struct Int32ValueDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Int32ValueDefaultTypeInternal _Int32Value_default_instance_;
constexpr UInt32Value::UInt32Value(
PROTOBUF_CONSTEXPR UInt32Value::UInt32Value(
::_pbi::ConstantInitialized)
: value_(0u){}
struct UInt32ValueDefaultTypeInternal {
constexpr UInt32ValueDefaultTypeInternal()
PROTOBUF_CONSTEXPR UInt32ValueDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~UInt32ValueDefaultTypeInternal() {}
union {
@ -93,11 +93,11 @@ struct UInt32ValueDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_;
constexpr BoolValue::BoolValue(
PROTOBUF_CONSTEXPR BoolValue::BoolValue(
::_pbi::ConstantInitialized)
: value_(false){}
struct BoolValueDefaultTypeInternal {
constexpr BoolValueDefaultTypeInternal()
PROTOBUF_CONSTEXPR BoolValueDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~BoolValueDefaultTypeInternal() {}
union {
@ -105,11 +105,11 @@ struct BoolValueDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 BoolValueDefaultTypeInternal _BoolValue_default_instance_;
constexpr StringValue::StringValue(
PROTOBUF_CONSTEXPR StringValue::StringValue(
::_pbi::ConstantInitialized)
: value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}){}
struct StringValueDefaultTypeInternal {
constexpr StringValueDefaultTypeInternal()
PROTOBUF_CONSTEXPR StringValueDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~StringValueDefaultTypeInternal() {}
union {
@ -117,11 +117,11 @@ struct StringValueDefaultTypeInternal {
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 StringValueDefaultTypeInternal _StringValue_default_instance_;
constexpr BytesValue::BytesValue(
PROTOBUF_CONSTEXPR BytesValue::BytesValue(
::_pbi::ConstantInitialized)
: value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}){}
struct BytesValueDefaultTypeInternal {
constexpr BytesValueDefaultTypeInternal()
PROTOBUF_CONSTEXPR BytesValueDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
~BytesValueDefaultTypeInternal() {}
union {

View File

@ -93,7 +93,7 @@ class PROTOBUF_EXPORT DoubleValue final :
public:
inline DoubleValue() : DoubleValue(nullptr) {}
~DoubleValue() override;
explicit constexpr DoubleValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR DoubleValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
DoubleValue(const DoubleValue& from);
DoubleValue(DoubleValue&& from) noexcept
@ -236,7 +236,7 @@ class PROTOBUF_EXPORT FloatValue final :
public:
inline FloatValue() : FloatValue(nullptr) {}
~FloatValue() override;
explicit constexpr FloatValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR FloatValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
FloatValue(const FloatValue& from);
FloatValue(FloatValue&& from) noexcept
@ -379,7 +379,7 @@ class PROTOBUF_EXPORT Int64Value final :
public:
inline Int64Value() : Int64Value(nullptr) {}
~Int64Value() override;
explicit constexpr Int64Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Int64Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Int64Value(const Int64Value& from);
Int64Value(Int64Value&& from) noexcept
@ -522,7 +522,7 @@ class PROTOBUF_EXPORT UInt64Value final :
public:
inline UInt64Value() : UInt64Value(nullptr) {}
~UInt64Value() override;
explicit constexpr UInt64Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR UInt64Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
UInt64Value(const UInt64Value& from);
UInt64Value(UInt64Value&& from) noexcept
@ -665,7 +665,7 @@ class PROTOBUF_EXPORT Int32Value final :
public:
inline Int32Value() : Int32Value(nullptr) {}
~Int32Value() override;
explicit constexpr Int32Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR Int32Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
Int32Value(const Int32Value& from);
Int32Value(Int32Value&& from) noexcept
@ -808,7 +808,7 @@ class PROTOBUF_EXPORT UInt32Value final :
public:
inline UInt32Value() : UInt32Value(nullptr) {}
~UInt32Value() override;
explicit constexpr UInt32Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR UInt32Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
UInt32Value(const UInt32Value& from);
UInt32Value(UInt32Value&& from) noexcept
@ -951,7 +951,7 @@ class PROTOBUF_EXPORT BoolValue final :
public:
inline BoolValue() : BoolValue(nullptr) {}
~BoolValue() override;
explicit constexpr BoolValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR BoolValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
BoolValue(const BoolValue& from);
BoolValue(BoolValue&& from) noexcept
@ -1094,7 +1094,7 @@ class PROTOBUF_EXPORT StringValue final :
public:
inline StringValue() : StringValue(nullptr) {}
~StringValue() override;
explicit constexpr StringValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR StringValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
StringValue(const StringValue& from);
StringValue(StringValue&& from) noexcept
@ -1242,7 +1242,7 @@ class PROTOBUF_EXPORT BytesValue final :
public:
inline BytesValue() : BytesValue(nullptr) {}
~BytesValue() override;
explicit constexpr BytesValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit PROTOBUF_CONSTEXPR BytesValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
BytesValue(const BytesValue& from);
BytesValue(BytesValue&& from) noexcept