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

pull/9570/head
Adam Cozzette 3 years ago
commit 0ece18cf2e
  1. 1
      cmake/libprotobuf.cmake
  2. 46
      java/core/src/main/java/com/google/protobuf/TextFormat.java
  3. 1
      java/core/src/test/java/com/google/protobuf/CodedOutputStreamTest.java
  4. 272
      java/core/src/test/java/com/google/protobuf/ServiceTest.java
  5. 1
      java/core/src/test/java/com/google/protobuf/TextFormatTest.java
  6. 4
      java/kotlin/src/test/kotlin/com/google/protobuf/Proto3Test.kt
  7. 2
      python/google/protobuf/pyext/message.cc
  8. 8
      src/Makefile.am
  9. 4
      src/google/protobuf/any.pb.cc
  10. 2
      src/google/protobuf/any.pb.h
  11. 12
      src/google/protobuf/api.pb.cc
  12. 6
      src/google/protobuf/api.pb.h
  13. 4
      src/google/protobuf/arenastring.cc
  14. 11
      src/google/protobuf/compiler/cpp/cpp_enum_field.cc
  15. 1
      src/google/protobuf/compiler/cpp/cpp_extension.cc
  16. 18
      src/google/protobuf/compiler/cpp/cpp_field.cc
  17. 2
      src/google/protobuf/compiler/cpp/cpp_file.cc
  18. 12
      src/google/protobuf/compiler/cpp/cpp_helpers.cc
  19. 26
      src/google/protobuf/compiler/cpp/cpp_helpers.h
  20. 208
      src/google/protobuf/compiler/cpp/cpp_message.cc
  21. 1
      src/google/protobuf/compiler/cpp/cpp_options.h
  22. 11
      src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc
  23. 11
      src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
  24. 4
      src/google/protobuf/compiler/cpp/cpp_string_field.cc
  25. 3
      src/google/protobuf/compiler/java/java_message.cc
  26. 3
      src/google/protobuf/compiler/java/java_message_lite.cc
  27. 5
      src/google/protobuf/compiler/parser.cc
  28. 3
      src/google/protobuf/compiler/parser.h
  29. 16
      src/google/protobuf/compiler/plugin.pb.cc
  30. 8
      src/google/protobuf/compiler/plugin.pb.h
  31. 356
      src/google/protobuf/descriptor.cc
  32. 108
      src/google/protobuf/descriptor.pb.cc
  33. 54
      src/google/protobuf/descriptor.pb.h
  34. 4
      src/google/protobuf/duration.pb.cc
  35. 2
      src/google/protobuf/duration.pb.h
  36. 4
      src/google/protobuf/empty.pb.cc
  37. 2
      src/google/protobuf/empty.pb.h
  38. 4
      src/google/protobuf/field_mask.pb.cc
  39. 2
      src/google/protobuf/field_mask.pb.h
  40. 4
      src/google/protobuf/generated_message_tctable_impl.h
  41. 47
      src/google/protobuf/generated_message_tctable_lite.cc
  42. 3
      src/google/protobuf/message.h
  43. 4
      src/google/protobuf/port_def.inc
  44. 1
      src/google/protobuf/port_undef.inc
  45. 16
      src/google/protobuf/repeated_field.h
  46. 2
      src/google/protobuf/repeated_ptr_field.h
  47. 4
      src/google/protobuf/source_context.pb.cc
  48. 2
      src/google/protobuf/source_context.pb.h
  49. 16
      src/google/protobuf/struct.pb.cc
  50. 8
      src/google/protobuf/struct.pb.h
  51. 4
      src/google/protobuf/timestamp.pb.cc
  52. 2
      src/google/protobuf/timestamp.pb.h
  53. 20
      src/google/protobuf/type.pb.cc
  54. 10
      src/google/protobuf/type.pb.h
  55. 4
      src/google/protobuf/unittest.proto
  56. 2
      src/google/protobuf/util/field_mask_util.cc
  57. 2
      src/google/protobuf/util/field_mask_util.h
  58. 2
      src/google/protobuf/util/internal/default_value_objectwriter_test.cc
  59. 2
      src/google/protobuf/util/internal/json_stream_parser.cc
  60. 2
      src/google/protobuf/util/internal/json_stream_parser_test.cc
  61. 2
      src/google/protobuf/util/internal/proto_writer.h
  62. 4
      src/google/protobuf/util/internal/protostream_objectsource_test.cc
  63. 2
      src/google/protobuf/util/internal/protostream_objectwriter.cc
  64. 12
      src/google/protobuf/util/internal/protostream_objectwriter_test.cc
  65. 4
      src/google/protobuf/util/internal/type_info_test_helper.cc
  66. 8
      src/google/protobuf/util/internal/type_info_test_helper.h
  67. 27
      src/google/protobuf/util/message_differencer.cc
  68. 36
      src/google/protobuf/wrappers.pb.cc
  69. 18
      src/google/protobuf/wrappers.pb.h

@ -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/delimited_message_util.h
${protobuf_source_dir}/src/google/protobuf/util/field_comparator.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/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/json_util.h
${protobuf_source_dir}/src/google/protobuf/util/message_differencer.h ${protobuf_source_dir}/src/google/protobuf/util/message_differencer.h
${protobuf_source_dir}/src/google/protobuf/util/time_util.h ${protobuf_source_dir}/src/google/protobuf/util/time_util.h

@ -59,6 +59,8 @@ public final class TextFormat {
private static final Logger logger = Logger.getLogger(TextFormat.class.getName()); 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. * 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); Pattern.compile("-?inf(inity)?f?", Pattern.CASE_INSENSITIVE);
private static final Pattern FLOAT_NAN = Pattern.compile("nanf?", 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. */ /** Construct a tokenizer that parses tokens from the given text. */
private Tokenizer(final CharSequence text) { private Tokenizer(final CharSequence text) {
this.text = text; this.text = text;
@ -969,6 +979,14 @@ public final class TextFormat {
return column; return column;
} }
boolean getContainsSilentMarkerAfterCurrentToken() {
return containsSilentMarkerAfterCurrentToken;
}
boolean getContainsSilentMarkerAfterPrevToken() {
return containsSilentMarkerAfterPrevToken;
}
/** Are we at the end of the input? */ /** Are we at the end of the input? */
public boolean atEnd() { public boolean atEnd() {
return currentToken.length() == 0; return currentToken.length() == 0;
@ -1534,6 +1552,23 @@ public final class TextFormat {
* control the parser behavior. * control the parser behavior.
*/ */
public static class Parser { 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, * 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": * 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. // start with "{" or "<" which indicates the beginning of a message body.
// If there is no ":" or there is a "{" or "<" after ":", this field has // If there is no ":" or there is a "{" or "<" after ":", this field has
// to be a message or the input is ill-formed. // to be a message or the input is ill-formed.
detectSilentMarker(tokenizer);
if (tokenizer.tryConsume(":") && !tokenizer.lookingAt("{") && !tokenizer.lookingAt("<")) { if (tokenizer.tryConsume(":") && !tokenizer.lookingAt("{") && !tokenizer.lookingAt("<")) {
skipFieldValue(tokenizer); skipFieldValue(tokenizer);
} else { } else {
@ -1900,6 +1936,7 @@ public final class TextFormat {
// Handle potential ':'. // Handle potential ':'.
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
detectSilentMarker(tokenizer);
tokenizer.tryConsume(":"); // optional tokenizer.tryConsume(":"); // optional
if (parseTreeBuilder != null) { if (parseTreeBuilder != null) {
TextFormatParseInfoTree.Builder childParseTreeBuilder = TextFormatParseInfoTree.Builder childParseTreeBuilder =
@ -1923,6 +1960,7 @@ public final class TextFormat {
unknownFields); unknownFields);
} }
} else { } else {
detectSilentMarker(tokenizer);
tokenizer.consume(":"); // required tokenizer.consume(":"); // required
consumeFieldValues( consumeFieldValues(
tokenizer, tokenizer,
@ -2184,6 +2222,7 @@ public final class TextFormat {
throw tokenizer.parseExceptionPreviousToken("Expected a valid type URL."); throw tokenizer.parseExceptionPreviousToken("Expected a valid type URL.");
} }
} }
detectSilentMarker(tokenizer);
tokenizer.tryConsume(":"); tokenizer.tryConsume(":");
final String anyEndToken; final String anyEndToken;
if (tokenizer.tryConsume("<")) { if (tokenizer.tryConsume("<")) {
@ -2220,7 +2259,7 @@ public final class TextFormat {
} }
/** Skips the next field including the field's name and value. */ /** 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("[")) { if (tokenizer.tryConsume("[")) {
// Extension name. // Extension name.
do { do {
@ -2237,6 +2276,7 @@ public final class TextFormat {
// start with "{" or "<" which indicates the beginning of a message body. // start with "{" or "<" which indicates the beginning of a message body.
// If there is no ":" or there is a "{" or "<" after ":", this field has // If there is no ":" or there is a "{" or "<" after ":", this field has
// to be a message or the input is ill-formed. // to be a message or the input is ill-formed.
detectSilentMarker(tokenizer);
if (tokenizer.tryConsume(":") && !tokenizer.lookingAt("<") && !tokenizer.lookingAt("{")) { if (tokenizer.tryConsume(":") && !tokenizer.lookingAt("<") && !tokenizer.lookingAt("{")) {
skipFieldValue(tokenizer); skipFieldValue(tokenizer);
} else { } else {
@ -2252,7 +2292,7 @@ public final class TextFormat {
/** /**
* Skips the whole body of a message including the beginning delimiter and the ending delimiter. * 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; final String delimiter;
if (tokenizer.tryConsume("<")) { if (tokenizer.tryConsume("<")) {
delimiter = ">"; delimiter = ">";
@ -2267,7 +2307,7 @@ public final class TextFormat {
} }
/** Skips a field value. */ /** Skips a field value. */
private static void skipFieldValue(Tokenizer tokenizer) throws ParseException { private void skipFieldValue(Tokenizer tokenizer) throws ParseException {
if (tokenizer.tryConsumeString()) { if (tokenizer.tryConsumeString()) {
while (tokenizer.tryConsumeString()) {} while (tokenizer.tryConsumeString()) {}
return; return;

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

@ -32,6 +32,8 @@ package com.google.protobuf;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage; 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.FileDescriptor;
import com.google.protobuf.Descriptors.MethodDescriptor; import com.google.protobuf.Descriptors.MethodDescriptor;
@ -46,145 +48,124 @@ import protobuf_unittest.UnittestProto.TestService;
import protobuf_unittest.no_generic_services_test.UnittestNoGenericServices; import protobuf_unittest.no_generic_services_test.UnittestNoGenericServices;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; 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.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
import org.mockito.InOrder;
import org.mockito.Mockito;
/** Tests services and stubs. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class ServiceTest { public class ServiceTest {
private IMocksControl control;
private RpcController mockController;
private final Descriptors.MethodDescriptor fooDescriptor = private final Descriptors.MethodDescriptor fooDescriptor =
TestService.getDescriptor().getMethods().get(0); TestService.getDescriptor().getMethods().get(0);
private final Descriptors.MethodDescriptor barDescriptor = private final Descriptors.MethodDescriptor barDescriptor =
TestService.getDescriptor().getMethods().get(1); TestService.getDescriptor().getMethods().get(1);
private static final FooRequest FOO_REQUEST = FooRequest.getDefaultInstance();
@Before private static final BarRequest BAR_REQUEST = BarRequest.getDefaultInstance();
public void setUp() throws Exception { private static final RpcController MOCK_RPC_CONTROLLER = Mockito.mock(RpcController.class);
control = EasyMock.createStrictControl(); private static final FooResponse FOO_RESPONSE = FooResponse.getDefaultInstance();
mockController = control.createMock(RpcController.class); private static final BarResponse BAR_RESPONSE = BarResponse.getDefaultInstance();
} private static final MessageWithNoOuter MESSAGE_WITH_NO_OUTER =
MessageWithNoOuter.getDefaultInstance();
// =================================================================
/** Tests Service.callMethod(). */ /** Tests Service.callMethod(). */
@Test @Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void testCallMethod() throws Exception { public void testCallMethod() throws Exception {
FooRequest fooRequest = FooRequest.newBuilder().build(); TestService mockService = Mockito.mock(TestService.class);
BarRequest barRequest = BarRequest.newBuilder().build(); RpcCallback mockFooRpcCallback = Mockito.mock(RpcCallback.class);
MockCallback<Message> fooCallback = new MockCallback<Message>(); RpcCallback mockBarRpcCallback = Mockito.mock(RpcCallback.class);
MockCallback<Message> barCallback = new MockCallback<Message>(); InOrder order = Mockito.inOrder(mockService);
TestService mockService = EasyMock.createMock(TestService.class);
mockService.callMethod(fooDescriptor, MOCK_RPC_CONTROLLER, FOO_REQUEST, mockFooRpcCallback);
mockService.foo( mockService.callMethod(barDescriptor, MOCK_RPC_CONTROLLER, BAR_REQUEST, mockBarRpcCallback);
EasyMock.same(mockController), order
EasyMock.same(fooRequest), .verify(mockService)
this.<FooResponse>wrapsCallback(fooCallback)); .foo(
mockService.bar( Mockito.same(MOCK_RPC_CONTROLLER),
EasyMock.same(mockController), Mockito.same(FOO_REQUEST),
EasyMock.same(barRequest), Mockito.same(mockFooRpcCallback));
this.<BarResponse>wrapsCallback(barCallback)); order
control.replay(); .verify(mockService)
.bar(
mockService.callMethod( Mockito.same(MOCK_RPC_CONTROLLER),
fooDescriptor, mockController, Mockito.same(BAR_REQUEST),
fooRequest, fooCallback); Mockito.same(mockBarRpcCallback));
mockService.callMethod(
barDescriptor, mockController,
barRequest, barCallback);
control.verify();
} }
/** Tests Service.get{Request,Response}Prototype(). */ /** Tests Service.get{Request,Response}Prototype(). */
@Test @Test
public void testGetPrototype() throws Exception { 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);
assertThat(mockService.getRequestPrototype(fooDescriptor)) TestService mockService = Mockito.mock(TestService.class);
.isSameInstanceAs(FooRequest.getDefaultInstance());
assertThat(mockService.getResponsePrototype(fooDescriptor)) assertThat(mockService.getRequestPrototype(fooDescriptor)).isSameInstanceAs(FOO_REQUEST);
.isSameInstanceAs(FooResponse.getDefaultInstance()); assertThat(mockService.getResponsePrototype(fooDescriptor)).isSameInstanceAs(FOO_RESPONSE);
assertThat(mockService.getRequestPrototype(barDescriptor)) assertThat(mockService.getRequestPrototype(barDescriptor)).isSameInstanceAs(BAR_REQUEST);
.isSameInstanceAs(BarRequest.getDefaultInstance()); assertThat(mockService.getResponsePrototype(barDescriptor)).isSameInstanceAs(BAR_RESPONSE);
assertThat(mockService.getResponsePrototype(barDescriptor))
.isSameInstanceAs(BarResponse.getDefaultInstance());
} }
/** Tests generated stubs. */ /** Tests generated stubs. */
@Test @Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void testStub() throws Exception { public void testStub() throws Exception {
FooRequest fooRequest = FooRequest.newBuilder().build(); RpcCallback mockFooRpcCallback = Mockito.mock(RpcCallback.class);
BarRequest barRequest = BarRequest.newBuilder().build(); RpcCallback mockBarRpcCallback = Mockito.mock(RpcCallback.class);
MockCallback<FooResponse> fooCallback = new MockCallback<FooResponse>(); RpcChannel mockRpcChannel = Mockito.mock(RpcChannel.class);
MockCallback<BarResponse> barCallback = new MockCallback<BarResponse>(); InOrder order = Mockito.inOrder(mockRpcChannel);
RpcChannel mockChannel = control.createMock(RpcChannel.class); TestService stub = TestService.newStub(mockRpcChannel);
TestService stub = TestService.newStub(mockChannel);
stub.foo(MOCK_RPC_CONTROLLER, FOO_REQUEST, mockFooRpcCallback);
mockChannel.callMethod( stub.bar(MOCK_RPC_CONTROLLER, BAR_REQUEST, mockBarRpcCallback);
EasyMock.same(fooDescriptor),
EasyMock.same(mockController), order
EasyMock.same(fooRequest), .verify(mockRpcChannel)
EasyMock.same(FooResponse.getDefaultInstance()), .callMethod(
this.<Message>wrapsCallback(fooCallback)); Mockito.same(fooDescriptor),
mockChannel.callMethod( Mockito.same(MOCK_RPC_CONTROLLER),
EasyMock.same(barDescriptor), Mockito.same(FOO_REQUEST),
EasyMock.same(mockController), Mockito.same(FOO_RESPONSE),
EasyMock.same(barRequest), Mockito.any(RpcCallback.class));
EasyMock.same(BarResponse.getDefaultInstance()), order
this.<Message>wrapsCallback(barCallback)); .verify(mockRpcChannel)
control.replay(); .callMethod(
Mockito.same(barDescriptor),
stub.foo(mockController, fooRequest, fooCallback); Mockito.same(MOCK_RPC_CONTROLLER),
stub.bar(mockController, barRequest, barCallback); Mockito.same(BAR_REQUEST),
control.verify(); Mockito.same(BAR_RESPONSE),
Mockito.any(RpcCallback.class));
} }
/** Tests generated blocking stubs. */ /** Tests generated blocking stubs. */
@Test @Test
public void testBlockingStub() throws Exception { public void testBlockingStub() throws Exception {
FooRequest fooRequest = FooRequest.newBuilder().build(); BlockingRpcChannel mockBlockingRpcChannel = Mockito.mock(BlockingRpcChannel.class);
BarRequest barRequest = BarRequest.newBuilder().build(); TestService.BlockingInterface stub = TestService.newBlockingStub(mockBlockingRpcChannel);
BlockingRpcChannel mockChannel = control.createMock(BlockingRpcChannel.class);
TestService.BlockingInterface stub = TestService.newBlockingStub(mockChannel); when(mockBlockingRpcChannel.callBlockingMethod(
Mockito.same(fooDescriptor),
FooResponse fooResponse = FooResponse.newBuilder().build(); Mockito.same(MOCK_RPC_CONTROLLER),
BarResponse barResponse = BarResponse.newBuilder().build(); Mockito.same(FOO_REQUEST),
Mockito.same(FOO_RESPONSE)))
EasyMock.expect( .thenReturn(FOO_RESPONSE);
mockChannel.callBlockingMethod( when(mockBlockingRpcChannel.callBlockingMethod(
EasyMock.same(fooDescriptor), Mockito.same(barDescriptor),
EasyMock.same(mockController), Mockito.same(MOCK_RPC_CONTROLLER),
EasyMock.same(fooRequest), Mockito.same(BAR_REQUEST),
EasyMock.same(FooResponse.getDefaultInstance()))) Mockito.same(BAR_RESPONSE)))
.andReturn(fooResponse); .thenReturn(BAR_RESPONSE);
EasyMock.expect(
mockChannel.callBlockingMethod( assertThat(FOO_RESPONSE).isSameInstanceAs(stub.foo(MOCK_RPC_CONTROLLER, FOO_REQUEST));
EasyMock.same(barDescriptor), assertThat(BAR_RESPONSE).isSameInstanceAs(stub.bar(MOCK_RPC_CONTROLLER, BAR_REQUEST));
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();
} }
@Test @Test
public void testNewReflectiveService() { public void testNewReflectiveService() {
ServiceWithNoOuter.Interface impl = control.createMock(ServiceWithNoOuter.Interface.class); ServiceWithNoOuter.Interface impl = Mockito.mock(ServiceWithNoOuter.Interface.class);
RpcController controller = control.createMock(RpcController.class);
Service service = ServiceWithNoOuter.newReflectiveService(impl); Service service = ServiceWithNoOuter.newReflectiveService(impl);
MethodDescriptor fooMethod = ServiceWithNoOuter.getDescriptor().findMethodByName("Foo"); MethodDescriptor fooMethod = ServiceWithNoOuter.getDescriptor().findMethodByName("Foo");
MessageWithNoOuter request = MessageWithNoOuter.getDefaultInstance();
RpcCallback<Message> callback = RpcCallback<Message> callback =
new RpcCallback<Message>() { new RpcCallback<Message>() {
@Override @Override
@ -195,36 +176,30 @@ public class ServiceTest {
}; };
RpcCallback<TestAllTypes> specializedCallback = RpcUtil.specializeCallback(callback); RpcCallback<TestAllTypes> specializedCallback = RpcUtil.specializeCallback(callback);
impl.foo(EasyMock.same(controller), EasyMock.same(request), EasyMock.same(specializedCallback)); service.callMethod(fooMethod, MOCK_RPC_CONTROLLER, MESSAGE_WITH_NO_OUTER, callback);
EasyMock.expectLastCall(); verify(impl)
.foo(
control.replay(); Mockito.same(MOCK_RPC_CONTROLLER),
Mockito.same(MESSAGE_WITH_NO_OUTER),
service.callMethod(fooMethod, controller, request, callback); Mockito.same(specializedCallback));
control.verify();
} }
@Test @Test
public void testNewReflectiveBlockingService() throws ServiceException { public void testNewReflectiveBlockingService() throws ServiceException {
ServiceWithNoOuter.BlockingInterface impl = ServiceWithNoOuter.BlockingInterface impl =
control.createMock(ServiceWithNoOuter.BlockingInterface.class); Mockito.mock(ServiceWithNoOuter.BlockingInterface.class);
RpcController controller = control.createMock(RpcController.class);
BlockingService service = ServiceWithNoOuter.newReflectiveBlockingService(impl); BlockingService service = ServiceWithNoOuter.newReflectiveBlockingService(impl);
MethodDescriptor fooMethod = ServiceWithNoOuter.getDescriptor().findMethodByName("Foo"); MethodDescriptor fooMethod = ServiceWithNoOuter.getDescriptor().findMethodByName("Foo");
MessageWithNoOuter request = MessageWithNoOuter.getDefaultInstance();
TestAllTypes expectedResponse = TestAllTypes.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); assertThat(response).isEqualTo(expectedResponse);
control.verify();
} }
@Test @Test
@ -243,7 +218,7 @@ public class ServiceTest {
"protobuf_unittest.no_generic_services_test.UnittestNoGenericServices"; "protobuf_unittest.no_generic_services_test.UnittestNoGenericServices";
Class<?> outerClass = Class.forName(outerName); Class<?> outerClass = Class.forName(outerName);
Set<String> innerClassNames = new HashSet<String>(); Set<String> innerClassNames = new HashSet<>();
for (Class<?> innerClass : outerClass.getClasses()) { for (Class<?> innerClass : outerClass.getClasses()) {
String fullName = innerClass.getName(); String fullName = innerClass.getName();
// Figure out the unqualified name of the inner class. // 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)");
}
}
} }

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

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

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

@ -172,6 +172,7 @@ nobase_include_HEADERS = \
google/protobuf/util/delimited_message_util.h \ google/protobuf/util/delimited_message_util.h \
google/protobuf/util/field_comparator.h \ google/protobuf/util/field_comparator.h \
google/protobuf/util/field_mask_util.h \ google/protobuf/util/field_mask_util.h \
google/protobuf/util/internal/json_escaping.h \
google/protobuf/util/json_util.h \ google/protobuf/util/json_util.h \
google/protobuf/util/message_differencer.h \ google/protobuf/util/message_differencer.h \
google/protobuf/util/time_util.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.cc \
google/protobuf/util/internal/field_mask_utility.h \ google/protobuf/util/internal/field_mask_utility.h \
google/protobuf/util/internal/json_escaping.cc \ 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.cc \
google/protobuf/util/internal/json_objectwriter.h \ google/protobuf/util/internal/json_objectwriter.h \
google/protobuf/util/internal/json_stream_parser.cc \ 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/delimited_message_util_test.cc \
google/protobuf/util/field_comparator_test.cc \ google/protobuf/util/field_comparator_test.cc \
google/protobuf/util/field_mask_util_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/json_util_test.cc \
google/protobuf/util/message_differencer_unittest.cc \ google/protobuf/util/message_differencer_unittest.cc \
google/protobuf/util/time_util_test.cc \ google/protobuf/util/time_util_test.cc \

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

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

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

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

@ -175,6 +175,10 @@ template <typename... Lazy>
std::string* ArenaStringPtr::MutableSlow(::google::protobuf::Arena* arena, std::string* ArenaStringPtr::MutableSlow(::google::protobuf::Arena* arena,
const Lazy&... lazy_default) { const Lazy&... lazy_default) {
GOOGLE_DCHECK(IsDefault()); 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()...); return NewString(arena, lazy_default.get()...);
} }

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

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

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

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

@ -229,6 +229,18 @@ void SetCommonVars(const Options& options,
(*variables)["string"] = "std::string"; (*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, void SetUnknownFieldsVariable(const Descriptor* descriptor,
const Options& options, const Options& options,
std::map<std::string, std::string>* variables) { std::map<std::string, std::string>* variables) {

@ -87,6 +87,10 @@ extern const char kThinSeparator[];
void SetCommonVars(const Options& options, void SetCommonVars(const Options& options,
std::map<std::string, std::string>* variables); 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, void SetUnknownFieldsVariable(const Descriptor* descriptor,
const Options& options, const Options& options,
std::map<std::string, std::string>* variables); std::map<std::string, std::string>* variables);
@ -362,8 +366,7 @@ inline bool IsExplicitLazy(const FieldDescriptor* field) {
inline bool IsLazilyVerifiedLazy(const FieldDescriptor* field, inline bool IsLazilyVerifiedLazy(const FieldDescriptor* field,
const Options& options) { const Options& options) {
// TODO(b/211906113): Make lazy() imply eagerly verified lazy. // TODO(b/211906113): Make lazy() imply eagerly verified lazy.
return IsExplicitLazy(field) && return IsExplicitLazy(field) && !field->is_repeated() &&
!field->is_repeated() &&
field->type() == FieldDescriptor::TYPE_MESSAGE && field->type() == FieldDescriptor::TYPE_MESSAGE &&
GetOptimizeFor(field->file(), options) != FileOptions::LITE_RUNTIME && GetOptimizeFor(field->file(), options) != FileOptions::LITE_RUNTIME &&
!options.opensource_runtime; !options.opensource_runtime;
@ -500,6 +503,25 @@ inline std::string MakeDefaultFieldName(const FieldDescriptor* field) {
return MakeDefaultName(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 FileDescriptor* descriptor, const Options& options);
bool IsAnyMessage(const Descriptor* descriptor, const Options& options); bool IsAnyMessage(const Descriptor* descriptor, const Options& options);

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

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

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

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

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

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

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

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

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

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

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

@ -143,7 +143,68 @@ struct ExpressionEater {
}; };
void Fold(std::initializer_list<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> template <typename T>
constexpr int FindTypeIndex() { constexpr int FindTypeIndex() {
@ -190,9 +251,12 @@ using PointerT = T*;
template <typename... T> template <typename... T>
class FlatAllocation { class FlatAllocation {
public: public:
static constexpr size_t kMaxAlign = Max(alignof(T)...);
FlatAllocation(const TypeMap<IntT, T...>& ends) : ends_(ends) { FlatAllocation(const TypeMap<IntT, T...>& ends) : ends_(ends) {
// The arrays start just after FlatAllocation, so adjust the 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>()...}); Fold({Init<T>()...});
} }
@ -228,38 +292,42 @@ class FlatAllocation {
constexpr int prev_type_index = type_index == 0 ? 0 : type_index - 1; constexpr int prev_type_index = type_index == 0 ? 0 : type_index - 1;
using PrevType = using PrevType =
typename std::tuple_element<prev_type_index, std::tuple<T...>>::type; 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>(); : ends_.template Get<PrevType>();
} }
template <typename U> template <typename U>
U* Begin() const { int EndOffset() const {
auto begin = BeginOffset<U>(); return ends_.template Get<U>();
}
// Avoid the reinterpret_cast if the array is empty. // Avoid the reinterpret_cast if the array is empty.
// Clang's Control Flow Integrity does not like the cast pointing to memory // Clang's Control Flow Integrity does not like the cast pointing to memory
// that is not yet initialized to be of that type. // that is not yet initialized to be of that type.
// (from -fsanitize=cfi-unrelated-cast) // (from -fsanitize=cfi-unrelated-cast)
if (begin == ends_.template Get<U>()) return nullptr; template <typename U>
U* Begin() const {
int begin = BeginOffset<U>(), end = EndOffset<U>();
if (begin == end) return nullptr;
return reinterpret_cast<U*>(data() + begin); 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> template <typename U>
size_t Size() const { U* End() const {
return static_cast<size_t>(ends_.template Get<U>() - BeginOffset<U>()) / int begin = BeginOffset<U>(), end = EndOffset<U>();
sizeof(U); if (begin == end) return nullptr;
return reinterpret_cast<U*>(data() + end);
} }
template <typename U> template <typename U>
bool Init() { bool Init() {
// Skip for the `char` block. No need to zero initialize it. // Skip for the `char` block. No need to zero initialize it.
if (std::is_same<U, char>::value) return true; if (std::is_same<U, char>::value) return true;
for (int i = 0, size = Size<U>(); i < size; ++i) { for (char *p = data() + BeginOffset<U>(), *end = data() + EndOffset<U>();
::new (data() + BeginOffset<U>() + sizeof(U) * i) U{}; p != end; p += sizeof(U)) {
::new (p) U{};
} }
return true; return true;
} }
@ -267,7 +335,7 @@ class FlatAllocation {
template <typename U> template <typename U>
bool Destroy() { bool Destroy() {
if (std::is_trivially_destructible<U>::value) return true; 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(); it->~U();
} }
return true; return true;
@ -285,7 +353,7 @@ TypeMap<IntT, T...> CalculateEnds(const TypeMap<IntT, T...>& sizes) {
int total = 0; int total = 0;
TypeMap<IntT, T...> out; TypeMap<IntT, T...> out;
Fold({(out.template Get<T>() = total += Fold({(out.template Get<T>() = total +=
RoundUp(sizeof(T) * sizes.template Get<T>()))...}); sizeof(T) * sizes.template Get<T>())...});
return out; return out;
} }
@ -302,7 +370,9 @@ class FlatAllocatorImpl {
// We can't call PlanArray after FinalizePlanning has been called. // We can't call PlanArray after FinalizePlanning has been called.
GOOGLE_CHECK(!has_allocated()); GOOGLE_CHECK(!has_allocated());
if (std::is_trivially_destructible<U>::value) { 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 { } else {
// Since we can't use `if constexpr`, just make the expression compile // Since we can't use `if constexpr`, just make the expression compile
// when this path is not taken. // when this path is not taken.
@ -324,7 +394,7 @@ class FlatAllocatorImpl {
TypeToUse*& data = pointers_.template Get<TypeToUse>(); TypeToUse*& data = pointers_.template Get<TypeToUse>();
int& used = used_.template Get<TypeToUse>(); int& used = used_.template Get<TypeToUse>();
U* res = reinterpret_cast<U*>(data + used); 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>()); GOOGLE_CHECK_LE(used, total_.template Get<TypeToUse>());
return res; return res;
} }
@ -492,29 +562,6 @@ class FlatAllocatorImpl {
} // namespace } // 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 { class Symbol {
public: public:
enum Type { enum Type {
@ -1081,9 +1128,126 @@ bool AllowedExtendeeInProto3(const std::string& name) {
return allowed_proto3_extendees->find(name) != return allowed_proto3_extendees->find(name) !=
allowed_proto3_extendees->end(); allowed_proto3_extendees->end();
} }
} // anonymous namespace } // 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 // DescriptorPool::Tables
@ -1199,7 +1363,7 @@ class DescriptorPool::Tables {
Type* Allocate(); Type* Allocate();
// Allocate some bytes which will be reclaimed when the pool is // Allocate some bytes which will be reclaimed when the pool is
// destroyed. // destroyed. Memory is aligned to 8 bytes.
void* AllocateBytes(int size); void* AllocateBytes(int size);
// Create a FlatAllocation for the corresponding sizes. // Create a FlatAllocation for the corresponding sizes.
@ -1257,100 +1421,6 @@ class DescriptorPool::Tables {
std::vector<DescriptorIntPair> extensions_after_checkpoint_; 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() { DescriptorPool::Tables::Tables() {
well_known_types_.insert({ well_known_types_.insert({
{"google.protobuf.DoubleValue", Descriptor::WELLKNOWNTYPE_DOUBLEVALUE}, {"google.protobuf.DoubleValue", Descriptor::WELLKNOWNTYPE_DOUBLEVALUE},
@ -1738,16 +1808,17 @@ bool DescriptorPool::Tables::AddExtension(const FieldDescriptor* field) {
template <typename Type> template <typename Type>
Type* DescriptorPool::Tables::Allocate() { Type* DescriptorPool::Tables::Allocate() {
static_assert(std::is_trivially_destructible<Type>::value, ""); static_assert(std::is_trivially_destructible<Type>::value, "");
static_assert(alignof(Type) <= 8, "");
return ::new (AllocateBytes(sizeof(Type))) Type{}; return ::new (AllocateBytes(sizeof(Type))) Type{};
} }
void* DescriptorPool::Tables::AllocateBytes(int size) { void* DescriptorPool::Tables::AllocateBytes(int size) {
if (size == 0) return nullptr; 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); int* sizep = static_cast<int*>(p);
misc_allocs_.emplace_back(sizep); misc_allocs_.emplace_back(sizep);
*sizep = size; *sizep = size;
return static_cast<char*>(p) + RoundUp(sizeof(int)); return static_cast<char*>(p) + RoundUpTo<8>(sizeof(int));
} }
template <typename... T> template <typename... T>
@ -1758,7 +1829,8 @@ internal::FlatAllocator::Allocation* DescriptorPool::Tables::CreateFlatAlloc(
int last_end = ends.template Get< int last_end = ends.template Get<
typename std::tuple_element<sizeof...(T) - 1, std::tuple<T...>>::type>(); 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)); char* data = static_cast<char*>(::operator new(total_size));
auto* res = ::new (data) FlatAlloc(ends); auto* res = ::new (data) FlatAlloc(ends);
flat_allocs_.emplace_back(res); flat_allocs_.emplace_back(res);

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

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

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

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

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

@ -61,7 +61,7 @@ class PROTOBUF_EXPORT Empty final :
public ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase /* @@protoc_insertion_point(class_definition:google.protobuf.Empty) */ { public ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase /* @@protoc_insertion_point(class_definition:google.protobuf.Empty) */ {
public: public:
inline Empty() : Empty(nullptr) {} 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(const Empty& from);
Empty(Empty&& from) noexcept Empty(Empty&& from) noexcept

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

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

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

@ -212,7 +212,9 @@ const TcParseTableBase::FieldEntry* TcParser::FindFieldEntry(
skipmap &= skipmap - 1; skipmap &= skipmap - 1;
} }
#endif #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(); const uint16_t* lookup_table = table->field_lookup_begin();
for (;;) { for (;;) {
@ -247,7 +249,9 @@ const TcParseTableBase::FieldEntry* TcParser::FindFieldEntry(
skipmap &= skipmap - 1; skipmap &= skipmap - 1;
} }
#endif #endif
return field_entries + adj_fnum; auto* entry = field_entries + adj_fnum;
PROTOBUF_ASSUME(entry != nullptr);
return entry;
} }
lookup_table += lookup_table +=
num_skip_entries * (sizeof(SkipEntry16) / sizeof(*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 ptr += sizeof(TagType); // Consume tag
hasbits |= (uint64_t{1} << data.hasbit_idx()); 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; uint64_t tmp;
PROTOBUF_ASSUME(static_cast<int8_t>(*ptr) < 0);
ptr = ParseVarint(ptr, &tmp); 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); return Error(PROTOBUF_TC_PARAM_PASS);
} }
RefAt<FieldType>(msg, data.offset()) = RefAt<FieldType>(msg, data.offset()) =

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

@ -598,6 +598,7 @@
#endif #endif
#if defined(__cpp_constinit) #if defined(__cpp_constinit)
#define PROTOBUF_CONSTINIT constinit #define PROTOBUF_CONSTINIT constinit
#define PROTOBUF_CONSTEXPR constexpr
// Some older Clang versions incorrectly raise an error about // Some older Clang versions incorrectly raise an error about
// constant-initializing weak default instance pointers. Versions 12.0 and // 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 // 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__ >= 13) || \
(!defined(__APPLE__) && __clang_major__ >= 12)) (!defined(__APPLE__) && __clang_major__ >= 12))
#define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]] #define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]]
#define PROTOBUF_CONSTEXPR constexpr
#elif PROTOBUF_GNUC_MIN(12, 0) #elif PROTOBUF_GNUC_MIN(12, 0)
#define PROTOBUF_CONSTINIT __constinit #define PROTOBUF_CONSTINIT __constinit
#define PROTOBUF_CONSTEXPR constexpr
#else #else
#define PROTOBUF_CONSTINIT #define PROTOBUF_CONSTINIT
#define PROTOBUF_CONSTEXPR inline
#endif #endif
// Some globals with an empty non-trivial destructor are annotated with // Some globals with an empty non-trivial destructor are annotated with

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -46,11 +46,11 @@
#include <google/protobuf/util/internal/testdata/proto3.pb.h> #include <google/protobuf/util/internal/testdata/proto3.pb.h>
#include <google/protobuf/util/internal/testdata/struct.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/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 <gtest/gtest.h>
#include <google/protobuf/stubs/casts.h> #include <google/protobuf/stubs/casts.h>
#include <google/protobuf/stubs/status.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 { namespace google {

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

@ -38,8 +38,6 @@
#include <google/protobuf/wrappers.pb.h> #include <google/protobuf/wrappers.pb.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h> #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/descriptor.pb.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/message.h>
#include <google/protobuf/util/internal/mock_error_listener.h> #include <google/protobuf/util/internal/mock_error_listener.h>
#include <google/protobuf/util/internal/testdata/anys.pb.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/struct.pb.h>
#include <google/protobuf/util/internal/testdata/timestamp_duration.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/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/bytestream.h>
#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/strutil.h>
#include <gtest/gtest.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 { namespace google {

@ -36,11 +36,11 @@
#include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include <google/protobuf/descriptor.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/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_objectsource.h>
#include <google/protobuf/util/internal/protostream_objectwriter.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.h>
#include <google/protobuf/util/type_resolver_util.h> #include <google/protobuf/util/type_resolver_util.h>

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

@ -66,6 +66,26 @@ namespace protobuf {
namespace util { 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. // A reporter to report the total number of diffs.
// TODO(ykzhu): we can improve this to take into account the value differencers. // TODO(ykzhu): we can improve this to take into account the value differencers.
class NumDiffsReporter : public google::protobuf::util::MessageDifferencer::Reporter { class NumDiffsReporter : public google::protobuf::util::MessageDifferencer::Reporter {
@ -2012,14 +2032,13 @@ void MessageDifferencer::StreamReporter::PrintValue(
if (field->is_map() && message1_ != nullptr && message2_ != nullptr) { if (field->is_map() && message1_ != nullptr && message2_ != nullptr) {
fd = field_message.GetDescriptor()->field(1); fd = field_message.GetDescriptor()->field(1);
if (fd->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { if (fd->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
output = field_message.GetReflection() output = PrintShortTextFormat(
->GetMessage(field_message, fd) field_message.GetReflection()->GetMessage(field_message, fd));
.ShortDebugString();
} else { } else {
TextFormat::PrintFieldValueToString(field_message, fd, -1, &output); TextFormat::PrintFieldValueToString(field_message, fd, -1, &output);
} }
} else { } else {
output = field_message.ShortDebugString(); output = PrintShortTextFormat(field_message);
} }
if (output.empty()) { if (output.empty()) {
printer_->Print("{ }"); printer_->Print("{ }");

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

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

Loading…
Cancel
Save