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

pull/9482/head
Joshua Haberman 3 years ago
commit 06196e9b4c
  1. 14
      conformance/conformance_test.cc
  2. 6
      conformance/conformance_test.h
  3. 6
      conformance/conformance_test_runner.cc
  4. 104
      conformance/failure_list_js.txt
  5. 7
      java/core/src/main/java/com/google/protobuf/ArrayDecoders.java
  6. 2
      java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
  7. 4
      java/core/src/main/java/com/google/protobuf/Internal.java
  8. 2
      java/core/src/main/java/com/google/protobuf/MessageReflection.java
  9. 2
      java/core/src/main/java/com/google/protobuf/MessageSetSchema.java
  10. 9
      java/core/src/main/java/com/google/protobuf/TextFormat.java
  11. 42
      java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java
  12. 6
      java/core/src/main/java/com/google/protobuf/Utf8.java
  13. 7
      java/core/src/test/java/com/google/protobuf/TextFormatTest.java
  14. 45
      java/kotlin/src/main/kotlin/com/google/protobuf/Anies.kt
  15. 70
      java/kotlin/src/test/kotlin/com/google/protobuf/AniesTest.kt
  16. 8
      python/google/protobuf/internal/descriptor_pool_test.py
  17. 12
      python/google/protobuf/json_format.py
  18. 2
      python/google/protobuf/pyext/message.cc
  19. 3
      python/google/protobuf/pyext/unknown_fields.cc
  20. 4
      src/google/protobuf/any.cc
  21. 18
      src/google/protobuf/any.pb.cc
  22. 26
      src/google/protobuf/any.pb.h
  23. 6
      src/google/protobuf/any_lite.cc
  24. 63
      src/google/protobuf/api.pb.cc
  25. 94
      src/google/protobuf/api.pb.h
  26. 42
      src/google/protobuf/arena.h
  27. 12
      src/google/protobuf/arena_unittest.cc
  28. 113
      src/google/protobuf/arenastring.cc
  29. 296
      src/google/protobuf/arenastring.h
  30. 39
      src/google/protobuf/arenastring_unittest.cc
  31. 35
      src/google/protobuf/compiler/cpp/cpp_enum_field.cc
  32. 9
      src/google/protobuf/compiler/cpp/cpp_field.cc
  33. 8
      src/google/protobuf/compiler/cpp/cpp_generator.cc
  34. 6
      src/google/protobuf/compiler/cpp/cpp_message.cc
  35. 118
      src/google/protobuf/compiler/cpp/cpp_message_field.cc
  36. 51
      src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc
  37. 43
      src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
  38. 4
      src/google/protobuf/compiler/cpp/cpp_primitive_field.h
  39. 165
      src/google/protobuf/compiler/cpp/cpp_string_field.cc
  40. 4
      src/google/protobuf/compiler/cpp/cpp_string_field.h
  41. 4
      src/google/protobuf/compiler/parser_unittest.cc
  42. 54
      src/google/protobuf/compiler/plugin.pb.cc
  43. 95
      src/google/protobuf/compiler/plugin.pb.h
  44. 59
      src/google/protobuf/compiler/subprocess.cc
  45. 89
      src/google/protobuf/descriptor.cc
  46. 297
      src/google/protobuf/descriptor.pb.cc
  47. 515
      src/google/protobuf/descriptor.pb.h
  48. 22
      src/google/protobuf/descriptor_unittest.cc
  49. 22
      src/google/protobuf/dynamic_message.cc
  50. 126
      src/google/protobuf/generated_message_reflection.cc
  51. 100
      src/google/protobuf/generated_message_tctable_impl.h
  52. 179
      src/google/protobuf/generated_message_tctable_lite.cc
  53. 385
      src/google/protobuf/generated_message_tctable_lite_test.cc
  54. 3
      src/google/protobuf/generated_message_util.cc
  55. 28
      src/google/protobuf/inlined_string_field.cc
  56. 301
      src/google/protobuf/inlined_string_field.h
  57. 1
      src/google/protobuf/inlined_string_field_unittest.cc
  58. 6
      src/google/protobuf/map_type_handler.h
  59. 3
      src/google/protobuf/message_lite.cc
  60. 23
      src/google/protobuf/message_unittest.inc
  61. 11
      src/google/protobuf/parse_context.cc
  62. 12
      src/google/protobuf/reflection_ops.cc
  63. 9
      src/google/protobuf/source_context.pb.cc
  64. 13
      src/google/protobuf/source_context.pb.h
  65. 6
      src/google/protobuf/struct.pb.cc
  66. 11
      src/google/protobuf/struct.pb.h
  67. 72
      src/google/protobuf/type.pb.cc
  68. 113
      src/google/protobuf/type.pb.h
  69. 2
      src/google/protobuf/wire_format_lite.cc
  70. 18
      src/google/protobuf/wrappers.pb.cc
  71. 26
      src/google/protobuf/wrappers.pb.h

@ -350,7 +350,17 @@ bool ConformanceTestSuite::CheckSetEmpty(
StringAppendF(&output_, "\n"); StringAppendF(&output_, "\n");
if (!write_to_file.empty()) { if (!write_to_file.empty()) {
std::ofstream os(write_to_file); std::string full_filename;
const std::string* filename = &write_to_file;
if (!output_dir_.empty()) {
full_filename = output_dir_;
if (*output_dir_.rbegin() != '/') {
full_filename.push_back('/');
}
full_filename += write_to_file;
filename = &full_filename;
}
std::ofstream os(*filename);
if (os) { if (os) {
for (std::set<string>::const_iterator iter = set_to_check.begin(); for (std::set<string>::const_iterator iter = set_to_check.begin();
iter != set_to_check.end(); ++iter) { iter != set_to_check.end(); ++iter) {
@ -358,7 +368,7 @@ bool ConformanceTestSuite::CheckSetEmpty(
} }
} else { } else {
StringAppendF(&output_, "Failed to open file: %s\n", StringAppendF(&output_, "Failed to open file: %s\n",
write_to_file.c_str()); filename->c_str());
} }
} }

@ -174,6 +174,11 @@ class ConformanceTestSuite {
failure_list_flag_name_ = failure_list_flag_name; failure_list_flag_name_ = failure_list_flag_name;
} }
// Sets the path of the output directory.
void SetOutputDir(const char* output_dir) {
output_dir_ = output_dir;
}
// Run all the conformance tests against the given test runner. // Run all the conformance tests against the given test runner.
// Test output will be stored in "output". // Test output will be stored in "output".
// //
@ -296,6 +301,7 @@ class ConformanceTestSuite {
bool verbose_; bool verbose_;
bool enforce_recommended_; bool enforce_recommended_;
std::string output_; std::string output_;
std::string output_dir_;
std::string failure_list_flag_name_; std::string failure_list_flag_name_;
std::string failure_list_filename_; std::string failure_list_filename_;

@ -141,6 +141,9 @@ void UsageError() {
" strictly conforming to protobuf\n"); " strictly conforming to protobuf\n");
fprintf(stderr, fprintf(stderr,
" spec.\n"); " spec.\n");
fprintf(stderr,
" --output_dir <dirname> Directory to write\n"
" output files.\n");
exit(1); exit(1);
} }
@ -208,6 +211,9 @@ int ForkPipeRunner::Run(
suite->SetVerbose(true); suite->SetVerbose(true);
} else if (strcmp(argv[arg], "--enforce_recommended") == 0) { } else if (strcmp(argv[arg], "--enforce_recommended") == 0) {
suite->SetEnforceRecommended(true); suite->SetEnforceRecommended(true);
} else if (strcmp(argv[arg], "--output_dir") == 0) {
if (++arg == argc) UsageError();
suite->SetOutputDir(argv[arg]);
} else if (argv[arg][0] == '-') { } else if (argv[arg][0] == '-') {
bool recognized_flag = false; bool recognized_flag = false;
for (ConformanceTestSuite* suite : suites) { for (ConformanceTestSuite* suite : suites) {

@ -0,0 +1,104 @@
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.FIXED64[2].ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.INT64[2].ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.SFIXED64[2].ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.SINT64[2].ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.UINT64[2].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.FIXED64[2].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.INT64[2].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.SFIXED64[2].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.SINT64[2].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.UINT64[2].ProtobufOutput
Required.Proto2.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput
Required.Proto2.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.INT64.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.FIXED64[2].ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.INT64[2].ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.SFIXED64[2].ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.SINT64[2].ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.UINT64[2].ProtobufOutput
Required.Proto3.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput
Required.Proto3.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.FIXED64[2].ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.INT64[2].ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.SFIXED64[2].ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.SINT64[2].ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.UINT64[2].ProtobufOutput

@ -45,14 +45,15 @@ import java.io.IOException;
*/ */
@CheckReturnValue @CheckReturnValue
final class ArrayDecoders { final class ArrayDecoders {
private ArrayDecoders() {
}
/** /**
* A helper used to return multiple values in a Java function. Java doesn't natively support * A helper used to return multiple values in a Java function. Java doesn't natively support
* returning multiple values in a function. Creating a new Object to hold the return values will * returning multiple values in a function. Creating a new Object to hold the return values will
* be too expensive. Instead, we pass a Registers instance to functions that want to return * be too expensive. Instead, we pass a Registers instance to functions that want to return
* multiple values and let the function set the return value in this Registers instance instead. * multiple values and let the function set the return value in this Registers instance instead.
*
* <p>TODO(xiaofeng): This could be merged into CodedInputStream or CodedInputStreamReader which
* is already being passed through all the parsing routines.
*/ */
static final class Registers { static final class Registers {
public int int1; public int int1;

@ -692,7 +692,7 @@ public abstract class GeneratedMessageLite<
// The wire format for MessageSet is: // The wire format for MessageSet is:
// message MessageSet { // message MessageSet {
// repeated group Item = 1 { // repeated group Item = 1 {
// required int32 typeId = 2; // required uint32 typeId = 2;
// required bytes message = 3; // required bytes message = 3;
// } // }
// } // }

@ -259,7 +259,9 @@ public final class Internal {
/** Helper method for implementing {@link Message#equals(Object)} for bytes field. */ /** Helper method for implementing {@link Message#equals(Object)} for bytes field. */
public static boolean equals(List<byte[]> a, List<byte[]> b) { public static boolean equals(List<byte[]> a, List<byte[]> b) {
if (a.size() != b.size()) return false; if (a.size() != b.size()) {
return false;
}
for (int i = 0; i < a.size(); ++i) { for (int i = 0; i < a.size(); ++i) {
if (!Arrays.equals(a.get(i), b.get(i))) { if (!Arrays.equals(a.get(i), b.get(i))) {
return false; return false;

@ -882,7 +882,7 @@ class MessageReflection {
// The wire format for MessageSet is: // The wire format for MessageSet is:
// message MessageSet { // message MessageSet {
// repeated group Item = 1 { // repeated group Item = 1 {
// required int32 typeId = 2; // required uint32 typeId = 2;
// required bytes message = 3; // required bytes message = 3;
// } // }
// } // }

@ -300,7 +300,7 @@ final class MessageSetSchema<T> implements Schema<T> {
// The wire format for MessageSet is: // The wire format for MessageSet is:
// message MessageSet { // message MessageSet {
// repeated group Item = 1 { // repeated group Item = 1 {
// required int32 typeId = 2; // required uint32 typeId = 2;
// required bytes message = 3; // required bytes message = 3;
// } // }
// } // }

@ -49,7 +49,7 @@ import java.util.regex.Pattern;
/** /**
* Provide text parsing and formatting support for proto2 instances. The implementation largely * Provide text parsing and formatting support for proto2 instances. The implementation largely
* follows google/protobuf/text_format.cc. * follows text_format.cc.
* *
* @author wenboz@google.com Wenbo Zhu * @author wenboz@google.com Wenbo Zhu
* @author kenton@google.com Kenton Varda * @author kenton@google.com Kenton Varda
@ -2307,7 +2307,7 @@ public final class TextFormat {
* Un-escape a byte sequence as escaped using {@link #escapeBytes(ByteString)}. Two-digit hex * Un-escape a byte sequence as escaped using {@link #escapeBytes(ByteString)}. Two-digit hex
* escapes (starting with "\x") are also recognized. * escapes (starting with "\x") are also recognized.
*/ */
public static ByteString unescapeBytes(final CharSequence charString) public static ByteString unescapeBytes(CharSequence charString)
throws InvalidEscapeSequenceException { throws InvalidEscapeSequenceException {
// First convert the Java character sequence to UTF-8 bytes. // First convert the Java character sequence to UTF-8 bytes.
ByteString input = ByteString.copyFromUtf8(charString.toString()); ByteString input = ByteString.copyFromUtf8(charString.toString());
@ -2444,9 +2444,10 @@ public final class TextFormat {
+ "' is not a valid code point value"); + "' is not a valid code point value");
} }
Character.UnicodeBlock unicodeBlock = Character.UnicodeBlock.of(codepoint); Character.UnicodeBlock unicodeBlock = Character.UnicodeBlock.of(codepoint);
if (unicodeBlock.equals(Character.UnicodeBlock.LOW_SURROGATES) if (unicodeBlock != null
&& (unicodeBlock.equals(Character.UnicodeBlock.LOW_SURROGATES)
|| unicodeBlock.equals(Character.UnicodeBlock.HIGH_SURROGATES) || unicodeBlock.equals(Character.UnicodeBlock.HIGH_SURROGATES)
|| unicodeBlock.equals(Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES)) { || unicodeBlock.equals(Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES))) {
throw new InvalidEscapeSequenceException( throw new InvalidEscapeSequenceException(
"Invalid escape sequence: '\\U" "Invalid escape sequence: '\\U"
+ input.substring(i, i + 8).toStringUtf8() + input.substring(i, i + 8).toStringUtf8()

@ -30,7 +30,24 @@
package com.google.protobuf; package com.google.protobuf;
/** Provide text format escaping support for proto2 instances. */ /**
* Provide text format escaping of proto instances. These ASCII characters are escaped:
*
* ASCII #7 (bell) --> \a
* ASCII #8 (backspace) --> \b
* ASCII #9 (horizontal tab) --> \t
* ASCII #10 (linefeed) --> \n
* ASCII #11 (vertical tab) --> \v
* ASCII #13 (carriage return) --> \r
* ASCII #12 (formfeed) --> \f
* ASCII #34 (apostrophe) --> \'
* ASCII #39 (straight double quote) --> \"
* ASCII #92 (backslash) --> \\
*
* Other printable ASCII characters between 32 and 127 inclusive are output as is, unescaped.
* Other ASCII characters less than 32 and all Unicode characters 128 or greater are
* first encoded as UTF-8, then each byte is escaped individually as a 3-digit octal escape.
*/
final class TextFormatEscaper { final class TextFormatEscaper {
private TextFormatEscaper() {} private TextFormatEscaper() {}
@ -41,17 +58,13 @@ final class TextFormatEscaper {
} }
/** /**
* Escapes bytes in the format used in protocol buffer text format, which is the same as the * Backslash escapes bytes in the format used in protocol buffer text format.
* format used for C string literals. All bytes that are not printable 7-bit ASCII characters are
* escaped, as well as backslash, single-quote, and double-quote characters. Characters for which
* no defined short-hand escape sequence is defined will be escaped using 3-digit octal sequences.
*/ */
static String escapeBytes(final ByteSequence input) { static String escapeBytes(ByteSequence input) {
final StringBuilder builder = new StringBuilder(input.size()); final StringBuilder builder = new StringBuilder(input.size());
for (int i = 0; i < input.size(); i++) { for (int i = 0; i < input.size(); i++) {
final byte b = input.byteAt(i); byte b = input.byteAt(i);
switch (b) { switch (b) {
// Java does not recognize \a or \v, apparently.
case 0x07: case 0x07:
builder.append("\\a"); builder.append("\\a");
break; break;
@ -100,10 +113,7 @@ final class TextFormatEscaper {
} }
/** /**
* Escapes bytes in the format used in protocol buffer text format, which is the same as the * Backslash escapes bytes in the format used in protocol buffer text format.
* format used for C string literals. All bytes that are not printable 7-bit ASCII characters are
* escaped, as well as backslash, single-quote, and double-quote characters. Characters for which
* no defined short-hand escape sequence is defined will be escaped using 3-digit octal sequences.
*/ */
static String escapeBytes(final ByteString input) { static String escapeBytes(final ByteString input) {
return escapeBytes( return escapeBytes(
@ -137,16 +147,14 @@ final class TextFormatEscaper {
} }
/** /**
* Like {@link #escapeBytes(ByteString)}, but escapes a text string. Non-ASCII characters are * Like {@link #escapeBytes(ByteString)}, but escapes a text string.
* first encoded as UTF-8, then each byte is escaped individually as a 3-digit octal escape. Yes,
* it's weird.
*/ */
static String escapeText(final String input) { static String escapeText(String input) {
return escapeBytes(ByteString.copyFromUtf8(input)); return escapeBytes(ByteString.copyFromUtf8(input));
} }
/** Escape double quotes and backslashes in a String for unicode output of a message. */ /** Escape double quotes and backslashes in a String for unicode output of a message. */
static String escapeDoubleQuotesAndBackslashes(final String input) { static String escapeDoubleQuotesAndBackslashes(String input) {
return input.replace("\\", "\\\\").replace("\"", "\\\""); return input.replace("\\", "\\\\").replace("\"", "\\\"");
} }
} }

@ -64,9 +64,9 @@ import java.nio.ByteBuffer;
* <em>Well Formed UTF-8 Byte Sequences</em>. * <em>Well Formed UTF-8 Byte Sequences</em>.
* *
* <p>This class supports decoding of partial byte sequences, so that the bytes in a complete UTF-8 * <p>This class supports decoding of partial byte sequences, so that the bytes in a complete UTF-8
* byte sequences can be stored in multiple segments. Methods typically return {@link #MALFORMED} if * byte sequence can be stored in multiple segments. Methods typically return {@link #MALFORMED} if
* the partial byte sequence is definitely not well-formed, {@link #COMPLETE} if it is well-formed * the partial byte sequence is definitely not well-formed; {@link #COMPLETE} if it is well-formed
* in the absence of additional input, or if the byte sequence apparently terminated in the middle * in the absence of additional input; or, if the byte sequence apparently terminated in the middle
* of a character, an opaque integer "state" value containing enough information to decode the * of a character, an opaque integer "state" value containing enough information to decode the
* character when passed to a subsequent invocation of a partial decoding method. * character when passed to a subsequent invocation of a partial decoding method.
* *

@ -170,6 +170,13 @@ public class TextFormatTest {
assertThat(javaText).isEqualTo(ALL_FIELDS_SET_TEXT); assertThat(javaText).isEqualTo(ALL_FIELDS_SET_TEXT);
} }
@Test
// https://github.com/protocolbuffers/protobuf/issues/9447
public void testCharacterNotInUnicodeBlock() throws TextFormat.InvalidEscapeSequenceException {
ByteString actual = TextFormat.unescapeBytes("\\U000358da");
assertThat(actual.size()).isEqualTo(4);
}
/** Print TestAllTypes as Builder and compare with golden file. */ /** Print TestAllTypes as Builder and compare with golden file. */
@Test @Test
public void testPrintMessageBuilder() throws Exception { public void testPrintMessageBuilder() throws Exception {

@ -0,0 +1,45 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.protobuf.kotlin
import com.google.protobuf.Any as ProtoAny
import com.google.protobuf.Message
/** Returns `true` if this [com.google.protobuf.Any] contains a message of type `T`. */
inline fun <reified T : Message> ProtoAny.isA(): Boolean = this.`is`(T::class.java)
/**
* Returns the message of type `T` encoded in this [com.google.protobuf.Any].
*
* @throws InvalidProtocolBufferException if this [com.google.protobuf.Any] does not contain a `T`
* message.
*/
inline fun <reified T : Message> ProtoAny.unpack(): T = unpack(T::class.java)

@ -0,0 +1,70 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.protobuf.kotlin
import com.google.common.truth.Truth.assertThat
import com.google.protobuf.Any as ProtoAny
import com.google.protobuf.InvalidProtocolBufferException
import protobuf_unittest.UnittestProto.BoolMessage
import protobuf_unittest.UnittestProto.Int32Message
import protobuf_unittest.int32Message
import kotlin.test.assertFailsWith
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
/** Tests for extension methods on [ProtoAny]. */
@RunWith(JUnit4::class)
class AniesTest {
companion object {
val anAny = ProtoAny.pack(int32Message { data = 5 })
}
@Test
fun isA_Positive() {
assertThat(anAny.isA<Int32Message>()).isTrue()
}
@Test
fun isA_Negative() {
assertThat(anAny.isA<BoolMessage>()).isFalse()
}
@Test
fun unpackValid() {
assertThat(anAny.unpack<Int32Message>().data).isEqualTo(5)
}
@Test
fun unpackInvalid() {
assertFailsWith<InvalidProtocolBufferException> { anAny.unpack<BoolMessage>() }
}
}

@ -541,7 +541,13 @@ class DescriptorPoolTestBase(object):
pool._AddExtensionDescriptor( pool._AddExtensionDescriptor(
file_descriptor.extensions_by_name['optional_int32_extension']) file_descriptor.extensions_by_name['optional_int32_extension'])
pool.Add(unittest_fd) pool.Add(unittest_fd)
pool.Add(conflict_fd) with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
pool.Add(conflict_fd)
self.assertTrue(len(w))
self.assertIs(w[0].category, RuntimeWarning)
self.assertIn('Conflict register for file "other_file": ',
str(w[0].message))
pool.FindFileByName(unittest_fd.name) pool.FindFileByName(unittest_fd.name)
with self.assertRaises(TypeError): with self.assertRaises(TypeError):
pool.FindFileByName(conflict_fd.name) pool.FindFileByName(conflict_fd.name)

@ -95,7 +95,8 @@ def MessageToJson(
sort_keys=False, sort_keys=False,
use_integers_for_enums=False, use_integers_for_enums=False,
descriptor_pool=None, descriptor_pool=None,
float_precision=None): float_precision=None,
ensure_ascii=True):
"""Converts protobuf message to JSON format. """Converts protobuf message to JSON format.
Args: Args:
@ -114,6 +115,8 @@ def MessageToJson(
descriptor_pool: A Descriptor Pool for resolving types. If None use the descriptor_pool: A Descriptor Pool for resolving types. If None use the
default. default.
float_precision: If set, use this to specify float field valid digits. float_precision: If set, use this to specify float field valid digits.
ensure_ascii: If True, strings with non-ASCII characters are escaped.
If False, Unicode strings are returned unchanged.
Returns: Returns:
A string containing the JSON formatted protocol buffer message. A string containing the JSON formatted protocol buffer message.
@ -124,7 +127,7 @@ def MessageToJson(
use_integers_for_enums, use_integers_for_enums,
descriptor_pool, descriptor_pool,
float_precision=float_precision) float_precision=float_precision)
return printer.ToJsonString(message, indent, sort_keys) return printer.ToJsonString(message, indent, sort_keys, ensure_ascii)
def MessageToDict( def MessageToDict(
@ -190,9 +193,10 @@ class _Printer(object):
else: else:
self.float_format = None self.float_format = None
def ToJsonString(self, message, indent, sort_keys): def ToJsonString(self, message, indent, sort_keys, ensure_ascii):
js = self._MessageToJsonObject(message) js = self._MessageToJsonObject(message)
return json.dumps(js, indent=indent, sort_keys=sort_keys) return json.dumps(
js, indent=indent, sort_keys=sort_keys, ensure_ascii=ensure_ascii)
def _MessageToJsonObject(self, message): def _MessageToJsonObject(self, message):
"""Converts message to an object according to Proto3 JSON Specification.""" """Converts message to an object according to Proto3 JSON Specification."""

@ -1002,7 +1002,7 @@ int DeleteRepeatedField(
} }
} }
Arena* arena = Arena::InternalHelper<Message>::GetArenaForAllocation(message); Arena* arena = Arena::InternalGetArenaForAllocation(message);
GOOGLE_DCHECK_EQ(arena, nullptr) GOOGLE_DCHECK_EQ(arena, nullptr)
<< "python protobuf is expected to be allocated from heap"; << "python protobuf is expected to be allocated from heap";
// Remove items, starting from the end. // Remove items, starting from the end.

@ -138,8 +138,9 @@ static void Dealloc(PyObject* pself) {
reinterpret_cast<CMessage*>(self->parent)->unknown_field_set = nullptr; reinterpret_cast<CMessage*>(self->parent)->unknown_field_set = nullptr;
} }
Py_CLEAR(self->parent); Py_CLEAR(self->parent);
auto* py_type = Py_TYPE(pself);
self->~PyUnknownFields(); self->~PyUnknownFields();
Py_TYPE(pself)->tp_free(pself); py_type->tp_free(pself);
} }
static PySequenceMethods SqMethods = { static PySequenceMethods SqMethods = {

@ -49,10 +49,8 @@ bool AnyMetadata::PackFrom(Arena* arena, const Message& message) {
bool AnyMetadata::PackFrom(Arena* arena, const Message& message, bool AnyMetadata::PackFrom(Arena* arena, const Message& message,
StringPiece type_url_prefix) { StringPiece type_url_prefix) {
type_url_->Set( type_url_->Set(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString(),
GetTypeUrl(message.GetDescriptor()->full_name(), type_url_prefix), arena); GetTypeUrl(message.GetDescriptor()->full_name(), type_url_prefix), arena);
return message.SerializeToString( return message.SerializeToString(value_->Mutable(arena));
value_->Mutable(ArenaStringPtr::EmptyDefault{}, arena));
} }
bool AnyMetadata::UnpackTo(Message* message) const { bool AnyMetadata::UnpackTo(Message* message) const {

@ -119,18 +119,18 @@ Any::Any(const Any& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
type_url_.InitDefault(); type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_type_url().empty()) { if (!from._internal_type_url().empty()) {
type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_url(), type_url_.Set(from._internal_type_url(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
value_.InitDefault(); value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_value().empty()) { if (!from._internal_value().empty()) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(), value_.Set(from._internal_value(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
// @@protoc_insertion_point(copy_constructor:google.protobuf.Any) // @@protoc_insertion_point(copy_constructor:google.protobuf.Any)
@ -139,11 +139,11 @@ Any::Any(const Any& from)
inline void Any::SharedCtor() { inline void Any::SharedCtor() {
type_url_.InitDefault(); type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
value_.InitDefault(); value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
} }
@ -158,8 +158,8 @@ Any::~Any() {
inline void Any::SharedDtor() { inline void Any::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); type_url_.Destroy();
value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); value_.Destroy();
} }
void Any::SetCachedSize(int size) const { void Any::SetCachedSize(int size) const {
@ -325,12 +325,10 @@ void Any::InternalSwap(Any* other) {
auto* rhs_arena = other->GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&type_url_, lhs_arena, &type_url_, lhs_arena,
&other->type_url_, rhs_arena &other->type_url_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&value_, lhs_arena, &value_, lhs_arena,
&other->value_, rhs_arena &other->value_, rhs_arena
); );

@ -275,7 +275,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Any::set_type_url(ArgT0&& arg0, ArgT... args) { void Any::set_type_url(ArgT0&& arg0, ArgT... args) {
type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Any.type_url) // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)
} }
inline std::string* Any::mutable_type_url() { inline std::string* Any::mutable_type_url() {
@ -288,15 +288,15 @@ inline const std::string& Any::_internal_type_url() const {
} }
inline void Any::_internal_set_type_url(const std::string& value) { inline void Any::_internal_set_type_url(const std::string& value) {
type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); type_url_.Set(value, GetArenaForAllocation());
} }
inline std::string* Any::_internal_mutable_type_url() { inline std::string* Any::_internal_mutable_type_url() {
return type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return type_url_.Mutable(GetArenaForAllocation());
} }
inline std::string* Any::release_type_url() { inline std::string* Any::release_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Any.type_url) // @@protoc_insertion_point(field_release:google.protobuf.Any.type_url)
return type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return type_url_.Release();
} }
inline void Any::set_allocated_type_url(std::string* type_url) { inline void Any::set_allocated_type_url(std::string* type_url) {
if (type_url != nullptr) { if (type_url != nullptr) {
@ -304,11 +304,10 @@ inline void Any::set_allocated_type_url(std::string* type_url) {
} else { } else {
} }
type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_url, type_url_.SetAllocated(type_url, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (type_url_.IsDefault()) { if (type_url_.IsDefault()) {
type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); type_url_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url)
@ -326,7 +325,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Any::set_value(ArgT0&& arg0, ArgT... args) { void Any::set_value(ArgT0&& arg0, ArgT... args) {
value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); value_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Any.value) // @@protoc_insertion_point(field_set:google.protobuf.Any.value)
} }
inline std::string* Any::mutable_value() { inline std::string* Any::mutable_value() {
@ -339,15 +338,15 @@ inline const std::string& Any::_internal_value() const {
} }
inline void Any::_internal_set_value(const std::string& value) { inline void Any::_internal_set_value(const std::string& value) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); value_.Set(value, GetArenaForAllocation());
} }
inline std::string* Any::_internal_mutable_value() { inline std::string* Any::_internal_mutable_value() {
return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return value_.Mutable(GetArenaForAllocation());
} }
inline std::string* Any::release_value() { inline std::string* Any::release_value() {
// @@protoc_insertion_point(field_release:google.protobuf.Any.value) // @@protoc_insertion_point(field_release:google.protobuf.Any.value)
return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return value_.Release();
} }
inline void Any::set_allocated_value(std::string* value) { inline void Any::set_allocated_value(std::string* value) {
if (value != nullptr) { if (value != nullptr) {
@ -355,11 +354,10 @@ inline void Any::set_allocated_value(std::string* value) {
} else { } else {
} }
value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, value_.SetAllocated(value, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (value_.IsDefault()) { if (value_.IsDefault()) {
value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); value_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value)

@ -55,10 +55,8 @@ const char kTypeGoogleProdComPrefix[] = "type.googleprod.com/";
bool AnyMetadata::InternalPackFrom(Arena* arena, const MessageLite& message, bool AnyMetadata::InternalPackFrom(Arena* arena, const MessageLite& message,
StringPiece type_url_prefix, StringPiece type_url_prefix,
StringPiece type_name) { StringPiece type_name) {
type_url_->Set(&::google::protobuf::internal::GetEmptyString(), type_url_->Set(GetTypeUrl(type_name, type_url_prefix), arena);
GetTypeUrl(type_name, type_url_prefix), arena); return message.SerializeToString(value_->Mutable(arena));
return message.SerializeToString(
value_->Mutable(ArenaStringPtr::EmptyDefault{}, arena));
} }
bool AnyMetadata::InternalUnpackTo(StringPiece type_name, bool AnyMetadata::InternalUnpackTo(StringPiece type_name,

@ -204,18 +204,18 @@ Api::Api(const Api& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
version_.InitDefault(); version_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
version_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); version_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_version().empty()) { if (!from._internal_version().empty()) {
version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_version(), version_.Set(from._internal_version(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
if (from._internal_has_source_context()) { if (from._internal_has_source_context()) {
@ -230,11 +230,11 @@ Api::Api(const Api& from)
inline void Api::SharedCtor() { inline void Api::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
version_.InitDefault(); version_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
version_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); version_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&source_context_) - reinterpret_cast<char*>(this)), reinterpret_cast<char*>(&source_context_) - reinterpret_cast<char*>(this)),
@ -253,8 +253,8 @@ Api::~Api() {
inline void Api::SharedDtor() { inline void Api::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
version_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); version_.Destroy();
if (this != internal_default_instance()) delete source_context_; if (this != internal_default_instance()) delete source_context_;
} }
@ -574,12 +574,10 @@ void Api::InternalSwap(Api* other) {
options_.InternalSwap(&other->options_); options_.InternalSwap(&other->options_);
mixins_.InternalSwap(&other->mixins_); mixins_.InternalSwap(&other->mixins_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&version_, lhs_arena, &version_, lhs_arena,
&other->version_, rhs_arena &other->version_, rhs_arena
); );
@ -619,26 +617,26 @@ Method::Method(const Method& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
request_type_url_.InitDefault(); request_type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
request_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); request_type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_request_type_url().empty()) { if (!from._internal_request_type_url().empty()) {
request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_request_type_url(), request_type_url_.Set(from._internal_request_type_url(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
response_type_url_.InitDefault(); response_type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
response_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); response_type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_response_type_url().empty()) { if (!from._internal_response_type_url().empty()) {
response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_response_type_url(), response_type_url_.Set(from._internal_response_type_url(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
::memcpy(&request_streaming_, &from.request_streaming_, ::memcpy(&request_streaming_, &from.request_streaming_,
@ -650,15 +648,15 @@ Method::Method(const Method& from)
inline void Method::SharedCtor() { inline void Method::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
request_type_url_.InitDefault(); request_type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
request_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); request_type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
response_type_url_.InitDefault(); response_type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
response_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); response_type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&request_streaming_) - reinterpret_cast<char*>(this)), reinterpret_cast<char*>(&request_streaming_) - reinterpret_cast<char*>(this)),
@ -677,9 +675,9 @@ Method::~Method() {
inline void Method::SharedDtor() { inline void Method::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
request_type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); request_type_url_.Destroy();
response_type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); response_type_url_.Destroy();
} }
void Method::SetCachedSize(int size) const { void Method::SetCachedSize(int size) const {
@ -984,17 +982,14 @@ void Method::InternalSwap(Method* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
options_.InternalSwap(&other->options_); options_.InternalSwap(&other->options_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&request_type_url_, lhs_arena, &request_type_url_, lhs_arena,
&other->request_type_url_, rhs_arena &other->request_type_url_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&response_type_url_, lhs_arena, &response_type_url_, lhs_arena,
&other->response_type_url_, rhs_arena &other->response_type_url_, rhs_arena
); );
@ -1029,18 +1024,18 @@ Mixin::Mixin(const Mixin& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
root_.InitDefault(); root_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
root_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); root_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_root().empty()) { if (!from._internal_root().empty()) {
root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_root(), root_.Set(from._internal_root(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
// @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin) // @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin)
@ -1049,11 +1044,11 @@ Mixin::Mixin(const Mixin& from)
inline void Mixin::SharedCtor() { inline void Mixin::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
root_.InitDefault(); root_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
root_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); root_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
} }
@ -1068,8 +1063,8 @@ Mixin::~Mixin() {
inline void Mixin::SharedDtor() { inline void Mixin::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
root_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); root_.Destroy();
} }
void Mixin::SetCachedSize(int size) const { void Mixin::SetCachedSize(int size) const {
@ -1240,12 +1235,10 @@ void Mixin::InternalSwap(Mixin* other) {
auto* rhs_arena = other->GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&root_, lhs_arena, &root_, lhs_arena,
&other->root_, rhs_arena &other->root_, rhs_arena
); );

@ -739,7 +739,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Api::set_name(ArgT0&& arg0, ArgT... args) { void Api::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Api.name) // @@protoc_insertion_point(field_set:google.protobuf.Api.name)
} }
inline std::string* Api::mutable_name() { inline std::string* Api::mutable_name() {
@ -752,15 +752,15 @@ inline const std::string& Api::_internal_name() const {
} }
inline void Api::_internal_set_name(const std::string& value) { inline void Api::_internal_set_name(const std::string& value) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); name_.Set(value, GetArenaForAllocation());
} }
inline std::string* Api::_internal_mutable_name() { inline std::string* Api::_internal_mutable_name() {
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return name_.Mutable(GetArenaForAllocation());
} }
inline std::string* Api::release_name() { inline std::string* Api::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Api.name) // @@protoc_insertion_point(field_release:google.protobuf.Api.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return name_.Release();
} }
inline void Api::set_allocated_name(std::string* name) { inline void Api::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -768,11 +768,10 @@ inline void Api::set_allocated_name(std::string* name) {
} else { } else {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(name, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (name_.IsDefault()) { if (name_.IsDefault()) {
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.name)
@ -867,7 +866,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Api::set_version(ArgT0&& arg0, ArgT... args) { void Api::set_version(ArgT0&& arg0, ArgT... args) {
version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); version_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Api.version) // @@protoc_insertion_point(field_set:google.protobuf.Api.version)
} }
inline std::string* Api::mutable_version() { inline std::string* Api::mutable_version() {
@ -880,15 +879,15 @@ inline const std::string& Api::_internal_version() const {
} }
inline void Api::_internal_set_version(const std::string& value) { inline void Api::_internal_set_version(const std::string& value) {
version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); version_.Set(value, GetArenaForAllocation());
} }
inline std::string* Api::_internal_mutable_version() { inline std::string* Api::_internal_mutable_version() {
return version_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return version_.Mutable(GetArenaForAllocation());
} }
inline std::string* Api::release_version() { inline std::string* Api::release_version() {
// @@protoc_insertion_point(field_release:google.protobuf.Api.version) // @@protoc_insertion_point(field_release:google.protobuf.Api.version)
return version_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return version_.Release();
} }
inline void Api::set_allocated_version(std::string* version) { inline void Api::set_allocated_version(std::string* version) {
if (version != nullptr) { if (version != nullptr) {
@ -896,11 +895,10 @@ inline void Api::set_allocated_version(std::string* version) {
} else { } else {
} }
version_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), version, version_.SetAllocated(version, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (version_.IsDefault()) { if (version_.IsDefault()) {
version_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); version_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version)
@ -977,8 +975,7 @@ inline void Api::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceCon
} }
if (source_context) { if (source_context) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper< ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(
::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena(
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context)); reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context));
if (message_arena != submessage_arena) { if (message_arena != submessage_arena) {
source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
@ -1068,7 +1065,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Method::set_name(ArgT0&& arg0, ArgT... args) { void Method::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Method.name) // @@protoc_insertion_point(field_set:google.protobuf.Method.name)
} }
inline std::string* Method::mutable_name() { inline std::string* Method::mutable_name() {
@ -1081,15 +1078,15 @@ inline const std::string& Method::_internal_name() const {
} }
inline void Method::_internal_set_name(const std::string& value) { inline void Method::_internal_set_name(const std::string& value) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); name_.Set(value, GetArenaForAllocation());
} }
inline std::string* Method::_internal_mutable_name() { inline std::string* Method::_internal_mutable_name() {
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return name_.Mutable(GetArenaForAllocation());
} }
inline std::string* Method::release_name() { inline std::string* Method::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Method.name) // @@protoc_insertion_point(field_release:google.protobuf.Method.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return name_.Release();
} }
inline void Method::set_allocated_name(std::string* name) { inline void Method::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -1097,11 +1094,10 @@ inline void Method::set_allocated_name(std::string* name) {
} else { } else {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(name, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (name_.IsDefault()) { if (name_.IsDefault()) {
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name)
@ -1119,7 +1115,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Method::set_request_type_url(ArgT0&& arg0, ArgT... args) { void Method::set_request_type_url(ArgT0&& arg0, ArgT... args) {
request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); request_type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url) // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url)
} }
inline std::string* Method::mutable_request_type_url() { inline std::string* Method::mutable_request_type_url() {
@ -1132,15 +1128,15 @@ inline const std::string& Method::_internal_request_type_url() const {
} }
inline void Method::_internal_set_request_type_url(const std::string& value) { inline void Method::_internal_set_request_type_url(const std::string& value) {
request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); request_type_url_.Set(value, GetArenaForAllocation());
} }
inline std::string* Method::_internal_mutable_request_type_url() { inline std::string* Method::_internal_mutable_request_type_url() {
return request_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return request_type_url_.Mutable(GetArenaForAllocation());
} }
inline std::string* Method::release_request_type_url() { inline std::string* Method::release_request_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Method.request_type_url) // @@protoc_insertion_point(field_release:google.protobuf.Method.request_type_url)
return request_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return request_type_url_.Release();
} }
inline void Method::set_allocated_request_type_url(std::string* request_type_url) { inline void Method::set_allocated_request_type_url(std::string* request_type_url) {
if (request_type_url != nullptr) { if (request_type_url != nullptr) {
@ -1148,11 +1144,10 @@ inline void Method::set_allocated_request_type_url(std::string* request_type_url
} else { } else {
} }
request_type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), request_type_url, request_type_url_.SetAllocated(request_type_url, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (request_type_url_.IsDefault()) { if (request_type_url_.IsDefault()) {
request_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); request_type_url_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url)
@ -1190,7 +1185,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Method::set_response_type_url(ArgT0&& arg0, ArgT... args) { void Method::set_response_type_url(ArgT0&& arg0, ArgT... args) {
response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); response_type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url) // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url)
} }
inline std::string* Method::mutable_response_type_url() { inline std::string* Method::mutable_response_type_url() {
@ -1203,15 +1198,15 @@ inline const std::string& Method::_internal_response_type_url() const {
} }
inline void Method::_internal_set_response_type_url(const std::string& value) { inline void Method::_internal_set_response_type_url(const std::string& value) {
response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); response_type_url_.Set(value, GetArenaForAllocation());
} }
inline std::string* Method::_internal_mutable_response_type_url() { inline std::string* Method::_internal_mutable_response_type_url() {
return response_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return response_type_url_.Mutable(GetArenaForAllocation());
} }
inline std::string* Method::release_response_type_url() { inline std::string* Method::release_response_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Method.response_type_url) // @@protoc_insertion_point(field_release:google.protobuf.Method.response_type_url)
return response_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return response_type_url_.Release();
} }
inline void Method::set_allocated_response_type_url(std::string* response_type_url) { inline void Method::set_allocated_response_type_url(std::string* response_type_url) {
if (response_type_url != nullptr) { if (response_type_url != nullptr) {
@ -1219,11 +1214,10 @@ inline void Method::set_allocated_response_type_url(std::string* response_type_u
} else { } else {
} }
response_type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), response_type_url, response_type_url_.SetAllocated(response_type_url, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (response_type_url_.IsDefault()) { if (response_type_url_.IsDefault()) {
response_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); response_type_url_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url)
@ -1322,7 +1316,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Mixin::set_name(ArgT0&& arg0, ArgT... args) { void Mixin::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.name) // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name)
} }
inline std::string* Mixin::mutable_name() { inline std::string* Mixin::mutable_name() {
@ -1335,15 +1329,15 @@ inline const std::string& Mixin::_internal_name() const {
} }
inline void Mixin::_internal_set_name(const std::string& value) { inline void Mixin::_internal_set_name(const std::string& value) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); name_.Set(value, GetArenaForAllocation());
} }
inline std::string* Mixin::_internal_mutable_name() { inline std::string* Mixin::_internal_mutable_name() {
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return name_.Mutable(GetArenaForAllocation());
} }
inline std::string* Mixin::release_name() { inline std::string* Mixin::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Mixin.name) // @@protoc_insertion_point(field_release:google.protobuf.Mixin.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return name_.Release();
} }
inline void Mixin::set_allocated_name(std::string* name) { inline void Mixin::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -1351,11 +1345,10 @@ inline void Mixin::set_allocated_name(std::string* name) {
} else { } else {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(name, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (name_.IsDefault()) { if (name_.IsDefault()) {
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name)
@ -1373,7 +1366,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Mixin::set_root(ArgT0&& arg0, ArgT... args) { void Mixin::set_root(ArgT0&& arg0, ArgT... args) {
root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); root_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.root) // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root)
} }
inline std::string* Mixin::mutable_root() { inline std::string* Mixin::mutable_root() {
@ -1386,15 +1379,15 @@ inline const std::string& Mixin::_internal_root() const {
} }
inline void Mixin::_internal_set_root(const std::string& value) { inline void Mixin::_internal_set_root(const std::string& value) {
root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); root_.Set(value, GetArenaForAllocation());
} }
inline std::string* Mixin::_internal_mutable_root() { inline std::string* Mixin::_internal_mutable_root() {
return root_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return root_.Mutable(GetArenaForAllocation());
} }
inline std::string* Mixin::release_root() { inline std::string* Mixin::release_root() {
// @@protoc_insertion_point(field_release:google.protobuf.Mixin.root) // @@protoc_insertion_point(field_release:google.protobuf.Mixin.root)
return root_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return root_.Release();
} }
inline void Mixin::set_allocated_root(std::string* root) { inline void Mixin::set_allocated_root(std::string* root) {
if (root != nullptr) { if (root != nullptr) {
@ -1402,11 +1395,10 @@ inline void Mixin::set_allocated_root(std::string* root) {
} else { } else {
} }
root_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), root, root_.SetAllocated(root, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (root_.IsDefault()) { if (root_.IsDefault()) {
root_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); root_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root)

@ -410,27 +410,10 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
template <typename T> template <typename T>
class InternalHelper { class InternalHelper {
public: private:
// Provides access to protected GetOwningArena to generated messages. // Provides access to protected GetOwningArena to generated messages.
static Arena* GetOwningArena(const T* p) { return p->GetOwningArena(); } static Arena* GetOwningArena(const T* p) { return p->GetOwningArena(); }
// Provides access to protected GetArenaForAllocation to generated messages.
static Arena* GetArenaForAllocation(const T* p) {
return GetArenaForAllocationInternal(
p, std::is_convertible<T*, MessageLite*>());
}
// Creates message-owned arena.
static Arena* CreateMessageOwnedArena() {
return new Arena(internal::MessageOwned{});
}
// Checks whether the given arena is message-owned.
static bool IsMessageOwnedArena(Arena* arena) {
return arena->IsMessageOwned();
}
private:
static Arena* GetArenaForAllocationInternal( static Arena* GetArenaForAllocationInternal(
const T* p, std::true_type /*is_derived_from<MessageLite>*/) { const T* p, std::true_type /*is_derived_from<MessageLite>*/) {
return p->GetArenaForAllocation(); return p->GetArenaForAllocation();
@ -513,6 +496,29 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
friend class TestUtil::ReflectionTester; friend class TestUtil::ReflectionTester;
}; };
// Provides access to protected GetOwningArena to generated messages. For
// internal use only.
template <typename T>
static Arena* InternalGetOwningArena(const T* p) {
return InternalHelper<T>::GetOwningArena(p);
}
// Provides access to protected GetArenaForAllocation to generated messages.
// For internal use only.
template <typename T>
static Arena* InternalGetArenaForAllocation(const T* p) {
return InternalHelper<T>::GetArenaForAllocationInternal(
p, std::is_convertible<T*, MessageLite*>());
}
// Creates message-owned arena. For internal use only.
static Arena* InternalCreateMessageOwnedArena() {
return new Arena(internal::MessageOwned{});
}
// Checks whether this arena is message-owned. For internal use only.
bool InternalIsMessageOwnedArena() { return IsMessageOwned(); }
// Helper typetraits that indicates support for arenas in a type T at compile // Helper typetraits that indicates support for arenas in a type T at compile
// time. This is public only to allow construction of higher-level templated // time. This is public only to allow construction of higher-level templated
// utilities. // utilities.

@ -547,13 +547,11 @@ TEST(ArenaTest, UnsafeArenaSwap) {
TEST(ArenaTest, GetOwningArena) { TEST(ArenaTest, GetOwningArena) {
Arena arena; Arena arena;
auto* m1 = Arena::CreateMessage<TestAllTypes>(&arena); auto* m1 = Arena::CreateMessage<TestAllTypes>(&arena);
EXPECT_EQ(Arena::InternalHelper<TestAllTypes>::GetOwningArena(m1), &arena); EXPECT_EQ(Arena::InternalGetOwningArena(m1), &arena);
EXPECT_EQ( EXPECT_EQ(&arena, Arena::InternalGetOwningArena(
&arena, m1->mutable_repeated_foreign_message()));
Arena::InternalHelper<RepeatedPtrField<ForeignMessage>>::GetOwningArena( EXPECT_EQ(&arena,
m1->mutable_repeated_foreign_message())); Arena::InternalGetOwningArena(m1->mutable_repeated_int32()));
EXPECT_EQ(&arena, Arena::InternalHelper<RepeatedField<int>>::GetOwningArena(
m1->mutable_repeated_int32()));
} }
TEST(ArenaTest, SwapBetweenArenasUsingReflection) { TEST(ArenaTest, SwapBetweenArenasUsingReflection) {

@ -112,13 +112,7 @@ std::string* ArenaStringPtr::SetAndReturnNewString() {
return new_string; return new_string;
} }
void ArenaStringPtr::DestroyNoArenaSlowPath() { void ArenaStringPtr::Set(ConstStringParam value, Arena* arena) {
GOOGLE_DCHECK(tagged_ptr_.IsAllocated());
delete UnsafeMutablePointer();
}
void ArenaStringPtr::Set(const std::string*, ConstStringParam value,
::google::protobuf::Arena* arena) {
if (IsDefault()) { if (IsDefault()) {
// If we're not on an arena, skip straight to a true string to avoid // If we're not on an arena, skip straight to a true string to avoid
// possible copy cost later. // possible copy cost later.
@ -128,8 +122,8 @@ void ArenaStringPtr::Set(const std::string*, ConstStringParam value,
UnsafeMutablePointer()->assign(value.data(), value.length()); UnsafeMutablePointer()->assign(value.data(), value.length());
} }
} }
void ArenaStringPtr::Set(const std::string*, std::string&& value,
::google::protobuf::Arena* arena) { void ArenaStringPtr::Set(std::string&& value, Arena* arena) {
if (IsDefault()) { if (IsDefault()) {
NewString(arena, std::move(value)); NewString(arena, std::move(value));
} else if (IsFixedSizeArena()) { } else if (IsFixedSizeArena()) {
@ -142,47 +136,26 @@ void ArenaStringPtr::Set(const std::string*, std::string&& value,
} }
} }
void ArenaStringPtr::Set(EmptyDefault, ConstStringParam value, std::string* ArenaStringPtr::Mutable(Arena* arena) {
::google::protobuf::Arena* arena) { if (tagged_ptr_.IsMutable()) {
Set(&GetEmptyStringAlreadyInited(), value, arena); return tagged_ptr_.Get();
}
void ArenaStringPtr::Set(EmptyDefault, std::string&& value,
::google::protobuf::Arena* arena) {
Set(&GetEmptyStringAlreadyInited(), std::move(value), arena);
}
void ArenaStringPtr::Set(NonEmptyDefault, ConstStringParam value,
::google::protobuf::Arena* arena) {
Set(nullptr, value, arena);
}
void ArenaStringPtr::Set(NonEmptyDefault, std::string&& value,
::google::protobuf::Arena* arena) {
Set(nullptr, std::move(value), arena);
}
std::string* ArenaStringPtr::Mutable(EmptyDefault, ::google::protobuf::Arena* arena) {
if (!IsFixedSizeArena() && !IsDefault()) {
return UnsafeMutablePointer();
} else { } else {
return MutableSlow(arena); return MutableSlow(arena);
} }
} }
std::string* ArenaStringPtr::Mutable(const LazyString& default_value, std::string* ArenaStringPtr::Mutable(const LazyString& default_value,
::google::protobuf::Arena* arena) { Arena* arena) {
if (!IsFixedSizeArena() && !IsDefault()) { if (tagged_ptr_.IsMutable()) {
return UnsafeMutablePointer(); return tagged_ptr_.Get();
} else { } else {
return MutableSlow(arena, default_value); return MutableSlow(arena, default_value);
} }
} }
std::string* ArenaStringPtr::MutableNoCopy(const std::string*, std::string* ArenaStringPtr::MutableNoCopy(Arena* arena) {
::google::protobuf::Arena* arena) { if (tagged_ptr_.IsMutable()) {
if (!IsFixedSizeArena() && !IsDefault()) { return tagged_ptr_.Get();
return UnsafeMutablePointer();
} else { } else {
GOOGLE_DCHECK(IsDefault()); GOOGLE_DCHECK(IsDefault());
// Allocate empty. The contents are not relevant. // Allocate empty. The contents are not relevant.
@ -197,45 +170,24 @@ std::string* ArenaStringPtr::MutableSlow(::google::protobuf::Arena* arena,
return NewString(arena, lazy_default.get()...); return NewString(arena, lazy_default.get()...);
} }
std::string* ArenaStringPtr::Release(const std::string* default_value, std::string* ArenaStringPtr::Release() {
::google::protobuf::Arena* arena) { if (IsDefault()) return nullptr;
if (IsDefault()) {
return nullptr;
} else {
return ReleaseNonDefault(default_value, arena);
}
}
std::string* ArenaStringPtr::ReleaseNonDefault(const std::string* default_value, std::string* released = tagged_ptr_.Get();
::google::protobuf::Arena* arena) { if (!tagged_ptr_.IsAllocated()) {
GOOGLE_DCHECK(!IsDefault()); released = tagged_ptr_.IsMutable() ? new std::string(std::move(*released))
: new std::string(*released);
if (!IsFixedSizeArena()) {
std::string* released;
if (arena != nullptr) {
released = new std::string;
released->swap(*UnsafeMutablePointer());
} else {
released = UnsafeMutablePointer();
}
tagged_ptr_.SetDefault(default_value);
return released;
} else /* IsFixedSizeArena() */ {
GOOGLE_DCHECK(arena != nullptr);
std::string* released = new std::string(Get());
tagged_ptr_.SetDefault(default_value);
return released;
} }
InitDefault();
return released;
} }
void ArenaStringPtr::SetAllocated(const std::string* default_value, void ArenaStringPtr::SetAllocated(std::string* value, Arena* arena) {
std::string* value, ::google::protobuf::Arena* arena) {
// Release what we have first. // Release what we have first.
if (arena == nullptr && !IsDefault()) { Destroy();
delete UnsafeMutablePointer();
}
if (value == nullptr) { if (value == nullptr) {
tagged_ptr_.SetDefault(default_value); InitDefault();
} else { } else {
#ifndef NDEBUG #ifndef NDEBUG
// On debug builds, copy the string so the address differs. delete will // On debug builds, copy the string so the address differs. delete will
@ -249,23 +201,12 @@ void ArenaStringPtr::SetAllocated(const std::string* default_value,
} }
} }
void ArenaStringPtr::Destroy(const std::string*, ::google::protobuf::Arena* arena) { void ArenaStringPtr::Destroy() {
if (arena == nullptr) { if (tagged_ptr_.IsAllocated()) {
GOOGLE_DCHECK(!IsFixedSizeArena()); delete tagged_ptr_.Get();
if (!IsDefault()) {
delete UnsafeMutablePointer();
}
} }
} }
void ArenaStringPtr::Destroy(EmptyDefault, ::google::protobuf::Arena* arena) {
Destroy(&GetEmptyStringAlreadyInited(), arena);
}
void ArenaStringPtr::Destroy(NonEmptyDefault, ::google::protobuf::Arena* arena) {
Destroy(nullptr, arena);
}
void ArenaStringPtr::ClearToEmpty() { void ArenaStringPtr::ClearToEmpty() {
if (IsDefault()) { if (IsDefault()) {
// Already set to default -- do nothing. // Already set to default -- do nothing.

@ -187,7 +187,7 @@ class TaggedPtr {
} }
inline T* TagAs(Type type, T* p) { inline T* TagAs(Type type, T* p) {
GOOGLE_DCHECK(type == kDefault || p != nullptr); GOOGLE_DCHECK(p != nullptr);
assert_aligned(p); assert_aligned(p);
ptr_ = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(p) | type); ptr_ = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(p) | type);
return p; return p;
@ -232,84 +232,84 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
struct EmptyDefault {}; struct EmptyDefault {};
struct NonEmptyDefault {}; struct NonEmptyDefault {};
void Set(const std::string* default_value, ConstStringParam value, // Called from generated code / reflection runtime only. Resets value to point
::google::protobuf::Arena* arena); // to a default string pointer, with the semantics that this ArenaStringPtr
void Set(const std::string* default_value, std::string&& value, // does not own the pointed-to memory. Disregards initial value of ptr_ (so
::google::protobuf::Arena* arena); // this is the *ONLY* safe method to call after construction or when
void Set(EmptyDefault, ConstStringParam value, ::google::protobuf::Arena* arena); // reinitializing after becoming the active field in a oneof union).
void Set(EmptyDefault, std::string&& value, ::google::protobuf::Arena* arena); inline void InitDefault();
void Set(NonEmptyDefault, ConstStringParam value, ::google::protobuf::Arena* arena);
void Set(NonEmptyDefault, std::string&& value, ::google::protobuf::Arena* arena); // Similar to `InitDefault` except that it allows the default value to be
template <typename FirstParam> // initialized to an externally owned string. This method is called from
void Set(FirstParam p1, const char* str, ::google::protobuf::Arena* arena) { // parsing code. `str` must not be null and outlive this instance.
Set(p1, ConstStringParam(str), arena); inline void InitExternal(const std::string* str);
}
template <typename FirstParam> // Called from generated code / reflection runtime only. Resets the value of
void Set(FirstParam p1, const char* str, size_t size, // this instances to the heap allocated value in `str`. `str` must not be
::google::protobuf::Arena* arena) { // null. Invokes `arena->Own(str)` to transfer ownership into the arena if
ConstStringParam sp{str, size}; // for string_view and `const string &` // `arena` is not null, else, `str` will be owned by ArenaStringPtr. This
Set(p1, sp, arena); // function should only be used to initialize a ArenaStringPtr or on an
} // instance known to not carry any heap allocated value.
template <typename FirstParam, typename RefWrappedType> inline void InitAllocated(std::string* str, Arena* arena);
void Set(FirstParam p1,
std::reference_wrapper<RefWrappedType> const_string_ref, void Set(ConstStringParam value, Arena* arena);
void Set(std::string&& value, Arena* arena);
void Set(const char* s, Arena* arena);
void Set(const char* s, size_t n, Arena* arena);
void SetBytes(ConstStringParam value, Arena* arena);
void SetBytes(std::string&& value, Arena* arena);
void SetBytes(const char* s, Arena* arena);
void SetBytes(const void* p, size_t n, Arena* arena);
template <typename RefWrappedType>
void Set(std::reference_wrapper<RefWrappedType> const_string_ref,
::google::protobuf::Arena* arena) { ::google::protobuf::Arena* arena) {
Set(p1, const_string_ref.get(), arena); Set(const_string_ref.get(), arena);
} }
template <typename FirstParam, typename SecondParam> // Returns a mutable std::string reference.
void SetBytes(FirstParam p1, SecondParam&& p2, ::google::protobuf::Arena* arena) { // The version accepting a `LazyString` value is used in the generated code to
Set(p1, static_cast<SecondParam&&>(p2), arena); // initialize mutable copies for fields with a non-empty default where the
} // default value is lazily initialized.
template <typename FirstParam> std::string* Mutable(Arena* arena);
void SetBytes(FirstParam p1, const void* str, size_t size, std::string* Mutable(const LazyString& default_value, Arena* arena);
::google::protobuf::Arena* arena) {
// must work whether ConstStringParam is string_view or `const string &` // Gets a mutable pointer with unspecified contents.
ConstStringParam sp{static_cast<const char*>(str), size}; // This function is identical to Mutable(), except it is optimized for the
Set(p1, sp, arena); // case where the caller is not interested in the current contents. For
} // example, if the current field is not mutable, it will re-initialize the
// value with an empty string rather than a (non-empty) default value.
// Likewise, if the current value is a fixed size arena string with contents,
// it will be initialized into an empty mutable arena string.
std::string* MutableNoCopy(Arena* arena);
// Basic accessors. // Basic accessors.
PROTOBUF_NDEBUG_INLINE const std::string& Get() const { PROTOBUF_NDEBUG_INLINE const std::string& Get() const {
// Unconditionally mask away the tag. // Unconditionally mask away the tag.
return *tagged_ptr_.Get(); return *tagged_ptr_.Get();
} }
PROTOBUF_NDEBUG_INLINE const std::string* GetPointer() const {
// Unconditionally mask away the tag. // Returns a pointer to the stored contents for this instance.
// This method is for internal debugging and tracking purposes only.
PROTOBUF_NDEBUG_INLINE const std::string* UnsafeGetPointer() const
PROTOBUF_RETURNS_NONNULL {
return tagged_ptr_.Get(); return tagged_ptr_.Get();
} }
// For fields with an empty default value.
std::string* Mutable(EmptyDefault, ::google::protobuf::Arena* arena);
// For fields with a non-empty default value.
std::string* Mutable(const LazyString& default_value, ::google::protobuf::Arena* arena);
// Release returns a std::string* instance that is heap-allocated and is not // Release returns a std::string* instance that is heap-allocated and is not
// Own()'d by any arena. If the field is not set, this returns nullptr. The // Own()'d by any arena. If the field is not set, this returns nullptr. The
// caller retains ownership. Clears this field back to nullptr state. Used to // caller retains ownership. Clears this field back to the default state.
// implement release_<field>() methods on generated classes. // Used to implement release_<field>() methods on generated classes.
PROTOBUF_NODISCARD std::string* Release(const std::string* default_value, PROTOBUF_NODISCARD std::string* Release();
::google::protobuf::Arena* arena);
PROTOBUF_NODISCARD std::string* ReleaseNonDefault(
const std::string* default_value, ::google::protobuf::Arena* arena);
// Takes a std::string that is heap-allocated, and takes ownership. The // Takes a std::string that is heap-allocated, and takes ownership. The
// std::string's destructor is registered with the arena. Used to implement // std::string's destructor is registered with the arena. Used to implement
// set_allocated_<field> in generated classes. // set_allocated_<field> in generated classes.
void SetAllocated(const std::string* default_value, std::string* value, void SetAllocated(std::string* value, Arena* arena);
::google::protobuf::Arena* arena);
// Swaps internal pointers. Arena-safety semantics: this is guarded by the
// logic in Swap()/UnsafeArenaSwap() at the message level, so this method is
// 'unsafe' if called directly.
inline PROTOBUF_NDEBUG_INLINE static void InternalSwap(
const std::string* default_value, ArenaStringPtr* rhs, Arena* rhs_arena,
ArenaStringPtr* lhs, Arena* lhs_arena);
// Frees storage (if not on an arena). // Frees storage (if not on an arena).
void Destroy(const std::string* default_value, ::google::protobuf::Arena* arena); void Destroy();
void Destroy(EmptyDefault, ::google::protobuf::Arena* arena);
void Destroy(NonEmptyDefault, ::google::protobuf::Arena* arena);
// Clears content, but keeps allocated std::string, to avoid the overhead of // Clears content, but keeps allocated std::string, to avoid the overhead of
// heap operations. After this returns, the content (as seen by the user) will // heap operations. After this returns, the content (as seen by the user) will
@ -326,37 +326,109 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
// (as seen by the user) will always be equal to |default_value|. // (as seen by the user) will always be equal to |default_value|.
void ClearToDefault(const LazyString& default_value, ::google::protobuf::Arena* arena); void ClearToDefault(const LazyString& default_value, ::google::protobuf::Arena* arena);
// Called from generated code / reflection runtime only. Resets value to point // Swaps internal pointers. Arena-safety semantics: this is guarded by the
// to a default string pointer, with the semantics that this ArenaStringPtr // logic in Swap()/UnsafeArenaSwap() at the message level, so this method is
// does not own the pointed-to memory. Disregards initial value of ptr_ (so // 'unsafe' if called directly.
// this is the *ONLY* safe method to call after construction or when inline PROTOBUF_NDEBUG_INLINE static void InternalSwap(ArenaStringPtr* rhs,
// reinitializing after becoming the active field in a oneof union). Arena* rhs_arena,
// This function allows an explicit default value other than the default ArenaStringPtr* lhs,
// global empty string. This is used in unit tests and by fields with Arena* lhs_arena);
// explicit non-empty default string values using null defaults.
inline void InitDefault(); // --------------------------------------------------------
inline void InitDefault(const std::string* str); // Below functions will be removed in subsequent code change
// --------------------------------------------------------
#ifdef DEPRECATED_METHODS_TO_BE_DELETED
PROTOBUF_NDEBUG_INLINE const std::string* GetPointer() const {
return UnsafeGetPointer();
}
// Called from generated code / reflection runtime only. Resets the value of template <typename DefaultArg>
// this instances to the heap allocated value in `str`. `str` must not be void Set(DefaultArg, ConstStringParam value, Arena* arena) {
// null. Invokes `arena->Own(str)` to transfer ownership into the arena if return Set(value, arena);
// `arena` is not null, else, `str` will be owned by ArenaStringPtr. This }
// function should only be used to initialize a ArenaStringPtr or on an template <typename DefaultArg>
// instance known to not carry any heap allocated value. void Set(DefaultArg, std::string&& value, Arena* arena) {
inline void InitAllocated(std::string* str, Arena* arena); return Set(std::move(value), arena);
}
template <typename DefaultArg>
void Set(DefaultArg, const char* s, Arena* arena) {
return Set(ConstStringParam{s}, arena);
}
template <typename DefaultArg>
void Set(DefaultArg, const char* s, size_t n, Arena* arena) {
return Set(ConstStringParam{s, n}, arena);
}
// Returns a mutable pointer, but doesn't initialize the string to the void SetBytes(EmptyDefault, ConstStringParam value, Arena* arena) {
// default value. return Set(value, arena);
std::string* MutableNoArenaNoDefault(const std::string* default_value); }
void SetBytes(NonEmptyDefault, ConstStringParam value, Arena* arena) {
return Set(value, arena);
}
void SetBytes(const std::string*, ConstStringParam value, Arena* arena) {
return Set(value, arena);
}
void SetBytes(EmptyDefault, std::string&& value, Arena* arena) {
return Set(std::move(value), arena);
}
void SetBytes(NonEmptyDefault, std::string&& value, Arena* arena) {
return Set(std::move(value), arena);
}
void SetBytes(const std::string*, std::string&& value, Arena* arena) {
return Set(std::move(value), arena);
}
void SetBytes(EmptyDefault, const char* s, Arena* arena) {
return Set(s, arena);
}
void SetBytes(NonEmptyDefault, const char* s, Arena* arena) {
return Set(s, arena);
}
void SetBytes(const std::string*, const char* s, Arena* arena) {
return Set(s, arena);
}
void SetBytes(EmptyDefault, const void* p, size_t n, Arena* arena) {
return SetBytes(p, n, arena);
}
void SetBytes(NonEmptyDefault, const void* p, size_t n, Arena* arena) {
return SetBytes(p, n, arena);
}
void SetBytes(const std::string*, const void* p, size_t n, Arena* arena) {
return SetBytes(p, n, arena);
}
std::string* Mutable(EmptyDefault, Arena* arena) { return Mutable(arena); }
std::string* MutableNoArenaNoDefault(const std::string*) {
return Mutable(nullptr);
}
std::string* MutableNoCopy(const std::string*, ::google::protobuf::Arena* arena) {
return MutableNoCopy(arena);
}
PROTOBUF_NODISCARD std::string* Release(const std::string*, Arena* arena) {
return Release();
}
PROTOBUF_NODISCARD std::string* ReleaseNonDefault(const std::string*,
Arena* arena) {
return Release();
}
// Get a mutable pointer with unspecified contents. void SetAllocated(const std::string*, std::string* value, Arena* arena) {
// Similar to `MutableNoArenaNoDefault`, but also handles the arena case. SetAllocated(value, arena);
// If the value was donated, the contents are discarded. }
std::string* MutableNoCopy(const std::string* default_value,
::google::protobuf::Arena* arena);
// Destroy the string. Assumes `arena == nullptr`. void Destroy(const std::string*, ::google::protobuf::Arena* arena) { Destroy(); }
void DestroyNoArena(const std::string* default_value); void Destroy(EmptyDefault, ::google::protobuf::Arena* arena) { Destroy(); }
void Destroy(NonEmptyDefault, ::google::protobuf::Arena* arena) { Destroy(); }
void DestroyNoArena(const std::string*) { Destroy(); }
inline PROTOBUF_NDEBUG_INLINE static void InternalSwap(const std::string*,
ArenaStringPtr* rhs,
Arena* rhs_arena,
ArenaStringPtr* lhs,
Arena* lhs_arena) {
InternalSwap(rhs, rhs_arena, lhs, lhs_arena);
}
#endif // DEPRECATED_METHODS_TO_BE_DELETED
// Internal setter used only at parse time to directly set a donated string // Internal setter used only at parse time to directly set a donated string
// value. // value.
@ -407,9 +479,6 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
// Sets value to a newly allocated string and returns it // Sets value to a newly allocated string and returns it
std::string* SetAndReturnNewString(); std::string* SetAndReturnNewString();
// Destroys the non-default string value out-of-line
void DestroyNoArenaSlowPath();
friend class EpsCopyInputStream; friend class EpsCopyInputStream;
}; };
@ -417,7 +486,7 @@ inline void ArenaStringPtr::InitDefault() {
tagged_ptr_ = TaggedPtr<std::string>(&fixed_address_empty_string); tagged_ptr_ = TaggedPtr<std::string>(&fixed_address_empty_string);
} }
inline void ArenaStringPtr::InitDefault(const std::string* str) { inline void ArenaStringPtr::InitExternal(const std::string* str) {
tagged_ptr_.SetDefault(str); tagged_ptr_.SetDefault(str);
} }
@ -430,9 +499,32 @@ inline void ArenaStringPtr::InitAllocated(std::string* str, Arena* arena) {
} }
} }
inline void ArenaStringPtr::Set(const char* s, Arena* arena) {
Set(ConstStringParam{s}, arena);
}
inline void ArenaStringPtr::Set(const char* s, size_t n, Arena* arena) {
Set(ConstStringParam{s, n}, arena);
}
inline void ArenaStringPtr::SetBytes(ConstStringParam value, Arena* arena) {
Set(value, arena);
}
inline void ArenaStringPtr::SetBytes(std::string&& value, Arena* arena) {
Set(std::move(value), arena);
}
inline void ArenaStringPtr::SetBytes(const char* s, Arena* arena) {
Set(s, arena);
}
inline void ArenaStringPtr::SetBytes(const void* p, size_t n, Arena* arena) {
Set(ConstStringParam{static_cast<const char*>(p), n}, arena);
}
// Make sure rhs_arena allocated rhs, and lhs_arena allocated lhs. // Make sure rhs_arena allocated rhs, and lhs_arena allocated lhs.
inline PROTOBUF_NDEBUG_INLINE void ArenaStringPtr::InternalSwap( // inline PROTOBUF_NDEBUG_INLINE void ArenaStringPtr::InternalSwap( //
const std::string*, //
ArenaStringPtr* rhs, Arena* rhs_arena, // ArenaStringPtr* rhs, Arena* rhs_arena, //
ArenaStringPtr* lhs, Arena* lhs_arena) { ArenaStringPtr* lhs, Arena* lhs_arena) {
// Silence unused variable warnings in release buildls. // Silence unused variable warnings in release buildls.
@ -466,28 +558,6 @@ inline void ArenaStringPtr::ClearNonDefaultToEmpty() {
tagged_ptr_.Get()->clear(); tagged_ptr_.Get()->clear();
} }
inline std::string* ArenaStringPtr::MutableNoArenaNoDefault(
const std::string* /* default_value */) {
// VERY IMPORTANT for performance and code size: this will reduce to a member
// variable load, a pointer check (against |default_value|, in practice a
// static global) and a branch to the slowpath (which calls operator new and
// the ctor). DO NOT add any tagged-pointer operations here.
GOOGLE_DCHECK(!tagged_ptr_.IsArena());
if (IsDefault()) {
return SetAndReturnNewString();
} else {
return UnsafeMutablePointer();
}
}
inline void ArenaStringPtr::DestroyNoArena(
const std::string* /* default_value */) {
GOOGLE_DCHECK(!tagged_ptr_.IsArena());
if (!IsDefault()) {
DestroyNoArenaSlowPath();
}
}
inline std::string* ArenaStringPtr::UnsafeMutablePointer() { inline std::string* ArenaStringPtr::UnsafeMutablePointer() {
GOOGLE_DCHECK(tagged_ptr_.IsMutable()); GOOGLE_DCHECK(tagged_ptr_.IsMutable());
GOOGLE_DCHECK(tagged_ptr_.Get() != nullptr); GOOGLE_DCHECK(tagged_ptr_.Get() != nullptr);

@ -34,6 +34,7 @@
#include <cstdlib> #include <cstdlib>
#include <memory> #include <memory>
#include <string> #include <string>
#include <utility>
#include <vector> #include <vector>
#include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/logging.h>
@ -72,37 +73,36 @@ INSTANTIATE_TEST_SUITE_P(ArenaString, SingleArena, testing::Bool());
TEST_P(SingleArena, GetSet) { TEST_P(SingleArena, GetSet) {
auto arena = GetArena(); auto arena = GetArena();
ArenaStringPtr field; ArenaStringPtr field;
field.InitDefault(empty_default); field.InitDefault();
EXPECT_EQ("", field.Get()); EXPECT_EQ("", field.Get());
field.Set(empty_default, "Test short", arena.get()); field.Set("Test short", arena.get());
EXPECT_EQ("Test short", field.Get()); EXPECT_EQ("Test short", field.Get());
field.Set(empty_default, "Test long long long long value", arena.get()); field.Set("Test long long long long value", arena.get());
EXPECT_EQ("Test long long long long value", field.Get()); EXPECT_EQ("Test long long long long value", field.Get());
field.Set(empty_default, "", arena.get()); field.Set("", arena.get());
field.Destroy(empty_default, arena.get()); field.Destroy();
} }
TEST_P(SingleArena, MutableAccessor) { TEST_P(SingleArena, MutableAccessor) {
auto arena = GetArena(); auto arena = GetArena();
ArenaStringPtr field; ArenaStringPtr field;
const std::string* empty_default = &internal::GetEmptyString(); field.InitDefault();
field.InitDefault(empty_default);
std::string* mut = field.Mutable(EmptyDefault{}, arena.get()); std::string* mut = field.Mutable(arena.get());
EXPECT_EQ(mut, field.Mutable(EmptyDefault{}, arena.get())); EXPECT_EQ(mut, field.Mutable(arena.get()));
EXPECT_EQ(mut, &field.Get()); EXPECT_EQ(mut, &field.Get());
EXPECT_NE(empty_default, mut); EXPECT_NE(empty_default, mut);
EXPECT_EQ("", *mut); EXPECT_EQ("", *mut);
*mut = "Test long long long long value"; // ensure string allocates storage *mut = "Test long long long long value"; // ensure string allocates storage
EXPECT_EQ("Test long long long long value", field.Get()); EXPECT_EQ("Test long long long long value", field.Get());
field.Destroy(empty_default, arena.get()); field.Destroy();
} }
TEST_P(SingleArena, NullDefault) { TEST_P(SingleArena, NullDefault) {
auto arena = GetArena(); auto arena = GetArena();
ArenaStringPtr field; ArenaStringPtr field;
field.InitDefault(nullptr); field.InitDefault();
std::string* mut = field.Mutable(nonempty_default, arena.get()); std::string* mut = field.Mutable(nonempty_default, arena.get());
EXPECT_EQ(mut, field.Mutable(nonempty_default, arena.get())); EXPECT_EQ(mut, field.Mutable(nonempty_default, arena.get()));
EXPECT_EQ(mut, &field.Get()); EXPECT_EQ(mut, &field.Get());
@ -110,7 +110,7 @@ TEST_P(SingleArena, NullDefault) {
EXPECT_EQ("default", *mut); EXPECT_EQ("default", *mut);
*mut = "Test long long long long value"; // ensure string allocates storage *mut = "Test long long long long value"; // ensure string allocates storage
EXPECT_EQ("Test long long long long value", field.Get()); EXPECT_EQ("Test long long long long value", field.Get());
field.Destroy(nullptr, arena.get()); field.Destroy();
} }
class DualArena : public testing::TestWithParam<std::tuple<bool, bool>> { class DualArena : public testing::TestWithParam<std::tuple<bool, bool>> {
@ -131,23 +131,22 @@ INSTANTIATE_TEST_SUITE_P(ArenaString, DualArena,
TEST_P(DualArena, Swap) { TEST_P(DualArena, Swap) {
auto lhs_arena = GetLhsArena(); auto lhs_arena = GetLhsArena();
ArenaStringPtr lhs; ArenaStringPtr lhs;
lhs.InitDefault(empty_default); lhs.InitDefault();
ArenaStringPtr rhs; ArenaStringPtr rhs;
rhs.InitDefault(empty_default); rhs.InitDefault();
{ {
auto rhs_arena = GetRhsArena(); auto rhs_arena = GetRhsArena();
lhs.Set(empty_default, "lhs value that has some heft", lhs_arena.get()); lhs.Set("lhs value that has some heft", lhs_arena.get());
rhs.Set(empty_default, "rhs value that has some heft", rhs_arena.get()); rhs.Set("rhs value that has some heft", rhs_arena.get());
ArenaStringPtr::InternalSwap(empty_default, // ArenaStringPtr::InternalSwap(&lhs, lhs_arena.get(), //
&lhs, lhs_arena.get(), //
&rhs, rhs_arena.get()); &rhs, rhs_arena.get());
EXPECT_EQ("rhs value that has some heft", lhs.Get()); EXPECT_EQ("rhs value that has some heft", lhs.Get());
EXPECT_EQ("lhs value that has some heft", rhs.Get()); EXPECT_EQ("lhs value that has some heft", rhs.Get());
lhs.Destroy(empty_default, rhs_arena.get()); lhs.Destroy();
} }
EXPECT_EQ("lhs value that has some heft", rhs.Get()); EXPECT_EQ("lhs value that has some heft", rhs.Get());
rhs.Destroy(empty_default, lhs_arena.get()); rhs.Destroy();
} }

@ -91,7 +91,7 @@ void EnumFieldGenerator::GenerateInlineAccessorDefinitions(
Formatter format(printer, variables_); Formatter format(printer, variables_);
format( format(
"inline $type$ $classname$::_internal_$name$() const {\n" "inline $type$ $classname$::_internal_$name$() const {\n"
" return static_cast< $type$ >($name$_);\n" " return static_cast< $type$ >($field$);\n"
"}\n" "}\n"
"inline $type$ $classname$::$name$() const {\n" "inline $type$ $classname$::$name$() const {\n"
"$annotate_get$" "$annotate_get$"
@ -104,7 +104,7 @@ void EnumFieldGenerator::GenerateInlineAccessorDefinitions(
} }
format( format(
" $set_hasbit$\n" " $set_hasbit$\n"
" $name$_ = value;\n" " $field$ = value;\n"
"}\n" "}\n"
"inline void $classname$::set_$name$($type$ value) {\n" "inline void $classname$::set_$name$($type$ value) {\n"
" _internal_set_$name$(value);\n" " _internal_set_$name$(value);\n"
@ -115,7 +115,7 @@ void EnumFieldGenerator::GenerateInlineAccessorDefinitions(
void EnumFieldGenerator::GenerateClearingCode(io::Printer* printer) const { void EnumFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_ = $default$;\n"); format("$field$ = $default$;\n");
} }
void EnumFieldGenerator::GenerateMergingCode(io::Printer* printer) const { void EnumFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
@ -125,7 +125,7 @@ void EnumFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
void EnumFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { void EnumFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("swap($name$_, other->$name$_);\n"); format("swap($field$, other->$field$);\n");
} }
void EnumFieldGenerator::GenerateConstructorCode(io::Printer* printer) const { void EnumFieldGenerator::GenerateConstructorCode(io::Printer* printer) const {
@ -177,7 +177,7 @@ void EnumOneofFieldGenerator::GenerateInlineAccessorDefinitions(
format( format(
"inline $type$ $classname$::_internal_$name$() const {\n" "inline $type$ $classname$::_internal_$name$() const {\n"
" if (_internal_has_$name$()) {\n" " if (_internal_has_$name$()) {\n"
" return static_cast< $type$ >($field_member$);\n" " return static_cast< $type$ >($field$);\n"
" }\n" " }\n"
" return static_cast< $type$ >($default$);\n" " return static_cast< $type$ >($default$);\n"
"}\n" "}\n"
@ -195,7 +195,7 @@ void EnumOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" clear_$oneof_name$();\n" " clear_$oneof_name$();\n"
" set_has_$name$();\n" " set_has_$name$();\n"
" }\n" " }\n"
" $field_member$ = value;\n" " $field$ = value;\n"
"}\n" "}\n"
"inline void $classname$::set_$name$($type$ value) {\n" "inline void $classname$::set_$name$($type$ value) {\n"
" _internal_set_$name$(value);\n" " _internal_set_$name$(value);\n"
@ -206,7 +206,7 @@ void EnumOneofFieldGenerator::GenerateInlineAccessorDefinitions(
void EnumOneofFieldGenerator::GenerateClearingCode(io::Printer* printer) const { void EnumOneofFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$field_member$ = $default$;\n"); format("$field$ = $default$;\n");
} }
void EnumOneofFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { void EnumOneofFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
@ -264,7 +264,7 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions(
Formatter format(printer, variables_); Formatter format(printer, variables_);
format( format(
"inline $type$ $classname$::_internal_$name$(int index) const {\n" "inline $type$ $classname$::_internal_$name$(int index) const {\n"
" return static_cast< $type$ >($name$_.Get(index));\n" " return static_cast< $type$ >($field$.Get(index));\n"
"}\n" "}\n"
"inline $type$ $classname$::$name$(int index) const {\n" "inline $type$ $classname$::$name$(int index) const {\n"
"$annotate_get$" "$annotate_get$"
@ -276,7 +276,7 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions(
format(" assert($type$_IsValid(value));\n"); format(" assert($type$_IsValid(value));\n");
} }
format( format(
" $name$_.Set(index, value);\n" " $field$.Set(index, value);\n"
"$annotate_set$" "$annotate_set$"
" // @@protoc_insertion_point(field_set:$full_name$)\n" " // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n" "}\n"
@ -285,7 +285,7 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions(
format(" assert($type$_IsValid(value));\n"); format(" assert($type$_IsValid(value));\n");
} }
format( format(
" $name$_.Add(value);\n" " $field$.Add(value);\n"
"}\n" "}\n"
"inline void $classname$::add_$name$($type$ value) {\n" "inline void $classname$::add_$name$($type$ value) {\n"
" _internal_add_$name$(value);\n" " _internal_add_$name$(value);\n"
@ -296,11 +296,11 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions(
"$classname$::$name$() const {\n" "$classname$::$name$() const {\n"
"$annotate_list$" "$annotate_list$"
" // @@protoc_insertion_point(field_list:$full_name$)\n" " // @@protoc_insertion_point(field_list:$full_name$)\n"
" return $name$_;\n" " return $field$;\n"
"}\n" "}\n"
"inline ::$proto_ns$::RepeatedField<int>*\n" "inline ::$proto_ns$::RepeatedField<int>*\n"
"$classname$::_internal_mutable_$name$() {\n" "$classname$::_internal_mutable_$name$() {\n"
" return &$name$_;\n" " return &$field$;\n"
"}\n" "}\n"
"inline ::$proto_ns$::RepeatedField<int>*\n" "inline ::$proto_ns$::RepeatedField<int>*\n"
"$classname$::mutable_$name$() {\n" "$classname$::mutable_$name$() {\n"
@ -313,19 +313,19 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions(
void RepeatedEnumFieldGenerator::GenerateClearingCode( void RepeatedEnumFieldGenerator::GenerateClearingCode(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_.Clear();\n"); format("$field$.Clear();\n");
} }
void RepeatedEnumFieldGenerator::GenerateMergingCode( void RepeatedEnumFieldGenerator::GenerateMergingCode(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_.MergeFrom(from.$name$_);\n"); format("$field$.MergeFrom(from.$field$);\n");
} }
void RepeatedEnumFieldGenerator::GenerateSwappingCode( void RepeatedEnumFieldGenerator::GenerateSwappingCode(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_.InternalSwap(&other->$name$_);\n"); format("$field$.InternalSwap(&other->$field$);\n");
} }
void RepeatedEnumFieldGenerator::GenerateConstructorCode( void RepeatedEnumFieldGenerator::GenerateConstructorCode(
@ -344,7 +344,7 @@ void RepeatedEnumFieldGenerator::GenerateSerializeWithCachedSizesToArray(
"_$name$_cached_byte_size_.load(std::memory_order_relaxed);\n" "_$name$_cached_byte_size_.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$, $name$_, byte_size, target);\n" " $number$, $field$, byte_size, target);\n"
" }\n" " }\n"
"}\n"); "}\n");
} else { } else {
@ -375,7 +375,8 @@ void RepeatedEnumFieldGenerator::GenerateByteSize(io::Printer* printer) const {
format( format(
"if (data_size > 0) {\n" "if (data_size > 0) {\n"
" total_size += $tag_size$ +\n" " total_size += $tag_size$ +\n"
" ::_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" "_$name$_cached_byte_size_.store(cached_size,\n"

@ -81,7 +81,7 @@ std::string GenerateTemplateForOneofString(const FieldDescriptor* descriptor,
std::string field_name = google::protobuf::compiler::cpp::FieldName(descriptor); std::string field_name = google::protobuf::compiler::cpp::FieldName(descriptor);
std::string field_pointer = std::string field_pointer =
descriptor->options().ctype() == google::protobuf::FieldOptions::STRING descriptor->options().ctype() == google::protobuf::FieldOptions::STRING
? "$0.GetPointer()" ? "$0.UnsafeGetPointer()"
: "$0"; : "$0";
if (descriptor->default_value_string().empty()) { if (descriptor->default_value_string().empty()) {
@ -114,7 +114,7 @@ std::string GenerateTemplateForSingleString(const FieldDescriptor* descriptor,
if (descriptor->options().ctype() == google::protobuf::FieldOptions::STRING) { if (descriptor->options().ctype() == google::protobuf::FieldOptions::STRING) {
return strings::Substitute( return strings::Substitute(
"$0.IsDefault() ? &$1.get() : $0.GetPointer()", field_member, "$0.IsDefault() ? &$1.get() : $0.UnsafeGetPointer()", field_member,
MakeDefaultName(descriptor)); MakeDefaultName(descriptor));
} }
@ -241,7 +241,12 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
(*variables)["number"] = StrCat(descriptor->number()); (*variables)["number"] = StrCat(descriptor->number());
(*variables)["classname"] = ClassName(FieldScope(descriptor), false); (*variables)["classname"] = ClassName(FieldScope(descriptor), false);
(*variables)["declared_type"] = DeclaredTypeMethodName(descriptor->type()); (*variables)["declared_type"] = DeclaredTypeMethodName(descriptor->type());
// TODO(b/218325252): convert all usages of "field_member" to "field" and
// remove this. The former may unnecessarily cause line breaks in protoc code.
// Note that the length of variables has no effect on the generated code. It
// only affects the readability of code template in protoc.
(*variables)["field_member"] = FieldMemberName(descriptor); (*variables)["field_member"] = FieldMemberName(descriptor);
(*variables)["field"] = FieldMemberName(descriptor);
(*variables)["tag_size"] = StrCat( (*variables)["tag_size"] = StrCat(
WireFormat::TagSize(descriptor->number(), descriptor->type())); WireFormat::TagSize(descriptor->number(), descriptor->type()));

@ -82,6 +82,12 @@ bool CppGenerator::Generate(const FileDescriptor* file,
// FOO_EXPORT is a macro which should expand to __declspec(dllexport) or // FOO_EXPORT is a macro which should expand to __declspec(dllexport) or
// __declspec(dllimport) depending on what is being compiled. // __declspec(dllimport) depending on what is being compiled.
// //
// If the proto_h option is passed to the compiler, we will generate all
// classes and enums so that they can be forward-declared from files that
// need them from imports.
//
// If the lite option is passed to the compiler, we will generate the
// current files and all transitive dependencies using the LITE runtime.
Options file_options; Options file_options;
file_options.opensource_runtime = opensource_runtime_; file_options.opensource_runtime = opensource_runtime_;
@ -111,6 +117,8 @@ bool CppGenerator::Generate(const FileDescriptor* file,
file_options.num_cc_files = file_options.num_cc_files =
strto32(options[i].second.c_str(), nullptr, 10); strto32(options[i].second.c_str(), nullptr, 10);
} }
} else if (options[i].first == "proto_h") {
file_options.proto_h = true;
} else if (options[i].first == "annotate_accessor") { } else if (options[i].first == "annotate_accessor") {
file_options.annotate_accessor = true; file_options.annotate_accessor = true;
} else if (options[i].first == "inject_field_listener_events") { } else if (options[i].first == "inject_field_listener_events") {

@ -1240,12 +1240,13 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) {
} else { } else {
format( format(
"inline int $classname$::_internal_$name$_size() const {\n" "inline int $classname$::_internal_$name$_size() const {\n"
" return $name$_$1$.size();\n" " return $1$$2$.size();\n"
"}\n" "}\n"
"inline int $classname$::$name$_size() const {\n" "inline int $classname$::$name$_size() const {\n"
"$annotate_size$" "$annotate_size$"
" return _internal_$name$_size();\n" " return _internal_$name$_size();\n"
"}\n", "}\n",
FieldMemberName(field),
IsImplicitWeakField(field, options_, scc_analyzer_) && IsImplicitWeakField(field, options_, scc_analyzer_) &&
field->message_type() field->message_type()
? ".weak" ? ".weak"
@ -1391,8 +1392,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
if (EnableMessageOwnedArena(descriptor_, options_)) { if (EnableMessageOwnedArena(descriptor_, options_)) {
format( format(
"inline $classname$() : $classname$(" "inline $classname$() : $classname$("
"::$proto_ns$::Arena::InternalHelper<$classname$>::\n" "::$proto_ns$::Arena::InternalCreateMessageOwnedArena(), true) {}\n");
" CreateMessageOwnedArena(), true) {}\n");
} else { } else {
format("inline $classname$() : $classname$(nullptr) {}\n"); format("inline $classname$() : $classname$(nullptr) {}\n");
} }

@ -182,14 +182,13 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
// If we're not on an arena, free whatever we were holding before. // If we're not on an arena, free whatever we were holding before.
// (If we are on arena, we can just forget the earlier pointer.) // (If we are on arena, we can just forget the earlier pointer.)
" if (GetArenaForAllocation() == nullptr) {\n" " if (GetArenaForAllocation() == nullptr) {\n"
" delete reinterpret_cast<::$proto_ns$::MessageLite*>($name$_);\n" " delete reinterpret_cast<::$proto_ns$::MessageLite*>($field$);\n"
" }\n"); " }\n");
if (implicit_weak_field_) { if (implicit_weak_field_) {
format( format(
" $name$_ = " " $field$ = reinterpret_cast<::$proto_ns$::MessageLite*>($name$);\n");
"reinterpret_cast<::$proto_ns$::MessageLite*>($name$);\n");
} else { } else {
format(" $name$_ = $name$;\n"); format(" $field$ = $name$;\n");
} }
format( format(
" if ($name$) {\n" " if ($name$) {\n"
@ -207,7 +206,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_release$" "$annotate_release$"
" $clear_hasbit$\n" " $clear_hasbit$\n"
" $type$* temp = $casted_member$;\n" " $type$* temp = $casted_member$;\n"
" $name$_ = nullptr;\n" " $field$ = nullptr;\n"
"#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE\n" "#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE\n"
" auto* old = reinterpret_cast<::$proto_ns$::MessageLite*>(temp);\n" " auto* old = reinterpret_cast<::$proto_ns$::MessageLite*>(temp);\n"
" temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n" " temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n"
@ -225,7 +224,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
"$type_reference_function$" "$type_reference_function$"
" $clear_hasbit$\n" " $clear_hasbit$\n"
" $type$* temp = $casted_member$;\n" " $type$* temp = $casted_member$;\n"
" $name$_ = nullptr;\n" " $field$ = nullptr;\n"
" return temp;\n" " return temp;\n"
"}\n"); "}\n");
@ -233,12 +232,12 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
"inline $type$* $classname$::_internal_mutable_$name$() {\n" "inline $type$* $classname$::_internal_mutable_$name$() {\n"
"$type_reference_function$" "$type_reference_function$"
" $set_hasbit$\n" " $set_hasbit$\n"
" if ($name$_ == nullptr) {\n" " if ($field$ == nullptr) {\n"
" auto* p = CreateMaybeMessage<$type$>(GetArenaForAllocation());\n"); " auto* p = CreateMaybeMessage<$type$>(GetArenaForAllocation());\n");
if (implicit_weak_field_) { if (implicit_weak_field_) {
format(" $name$_ = reinterpret_cast<::$proto_ns$::MessageLite*>(p);\n"); format(" $field$ = reinterpret_cast<::$proto_ns$::MessageLite*>(p);\n");
} else { } else {
format(" $name$_ = p;\n"); format(" $field$ = p;\n");
} }
format( format(
" }\n" " }\n"
@ -259,9 +258,9 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
format(" if (message_arena == nullptr) {\n"); format(" if (message_arena == nullptr) {\n");
if (IsCrossFileMessage(descriptor_)) { if (IsCrossFileMessage(descriptor_)) {
format( format(
" delete reinterpret_cast< ::$proto_ns$::MessageLite*>($name$_);\n"); " delete reinterpret_cast< ::$proto_ns$::MessageLite*>($field$);\n");
} else { } else {
format(" delete $name$_;\n"); format(" delete $field$;\n");
} }
format( format(
" }\n" " }\n"
@ -271,14 +270,13 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
// isn't defined in this file. // isn't defined in this file.
format( format(
" ::$proto_ns$::Arena* submessage_arena =\n" " ::$proto_ns$::Arena* submessage_arena =\n"
" ::$proto_ns$::Arena::InternalHelper<\n" " ::$proto_ns$::Arena::InternalGetOwningArena(\n"
" ::$proto_ns$::MessageLite>::GetOwningArena(\n"
" reinterpret_cast<::$proto_ns$::MessageLite*>(" " reinterpret_cast<::$proto_ns$::MessageLite*>("
"$name$));\n"); "$name$));\n");
} else { } else {
format( format(
" ::$proto_ns$::Arena* submessage_arena =\n" " ::$proto_ns$::Arena* submessage_arena =\n"
" ::$proto_ns$::Arena::InternalHelper<$type$>::GetOwningArena(" " ::$proto_ns$::Arena::InternalGetOwningArena("
"$name$);\n"); "$name$);\n");
} }
format( format(
@ -291,9 +289,9 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
" $clear_hasbit$\n" " $clear_hasbit$\n"
" }\n"); " }\n");
if (implicit_weak_field_) { if (implicit_weak_field_) {
format(" $name$_ = reinterpret_cast<MessageLite*>($name$);\n"); format(" $field$ = reinterpret_cast<MessageLite*>($name$);\n");
} else { } else {
format(" $name$_ = $name$;\n"); format(" $field$ = $name$;\n");
} }
format( format(
"$annotate_set$" "$annotate_set$"
@ -328,8 +326,8 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions(
format( format(
"const ::$proto_ns$::MessageLite& $classname$::_Internal::$name$(\n" "const ::$proto_ns$::MessageLite& $classname$::_Internal::$name$(\n"
" const $classname$* msg) {\n" " const $classname$* msg) {\n"
" if (msg->$field_member$ != nullptr) {\n" " if (msg->$field$ != nullptr) {\n"
" return *msg->$field_member$;\n" " return *msg->$field$;\n"
" } else {\n" " } else {\n"
" return *$type_default_instance_ptr$;\n" " return *$type_default_instance_ptr$;\n"
" }\n" " }\n"
@ -341,7 +339,7 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions(
format(" msg->$set_hasbit$\n"); format(" msg->$set_hasbit$\n");
} }
if (descriptor_->real_containing_oneof() == nullptr) { if (descriptor_->real_containing_oneof() == nullptr) {
format(" if (msg->$field_member$ == nullptr) {\n"); format(" if (msg->$field$ == nullptr) {\n");
} else { } else {
format( format(
" if (!msg->_internal_has_$name$()) {\n" " if (!msg->_internal_has_$name$()) {\n"
@ -349,10 +347,10 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions(
" msg->set_has_$name$();\n"); " msg->set_has_$name$();\n");
} }
format( format(
" msg->$field_member$ = $type_default_instance_ptr$->New(\n" " msg->$field$ = $type_default_instance_ptr$->New(\n"
" msg->GetArenaForAllocation());\n" " msg->GetArenaForAllocation());\n"
" }\n" " }\n"
" return msg->$field_member$;\n" " return msg->$field$;\n"
"}\n"); "}\n");
} else { } else {
// This inline accessor directly returns member field and is used in // This inline accessor directly returns member field and is used in
@ -361,7 +359,7 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions(
format( format(
"const $type$&\n" "const $type$&\n"
"$classname$::_Internal::$name$(const $classname$* msg) {\n" "$classname$::_Internal::$name$(const $classname$* msg) {\n"
" return *msg->$field_member$;\n" " return *msg->$field$;\n"
"}\n"); "}\n");
} }
} }
@ -374,12 +372,12 @@ void MessageFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
// If we don't have has-bits, message presence is indicated only by ptr != // If we don't have has-bits, message presence is indicated only by ptr !=
// nullptr. Thus on clear, we need to delete the object. // nullptr. Thus on clear, we need to delete the object.
format( format(
"if (GetArenaForAllocation() == nullptr && $name$_ != nullptr) {\n" "if (GetArenaForAllocation() == nullptr && $field$ != nullptr) {\n"
" delete $name$_;\n" " delete $field$;\n"
"}\n" "}\n"
"$name$_ = nullptr;\n"); "$field$ = nullptr;\n");
} else { } else {
format("if ($name$_ != nullptr) $name$_->Clear();\n"); format("if ($field$ != nullptr) $field$->Clear();\n");
} }
} }
@ -392,14 +390,14 @@ void MessageFieldGenerator::GenerateMessageClearingCode(
// If we don't have has-bits, message presence is indicated only by ptr != // If we don't have has-bits, message presence is indicated only by ptr !=
// nullptr. Thus on clear, we need to delete the object. // nullptr. Thus on clear, we need to delete the object.
format( format(
"if (GetArenaForAllocation() == nullptr && $name$_ != nullptr) {\n" "if (GetArenaForAllocation() == nullptr && $field$ != nullptr) {\n"
" delete $name$_;\n" " delete $field$;\n"
"}\n" "}\n"
"$name$_ = nullptr;\n"); "$field$ = nullptr;\n");
} else { } else {
format( format(
"$DCHK$($name$_ != nullptr);\n" "$DCHK$($field$ != nullptr);\n"
"$name$_->Clear();\n"); "$field$->Clear();\n");
} }
} }
@ -422,7 +420,7 @@ void MessageFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("swap($name$_, other->$name$_);\n"); format("swap($field$, other->$field$);\n");
} }
void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const { void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
@ -487,7 +485,7 @@ void MessageFieldGenerator::GenerateByteSize(io::Printer* printer) const {
format( format(
"total_size += $tag_size$ +\n" "total_size += $tag_size$ +\n"
" ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n" " ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n"
" *$field_member$);\n"); " *$field$);\n");
} }
void MessageFieldGenerator::GenerateIsInitialized(io::Printer* printer) const { void MessageFieldGenerator::GenerateIsInitialized(io::Printer* printer) const {
@ -498,7 +496,7 @@ void MessageFieldGenerator::GenerateIsInitialized(io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format( format(
"if (_internal_has_$name$()) {\n" "if (_internal_has_$name$()) {\n"
" if (!$name$_->IsInitialized()) return false;\n" " if (!$field$->IsInitialized()) return false;\n"
"}\n"); "}\n");
} }
@ -532,15 +530,13 @@ void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions(
// isn't defined in this file. // isn't defined in this file.
format( format(
" ::$proto_ns$::Arena* submessage_arena =\n" " ::$proto_ns$::Arena* submessage_arena =\n"
" ::$proto_ns$::Arena::InternalHelper<\n" " ::$proto_ns$::Arena::InternalGetOwningArena(\n"
" ::$proto_ns$::MessageLite>::GetOwningArena(\n"
" reinterpret_cast<::$proto_ns$::MessageLite*>(" " reinterpret_cast<::$proto_ns$::MessageLite*>("
"$name$));\n"); "$name$));\n");
} else { } else {
format( format(
" ::$proto_ns$::Arena* submessage_arena =\n" " ::$proto_ns$::Arena* submessage_arena =\n"
" ::$proto_ns$::Arena::InternalHelper<" " ::$proto_ns$::Arena::InternalGetOwningArena($name$);\n");
"$type$>::GetOwningArena($name$);\n");
} }
format( format(
" if (message_arena != submessage_arena) {\n" " if (message_arena != submessage_arena) {\n"
@ -548,7 +544,7 @@ void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions(
" message_arena, $name$, submessage_arena);\n" " message_arena, $name$, submessage_arena);\n"
" }\n" " }\n"
" set_has_$name$();\n" " set_has_$name$();\n"
" $field_member$ = $name$;\n" " $field$ = $name$;\n"
" }\n" " }\n"
"$annotate_set$" "$annotate_set$"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
@ -569,7 +565,7 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" if (GetArenaForAllocation() != nullptr) {\n" " if (GetArenaForAllocation() != nullptr) {\n"
" temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n" " temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n"
" }\n" " }\n"
" $field_member$ = nullptr;\n" " $field$ = nullptr;\n"
" return temp;\n" " return temp;\n"
" } else {\n" " } else {\n"
" return nullptr;\n" " return nullptr;\n"
@ -596,7 +592,7 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" if (_internal_has_$name$()) {\n" " if (_internal_has_$name$()) {\n"
" clear_has_$oneof_name$();\n" " clear_has_$oneof_name$();\n"
" $type$* temp = $casted_member$;\n" " $type$* temp = $casted_member$;\n"
" $field_member$ = nullptr;\n" " $field$ = nullptr;\n"
" return temp;\n" " return temp;\n"
" } else {\n" " } else {\n"
" return nullptr;\n" " return nullptr;\n"
@ -612,10 +608,10 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" set_has_$name$();\n"); " set_has_$name$();\n");
if (implicit_weak_field_) { if (implicit_weak_field_) {
format( format(
" $field_member$ = " " $field$ = "
"reinterpret_cast<::$proto_ns$::MessageLite*>($name$);\n"); "reinterpret_cast<::$proto_ns$::MessageLite*>($name$);\n");
} else { } else {
format(" $field_member$ = $name$;\n"); format(" $field$ = $name$;\n");
} }
format( format(
" }\n" " }\n"
@ -630,12 +626,12 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" set_has_$name$();\n"); " set_has_$name$();\n");
if (implicit_weak_field_) { if (implicit_weak_field_) {
format( format(
" $field_member$ = " " $field$ = "
"reinterpret_cast<::$proto_ns$::MessageLite*>(CreateMaybeMessage< " "reinterpret_cast<::$proto_ns$::MessageLite*>(CreateMaybeMessage< "
"$type$ >(GetArenaForAllocation()));\n"); "$type$ >(GetArenaForAllocation()));\n");
} else { } else {
format( format(
" $field_member$ = CreateMaybeMessage< $type$ " " $field$ = CreateMaybeMessage< $type$ "
">(GetArenaForAllocation());\n"); ">(GetArenaForAllocation());\n");
} }
format( format(
@ -657,7 +653,7 @@ void MessageOneofFieldGenerator::GenerateClearingCode(
Formatter format(printer, variables_); Formatter format(printer, variables_);
format( format(
"if (GetArenaForAllocation() == nullptr) {\n" "if (GetArenaForAllocation() == nullptr) {\n"
" delete $field_member$;\n" " delete $field$;\n"
"}\n"); "}\n");
} }
@ -690,7 +686,7 @@ void MessageOneofFieldGenerator::GenerateIsInitialized(
Formatter format(printer, variables_); Formatter format(printer, variables_);
format( format(
"if (_internal_has_$name$()) {\n" "if (_internal_has_$name$()) {\n"
" if (!$field_member$->IsInitialized()) return false;\n" " if (!$field$->IsInitialized()) return false;\n"
"}\n"); "}\n");
} }
@ -769,21 +765,21 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions(
// TODO(dlj): move insertion points // TODO(dlj): move insertion points
" // @@protoc_insertion_point(field_mutable:$full_name$)\n" " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
"$type_reference_function$" "$type_reference_function$"
" return $name$_$weak$.Mutable(index);\n" " return $field$$weak$.Mutable(index);\n"
"}\n" "}\n"
"inline ::$proto_ns$::RepeatedPtrField< $type$ >*\n" "inline ::$proto_ns$::RepeatedPtrField< $type$ >*\n"
"$classname$::mutable_$name$() {\n" "$classname$::mutable_$name$() {\n"
"$annotate_mutable_list$" "$annotate_mutable_list$"
" // @@protoc_insertion_point(field_mutable_list:$full_name$)\n" " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
"$type_reference_function$" "$type_reference_function$"
" return &$name$_$weak$;\n" " return &$field$$weak$;\n"
"}\n"); "}\n");
if (options_.safe_boundary_check) { if (options_.safe_boundary_check) {
format( format(
"inline const $type$& $classname$::_internal_$name$(int index) const " "inline const $type$& $classname$::_internal_$name$(int index) const "
"{\n" "{\n"
" return $name$_$weak$.InternalCheckedGet(index,\n" " return $field$$weak$.InternalCheckedGet(index,\n"
" reinterpret_cast<const $type$&>($type_default_instance$));\n" " reinterpret_cast<const $type$&>($type_default_instance$));\n"
"}\n"); "}\n");
} else { } else {
@ -791,7 +787,7 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions(
"inline const $type$& $classname$::_internal_$name$(int index) const " "inline const $type$& $classname$::_internal_$name$(int index) const "
"{\n" "{\n"
"$type_reference_function$" "$type_reference_function$"
" return $name$_$weak$.Get(index);\n" " return $field$$weak$.Get(index);\n"
"}\n"); "}\n");
} }
@ -802,7 +798,7 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions(
" return _internal_$name$(index);\n" " return _internal_$name$(index);\n"
"}\n" "}\n"
"inline $type$* $classname$::_internal_add_$name$() {\n" "inline $type$* $classname$::_internal_add_$name$() {\n"
" return $name$_$weak$.Add();\n" " return $field$$weak$.Add();\n"
"}\n" "}\n"
"inline $type$* $classname$::add_$name$() {\n" "inline $type$* $classname$::add_$name$() {\n"
" $type$* _add = _internal_add_$name$();\n" " $type$* _add = _internal_add_$name$();\n"
@ -817,7 +813,7 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_list$" "$annotate_list$"
" // @@protoc_insertion_point(field_list:$full_name$)\n" " // @@protoc_insertion_point(field_list:$full_name$)\n"
"$type_reference_function$" "$type_reference_function$"
" return $name$_$weak$;\n" " return $field$$weak$;\n"
"}\n"); "}\n");
} }
@ -826,7 +822,7 @@ void RepeatedMessageFieldGenerator::GenerateClearingCode(
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_.Clear();\n"); format("$field$.Clear();\n");
} }
void RepeatedMessageFieldGenerator::GenerateMergingCode( void RepeatedMessageFieldGenerator::GenerateMergingCode(
@ -834,7 +830,7 @@ void RepeatedMessageFieldGenerator::GenerateMergingCode(
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_.MergeFrom(from.$name$_);\n"); format("$field$.MergeFrom(from.$field$);\n");
} }
void RepeatedMessageFieldGenerator::GenerateSwappingCode( void RepeatedMessageFieldGenerator::GenerateSwappingCode(
@ -842,7 +838,7 @@ void RepeatedMessageFieldGenerator::GenerateSwappingCode(
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_.InternalSwap(&other->$name$_);\n"); format("$field$.InternalSwap(&other->$field$);\n");
} }
void RepeatedMessageFieldGenerator::GenerateConstructorCode( void RepeatedMessageFieldGenerator::GenerateConstructorCode(
@ -857,8 +853,8 @@ void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (implicit_weak_field_) { if (implicit_weak_field_) {
format( format(
"for (auto it = this->$name$_.pointer_begin(),\n" "for (auto it = this->$field$.pointer_begin(),\n"
" end = this->$name$_.pointer_end(); it < end; ++it) {\n"); " end = this->$field$.pointer_end(); it < end; ++it) {\n");
if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) { if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) {
format( format(
" target = ::$proto_ns$::internal::WireFormatLite::\n" " target = ::$proto_ns$::internal::WireFormatLite::\n"
@ -902,7 +898,7 @@ void RepeatedMessageFieldGenerator::GenerateByteSize(
Formatter format(printer, variables_); Formatter format(printer, variables_);
format( format(
"total_size += $tag_size$UL * this->_internal_$name$_size();\n" "total_size += $tag_size$UL * this->_internal_$name$_size();\n"
"for (const auto& msg : this->$name$_) {\n" "for (const auto& msg : this->$field$) {\n"
" total_size +=\n" " total_size +=\n"
" ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(msg);\n" " ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(msg);\n"
"}\n"); "}\n");
@ -917,11 +913,11 @@ void RepeatedMessageFieldGenerator::GenerateIsInitialized(
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (implicit_weak_field_) { if (implicit_weak_field_) {
format( format(
"if (!::$proto_ns$::internal::AllAreInitializedWeak($name$_.weak))\n" "if (!::$proto_ns$::internal::AllAreInitializedWeak($field$.weak))\n"
" return false;\n"); " return false;\n");
} else { } else {
format( format(
"if (!::$proto_ns$::internal::AllAreInitialized($name$_))\n" "if (!::$proto_ns$::internal::AllAreInitialized($field$))\n"
" return false;\n"); " return false;\n");
} }
} }

@ -88,8 +88,7 @@ bool IsFieldEligibleForFastParsing(
return false; return false;
} }
switch (field->type()) { switch (field->type()) {
// Strings, enums, and groups are not handled on the fast path. // Groups are not handled on the fast path.
case FieldDescriptor::TYPE_STRING:
case FieldDescriptor::TYPE_GROUP: case FieldDescriptor::TYPE_GROUP:
return false; return false;
@ -105,6 +104,7 @@ bool IsFieldEligibleForFastParsing(
break; break;
// Some bytes fields can be handled on fast path. // Some bytes fields can be handled on fast path.
case FieldDescriptor::TYPE_STRING:
case FieldDescriptor::TYPE_BYTES: case FieldDescriptor::TYPE_BYTES:
if (field->options().ctype() != FieldOptions::STRING || if (field->options().ctype() != FieldOptions::STRING ||
!field->default_value_string().empty() || !field->default_value_string().empty() ||
@ -233,15 +233,15 @@ std::vector<const FieldDescriptor*> FilterMiniParsedFields(
} }
break; break;
// TODO(b/209516305): add TYPE_STRING once field names are available. case FieldDescriptor::TYPE_BYTES:
case FieldDescriptor::TYPE_BYTES: case FieldDescriptor::TYPE_STRING:
if (IsStringInlined(field, options)) { if (IsStringInlined(field, options)) {
// TODO(b/198211897): support InilnedStringField. // TODO(b/198211897): support InilnedStringField.
handled = false; handled = false;
} else { } else {
handled = true; handled = true;
} }
break; break;
case FieldDescriptor::TYPE_MESSAGE: case FieldDescriptor::TYPE_MESSAGE:
// TODO(b/210762816): support remaining field types. // TODO(b/210762816): support remaining field types.
@ -773,9 +773,9 @@ void ParseFunctionGenerator::GenerateFastFieldEntries(Formatter& format) {
} else { } else {
format( format(
"{$1$,\n" "{$1$,\n"
" {$2$, $3$, $4$, PROTOBUF_FIELD_OFFSET($classname$, $5$_)}},\n", " {$2$, $3$, $4$, PROTOBUF_FIELD_OFFSET($classname$, $5$)}},\n",
info.func_name, info.coded_tag, info.hasbit_idx, info.aux_idx, info.func_name, info.coded_tag, info.hasbit_idx, info.aux_idx,
FieldName(info.field)); FieldMemberName(info.field));
} }
} }
} }
@ -999,7 +999,7 @@ void ParseFunctionGenerator::GenerateArenaString(Formatter& format,
"::" + MakeDefaultName(field) + ".get()"; "::" + MakeDefaultName(field) + ".get()";
format( format(
"if (arena != nullptr) {\n" "if (arena != nullptr) {\n"
" ptr = ctx->ReadArenaString(ptr, &$msg$$name$_, arena"); " ptr = ctx->ReadArenaString(ptr, &$msg$$field$, arena");
if (IsStringInlined(field, options_)) { if (IsStringInlined(field, options_)) {
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()];
@ -1018,10 +1018,9 @@ void ParseFunctionGenerator::GenerateArenaString(Formatter& format,
");\n" ");\n"
"} else {\n" "} else {\n"
" ptr = ::_pbi::InlineGreedyStringParser(" " ptr = ::_pbi::InlineGreedyStringParser("
"$msg$$name$_.MutableNoArenaNoDefault(&$1$), ptr, ctx);\n" "$msg$$field$.MutableNoCopy(nullptr), ptr, ctx);\n"
"}\n" "}\n"
"const std::string* str = &$msg$$name$_.Get(); (void)str;\n", "const std::string* str = &$msg$$field$.Get(); (void)str;\n");
default_string);
} }
void ParseFunctionGenerator::GenerateStrings(Formatter& format, void ParseFunctionGenerator::GenerateStrings(Formatter& format,
@ -1130,13 +1129,13 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format,
format( format(
"auto object = " "auto object = "
"::$proto_ns$::internal::InitEnumParseWrapper<" "::$proto_ns$::internal::InitEnumParseWrapper<"
"$unknown_fields_type$>(&$msg$$name$_, $1$_IsValid, " "$unknown_fields_type$>(&$msg$$field$, $1$_IsValid, "
"$2$, &$msg$_internal_metadata_);\n" "$2$, &$msg$_internal_metadata_);\n"
"ptr = ctx->ParseMessage(&object, ptr);\n", "ptr = ctx->ParseMessage(&object, ptr);\n",
QualifiedClassName(val->enum_type(), options_), QualifiedClassName(val->enum_type(), options_),
field->number()); field->number());
} else { } else {
format("ptr = ctx->ParseMessage(&$msg$$name$_, ptr);\n"); format("ptr = ctx->ParseMessage(&$msg$$field$, ptr);\n");
} }
} else if (IsLazy(field, options_, scc_analyzer_)) { } else if (IsLazy(field, options_, scc_analyzer_)) {
bool eager_verify = bool eager_verify =
@ -1153,19 +1152,19 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format,
format( format(
"if (!$msg$_internal_has_$name$()) {\n" "if (!$msg$_internal_has_$name$()) {\n"
" $msg$clear_$1$();\n" " $msg$clear_$1$();\n"
" $msg$$1$_.$name$_ = ::$proto_ns$::Arena::CreateMessage<\n" " $msg$$field$ = ::$proto_ns$::Arena::CreateMessage<\n"
" ::$proto_ns$::internal::LazyField>(" " ::$proto_ns$::internal::LazyField>("
"$msg$GetArenaForAllocation());\n" "$msg$GetArenaForAllocation());\n"
" $msg$set_has_$name$();\n" " $msg$set_has_$name$();\n"
"}\n" "}\n"
"auto* lazy_field = $msg$$1$_.$name$_;\n", "auto* lazy_field = $msg$$field$;\n",
field->containing_oneof()->name()); field->containing_oneof()->name());
} else if (HasHasbit(field)) { } else if (HasHasbit(field)) {
format( format(
"_Internal::set_has_$name$(&$has_bits$);\n" "_Internal::set_has_$name$(&$has_bits$);\n"
"auto* lazy_field = &$msg$$name$_;\n"); "auto* lazy_field = &$msg$$field$;\n");
} else { } else {
format("auto* lazy_field = &$msg$$name$_;\n"); format("auto* lazy_field = &$msg$$field$;\n");
} }
format( format(
"::$proto_ns$::internal::LazyFieldParseHelper<\n" "::$proto_ns$::internal::LazyFieldParseHelper<\n"
@ -1188,7 +1187,7 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format,
"ptr);\n"); "ptr);\n");
} else { } else {
format( format(
"ptr = ctx->ParseMessage($msg$$name$_.AddWeak(" "ptr = ctx->ParseMessage($msg$$field$.AddWeak("
"reinterpret_cast<const ::$proto_ns$::MessageLite*>($1$ptr_)" "reinterpret_cast<const ::$proto_ns$::MessageLite*>($1$ptr_)"
"), ptr);\n", "), ptr);\n",
QualifiedDefaultInstanceName(field->message_type(), options_)); QualifiedDefaultInstanceName(field->message_type(), options_));
@ -1287,7 +1286,7 @@ void ParseFunctionGenerator::GenerateFieldBody(
format("_Internal::set_has_$name$(&$has_bits$);\n"); format("_Internal::set_has_$name$(&$has_bits$);\n");
} }
format( format(
"$msg$$name$_ = ::$proto_ns$::internal::ReadVarint$1$$2$(&ptr);\n" "$msg$$field$ = ::$proto_ns$::internal::ReadVarint$1$$2$(&ptr);\n"
"CHK_(ptr);\n", "CHK_(ptr);\n",
zigzag, size); zigzag, size);
} }
@ -1434,6 +1433,8 @@ void ParseFunctionGenerator::GenerateFieldSwitch(
format.Indent(); format.Indent();
for (const auto* field : fields) { for (const auto* field : fields) {
// Set abbreviated form instead of field_member.
format.Set("field", FieldMemberName(field));
PrintFieldComment(format, field); PrintFieldComment(format, field);
format("case $1$:\n", field->number()); format("case $1$:\n", field->number());
format.Indent(); format.Indent();

@ -150,7 +150,7 @@ void PrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
Formatter format(printer, variables_); Formatter format(printer, variables_);
format( format(
"inline $type$ $classname$::_internal_$name$() const {\n" "inline $type$ $classname$::_internal_$name$() const {\n"
" return $name$_;\n" " return $field$;\n"
"}\n" "}\n"
"inline $type$ $classname$::$name$() const {\n" "inline $type$ $classname$::$name$() const {\n"
"$annotate_get$" "$annotate_get$"
@ -159,7 +159,7 @@ void PrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
"}\n" "}\n"
"inline void $classname$::_internal_set_$name$($type$ value) {\n" "inline void $classname$::_internal_set_$name$($type$ value) {\n"
" $set_hasbit$\n" " $set_hasbit$\n"
" $name$_ = value;\n" " $field$ = value;\n"
"}\n" "}\n"
"inline void $classname$::set_$name$($type$ value) {\n" "inline void $classname$::set_$name$($type$ value) {\n"
" _internal_set_$name$(value);\n" " _internal_set_$name$(value);\n"
@ -170,7 +170,7 @@ void PrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
void PrimitiveFieldGenerator::GenerateClearingCode(io::Printer* printer) const { void PrimitiveFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_ = $default$;\n"); format("$field$ = $default$;\n");
} }
void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) const { void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
@ -180,7 +180,7 @@ void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
void PrimitiveFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { void PrimitiveFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("swap($name$_, other->$name$_);\n"); format("swap($field$, other->$field$);\n");
} }
void PrimitiveFieldGenerator::GenerateConstructorCode( void PrimitiveFieldGenerator::GenerateConstructorCode(
@ -249,7 +249,7 @@ void PrimitiveOneofFieldGenerator::GenerateInlineAccessorDefinitions(
format( format(
"inline $type$ $classname$::_internal_$name$() const {\n" "inline $type$ $classname$::_internal_$name$() const {\n"
" if (_internal_has_$name$()) {\n" " if (_internal_has_$name$()) {\n"
" return $field_member$;\n" " return $field$;\n"
" }\n" " }\n"
" return $default$;\n" " return $default$;\n"
"}\n" "}\n"
@ -258,7 +258,7 @@ void PrimitiveOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" clear_$oneof_name$();\n" " clear_$oneof_name$();\n"
" set_has_$name$();\n" " set_has_$name$();\n"
" }\n" " }\n"
" $field_member$ = value;\n" " $field$ = value;\n"
"}\n" "}\n"
"inline $type$ $classname$::$name$() const {\n" "inline $type$ $classname$::$name$() const {\n"
"$annotate_get$" "$annotate_get$"
@ -275,7 +275,7 @@ void PrimitiveOneofFieldGenerator::GenerateInlineAccessorDefinitions(
void PrimitiveOneofFieldGenerator::GenerateClearingCode( void PrimitiveOneofFieldGenerator::GenerateClearingCode(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$field_member$ = $default$;\n"); format("$field$ = $default$;\n");
} }
void PrimitiveOneofFieldGenerator::GenerateSwappingCode( void PrimitiveOneofFieldGenerator::GenerateSwappingCode(
@ -344,7 +344,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
Formatter format(printer, variables_); Formatter format(printer, variables_);
format( format(
"inline $type$ $classname$::_internal_$name$(int index) const {\n" "inline $type$ $classname$::_internal_$name$(int index) const {\n"
" return $name$_.Get(index);\n" " return $field$.Get(index);\n"
"}\n" "}\n"
"inline $type$ $classname$::$name$(int index) const {\n" "inline $type$ $classname$::$name$(int index) const {\n"
"$annotate_get$" "$annotate_get$"
@ -353,11 +353,11 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
"}\n" "}\n"
"inline void $classname$::set_$name$(int index, $type$ value) {\n" "inline void $classname$::set_$name$(int index, $type$ value) {\n"
"$annotate_set$" "$annotate_set$"
" $name$_.Set(index, value);\n" " $field$.Set(index, value);\n"
" // @@protoc_insertion_point(field_set:$full_name$)\n" " // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n" "}\n"
"inline void $classname$::_internal_add_$name$($type$ value) {\n" "inline void $classname$::_internal_add_$name$($type$ value) {\n"
" $name$_.Add(value);\n" " $field$.Add(value);\n"
"}\n" "}\n"
"inline void $classname$::add_$name$($type$ value) {\n" "inline void $classname$::add_$name$($type$ value) {\n"
" _internal_add_$name$(value);\n" " _internal_add_$name$(value);\n"
@ -366,7 +366,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
"}\n" "}\n"
"inline const ::$proto_ns$::RepeatedField< $type$ >&\n" "inline const ::$proto_ns$::RepeatedField< $type$ >&\n"
"$classname$::_internal_$name$() const {\n" "$classname$::_internal_$name$() const {\n"
" return $name$_;\n" " return $field$;\n"
"}\n" "}\n"
"inline const ::$proto_ns$::RepeatedField< $type$ >&\n" "inline const ::$proto_ns$::RepeatedField< $type$ >&\n"
"$classname$::$name$() const {\n" "$classname$::$name$() const {\n"
@ -376,7 +376,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
"}\n" "}\n"
"inline ::$proto_ns$::RepeatedField< $type$ >*\n" "inline ::$proto_ns$::RepeatedField< $type$ >*\n"
"$classname$::_internal_mutable_$name$() {\n" "$classname$::_internal_mutable_$name$() {\n"
" return &$name$_;\n" " return &$field$;\n"
"}\n" "}\n"
"inline ::$proto_ns$::RepeatedField< $type$ >*\n" "inline ::$proto_ns$::RepeatedField< $type$ >*\n"
"$classname$::mutable_$name$() {\n" "$classname$::mutable_$name$() {\n"
@ -389,30 +389,19 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
void RepeatedPrimitiveFieldGenerator::GenerateClearingCode( void RepeatedPrimitiveFieldGenerator::GenerateClearingCode(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_.Clear();\n"); format("$field$.Clear();\n");
} }
void RepeatedPrimitiveFieldGenerator::GenerateMergingCode( void RepeatedPrimitiveFieldGenerator::GenerateMergingCode(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_.MergeFrom(from.$name$_);\n"); format("$field$.MergeFrom(from.$field$);\n");
} }
void RepeatedPrimitiveFieldGenerator::GenerateSwappingCode( void RepeatedPrimitiveFieldGenerator::GenerateSwappingCode(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_.InternalSwap(&other->$name$_);\n"); format("$field$.InternalSwap(&other->$field$);\n");
}
void RepeatedPrimitiveFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const {
// Not needed for repeated fields.
}
void RepeatedPrimitiveFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.CopyFrom(from.$name$_);\n");
} }
void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray( void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
@ -456,7 +445,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateByteSize(
if (fixed_size == -1) { if (fixed_size == -1) {
format( format(
"size_t data_size = ::_pbi::WireFormatLite::\n" "size_t data_size = ::_pbi::WireFormatLite::\n"
" $declared_type$Size(this->$name$_);\n"); " $declared_type$Size(this->$field$);\n");
} else { } else {
format( format(
"unsigned int count = static_cast<unsigned " "unsigned int count = static_cast<unsigned "

@ -98,8 +98,8 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator {
void GenerateClearingCode(io::Printer* printer) const override; void GenerateClearingCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override;
void GenerateSwappingCode(io::Printer* printer) const override; void GenerateSwappingCode(io::Printer* printer) const override;
void GenerateConstructorCode(io::Printer* printer) const override; void GenerateConstructorCode(io::Printer* printer) const override {}
void GenerateCopyConstructorCode(io::Printer* printer) const override; void GenerateCopyConstructorCode(io::Printer* printer) const override {}
void GenerateSerializeWithCachedSizesToArray( void GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const override; io::Printer* printer) const override;
void GenerateByteSize(io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override;

@ -54,8 +54,6 @@ void SetStringVariables(const FieldDescriptor* descriptor,
const std::string kNS = "::" + (*variables)["proto_ns"] + "::internal::"; const std::string kNS = "::" + (*variables)["proto_ns"] + "::internal::";
const std::string kArenaStringPtr = kNS + "ArenaStringPtr"; const std::string kArenaStringPtr = kNS + "ArenaStringPtr";
const std::string kEmptyDefault = kArenaStringPtr + "::EmptyDefault{}";
const std::string kNonEmptyDefault = kArenaStringPtr + "::NonEmptyDefault{}";
(*variables)["default"] = DefaultValue(options, descriptor); (*variables)["default"] = DefaultValue(options, descriptor);
(*variables)["default_length"] = (*variables)["default_length"] =
@ -64,21 +62,17 @@ void SetStringVariables(const FieldDescriptor* descriptor,
(*variables)["default_variable_name"] = default_variable_string; (*variables)["default_variable_name"] = default_variable_string;
if (descriptor->default_value_string().empty()) { if (descriptor->default_value_string().empty()) {
(*variables)["init_value"] = "";
(*variables)["default_string"] = kNS + "GetEmptyStringAlreadyInited()"; (*variables)["default_string"] = kNS + "GetEmptyStringAlreadyInited()";
(*variables)["default_value"] = "&" + (*variables)["default_string"]; (*variables)["default_value"] = "&" + (*variables)["default_string"];
(*variables)["default_value_tag"] = kEmptyDefault; (*variables)["lazy_variable_args"] = "";
(*variables)["default_variable_or_tag"] = kEmptyDefault;
} else { } else {
(*variables)["lazy_variable"] = (*variables)["lazy_variable"] =
QualifiedClassName(descriptor->containing_type(), options) + QualifiedClassName(descriptor->containing_type(), options) +
"::" + default_variable_string; "::" + default_variable_string;
(*variables)["init_value"] = "nullptr";
(*variables)["default_string"] = (*variables)["lazy_variable"] + ".get()"; (*variables)["default_string"] = (*variables)["lazy_variable"] + ".get()";
(*variables)["default_value"] = "nullptr"; (*variables)["default_value"] = "nullptr";
(*variables)["default_value_tag"] = kNonEmptyDefault; (*variables)["lazy_variable_args"] = (*variables)["lazy_variable"] + ", ";
(*variables)["default_variable_or_tag"] = (*variables)["lazy_variable"];
} }
(*variables)["pointer_type"] = (*variables)["pointer_type"] =
@ -210,7 +204,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
" // @@protoc_insertion_point(field_get:$full_name$)\n"); " // @@protoc_insertion_point(field_get:$full_name$)\n");
if (!descriptor_->default_value_string().empty()) { if (!descriptor_->default_value_string().empty()) {
format( format(
" if ($name$_.IsDefault()) return " " if ($field$.IsDefault()) return "
"$default_variable_name$.get();\n"); "$default_variable_name$.get();\n");
} }
format( format(
@ -222,7 +216,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
"inline PROTOBUF_ALWAYS_INLINE\n" "inline PROTOBUF_ALWAYS_INLINE\n"
"void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n" "void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n"
" $set_hasbit$\n" " $set_hasbit$\n"
" $name$_.$setter$($default_value_tag$, static_cast<ArgT0 &&>(arg0)," " $field$.$setter$(static_cast<ArgT0 &&>(arg0),"
" args..., GetArenaForAllocation());\n" " args..., GetArenaForAllocation());\n"
"$annotate_set$" "$annotate_set$"
" // @@protoc_insertion_point(field_set:$full_name$)\n" " // @@protoc_insertion_point(field_set:$full_name$)\n"
@ -233,7 +227,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
"inline PROTOBUF_ALWAYS_INLINE\n" "inline PROTOBUF_ALWAYS_INLINE\n"
"void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n" "void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n"
" $set_hasbit$\n" " $set_hasbit$\n"
" $name$_.$setter$(nullptr, static_cast<ArgT0 &&>(arg0)," " $field$.$setter$(static_cast<ArgT0 &&>(arg0),"
" args..., GetArenaForAllocation(), _internal_$name$_donated(), " " args..., GetArenaForAllocation(), _internal_$name$_donated(), "
"&$donating_states_word$, $mask_for_undonate$, this);\n" "&$donating_states_word$, $mask_for_undonate$, this);\n"
"$annotate_set$" "$annotate_set$"
@ -252,18 +246,18 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
" return _s;\n" " return _s;\n"
"}\n" "}\n"
"inline const std::string& $classname$::_internal_$name$() const {\n" "inline const std::string& $classname$::_internal_$name$() const {\n"
" return $name$_.Get();\n" " return $field$.Get();\n"
"}\n" "}\n"
"inline void $classname$::_internal_set_$name$(const std::string& " "inline void $classname$::_internal_set_$name$(const std::string& "
"value) {\n" "value) {\n"
" $set_hasbit$\n"); " $set_hasbit$\n");
if (!inlined_) { if (!inlined_) {
format( format(
" $name$_.Set($default_value_tag$, value, GetArenaForAllocation());\n" " $field$.Set(value, GetArenaForAllocation());\n"
"}\n"); "}\n");
} else { } else {
format( format(
" $name$_.Set(nullptr, value, GetArenaForAllocation(),\n" " $field$.Set(value, GetArenaForAllocation(),\n"
" _internal_$name$_donated(), &$donating_states_word$, " " _internal_$name$_donated(), &$donating_states_word$, "
"$mask_for_undonate$, this);\n" "$mask_for_undonate$, this);\n"
"}\n"); "}\n");
@ -273,12 +267,12 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
" $set_hasbit$\n"); " $set_hasbit$\n");
if (!inlined_) { if (!inlined_) {
format( format(
" return $name$_.Mutable($default_variable_or_tag$, " " return $field$.Mutable($lazy_variable_args$"
"GetArenaForAllocation());\n" "GetArenaForAllocation());\n"
"}\n"); "}\n");
} else { } else {
format( format(
" return $name$_.Mutable($default_variable_or_tag$, " " return $field$.Mutable($lazy_variable_args$"
"GetArenaForAllocation(), _internal_$name$_donated(), " "GetArenaForAllocation(), _internal_$name$_donated(), "
"&$donating_states_word$, $mask_for_undonate$, this);\n" "&$donating_states_word$, $mask_for_undonate$, this);\n"
"}\n"); "}\n");
@ -295,26 +289,23 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
" }\n" " }\n"
" $clear_hasbit$\n"); " $clear_hasbit$\n");
if (!inlined_) { if (!inlined_) {
format( format(" auto* p = $field$.Release();\n");
" auto* p = $name$_.ReleaseNonDefault($default_value$, "
"GetArenaForAllocation());\n");
if (descriptor_->default_value_string().empty()) { if (descriptor_->default_value_string().empty()) {
format( format(
"#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n" "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"
" if ($name$_.IsDefault()) {\n" " if ($field$.IsDefault()) {\n"
" $name$_.Set($default_value$, \"\", GetArenaForAllocation());\n" " $field$.Set(\"\", GetArenaForAllocation());\n"
" }\n" " }\n"
"#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"); "#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n");
} }
format(" return p;\n"); format(" return p;\n");
} else { } else {
format( format(
" return $name$_.Release(nullptr, GetArenaForAllocation(), " " return $field$.Release(GetArenaForAllocation(), "
"_internal_$name$_donated());\n"); "_internal_$name$_donated());\n");
} }
} else { } else {
format( format(" return $field$.Release();\n");
" return $name$_.Release($default_value$, GetArenaForAllocation());\n");
} }
format( format(
@ -326,21 +317,19 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
" $clear_hasbit$\n" " $clear_hasbit$\n"
" }\n"); " }\n");
if (!inlined_) { if (!inlined_) {
format( format(" $field$.SetAllocated($name$, GetArenaForAllocation());\n");
" $name$_.SetAllocated($default_value$, $name$,\n"
" GetArenaForAllocation());\n");
if (descriptor_->default_value_string().empty()) { if (descriptor_->default_value_string().empty()) {
format( format(
"#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n" "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"
" if ($name$_.IsDefault()) {\n" " if ($field$.IsDefault()) {\n"
" $name$_.Set($default_value$, \"\", GetArenaForAllocation());\n" " $field$.Set(\"\", GetArenaForAllocation());\n"
" }\n" " }\n"
"#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"); "#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n");
} }
} else { } else {
// Currently, string fields with default value can't be inlined. // Currently, string fields with default value can't be inlined.
format( format(
" $name$_.SetAllocated(nullptr, $name$, GetArenaForAllocation(), " " $field$.SetAllocated(nullptr, $name$, GetArenaForAllocation(), "
"_internal_$name$_donated(), &$donating_states_word$, " "_internal_$name$_donated(), &$donating_states_word$, "
"$mask_for_undonate$, this);\n"); "$mask_for_undonate$, this);\n");
} }
@ -364,11 +353,11 @@ void StringFieldGenerator::GenerateNonInlineAccessorDefinitions(
void StringFieldGenerator::GenerateClearingCode(io::Printer* printer) const { void StringFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (descriptor_->default_value_string().empty()) { if (descriptor_->default_value_string().empty()) {
format("$name$_.ClearToEmpty();\n"); format("$field$.ClearToEmpty();\n");
} else { } else {
GOOGLE_DCHECK(!inlined_); GOOGLE_DCHECK(!inlined_);
format( format(
"$name$_.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n"); "$field$.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n");
} }
} }
@ -394,20 +383,20 @@ void StringFieldGenerator::GenerateMessageClearingCode(
// //
// For non-inlined strings, we distinguish from non-default by comparing // For non-inlined strings, we distinguish from non-default by comparing
// instances, rather than contents. // instances, rather than contents.
format("$DCHK$(!$name$_.IsDefault());\n"); format("$DCHK$(!$field$.IsDefault());\n");
} }
if (descriptor_->default_value_string().empty()) { if (descriptor_->default_value_string().empty()) {
if (must_be_present) { if (must_be_present) {
format("$name$_.ClearNonDefaultToEmpty();\n"); format("$field$.ClearNonDefaultToEmpty();\n");
} else { } else {
format("$name$_.ClearToEmpty();\n"); format("$field$.ClearToEmpty();\n");
} }
} else { } else {
// Clear to a non-empty default is more involved, as we try to use the // Clear to a non-empty default is more involved, as we try to use the
// Arena if one is present and may need to reallocate the string. // Arena if one is present and may need to reallocate the string.
format( format(
"$name$_.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n "); "$field$.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n ");
} }
} }
@ -422,16 +411,15 @@ void StringFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
if (!inlined_) { if (!inlined_) {
format( format(
"::$proto_ns$::internal::ArenaStringPtr::InternalSwap(\n" "::$proto_ns$::internal::ArenaStringPtr::InternalSwap(\n"
" $default_value$,\n" " &$field$, lhs_arena,\n"
" &$name$_, lhs_arena,\n" " &other->$field$, rhs_arena\n"
" &other->$name$_, rhs_arena\n"
");\n"); ");\n");
} else { } else {
format( format(
"::$proto_ns$::internal::InlinedStringField::InternalSwap(\n" "::$proto_ns$::internal::InlinedStringField::InternalSwap(\n"
" &$name$_, lhs_arena, " " &$field$, lhs_arena, "
"(_inlined_string_donated_[0] & 0x1u) == 0, this,\n" "(_inlined_string_donated_[0] & 0x1u) == 0, this,\n"
" &other->$name$_, rhs_arena, " " &other->$field$, rhs_arena, "
"(other->_inlined_string_donated_[0] & 0x1u) == 0, other);\n"); "(other->_inlined_string_donated_[0] & 0x1u) == 0, other);\n");
} }
} }
@ -442,12 +430,12 @@ void StringFieldGenerator::GenerateConstructorCode(io::Printer* printer) const {
return; return;
} }
GOOGLE_DCHECK(!inlined_); GOOGLE_DCHECK(!inlined_);
format("$name$_.InitDefault($init_value$);\n"); format("$name$_.InitDefault();\n");
if (IsString(descriptor_, options_) && if (IsString(descriptor_, options_) &&
descriptor_->default_value_string().empty()) { descriptor_->default_value_string().empty()) {
format( format(
"#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n" "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"
" $name$_.Set($default_value$, \"\", GetArenaForAllocation());\n" " $name$_.Set(\"\", GetArenaForAllocation());\n"
"#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"); "#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n");
} }
} }
@ -470,11 +458,11 @@ void StringFieldGenerator::GenerateCopyConstructorCode(
if (!inlined_) { if (!inlined_) {
format( format(
"$name$_.Set($default_value_tag$, from._internal_$name$(), \n" "$field$.Set(from._internal_$name$(), \n"
" GetArenaForAllocation());\n"); " GetArenaForAllocation());\n");
} else { } else {
format( format(
"$name$_.Set(nullptr, from._internal_$name$(),\n" "$field$.Set(from._internal_$name$(),\n"
" GetArenaForAllocation(), _internal_$name$_donated(), " " GetArenaForAllocation(), _internal_$name$_donated(), "
"&$donating_states_word$, $mask_for_undonate$, this);\n"); "&$donating_states_word$, $mask_for_undonate$, this);\n");
} }
@ -486,14 +474,14 @@ void StringFieldGenerator::GenerateCopyConstructorCode(
void StringFieldGenerator::GenerateDestructorCode(io::Printer* printer) const { void StringFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (!inlined_) { if (!inlined_) {
format("$name$_.DestroyNoArena($default_value$);\n"); format("$field$.Destroy();\n");
return; return;
} }
// Explicitly calls ~InlinedStringField as its automatic call is disabled. // Explicitly calls ~InlinedStringField as its automatic call is disabled.
// Destructor has been implicitly skipped as a union, and even the // Destructor has been implicitly skipped as a union, and even the
// message-owned arena is enabled, arena could still be missing for // message-owned arena is enabled, arena could still be missing for
// Arena::CreateMessage(nullptr). // Arena::CreateMessage(nullptr).
format("$name$_.~InlinedStringField();\n"); format("$field$.~InlinedStringField();\n");
} }
ArenaDtorNeeds StringFieldGenerator::NeedsArenaDestructor() const { ArenaDtorNeeds StringFieldGenerator::NeedsArenaDestructor() const {
@ -507,7 +495,7 @@ void StringFieldGenerator::GenerateArenaDestructorCode(
// _this is the object being destructed (we are inside a static method here). // _this is the object being destructed (we are inside a static method here).
format( format(
"if (!_this->_internal_$name$_donated()) {\n" "if (!_this->_internal_$name$_donated()) {\n"
" _this->$name$_.~InlinedStringField();\n" " _this->$field$.~InlinedStringField();\n"
"}\n"); "}\n");
} }
@ -575,9 +563,9 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" if (!_internal_has_$name$()) {\n" " if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n" " clear_$oneof_name$();\n"
" set_has_$name$();\n" " set_has_$name$();\n"
" $field_member$.InitDefault($init_value$);\n" " $field$.InitDefault();\n"
" }\n" " }\n"
" $field_member$.$setter$($default_value_tag$," " $field$.$setter$("
" static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());\n" " static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());\n"
"$annotate_set$" "$annotate_set$"
" // @@protoc_insertion_point(field_set:$full_name$)\n" " // @@protoc_insertion_point(field_set:$full_name$)\n"
@ -590,7 +578,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
"}\n" "}\n"
"inline const std::string& $classname$::_internal_$name$() const {\n" "inline const std::string& $classname$::_internal_$name$() const {\n"
" if (_internal_has_$name$()) {\n" " if (_internal_has_$name$()) {\n"
" return $field_member$.Get();\n" " return $field$.Get();\n"
" }\n" " }\n"
" return $default_string$;\n" " return $default_string$;\n"
"}\n" "}\n"
@ -599,28 +587,26 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" if (!_internal_has_$name$()) {\n" " if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n" " clear_$oneof_name$();\n"
" set_has_$name$();\n" " set_has_$name$();\n"
" $field_member$.InitDefault($init_value$);\n" " $field$.InitDefault();\n"
" }\n" " }\n"
" $field_member$.Set($default_value_tag$, value, " " $field$.Set(value, GetArenaForAllocation());\n"
"GetArenaForAllocation());\n"
"}\n"); "}\n");
format( format(
"inline std::string* $classname$::_internal_mutable_$name$() {\n" "inline std::string* $classname$::_internal_mutable_$name$() {\n"
" if (!_internal_has_$name$()) {\n" " if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n" " clear_$oneof_name$();\n"
" set_has_$name$();\n" " set_has_$name$();\n"
" $field_member$.InitDefault($init_value$);\n" " $field$.InitDefault();\n"
" }\n" " }\n"
" return $field_member$.Mutable(\n" " return $field$.Mutable($lazy_variable_args$"
" $default_variable_or_tag$, GetArenaForAllocation());\n" " GetArenaForAllocation());\n"
"}\n" "}\n"
"inline std::string* $classname$::$release_name$() {\n" "inline std::string* $classname$::$release_name$() {\n"
"$annotate_release$" "$annotate_release$"
" // @@protoc_insertion_point(field_release:$full_name$)\n" " // @@protoc_insertion_point(field_release:$full_name$)\n"
" if (_internal_has_$name$()) {\n" " if (_internal_has_$name$()) {\n"
" clear_has_$oneof_name$();\n" " clear_has_$oneof_name$();\n"
" return $field_member$.ReleaseNonDefault($default_value$, " " return $field$.Release();\n"
"GetArenaForAllocation());\n"
" } else {\n" " } else {\n"
" return nullptr;\n" " return nullptr;\n"
" }\n" " }\n"
@ -631,7 +617,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" }\n" " }\n"
" if ($name$ != nullptr) {\n" " if ($name$ != nullptr) {\n"
" set_has_$name$();\n" " set_has_$name$();\n"
" $field_member$.InitAllocated($name$, GetArenaForAllocation());\n" " $field$.InitAllocated($name$, GetArenaForAllocation());\n"
" }\n" " }\n"
"$annotate_set$" "$annotate_set$"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
@ -641,9 +627,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
void StringOneofFieldGenerator::GenerateClearingCode( void StringOneofFieldGenerator::GenerateClearingCode(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format( format("$field$.Destroy();\n");
"$field_member$.Destroy($default_value_tag$, "
"GetArenaForAllocation());\n");
} }
void StringOneofFieldGenerator::GenerateMessageClearingCode( void StringOneofFieldGenerator::GenerateMessageClearingCode(
@ -758,14 +742,14 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions(
format( format(
"inline const std::string& $classname$::_internal_$name$(int index) " "inline const std::string& $classname$::_internal_$name$(int index) "
"const {\n" "const {\n"
" return $name$_.InternalCheckedGet(\n" " return $field$.InternalCheckedGet(\n"
" index, ::$proto_ns$::internal::GetEmptyStringAlreadyInited());\n" " index, ::$proto_ns$::internal::GetEmptyStringAlreadyInited());\n"
"}\n"); "}\n");
} else { } else {
format( format(
"inline const std::string& $classname$::_internal_$name$(int index) " "inline const std::string& $classname$::_internal_$name$(int index) "
"const {\n" "const {\n"
" return $name$_.Get(index);\n" " return $field$.Get(index);\n"
"}\n"); "}\n");
} }
format( format(
@ -777,23 +761,23 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions(
"inline std::string* $classname$::mutable_$name$(int index) {\n" "inline std::string* $classname$::mutable_$name$(int index) {\n"
"$annotate_mutable$" "$annotate_mutable$"
" // @@protoc_insertion_point(field_mutable:$full_name$)\n" " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
" return $name$_.Mutable(index);\n" " return $field$.Mutable(index);\n"
"}\n" "}\n"
"inline void $classname$::set_$name$(int index, const std::string& " "inline void $classname$::set_$name$(int index, const std::string& "
"value) " "value) "
"{\n" "{\n"
" $name$_.Mutable(index)->assign(value);\n" " $field$.Mutable(index)->assign(value);\n"
"$annotate_set$" "$annotate_set$"
" // @@protoc_insertion_point(field_set:$full_name$)\n" " // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n" "}\n"
"inline void $classname$::set_$name$(int index, std::string&& value) {\n" "inline void $classname$::set_$name$(int index, std::string&& value) {\n"
" $name$_.Mutable(index)->assign(std::move(value));\n" " $field$.Mutable(index)->assign(std::move(value));\n"
"$annotate_set$" "$annotate_set$"
" // @@protoc_insertion_point(field_set:$full_name$)\n" " // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n" "}\n"
"inline void $classname$::set_$name$(int index, const char* value) {\n" "inline void $classname$::set_$name$(int index, const char* value) {\n"
" $null_check$" " $null_check$"
" $name$_.Mutable(index)->assign(value);\n" " $field$.Mutable(index)->assign(value);\n"
"$annotate_set$" "$annotate_set$"
" // @@protoc_insertion_point(field_set_char:$full_name$)\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n"
"}\n"); "}\n");
@ -801,7 +785,7 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions(
format( format(
"inline void " "inline void "
"$classname$::set_$name$(int index, StringPiece value) {\n" "$classname$::set_$name$(int index, StringPiece value) {\n"
" $name$_.Mutable(index)->assign(value.data(), value.size());\n" " $field$.Mutable(index)->assign(value.data(), value.size());\n"
"$annotate_set$" "$annotate_set$"
" // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n" " // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n"
"}\n"); "}\n");
@ -810,34 +794,34 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions(
"inline void " "inline void "
"$classname$::set_$name$" "$classname$::set_$name$"
"(int index, const $pointer_type$* value, size_t size) {\n" "(int index, const $pointer_type$* value, size_t size) {\n"
" $name$_.Mutable(index)->assign(\n" " $field$.Mutable(index)->assign(\n"
" reinterpret_cast<const char*>(value), size);\n" " reinterpret_cast<const char*>(value), size);\n"
"$annotate_set$" "$annotate_set$"
" // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
"}\n" "}\n"
"inline std::string* $classname$::_internal_add_$name$() {\n" "inline std::string* $classname$::_internal_add_$name$() {\n"
" return $name$_.Add();\n" " return $field$.Add();\n"
"}\n" "}\n"
"inline void $classname$::add_$name$(const std::string& value) {\n" "inline void $classname$::add_$name$(const std::string& value) {\n"
" $name$_.Add()->assign(value);\n" " $field$.Add()->assign(value);\n"
"$annotate_add$" "$annotate_add$"
" // @@protoc_insertion_point(field_add:$full_name$)\n" " // @@protoc_insertion_point(field_add:$full_name$)\n"
"}\n" "}\n"
"inline void $classname$::add_$name$(std::string&& value) {\n" "inline void $classname$::add_$name$(std::string&& value) {\n"
" $name$_.Add(std::move(value));\n" " $field$.Add(std::move(value));\n"
"$annotate_add$" "$annotate_add$"
" // @@protoc_insertion_point(field_add:$full_name$)\n" " // @@protoc_insertion_point(field_add:$full_name$)\n"
"}\n" "}\n"
"inline void $classname$::add_$name$(const char* value) {\n" "inline void $classname$::add_$name$(const char* value) {\n"
" $null_check$" " $null_check$"
" $name$_.Add()->assign(value);\n" " $field$.Add()->assign(value);\n"
"$annotate_add$" "$annotate_add$"
" // @@protoc_insertion_point(field_add_char:$full_name$)\n" " // @@protoc_insertion_point(field_add_char:$full_name$)\n"
"}\n"); "}\n");
if (!options_.opensource_runtime) { if (!options_.opensource_runtime) {
format( format(
"inline void $classname$::add_$name$(StringPiece value) {\n" "inline void $classname$::add_$name$(StringPiece value) {\n"
" $name$_.Add()->assign(value.data(), value.size());\n" " $field$.Add()->assign(value.data(), value.size());\n"
"$annotate_add$" "$annotate_add$"
" // @@protoc_insertion_point(field_add_string_piece:$full_name$)\n" " // @@protoc_insertion_point(field_add_string_piece:$full_name$)\n"
"}\n"); "}\n");
@ -845,7 +829,7 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions(
format( format(
"inline void " "inline void "
"$classname$::add_$name$(const $pointer_type$* value, size_t size) {\n" "$classname$::add_$name$(const $pointer_type$* value, size_t size) {\n"
" $name$_.Add()->assign(reinterpret_cast<const char*>(value), size);\n" " $field$.Add()->assign(reinterpret_cast<const char*>(value), size);\n"
"$annotate_add$" "$annotate_add$"
" // @@protoc_insertion_point(field_add_pointer:$full_name$)\n" " // @@protoc_insertion_point(field_add_pointer:$full_name$)\n"
"}\n" "}\n"
@ -853,43 +837,32 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions(
"$classname$::$name$() const {\n" "$classname$::$name$() const {\n"
"$annotate_list$" "$annotate_list$"
" // @@protoc_insertion_point(field_list:$full_name$)\n" " // @@protoc_insertion_point(field_list:$full_name$)\n"
" return $name$_;\n" " return $field$;\n"
"}\n" "}\n"
"inline ::$proto_ns$::RepeatedPtrField<std::string>*\n" "inline ::$proto_ns$::RepeatedPtrField<std::string>*\n"
"$classname$::mutable_$name$() {\n" "$classname$::mutable_$name$() {\n"
"$annotate_mutable_list$" "$annotate_mutable_list$"
" // @@protoc_insertion_point(field_mutable_list:$full_name$)\n" " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
" return &$name$_;\n" " return &$field$;\n"
"}\n"); "}\n");
} }
void RepeatedStringFieldGenerator::GenerateClearingCode( void RepeatedStringFieldGenerator::GenerateClearingCode(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_.Clear();\n"); format("$field$.Clear();\n");
} }
void RepeatedStringFieldGenerator::GenerateMergingCode( void RepeatedStringFieldGenerator::GenerateMergingCode(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_.MergeFrom(from.$name$_);\n"); format("$field$.MergeFrom(from.$field$);\n");
} }
void RepeatedStringFieldGenerator::GenerateSwappingCode( void RepeatedStringFieldGenerator::GenerateSwappingCode(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$name$_.InternalSwap(&other->$name$_);\n"); format("$field$.InternalSwap(&other->$field$);\n");
}
void RepeatedStringFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const {
// Not needed for repeated fields.
}
void RepeatedStringFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.CopyFrom(from.$name$_);");
} }
void RepeatedStringFieldGenerator::GenerateSerializeWithCachedSizesToArray( void RepeatedStringFieldGenerator::GenerateSerializeWithCachedSizesToArray(
@ -916,11 +889,11 @@ void RepeatedStringFieldGenerator::GenerateByteSize(
Formatter format(printer, variables_); Formatter format(printer, variables_);
format( format(
"total_size += $tag_size$ *\n" "total_size += $tag_size$ *\n"
" ::$proto_ns$::internal::FromIntSize($name$_.size());\n" " ::$proto_ns$::internal::FromIntSize($field$.size());\n"
"for (int i = 0, n = $name$_.size(); i < n; i++) {\n" "for (int i = 0, n = $field$.size(); i < n; i++) {\n"
" total_size += " " total_size += "
"::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n" "::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n"
" $name$_.Get(i));\n" " $field$.Get(i));\n"
"}\n"); "}\n");
} }

@ -111,8 +111,8 @@ class RepeatedStringFieldGenerator : public FieldGenerator {
void GenerateClearingCode(io::Printer* printer) const override; void GenerateClearingCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override;
void GenerateSwappingCode(io::Printer* printer) const override; void GenerateSwappingCode(io::Printer* printer) const override;
void GenerateConstructorCode(io::Printer* printer) const override; void GenerateConstructorCode(io::Printer* printer) const override {}
void GenerateCopyConstructorCode(io::Printer* printer) const override; void GenerateCopyConstructorCode(io::Printer* printer) const override {}
void GenerateSerializeWithCachedSizesToArray( void GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const override; io::Printer* printer) const override;
void GenerateByteSize(io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override;

@ -2466,7 +2466,9 @@ TEST_F(ParseDescriptorDebugTest, TestMaps) {
// *output_field to the descriptor of the field, and *output_index to -1. // *output_field to the descriptor of the field, and *output_index to -1.
// Returns true if the path was valid, false otherwise. A gTest failure is // Returns true if the path was valid, false otherwise. A gTest failure is
// recorded before returning false. // recorded before returning false.
bool FollowPath(const Message& root, const int* path_begin, const int* path_end, bool FollowPath(const Message& root,
RepeatedField<int>::const_iterator path_begin,
RepeatedField<int>::const_iterator path_end,
const Message** output_message, const Message** output_message,
const FieldDescriptor** output_field, int* output_index) { const FieldDescriptor** output_field, int* output_index) {
if (path_begin == path_end) { if (path_begin == path_end) {

@ -252,10 +252,10 @@ Version::Version(const Version& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
suffix_.InitDefault(); suffix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); suffix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_suffix()) { if (from._internal_has_suffix()) {
suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_suffix(), suffix_.Set(from._internal_suffix(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
::memcpy(&major_, &from.major_, ::memcpy(&major_, &from.major_,
@ -267,7 +267,7 @@ Version::Version(const Version& from)
inline void Version::SharedCtor() { inline void Version::SharedCtor() {
suffix_.InitDefault(); suffix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); suffix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&major_) - reinterpret_cast<char*>(this)), reinterpret_cast<char*>(&major_) - reinterpret_cast<char*>(this)),
@ -286,7 +286,7 @@ Version::~Version() {
inline void Version::SharedDtor() { inline void Version::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
suffix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); suffix_.Destroy();
} }
void Version::SetCachedSize(int size) const { void Version::SetCachedSize(int size) const {
@ -517,7 +517,6 @@ void Version::InternalSwap(Version* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&suffix_, lhs_arena, &suffix_, lhs_arena,
&other->suffix_, rhs_arena &other->suffix_, rhs_arena
); );
@ -572,10 +571,10 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
parameter_.InitDefault(); parameter_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); parameter_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_parameter()) { if (from._internal_has_parameter()) {
parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_parameter(), parameter_.Set(from._internal_parameter(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
if (from._internal_has_compiler_version()) { if (from._internal_has_compiler_version()) {
@ -589,7 +588,7 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)
inline void CodeGeneratorRequest::SharedCtor() { inline void CodeGeneratorRequest::SharedCtor() {
parameter_.InitDefault(); parameter_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); parameter_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
compiler_version_ = nullptr; compiler_version_ = nullptr;
} }
@ -605,7 +604,7 @@ CodeGeneratorRequest::~CodeGeneratorRequest() {
inline void CodeGeneratorRequest::SharedDtor() { inline void CodeGeneratorRequest::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
parameter_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); parameter_.Destroy();
if (this != internal_default_instance()) delete compiler_version_; if (this != internal_default_instance()) delete compiler_version_;
} }
@ -864,7 +863,6 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
file_to_generate_.InternalSwap(&other->file_to_generate_); file_to_generate_.InternalSwap(&other->file_to_generate_);
proto_file_.InternalSwap(&other->proto_file_); proto_file_.InternalSwap(&other->proto_file_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&parameter_, lhs_arena, &parameter_, lhs_arena,
&other->parameter_, rhs_arena &other->parameter_, rhs_arena
); );
@ -917,26 +915,26 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
insertion_point_.InitDefault(); insertion_point_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); insertion_point_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_insertion_point()) { if (from._internal_has_insertion_point()) {
insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_insertion_point(), insertion_point_.Set(from._internal_insertion_point(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
content_.InitDefault(); content_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); content_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_content()) { if (from._internal_has_content()) {
content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_content(), content_.Set(from._internal_content(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
if (from._internal_has_generated_code_info()) { if (from._internal_has_generated_code_info()) {
@ -950,15 +948,15 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon
inline void CodeGeneratorResponse_File::SharedCtor() { inline void CodeGeneratorResponse_File::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
insertion_point_.InitDefault(); insertion_point_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); insertion_point_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
content_.InitDefault(); content_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); content_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
generated_code_info_ = nullptr; generated_code_info_ = nullptr;
} }
@ -974,9 +972,9 @@ CodeGeneratorResponse_File::~CodeGeneratorResponse_File() {
inline void CodeGeneratorResponse_File::SharedDtor() { inline void CodeGeneratorResponse_File::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
insertion_point_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); insertion_point_.Destroy();
content_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); content_.Destroy();
if (this != internal_default_instance()) delete generated_code_info_; if (this != internal_default_instance()) delete generated_code_info_;
} }
@ -1234,17 +1232,14 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other)
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&insertion_point_, lhs_arena, &insertion_point_, lhs_arena,
&other->insertion_point_, rhs_arena &other->insertion_point_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&content_, lhs_arena, &content_, lhs_arena,
&other->content_, rhs_arena &other->content_, rhs_arena
); );
@ -1284,10 +1279,10 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
error_.InitDefault(); error_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); error_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_error()) { if (from._internal_has_error()) {
error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_error(), error_.Set(from._internal_error(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
supported_features_ = from.supported_features_; supported_features_ = from.supported_features_;
@ -1297,7 +1292,7 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
inline void CodeGeneratorResponse::SharedCtor() { inline void CodeGeneratorResponse::SharedCtor() {
error_.InitDefault(); error_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); error_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
supported_features_ = uint64_t{0u}; supported_features_ = uint64_t{0u};
} }
@ -1313,7 +1308,7 @@ CodeGeneratorResponse::~CodeGeneratorResponse() {
inline void CodeGeneratorResponse::SharedDtor() { inline void CodeGeneratorResponse::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
error_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); error_.Destroy();
} }
void CodeGeneratorResponse::SetCachedSize(int size) const { void CodeGeneratorResponse::SetCachedSize(int size) const {
@ -1525,7 +1520,6 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
file_.InternalSwap(&other->file_); file_.InternalSwap(&other->file_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&error_, lhs_arena, &error_, lhs_arena,
&other->error_, rhs_arena &other->error_, rhs_arena
); );

@ -1093,7 +1093,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Version::set_suffix(ArgT0&& arg0, ArgT... args) { void Version::set_suffix(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); suffix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix) // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix)
} }
inline std::string* Version::mutable_suffix() { inline std::string* Version::mutable_suffix() {
@ -1106,11 +1106,11 @@ inline const std::string& Version::_internal_suffix() const {
} }
inline void Version::_internal_set_suffix(const std::string& value) { inline void Version::_internal_set_suffix(const std::string& value) {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); suffix_.Set(value, GetArenaForAllocation());
} }
inline std::string* Version::_internal_mutable_suffix() { inline std::string* Version::_internal_mutable_suffix() {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
return suffix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return suffix_.Mutable(GetArenaForAllocation());
} }
inline std::string* Version::release_suffix() { inline std::string* Version::release_suffix() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix) // @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix)
@ -1118,10 +1118,10 @@ inline std::string* Version::release_suffix() {
return nullptr; return nullptr;
} }
_has_bits_[0] &= ~0x00000001u; _has_bits_[0] &= ~0x00000001u;
auto* p = suffix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); auto* p = suffix_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (suffix_.IsDefault()) { if (suffix_.IsDefault()) {
suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); suffix_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p; return p;
@ -1132,11 +1132,10 @@ inline void Version::set_allocated_suffix(std::string* suffix) {
} else { } else {
_has_bits_[0] &= ~0x00000001u; _has_bits_[0] &= ~0x00000001u;
} }
suffix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), suffix, suffix_.SetAllocated(suffix, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (suffix_.IsDefault()) { if (suffix_.IsDefault()) {
suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); suffix_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix) // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix)
@ -1241,7 +1240,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorRequest::set_parameter(ArgT0&& arg0, ArgT... args) { void CodeGeneratorRequest::set_parameter(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); parameter_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter) // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter)
} }
inline std::string* CodeGeneratorRequest::mutable_parameter() { inline std::string* CodeGeneratorRequest::mutable_parameter() {
@ -1254,11 +1253,11 @@ inline const std::string& CodeGeneratorRequest::_internal_parameter() const {
} }
inline void CodeGeneratorRequest::_internal_set_parameter(const std::string& value) { inline void CodeGeneratorRequest::_internal_set_parameter(const std::string& value) {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); parameter_.Set(value, GetArenaForAllocation());
} }
inline std::string* CodeGeneratorRequest::_internal_mutable_parameter() { inline std::string* CodeGeneratorRequest::_internal_mutable_parameter() {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
return parameter_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return parameter_.Mutable(GetArenaForAllocation());
} }
inline std::string* CodeGeneratorRequest::release_parameter() { inline std::string* CodeGeneratorRequest::release_parameter() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter) // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter)
@ -1266,10 +1265,10 @@ inline std::string* CodeGeneratorRequest::release_parameter() {
return nullptr; return nullptr;
} }
_has_bits_[0] &= ~0x00000001u; _has_bits_[0] &= ~0x00000001u;
auto* p = parameter_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); auto* p = parameter_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (parameter_.IsDefault()) { if (parameter_.IsDefault()) {
parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); parameter_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p; return p;
@ -1280,11 +1279,10 @@ inline void CodeGeneratorRequest::set_allocated_parameter(std::string* parameter
} else { } else {
_has_bits_[0] &= ~0x00000001u; _has_bits_[0] &= ~0x00000001u;
} }
parameter_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), parameter, parameter_.SetAllocated(parameter, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (parameter_.IsDefault()) { if (parameter_.IsDefault()) {
parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); parameter_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter) // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter)
@ -1404,7 +1402,7 @@ inline void CodeGeneratorRequest::set_allocated_compiler_version(::PROTOBUF_NAME
} }
if (compiler_version) { if (compiler_version) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::compiler::Version>::GetOwningArena(compiler_version); ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(compiler_version);
if (message_arena != submessage_arena) { if (message_arena != submessage_arena) {
compiler_version = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( compiler_version = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, compiler_version, submessage_arena); message_arena, compiler_version, submessage_arena);
@ -1441,7 +1439,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse_File::set_name(ArgT0&& arg0, ArgT... args) { void CodeGeneratorResponse_File::set_name(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name) // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name)
} }
inline std::string* CodeGeneratorResponse_File::mutable_name() { inline std::string* CodeGeneratorResponse_File::mutable_name() {
@ -1454,11 +1452,11 @@ inline const std::string& CodeGeneratorResponse_File::_internal_name() const {
} }
inline void CodeGeneratorResponse_File::_internal_set_name(const std::string& value) { inline void CodeGeneratorResponse_File::_internal_set_name(const std::string& value) {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); name_.Set(value, GetArenaForAllocation());
} }
inline std::string* CodeGeneratorResponse_File::_internal_mutable_name() { inline std::string* CodeGeneratorResponse_File::_internal_mutable_name() {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return name_.Mutable(GetArenaForAllocation());
} }
inline std::string* CodeGeneratorResponse_File::release_name() { inline std::string* CodeGeneratorResponse_File::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name) // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name)
@ -1466,10 +1464,10 @@ inline std::string* CodeGeneratorResponse_File::release_name() {
return nullptr; return nullptr;
} }
_has_bits_[0] &= ~0x00000001u; _has_bits_[0] &= ~0x00000001u;
auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); auto* p = name_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (name_.IsDefault()) { if (name_.IsDefault()) {
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p; return p;
@ -1480,11 +1478,10 @@ inline void CodeGeneratorResponse_File::set_allocated_name(std::string* name) {
} else { } else {
_has_bits_[0] &= ~0x00000001u; _has_bits_[0] &= ~0x00000001u;
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(name, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (name_.IsDefault()) { if (name_.IsDefault()) {
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name)
@ -1510,7 +1507,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse_File::set_insertion_point(ArgT0&& arg0, ArgT... args) { void CodeGeneratorResponse_File::set_insertion_point(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000002u; _has_bits_[0] |= 0x00000002u;
insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); insertion_point_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
} }
inline std::string* CodeGeneratorResponse_File::mutable_insertion_point() { inline std::string* CodeGeneratorResponse_File::mutable_insertion_point() {
@ -1523,11 +1520,11 @@ inline const std::string& CodeGeneratorResponse_File::_internal_insertion_point(
} }
inline void CodeGeneratorResponse_File::_internal_set_insertion_point(const std::string& value) { inline void CodeGeneratorResponse_File::_internal_set_insertion_point(const std::string& value) {
_has_bits_[0] |= 0x00000002u; _has_bits_[0] |= 0x00000002u;
insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); insertion_point_.Set(value, GetArenaForAllocation());
} }
inline std::string* CodeGeneratorResponse_File::_internal_mutable_insertion_point() { inline std::string* CodeGeneratorResponse_File::_internal_mutable_insertion_point() {
_has_bits_[0] |= 0x00000002u; _has_bits_[0] |= 0x00000002u;
return insertion_point_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return insertion_point_.Mutable(GetArenaForAllocation());
} }
inline std::string* CodeGeneratorResponse_File::release_insertion_point() { inline std::string* CodeGeneratorResponse_File::release_insertion_point() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
@ -1535,10 +1532,10 @@ inline std::string* CodeGeneratorResponse_File::release_insertion_point() {
return nullptr; return nullptr;
} }
_has_bits_[0] &= ~0x00000002u; _has_bits_[0] &= ~0x00000002u;
auto* p = insertion_point_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); auto* p = insertion_point_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (insertion_point_.IsDefault()) { if (insertion_point_.IsDefault()) {
insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); insertion_point_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p; return p;
@ -1549,11 +1546,10 @@ inline void CodeGeneratorResponse_File::set_allocated_insertion_point(std::strin
} else { } else {
_has_bits_[0] &= ~0x00000002u; _has_bits_[0] &= ~0x00000002u;
} }
insertion_point_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), insertion_point, insertion_point_.SetAllocated(insertion_point, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (insertion_point_.IsDefault()) { if (insertion_point_.IsDefault()) {
insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); insertion_point_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
@ -1579,7 +1575,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse_File::set_content(ArgT0&& arg0, ArgT... args) { void CodeGeneratorResponse_File::set_content(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000004u; _has_bits_[0] |= 0x00000004u;
content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); content_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content) // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content)
} }
inline std::string* CodeGeneratorResponse_File::mutable_content() { inline std::string* CodeGeneratorResponse_File::mutable_content() {
@ -1592,11 +1588,11 @@ inline const std::string& CodeGeneratorResponse_File::_internal_content() const
} }
inline void CodeGeneratorResponse_File::_internal_set_content(const std::string& value) { inline void CodeGeneratorResponse_File::_internal_set_content(const std::string& value) {
_has_bits_[0] |= 0x00000004u; _has_bits_[0] |= 0x00000004u;
content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); content_.Set(value, GetArenaForAllocation());
} }
inline std::string* CodeGeneratorResponse_File::_internal_mutable_content() { inline std::string* CodeGeneratorResponse_File::_internal_mutable_content() {
_has_bits_[0] |= 0x00000004u; _has_bits_[0] |= 0x00000004u;
return content_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return content_.Mutable(GetArenaForAllocation());
} }
inline std::string* CodeGeneratorResponse_File::release_content() { inline std::string* CodeGeneratorResponse_File::release_content() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content) // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content)
@ -1604,10 +1600,10 @@ inline std::string* CodeGeneratorResponse_File::release_content() {
return nullptr; return nullptr;
} }
_has_bits_[0] &= ~0x00000004u; _has_bits_[0] &= ~0x00000004u;
auto* p = content_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); auto* p = content_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (content_.IsDefault()) { if (content_.IsDefault()) {
content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); content_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p; return p;
@ -1618,11 +1614,10 @@ inline void CodeGeneratorResponse_File::set_allocated_content(std::string* conte
} else { } else {
_has_bits_[0] &= ~0x00000004u; _has_bits_[0] &= ~0x00000004u;
} }
content_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), content, content_.SetAllocated(content, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (content_.IsDefault()) { if (content_.IsDefault()) {
content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); content_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)
@ -1701,8 +1696,7 @@ inline void CodeGeneratorResponse_File::set_allocated_generated_code_info(::PROT
} }
if (generated_code_info) { if (generated_code_info) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper< ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(
::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena(
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info)); reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info));
if (message_arena != submessage_arena) { if (message_arena != submessage_arena) {
generated_code_info = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( generated_code_info = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
@ -1740,7 +1734,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse::set_error(ArgT0&& arg0, ArgT... args) { void CodeGeneratorResponse::set_error(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); error_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error) // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error)
} }
inline std::string* CodeGeneratorResponse::mutable_error() { inline std::string* CodeGeneratorResponse::mutable_error() {
@ -1753,11 +1747,11 @@ inline const std::string& CodeGeneratorResponse::_internal_error() const {
} }
inline void CodeGeneratorResponse::_internal_set_error(const std::string& value) { inline void CodeGeneratorResponse::_internal_set_error(const std::string& value) {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); error_.Set(value, GetArenaForAllocation());
} }
inline std::string* CodeGeneratorResponse::_internal_mutable_error() { inline std::string* CodeGeneratorResponse::_internal_mutable_error() {
_has_bits_[0] |= 0x00000001u; _has_bits_[0] |= 0x00000001u;
return error_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return error_.Mutable(GetArenaForAllocation());
} }
inline std::string* CodeGeneratorResponse::release_error() { inline std::string* CodeGeneratorResponse::release_error() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error) // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error)
@ -1765,10 +1759,10 @@ inline std::string* CodeGeneratorResponse::release_error() {
return nullptr; return nullptr;
} }
_has_bits_[0] &= ~0x00000001u; _has_bits_[0] &= ~0x00000001u;
auto* p = error_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); auto* p = error_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (error_.IsDefault()) { if (error_.IsDefault()) {
error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); error_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p; return p;
@ -1779,11 +1773,10 @@ inline void CodeGeneratorResponse::set_allocated_error(std::string* error) {
} else { } else {
_has_bits_[0] &= ~0x00000001u; _has_bits_[0] &= ~0x00000001u;
} }
error_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), error, error_.SetAllocated(error, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (error_.IsDefault()) { if (error_.IsDefault()) {
error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); error_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error) // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error)

@ -73,15 +73,15 @@ static void CloseHandleOrDie(HANDLE handle) {
Subprocess::Subprocess() Subprocess::Subprocess()
: process_start_error_(ERROR_SUCCESS), : process_start_error_(ERROR_SUCCESS),
child_handle_(NULL), child_handle_(nullptr),
child_stdin_(NULL), child_stdin_(nullptr),
child_stdout_(NULL) {} child_stdout_(nullptr) {}
Subprocess::~Subprocess() { Subprocess::~Subprocess() {
if (child_stdin_ != NULL) { if (child_stdin_ != nullptr) {
CloseHandleOrDie(child_stdin_); CloseHandleOrDie(child_stdin_);
} }
if (child_stdout_ != NULL) { if (child_stdout_ != nullptr) {
CloseHandleOrDie(child_stdout_); CloseHandleOrDie(child_stdout_);
} }
} }
@ -93,10 +93,10 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) {
HANDLE stdout_pipe_read; HANDLE stdout_pipe_read;
HANDLE stdout_pipe_write; HANDLE stdout_pipe_write;
if (!CreatePipe(&stdin_pipe_read, &stdin_pipe_write, NULL, 0)) { if (!CreatePipe(&stdin_pipe_read, &stdin_pipe_write, nullptr, 0)) {
GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError()); GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError());
} }
if (!CreatePipe(&stdout_pipe_read, &stdout_pipe_write, NULL, 0)) { if (!CreatePipe(&stdout_pipe_read, &stdout_pipe_write, nullptr, 0)) {
GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError()); GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError());
} }
@ -134,14 +134,14 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) {
// Create the process. // Create the process.
PROCESS_INFORMATION process_info; PROCESS_INFORMATION process_info;
if (CreateProcessA((search_mode == SEARCH_PATH) ? NULL : program.c_str(), if (CreateProcessA((search_mode == SEARCH_PATH) ? nullptr : program.c_str(),
(search_mode == SEARCH_PATH) ? command_line : NULL, (search_mode == SEARCH_PATH) ? command_line : nullptr,
NULL, // process security attributes nullptr, // process security attributes
NULL, // thread security attributes nullptr, // thread security attributes
TRUE, // inherit handles? TRUE, // inherit handles?
0, // obscure creation flags 0, // obscure creation flags
NULL, // environment (inherit from parent) nullptr, // environment (inherit from parent)
NULL, // current directory (inherit from parent) nullptr, // current directory (inherit from parent)
&startup_info, &process_info)) { &startup_info, &process_info)) {
child_handle_ = process_info.hProcess; child_handle_ = process_info.hProcess;
CloseHandleOrDie(process_info.hThread); CloseHandleOrDie(process_info.hThread);
@ -165,28 +165,28 @@ bool Subprocess::Communicate(const Message& input, Message* output,
return false; return false;
} }
GOOGLE_CHECK(child_handle_ != NULL) << "Must call Start() first."; GOOGLE_CHECK(child_handle_ != nullptr) << "Must call Start() first.";
std::string input_data = input.SerializeAsString(); std::string input_data = input.SerializeAsString();
std::string output_data; std::string output_data;
int input_pos = 0; int input_pos = 0;
while (child_stdout_ != NULL) { while (child_stdout_ != nullptr) {
HANDLE handles[2]; HANDLE handles[2];
int handle_count = 0; int handle_count = 0;
if (child_stdin_ != NULL) { if (child_stdin_ != nullptr) {
handles[handle_count++] = child_stdin_; handles[handle_count++] = child_stdin_;
} }
if (child_stdout_ != NULL) { if (child_stdout_ != nullptr) {
handles[handle_count++] = child_stdout_; handles[handle_count++] = child_stdout_;
} }
DWORD wait_result = DWORD wait_result =
WaitForMultipleObjects(handle_count, handles, FALSE, INFINITE); WaitForMultipleObjects(handle_count, handles, FALSE, INFINITE);
HANDLE signaled_handle = NULL; HANDLE signaled_handle = nullptr;
if (wait_result >= WAIT_OBJECT_0 && if (wait_result >= WAIT_OBJECT_0 &&
wait_result < WAIT_OBJECT_0 + handle_count) { wait_result < WAIT_OBJECT_0 + handle_count) {
signaled_handle = handles[wait_result - WAIT_OBJECT_0]; signaled_handle = handles[wait_result - WAIT_OBJECT_0];
@ -201,7 +201,7 @@ bool Subprocess::Communicate(const Message& input, Message* output,
if (signaled_handle == child_stdin_) { if (signaled_handle == child_stdin_) {
DWORD n; DWORD n;
if (!WriteFile(child_stdin_, input_data.data() + input_pos, if (!WriteFile(child_stdin_, input_data.data() + input_pos,
input_data.size() - input_pos, &n, NULL)) { input_data.size() - input_pos, &n, nullptr)) {
// Child closed pipe. Presumably it will report an error later. // Child closed pipe. Presumably it will report an error later.
// Pretend we're done for now. // Pretend we're done for now.
input_pos = input_data.size(); input_pos = input_data.size();
@ -212,27 +212,27 @@ bool Subprocess::Communicate(const Message& input, Message* output,
if (input_pos == input_data.size()) { if (input_pos == input_data.size()) {
// We're done writing. Close. // We're done writing. Close.
CloseHandleOrDie(child_stdin_); CloseHandleOrDie(child_stdin_);
child_stdin_ = NULL; child_stdin_ = nullptr;
} }
} else if (signaled_handle == child_stdout_) { } else if (signaled_handle == child_stdout_) {
char buffer[4096]; char buffer[4096];
DWORD n; DWORD n;
if (!ReadFile(child_stdout_, buffer, sizeof(buffer), &n, NULL)) { if (!ReadFile(child_stdout_, buffer, sizeof(buffer), &n, nullptr)) {
// We're done reading. Close. // We're done reading. Close.
CloseHandleOrDie(child_stdout_); CloseHandleOrDie(child_stdout_);
child_stdout_ = NULL; child_stdout_ = nullptr;
} else { } else {
output_data.append(buffer, n); output_data.append(buffer, n);
} }
} }
} }
if (child_stdin_ != NULL) { if (child_stdin_ != nullptr) {
// Child did not finish reading input before it closed the output. // Child did not finish reading input before it closed the output.
// Presumably it exited with an error. // Presumably it exited with an error.
CloseHandleOrDie(child_stdin_); CloseHandleOrDie(child_stdin_);
child_stdin_ = NULL; child_stdin_ = nullptr;
} }
DWORD wait_result = WaitForSingleObject(child_handle_, INFINITE); DWORD wait_result = WaitForSingleObject(child_handle_, INFINITE);
@ -252,7 +252,7 @@ bool Subprocess::Communicate(const Message& input, Message* output,
} }
CloseHandleOrDie(child_handle_); CloseHandleOrDie(child_handle_);
child_handle_ = NULL; child_handle_ = nullptr;
if (exit_code != 0) { if (exit_code != 0) {
*error = strings::Substitute("Plugin failed with status code $0.", exit_code); *error = strings::Substitute("Plugin failed with status code $0.", exit_code);
@ -273,9 +273,10 @@ std::string Subprocess::Win32ErrorMessage(DWORD error_code) {
// WTF? // WTF?
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, error_code, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), nullptr, error_code,
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
(LPSTR)&message, // NOT A BUG! (LPSTR)&message, // NOT A BUG!
0, NULL); 0, nullptr);
std::string result = message; std::string result = message;
LocalFree(message); LocalFree(message);

@ -49,7 +49,6 @@
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/once.h> #include <google/protobuf/stubs/once.h>
#include <google/protobuf/any.h> #include <google/protobuf/any.h>
@ -58,6 +57,7 @@
#include <google/protobuf/io/tokenizer.h> #include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/stubs/casts.h> #include <google/protobuf/stubs/casts.h>
#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/stubs/substitute.h> #include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/descriptor_database.h> #include <google/protobuf/descriptor_database.h>
#include <google/protobuf/dynamic_message.h> #include <google/protobuf/dynamic_message.h>
@ -1300,10 +1300,6 @@ class FileDescriptorTables {
bool AddFieldByNumber(FieldDescriptor* field); bool AddFieldByNumber(FieldDescriptor* field);
bool AddEnumValueByNumber(EnumValueDescriptor* value); bool AddEnumValueByNumber(EnumValueDescriptor* value);
// Adds the field to the lowercase_name and camelcase_name maps. Never
// fails because we allow duplicates; the first field by the name wins.
void AddFieldByStylizedNames(const FieldDescriptor* field);
// Populates p->first->locations_by_path_ from p->second. // Populates p->first->locations_by_path_ from p->second.
// Unusual signature dictated by internal::call_once. // Unusual signature dictated by internal::call_once.
static void BuildLocationsByPath( static void BuildLocationsByPath(
@ -1330,12 +1326,13 @@ class FileDescriptorTables {
void FieldsByCamelcaseNamesLazyInitInternal() const; void FieldsByCamelcaseNamesLazyInitInternal() const;
SymbolsByParentSet symbols_by_parent_; SymbolsByParentSet symbols_by_parent_;
mutable FieldsByNameMap fields_by_lowercase_name_;
std::unique_ptr<FieldsByNameMap> fields_by_lowercase_name_tmp_;
mutable internal::once_flag fields_by_lowercase_name_once_; mutable internal::once_flag fields_by_lowercase_name_once_;
mutable FieldsByNameMap fields_by_camelcase_name_;
std::unique_ptr<FieldsByNameMap> fields_by_camelcase_name_tmp_;
mutable internal::once_flag fields_by_camelcase_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. FieldsByNumberSet fields_by_number_; // Not including extensions.
EnumValuesByNumberSet enum_values_by_number_; EnumValuesByNumberSet enum_values_by_number_;
mutable EnumValuesByNumberSet unknown_enum_values_by_number_ mutable EnumValuesByNumberSet unknown_enum_values_by_number_
@ -1373,11 +1370,12 @@ DescriptorPool::Tables::Tables() {
DescriptorPool::Tables::~Tables() { GOOGLE_DCHECK(checkpoints_.empty()); } DescriptorPool::Tables::~Tables() { GOOGLE_DCHECK(checkpoints_.empty()); }
FileDescriptorTables::FileDescriptorTables() FileDescriptorTables::FileDescriptorTables() {}
: fields_by_lowercase_name_tmp_(new FieldsByNameMap()),
fields_by_camelcase_name_tmp_(new FieldsByNameMap()) {}
FileDescriptorTables::~FileDescriptorTables() {} FileDescriptorTables::~FileDescriptorTables() {
delete fields_by_lowercase_name_.load(std::memory_order_acquire);
delete fields_by_camelcase_name_.load(std::memory_order_acquire);
}
inline const FileDescriptorTables& FileDescriptorTables::GetEmptyInstance() { inline const FileDescriptorTables& FileDescriptorTables::GetEmptyInstance() {
static auto file_descriptor_tables = static auto file_descriptor_tables =
@ -1520,13 +1518,14 @@ void FileDescriptorTables::FieldsByLowercaseNamesLazyInitStatic(
} }
void FileDescriptorTables::FieldsByLowercaseNamesLazyInitInternal() const { void FileDescriptorTables::FieldsByLowercaseNamesLazyInitInternal() const {
auto* map = new FieldsByNameMap;
for (Symbol symbol : symbols_by_parent_) { for (Symbol symbol : symbols_by_parent_) {
const FieldDescriptor* field = symbol.field_descriptor(); const FieldDescriptor* field = symbol.field_descriptor();
if (!field) continue; if (!field) continue;
PointerStringPair lowercase_key(FindParentForFieldsByMap(field), (*map)[{FindParentForFieldsByMap(field), field->lowercase_name().c_str()}] =
field->lowercase_name().c_str()); field;
InsertIfNotPresent(&fields_by_lowercase_name_, lowercase_key, field);
} }
fields_by_lowercase_name_.store(map, std::memory_order_release);
} }
inline const FieldDescriptor* FileDescriptorTables::FindFieldByLowercaseName( inline const FieldDescriptor* FileDescriptorTables::FindFieldByLowercaseName(
@ -1534,8 +1533,9 @@ inline const FieldDescriptor* FileDescriptorTables::FindFieldByLowercaseName(
internal::call_once( internal::call_once(
fields_by_lowercase_name_once_, fields_by_lowercase_name_once_,
&FileDescriptorTables::FieldsByLowercaseNamesLazyInitStatic, this); &FileDescriptorTables::FieldsByLowercaseNamesLazyInitStatic, this);
return FindPtrOrNull(fields_by_lowercase_name_, return FindPtrOrNull(
PointerStringPair(parent, lowercase_name)); *fields_by_lowercase_name_.load(std::memory_order_acquire),
PointerStringPair(parent, lowercase_name));
} }
void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic( void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic(
@ -1544,13 +1544,14 @@ void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic(
} }
void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitInternal() const { void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitInternal() const {
auto* map = new FieldsByNameMap;
for (Symbol symbol : symbols_by_parent_) { for (Symbol symbol : symbols_by_parent_) {
const FieldDescriptor* field = symbol.field_descriptor(); const FieldDescriptor* field = symbol.field_descriptor();
if (!field) continue; if (!field) continue;
PointerStringPair camelcase_key(FindParentForFieldsByMap(field), (*map)[{FindParentForFieldsByMap(field), field->camelcase_name().c_str()}] =
field->camelcase_name().c_str()); field;
InsertIfNotPresent(&fields_by_camelcase_name_, camelcase_key, field);
} }
fields_by_camelcase_name_.store(map, std::memory_order_release);
} }
inline const FieldDescriptor* FileDescriptorTables::FindFieldByCamelcaseName( inline const FieldDescriptor* FileDescriptorTables::FindFieldByCamelcaseName(
@ -1558,8 +1559,9 @@ inline const FieldDescriptor* FileDescriptorTables::FindFieldByCamelcaseName(
internal::call_once( internal::call_once(
fields_by_camelcase_name_once_, fields_by_camelcase_name_once_,
FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic, this); FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic, this);
return FindPtrOrNull(fields_by_camelcase_name_, return FindPtrOrNull(
PointerStringPair(parent, camelcase_name)); *fields_by_camelcase_name_.load(std::memory_order_acquire),
PointerStringPair(parent, camelcase_name));
} }
inline const EnumValueDescriptor* FileDescriptorTables::FindEnumValueByNumber( inline const EnumValueDescriptor* FileDescriptorTables::FindEnumValueByNumber(
@ -1619,8 +1621,8 @@ FileDescriptorTables::FindEnumValueByNumberCreatingIfUnknown(
// EnumDescriptor (it's not a part of the enum as originally defined), but // EnumDescriptor (it's not a part of the enum as originally defined), but
// we do insert it into the table so that we can return the same pointer // we do insert it into the table so that we can return the same pointer
// later. // later.
std::string enum_value_name = StringPrintf("UNKNOWN_ENUM_VALUE_%s_%d", std::string enum_value_name = StringPrintf(
parent->name().c_str(), number); "UNKNOWN_ENUM_VALUE_%s_%d", parent->name().c_str(), number);
auto* pool = DescriptorPool::generated_pool(); auto* pool = DescriptorPool::generated_pool();
auto* tables = const_cast<DescriptorPool::Tables*>(pool->tables_.get()); auto* tables = const_cast<DescriptorPool::Tables*>(pool->tables_.get());
internal::FlatAllocator alloc; internal::FlatAllocator alloc;
@ -1689,39 +1691,7 @@ bool DescriptorPool::Tables::AddFile(const FileDescriptor* file) {
} }
} }
void FileDescriptorTables::FinalizeTables() { void FileDescriptorTables::FinalizeTables() {}
// Clean up the temporary maps used by AddFieldByStylizedNames().
fields_by_lowercase_name_tmp_ = nullptr;
fields_by_camelcase_name_tmp_ = nullptr;
}
void FileDescriptorTables::AddFieldByStylizedNames(
const FieldDescriptor* field) {
const void* parent = FindParentForFieldsByMap(field);
// We want fields_by_{lower,camel}case_name_ to be lazily built, but
// cross-link order determines which entry will be present in the case of a
// conflict. So we use the temporary maps that get destroyed after
// BuildFileImpl() to detect the conflicts, and only store the conflicts in
// the map that will persist. We will then lazily populate the rest of the
// entries from fields_by_number_.
PointerStringPair lowercase_key(parent, field->lowercase_name().c_str());
if (!InsertIfNotPresent(fields_by_lowercase_name_tmp_.get(),
lowercase_key, field)) {
InsertIfNotPresent(
&fields_by_lowercase_name_, lowercase_key,
FindPtrOrNull(*fields_by_lowercase_name_tmp_, lowercase_key));
}
PointerStringPair camelcase_key(parent, field->camelcase_name().c_str());
if (!InsertIfNotPresent(fields_by_camelcase_name_tmp_.get(),
camelcase_key, field)) {
InsertIfNotPresent(
&fields_by_camelcase_name_, camelcase_key,
FindPtrOrNull(*fields_by_camelcase_name_tmp_, camelcase_key));
}
}
bool FileDescriptorTables::AddFieldByNumber(FieldDescriptor* field) { bool FileDescriptorTables::AddFieldByNumber(FieldDescriptor* field) {
// Skip fields that are at the start of the sequence. // Skip fields that are at the start of the sequence.
@ -6271,9 +6241,6 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field,
field->options_ = &FieldOptions::default_instance(); field->options_ = &FieldOptions::default_instance();
} }
// Add the field to the lowercase-name and camelcase-name tables.
file_tables_->AddFieldByStylizedNames(field);
if (proto.has_extendee()) { if (proto.has_extendee()) {
Symbol extendee = Symbol extendee =
LookupSymbol(proto.extendee(), field->full_name(), LookupSymbol(proto.extendee(), field->full_name(),

@ -1506,26 +1506,26 @@ FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
package_.InitDefault(); package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_package()) { if (from._internal_has_package()) {
package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_package(), package_.Set(from._internal_package(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
syntax_.InitDefault(); syntax_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); syntax_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_syntax()) { if (from._internal_has_syntax()) {
syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_syntax(), syntax_.Set(from._internal_syntax(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
@ -1544,15 +1544,15 @@ FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from)
inline void FileDescriptorProto::SharedCtor() { inline void FileDescriptorProto::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
package_.InitDefault(); package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
syntax_.InitDefault(); syntax_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); syntax_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)), reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)),
@ -1571,9 +1571,9 @@ FileDescriptorProto::~FileDescriptorProto() {
inline void FileDescriptorProto::SharedDtor() { inline void FileDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); package_.Destroy();
syntax_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); syntax_.Destroy();
if (this != internal_default_instance()) delete options_; if (this != internal_default_instance()) delete options_;
if (this != internal_default_instance()) delete source_code_info_; if (this != internal_default_instance()) delete source_code_info_;
} }
@ -2102,17 +2102,14 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) {
public_dependency_.InternalSwap(&other->public_dependency_); public_dependency_.InternalSwap(&other->public_dependency_);
weak_dependency_.InternalSwap(&other->weak_dependency_); weak_dependency_.InternalSwap(&other->weak_dependency_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&package_, lhs_arena, &package_, lhs_arena,
&other->package_, rhs_arena &other->package_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&syntax_, lhs_arena, &syntax_, lhs_arena,
&other->syntax_, rhs_arena &other->syntax_, rhs_arena
); );
@ -2682,10 +2679,10 @@ DescriptorProto::DescriptorProto(const DescriptorProto& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
@ -2699,7 +2696,7 @@ DescriptorProto::DescriptorProto(const DescriptorProto& from)
inline void DescriptorProto::SharedCtor() { inline void DescriptorProto::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
options_ = nullptr; options_ = nullptr;
} }
@ -2715,7 +2712,7 @@ DescriptorProto::~DescriptorProto() {
inline void DescriptorProto::SharedDtor() { inline void DescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
if (this != internal_default_instance()) delete options_; if (this != internal_default_instance()) delete options_;
} }
@ -3173,7 +3170,6 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) {
reserved_range_.InternalSwap(&other->reserved_range_); reserved_range_.InternalSwap(&other->reserved_range_);
reserved_name_.InternalSwap(&other->reserved_name_); reserved_name_.InternalSwap(&other->reserved_name_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
@ -3443,42 +3439,42 @@ FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
extendee_.InitDefault(); extendee_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); extendee_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_extendee()) { if (from._internal_has_extendee()) {
extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_extendee(), extendee_.Set(from._internal_extendee(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
type_name_.InitDefault(); type_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); type_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_type_name()) { if (from._internal_has_type_name()) {
type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_name(), type_name_.Set(from._internal_type_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
default_value_.InitDefault(); default_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); default_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_default_value()) { if (from._internal_has_default_value()) {
default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_default_value(), default_value_.Set(from._internal_default_value(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
json_name_.InitDefault(); json_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); json_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_json_name()) { if (from._internal_has_json_name()) {
json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_json_name(), json_name_.Set(from._internal_json_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
@ -3495,23 +3491,23 @@ FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from)
inline void FieldDescriptorProto::SharedCtor() { inline void FieldDescriptorProto::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
extendee_.InitDefault(); extendee_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); extendee_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
type_name_.InitDefault(); type_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); type_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
default_value_.InitDefault(); default_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); default_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
json_name_.InitDefault(); json_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); json_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)), reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)),
@ -3532,11 +3528,11 @@ FieldDescriptorProto::~FieldDescriptorProto() {
inline void FieldDescriptorProto::SharedDtor() { inline void FieldDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
extendee_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); extendee_.Destroy();
type_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); type_name_.Destroy();
default_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); default_value_.Destroy();
json_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); json_name_.Destroy();
if (this != internal_default_instance()) delete options_; if (this != internal_default_instance()) delete options_;
} }
@ -4010,27 +4006,22 @@ void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&extendee_, lhs_arena, &extendee_, lhs_arena,
&other->extendee_, rhs_arena &other->extendee_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&type_name_, lhs_arena, &type_name_, lhs_arena,
&other->type_name_, rhs_arena &other->type_name_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&default_value_, lhs_arena, &default_value_, lhs_arena,
&other->default_value_, rhs_arena &other->default_value_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&json_name_, lhs_arena, &json_name_, lhs_arena,
&other->json_name_, rhs_arena &other->json_name_, rhs_arena
); );
@ -4080,10 +4071,10 @@ OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
@ -4097,7 +4088,7 @@ OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from)
inline void OneofDescriptorProto::SharedCtor() { inline void OneofDescriptorProto::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
options_ = nullptr; options_ = nullptr;
} }
@ -4113,7 +4104,7 @@ OneofDescriptorProto::~OneofDescriptorProto() {
inline void OneofDescriptorProto::SharedDtor() { inline void OneofDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
if (this != internal_default_instance()) delete options_; if (this != internal_default_instance()) delete options_;
} }
@ -4304,7 +4295,6 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
@ -4583,10 +4573,10 @@ EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
@ -4600,7 +4590,7 @@ EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from)
inline void EnumDescriptorProto::SharedCtor() { inline void EnumDescriptorProto::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
options_ = nullptr; options_ = nullptr;
} }
@ -4616,7 +4606,7 @@ EnumDescriptorProto::~EnumDescriptorProto() {
inline void EnumDescriptorProto::SharedDtor() { inline void EnumDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
if (this != internal_default_instance()) delete options_; if (this != internal_default_instance()) delete options_;
} }
@ -4909,7 +4899,6 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) {
reserved_range_.InternalSwap(&other->reserved_range_); reserved_range_.InternalSwap(&other->reserved_range_);
reserved_name_.InternalSwap(&other->reserved_name_); reserved_name_.InternalSwap(&other->reserved_name_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
@ -4955,10 +4944,10 @@ EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProt
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
@ -4973,7 +4962,7 @@ EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProt
inline void EnumValueDescriptorProto::SharedCtor() { inline void EnumValueDescriptorProto::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)), reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)),
@ -4992,7 +4981,7 @@ EnumValueDescriptorProto::~EnumValueDescriptorProto() {
inline void EnumValueDescriptorProto::SharedDtor() { inline void EnumValueDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
if (this != internal_default_instance()) delete options_; if (this != internal_default_instance()) delete options_;
} }
@ -5208,7 +5197,6 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
@ -5258,10 +5246,10 @@ ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& fro
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
@ -5275,7 +5263,7 @@ ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& fro
inline void ServiceDescriptorProto::SharedCtor() { inline void ServiceDescriptorProto::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
options_ = nullptr; options_ = nullptr;
} }
@ -5291,7 +5279,7 @@ ServiceDescriptorProto::~ServiceDescriptorProto() {
inline void ServiceDescriptorProto::SharedDtor() { inline void ServiceDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
if (this != internal_default_instance()) delete options_; if (this != internal_default_instance()) delete options_;
} }
@ -5515,7 +5503,6 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) {
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
method_.InternalSwap(&other->method_); method_.InternalSwap(&other->method_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
@ -5570,26 +5557,26 @@ MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) { if (from._internal_has_name()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
input_type_.InitDefault(); input_type_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); input_type_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_input_type()) { if (from._internal_has_input_type()) {
input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_input_type(), input_type_.Set(from._internal_input_type(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
output_type_.InitDefault(); output_type_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); output_type_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_output_type()) { if (from._internal_has_output_type()) {
output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_output_type(), output_type_.Set(from._internal_output_type(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
if (from._internal_has_options()) { if (from._internal_has_options()) {
@ -5606,15 +5593,15 @@ MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from)
inline void MethodDescriptorProto::SharedCtor() { inline void MethodDescriptorProto::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
input_type_.InitDefault(); input_type_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); input_type_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
output_type_.InitDefault(); output_type_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); output_type_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)), reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)),
@ -5633,9 +5620,9 @@ MethodDescriptorProto::~MethodDescriptorProto() {
inline void MethodDescriptorProto::SharedDtor() { inline void MethodDescriptorProto::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
input_type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); input_type_.Destroy();
output_type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); output_type_.Destroy();
if (this != internal_default_instance()) delete options_; if (this != internal_default_instance()) delete options_;
} }
@ -5946,17 +5933,14 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&input_type_, lhs_arena, &input_type_, lhs_arena,
&other->input_type_, rhs_arena &other->input_type_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&output_type_, lhs_arena, &output_type_, lhs_arena,
&other->output_type_, rhs_arena &other->output_type_, rhs_arena
); );
@ -6057,82 +6041,82 @@ FileOptions::FileOptions(const FileOptions& from)
_extensions_.MergeFrom(internal_default_instance(), from._extensions_); _extensions_.MergeFrom(internal_default_instance(), from._extensions_);
java_package_.InitDefault(); java_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); java_package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_java_package()) { if (from._internal_has_java_package()) {
java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_java_package(), java_package_.Set(from._internal_java_package(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
java_outer_classname_.InitDefault(); java_outer_classname_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); java_outer_classname_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_java_outer_classname()) { if (from._internal_has_java_outer_classname()) {
java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_java_outer_classname(), java_outer_classname_.Set(from._internal_java_outer_classname(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
go_package_.InitDefault(); go_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); go_package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_go_package()) { if (from._internal_has_go_package()) {
go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_go_package(), go_package_.Set(from._internal_go_package(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
objc_class_prefix_.InitDefault(); objc_class_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); objc_class_prefix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_objc_class_prefix()) { if (from._internal_has_objc_class_prefix()) {
objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_objc_class_prefix(), objc_class_prefix_.Set(from._internal_objc_class_prefix(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
csharp_namespace_.InitDefault(); csharp_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); csharp_namespace_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_csharp_namespace()) { if (from._internal_has_csharp_namespace()) {
csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_csharp_namespace(), csharp_namespace_.Set(from._internal_csharp_namespace(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
swift_prefix_.InitDefault(); swift_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); swift_prefix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_swift_prefix()) { if (from._internal_has_swift_prefix()) {
swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_swift_prefix(), swift_prefix_.Set(from._internal_swift_prefix(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
php_class_prefix_.InitDefault(); php_class_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); php_class_prefix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_php_class_prefix()) { if (from._internal_has_php_class_prefix()) {
php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_php_class_prefix(), php_class_prefix_.Set(from._internal_php_class_prefix(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
php_namespace_.InitDefault(); php_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); php_namespace_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_php_namespace()) { if (from._internal_has_php_namespace()) {
php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_php_namespace(), php_namespace_.Set(from._internal_php_namespace(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
php_metadata_namespace_.InitDefault(); php_metadata_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); php_metadata_namespace_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_php_metadata_namespace()) { if (from._internal_has_php_metadata_namespace()) {
php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_php_metadata_namespace(), php_metadata_namespace_.Set(from._internal_php_metadata_namespace(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
ruby_package_.InitDefault(); ruby_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); ruby_package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_ruby_package()) { if (from._internal_has_ruby_package()) {
ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_ruby_package(), ruby_package_.Set(from._internal_ruby_package(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
::memcpy(&java_multiple_files_, &from.java_multiple_files_, ::memcpy(&java_multiple_files_, &from.java_multiple_files_,
@ -6144,43 +6128,43 @@ FileOptions::FileOptions(const FileOptions& from)
inline void FileOptions::SharedCtor() { inline void FileOptions::SharedCtor() {
java_package_.InitDefault(); java_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); java_package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
java_outer_classname_.InitDefault(); java_outer_classname_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); java_outer_classname_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
go_package_.InitDefault(); go_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); go_package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
objc_class_prefix_.InitDefault(); objc_class_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); objc_class_prefix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
csharp_namespace_.InitDefault(); csharp_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); csharp_namespace_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
swift_prefix_.InitDefault(); swift_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); swift_prefix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
php_class_prefix_.InitDefault(); php_class_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); php_class_prefix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
php_namespace_.InitDefault(); php_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); php_namespace_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
php_metadata_namespace_.InitDefault(); php_metadata_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); php_metadata_namespace_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
ruby_package_.InitDefault(); ruby_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); ruby_package_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&java_multiple_files_) - reinterpret_cast<char*>(this)), reinterpret_cast<char*>(&java_multiple_files_) - reinterpret_cast<char*>(this)),
@ -6201,16 +6185,16 @@ FileOptions::~FileOptions() {
inline void FileOptions::SharedDtor() { inline void FileOptions::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
java_package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); java_package_.Destroy();
java_outer_classname_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); java_outer_classname_.Destroy();
go_package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); go_package_.Destroy();
objc_class_prefix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); objc_class_prefix_.Destroy();
csharp_namespace_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.Destroy();
swift_prefix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); swift_prefix_.Destroy();
php_class_prefix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); php_class_prefix_.Destroy();
php_namespace_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); php_namespace_.Destroy();
php_metadata_namespace_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); php_metadata_namespace_.Destroy();
ruby_package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); ruby_package_.Destroy();
} }
void FileOptions::SetCachedSize(int size) const { void FileOptions::SetCachedSize(int size) const {
@ -6994,52 +6978,42 @@ void FileOptions::InternalSwap(FileOptions* other) {
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&java_package_, lhs_arena, &java_package_, lhs_arena,
&other->java_package_, rhs_arena &other->java_package_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&java_outer_classname_, lhs_arena, &java_outer_classname_, lhs_arena,
&other->java_outer_classname_, rhs_arena &other->java_outer_classname_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&go_package_, lhs_arena, &go_package_, lhs_arena,
&other->go_package_, rhs_arena &other->go_package_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&objc_class_prefix_, lhs_arena, &objc_class_prefix_, lhs_arena,
&other->objc_class_prefix_, rhs_arena &other->objc_class_prefix_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&csharp_namespace_, lhs_arena, &csharp_namespace_, lhs_arena,
&other->csharp_namespace_, rhs_arena &other->csharp_namespace_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&swift_prefix_, lhs_arena, &swift_prefix_, lhs_arena,
&other->swift_prefix_, rhs_arena &other->swift_prefix_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&php_class_prefix_, lhs_arena, &php_class_prefix_, lhs_arena,
&other->php_class_prefix_, rhs_arena &other->php_class_prefix_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&php_namespace_, lhs_arena, &php_namespace_, lhs_arena,
&other->php_namespace_, rhs_arena &other->php_namespace_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&php_metadata_namespace_, lhs_arena, &php_metadata_namespace_, lhs_arena,
&other->php_metadata_namespace_, rhs_arena &other->php_metadata_namespace_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&ruby_package_, lhs_arena, &ruby_package_, lhs_arena,
&other->ruby_package_, rhs_arena &other->ruby_package_, rhs_arena
); );
@ -9097,10 +9071,10 @@ UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOp
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_part_.InitDefault(); name_part_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_part_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name_part()) { if (from._internal_has_name_part()) {
name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name_part(), name_part_.Set(from._internal_name_part(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
is_extension_ = from.is_extension_; is_extension_ = from.is_extension_;
@ -9110,7 +9084,7 @@ UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOp
inline void UninterpretedOption_NamePart::SharedCtor() { inline void UninterpretedOption_NamePart::SharedCtor() {
name_part_.InitDefault(); name_part_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_part_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
is_extension_ = false; is_extension_ = false;
} }
@ -9126,7 +9100,7 @@ UninterpretedOption_NamePart::~UninterpretedOption_NamePart() {
inline void UninterpretedOption_NamePart::SharedDtor() { inline void UninterpretedOption_NamePart::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_part_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_part_.Destroy();
} }
void UninterpretedOption_NamePart::SetCachedSize(int size) const { void UninterpretedOption_NamePart::SetCachedSize(int size) const {
@ -9323,7 +9297,6 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_part_, lhs_arena, &name_part_, lhs_arena,
&other->name_part_, rhs_arena &other->name_part_, rhs_arena
); );
@ -9375,26 +9348,26 @@ UninterpretedOption::UninterpretedOption(const UninterpretedOption& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
identifier_value_.InitDefault(); identifier_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); identifier_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_identifier_value()) { if (from._internal_has_identifier_value()) {
identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_identifier_value(), identifier_value_.Set(from._internal_identifier_value(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
string_value_.InitDefault(); string_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); string_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_string_value()) { if (from._internal_has_string_value()) {
string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_string_value(), string_value_.Set(from._internal_string_value(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
aggregate_value_.InitDefault(); aggregate_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); aggregate_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_aggregate_value()) { if (from._internal_has_aggregate_value()) {
aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_aggregate_value(), aggregate_value_.Set(from._internal_aggregate_value(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
::memcpy(&positive_int_value_, &from.positive_int_value_, ::memcpy(&positive_int_value_, &from.positive_int_value_,
@ -9406,15 +9379,15 @@ UninterpretedOption::UninterpretedOption(const UninterpretedOption& from)
inline void UninterpretedOption::SharedCtor() { inline void UninterpretedOption::SharedCtor() {
identifier_value_.InitDefault(); identifier_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); identifier_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
string_value_.InitDefault(); string_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); string_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
aggregate_value_.InitDefault(); aggregate_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); aggregate_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&positive_int_value_) - reinterpret_cast<char*>(this)), reinterpret_cast<char*>(&positive_int_value_) - reinterpret_cast<char*>(this)),
@ -9433,9 +9406,9 @@ UninterpretedOption::~UninterpretedOption() {
inline void UninterpretedOption::SharedDtor() { inline void UninterpretedOption::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
identifier_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); identifier_value_.Destroy();
string_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); string_value_.Destroy();
aggregate_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); aggregate_value_.Destroy();
} }
void UninterpretedOption::SetCachedSize(int size) const { void UninterpretedOption::SetCachedSize(int size) const {
@ -9764,17 +9737,14 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) {
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
name_.InternalSwap(&other->name_); name_.InternalSwap(&other->name_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&identifier_value_, lhs_arena, &identifier_value_, lhs_arena,
&other->identifier_value_, rhs_arena &other->identifier_value_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&string_value_, lhs_arena, &string_value_, lhs_arena,
&other->string_value_, rhs_arena &other->string_value_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&aggregate_value_, lhs_arena, &aggregate_value_, lhs_arena,
&other->aggregate_value_, rhs_arena &other->aggregate_value_, rhs_arena
); );
@ -9823,18 +9793,18 @@ SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location&
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
leading_comments_.InitDefault(); leading_comments_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); leading_comments_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_leading_comments()) { if (from._internal_has_leading_comments()) {
leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_leading_comments(), leading_comments_.Set(from._internal_leading_comments(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
trailing_comments_.InitDefault(); trailing_comments_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); trailing_comments_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_trailing_comments()) { if (from._internal_has_trailing_comments()) {
trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_trailing_comments(), trailing_comments_.Set(from._internal_trailing_comments(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
// @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location) // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location)
@ -9843,11 +9813,11 @@ SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location&
inline void SourceCodeInfo_Location::SharedCtor() { inline void SourceCodeInfo_Location::SharedCtor() {
leading_comments_.InitDefault(); leading_comments_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); leading_comments_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
trailing_comments_.InitDefault(); trailing_comments_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); trailing_comments_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
} }
@ -9862,8 +9832,8 @@ SourceCodeInfo_Location::~SourceCodeInfo_Location() {
inline void SourceCodeInfo_Location::SharedDtor() { inline void SourceCodeInfo_Location::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
leading_comments_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); leading_comments_.Destroy();
trailing_comments_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); trailing_comments_.Destroy();
} }
void SourceCodeInfo_Location::SetCachedSize(int size) const { void SourceCodeInfo_Location::SetCachedSize(int size) const {
@ -10168,12 +10138,10 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) {
span_.InternalSwap(&other->span_); span_.InternalSwap(&other->span_);
leading_detached_comments_.InternalSwap(&other->leading_detached_comments_); leading_detached_comments_.InternalSwap(&other->leading_detached_comments_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&leading_comments_, lhs_arena, &leading_comments_, lhs_arena,
&other->leading_comments_, rhs_arena &other->leading_comments_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&trailing_comments_, lhs_arena, &trailing_comments_, lhs_arena,
&other->trailing_comments_, rhs_arena &other->trailing_comments_, rhs_arena
); );
@ -10393,10 +10361,10 @@ GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeIn
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
source_file_.InitDefault(); source_file_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); source_file_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_source_file()) { if (from._internal_has_source_file()) {
source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_source_file(), source_file_.Set(from._internal_source_file(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
::memcpy(&begin_, &from.begin_, ::memcpy(&begin_, &from.begin_,
@ -10408,7 +10376,7 @@ GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeIn
inline void GeneratedCodeInfo_Annotation::SharedCtor() { inline void GeneratedCodeInfo_Annotation::SharedCtor() {
source_file_.InitDefault(); source_file_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); source_file_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&begin_) - reinterpret_cast<char*>(this)), reinterpret_cast<char*>(&begin_) - reinterpret_cast<char*>(this)),
@ -10427,7 +10395,7 @@ GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() {
inline void GeneratedCodeInfo_Annotation::SharedDtor() { inline void GeneratedCodeInfo_Annotation::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
source_file_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); source_file_.Destroy();
} }
void GeneratedCodeInfo_Annotation::SetCachedSize(int size) const { void GeneratedCodeInfo_Annotation::SetCachedSize(int size) const {
@ -10672,7 +10640,6 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot
swap(_has_bits_[0], other->_has_bits_[0]); swap(_has_bits_[0], other->_has_bits_[0]);
path_.InternalSwap(&other->path_); path_.InternalSwap(&other->path_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&source_file_, lhs_arena, &source_file_, lhs_arena,
&other->source_file_, rhs_arena &other->source_file_, rhs_arena
); );

File diff suppressed because it is too large Load Diff

@ -66,6 +66,8 @@
// Must be included last. // Must be included last.
#include <google/protobuf/port_def.inc> #include <google/protobuf/port_def.inc>
using ::testing::AnyOf;
namespace google { namespace google {
namespace protobuf { namespace protobuf {
@ -1307,7 +1309,8 @@ TEST_F(StylizedFieldNamesTest, CamelcaseName) {
TEST_F(StylizedFieldNamesTest, FindByLowercaseName) { TEST_F(StylizedFieldNamesTest, FindByLowercaseName) {
EXPECT_EQ(message_->field(0), message_->FindFieldByLowercaseName("foo_foo")); EXPECT_EQ(message_->field(0), message_->FindFieldByLowercaseName("foo_foo"));
EXPECT_EQ(message_->field(1), message_->FindFieldByLowercaseName("foobar")); EXPECT_THAT(message_->FindFieldByLowercaseName("foobar"),
AnyOf(message_->field(1), message_->field(4)));
EXPECT_EQ(message_->field(2), message_->FindFieldByLowercaseName("foobaz")); EXPECT_EQ(message_->field(2), message_->FindFieldByLowercaseName("foobaz"));
EXPECT_TRUE(message_->FindFieldByLowercaseName("FooBar") == nullptr); EXPECT_TRUE(message_->FindFieldByLowercaseName("FooBar") == nullptr);
EXPECT_TRUE(message_->FindFieldByLowercaseName("fooBaz") == nullptr); EXPECT_TRUE(message_->FindFieldByLowercaseName("fooBaz") == nullptr);
@ -1316,8 +1319,8 @@ TEST_F(StylizedFieldNamesTest, FindByLowercaseName) {
EXPECT_EQ(message_->extension(0), EXPECT_EQ(message_->extension(0),
message_->FindExtensionByLowercaseName("bar_foo")); message_->FindExtensionByLowercaseName("bar_foo"));
EXPECT_EQ(message_->extension(1), EXPECT_THAT(message_->FindExtensionByLowercaseName("barbar"),
message_->FindExtensionByLowercaseName("barbar")); AnyOf(message_->extension(1), message_->extension(4)));
EXPECT_EQ(message_->extension(2), EXPECT_EQ(message_->extension(2),
message_->FindExtensionByLowercaseName("barbaz")); message_->FindExtensionByLowercaseName("barbaz"));
EXPECT_TRUE(message_->FindExtensionByLowercaseName("BarBar") == nullptr); EXPECT_TRUE(message_->FindExtensionByLowercaseName("BarBar") == nullptr);
@ -1327,7 +1330,8 @@ TEST_F(StylizedFieldNamesTest, FindByLowercaseName) {
EXPECT_EQ(file_->extension(0), EXPECT_EQ(file_->extension(0),
file_->FindExtensionByLowercaseName("baz_foo")); file_->FindExtensionByLowercaseName("baz_foo"));
EXPECT_EQ(file_->extension(1), file_->FindExtensionByLowercaseName("bazbar")); EXPECT_THAT(file_->FindExtensionByLowercaseName("bazbar"),
AnyOf(file_->extension(1), file_->extension(4)));
EXPECT_EQ(file_->extension(2), file_->FindExtensionByLowercaseName("bazbaz")); EXPECT_EQ(file_->extension(2), file_->FindExtensionByLowercaseName("bazbaz"));
EXPECT_TRUE(file_->FindExtensionByLowercaseName("BazBar") == nullptr); EXPECT_TRUE(file_->FindExtensionByLowercaseName("BazBar") == nullptr);
EXPECT_TRUE(file_->FindExtensionByLowercaseName("bazBaz") == nullptr); EXPECT_TRUE(file_->FindExtensionByLowercaseName("bazBaz") == nullptr);
@ -1335,7 +1339,8 @@ TEST_F(StylizedFieldNamesTest, FindByLowercaseName) {
} }
TEST_F(StylizedFieldNamesTest, FindByCamelcaseName) { TEST_F(StylizedFieldNamesTest, FindByCamelcaseName) {
EXPECT_EQ(message_->field(0), message_->FindFieldByCamelcaseName("fooFoo")); EXPECT_THAT(message_->FindFieldByCamelcaseName("fooFoo"),
AnyOf(message_->field(0), message_->field(3)));
EXPECT_EQ(message_->field(1), message_->FindFieldByCamelcaseName("fooBar")); EXPECT_EQ(message_->field(1), message_->FindFieldByCamelcaseName("fooBar"));
EXPECT_EQ(message_->field(2), message_->FindFieldByCamelcaseName("fooBaz")); EXPECT_EQ(message_->field(2), message_->FindFieldByCamelcaseName("fooBaz"));
EXPECT_TRUE(message_->FindFieldByCamelcaseName("foo_foo") == nullptr); EXPECT_TRUE(message_->FindFieldByCamelcaseName("foo_foo") == nullptr);
@ -1343,8 +1348,8 @@ TEST_F(StylizedFieldNamesTest, FindByCamelcaseName) {
EXPECT_TRUE(message_->FindFieldByCamelcaseName("barFoo") == nullptr); EXPECT_TRUE(message_->FindFieldByCamelcaseName("barFoo") == nullptr);
EXPECT_TRUE(message_->FindFieldByCamelcaseName("nosuchfield") == nullptr); EXPECT_TRUE(message_->FindFieldByCamelcaseName("nosuchfield") == nullptr);
EXPECT_EQ(message_->extension(0), EXPECT_THAT(message_->FindExtensionByCamelcaseName("barFoo"),
message_->FindExtensionByCamelcaseName("barFoo")); AnyOf(message_->extension(0), message_->extension(3)));
EXPECT_EQ(message_->extension(1), EXPECT_EQ(message_->extension(1),
message_->FindExtensionByCamelcaseName("barBar")); message_->FindExtensionByCamelcaseName("barBar"));
EXPECT_EQ(message_->extension(2), EXPECT_EQ(message_->extension(2),
@ -1354,7 +1359,8 @@ TEST_F(StylizedFieldNamesTest, FindByCamelcaseName) {
EXPECT_TRUE(message_->FindExtensionByCamelcaseName("fooFoo") == nullptr); EXPECT_TRUE(message_->FindExtensionByCamelcaseName("fooFoo") == nullptr);
EXPECT_TRUE(message_->FindExtensionByCamelcaseName("nosuchfield") == nullptr); EXPECT_TRUE(message_->FindExtensionByCamelcaseName("nosuchfield") == nullptr);
EXPECT_EQ(file_->extension(0), file_->FindExtensionByCamelcaseName("bazFoo")); EXPECT_THAT(file_->FindExtensionByCamelcaseName("bazFoo"),
AnyOf(file_->extension(0), file_->extension(3)));
EXPECT_EQ(file_->extension(1), file_->FindExtensionByCamelcaseName("bazBar")); EXPECT_EQ(file_->extension(1), file_->FindExtensionByCamelcaseName("bazBar"));
EXPECT_EQ(file_->extension(2), file_->FindExtensionByCamelcaseName("bazBaz")); EXPECT_EQ(file_->extension(2), file_->FindExtensionByCamelcaseName("bazBaz"));
EXPECT_TRUE(file_->FindExtensionByCamelcaseName("baz_foo") == nullptr); EXPECT_TRUE(file_->FindExtensionByCamelcaseName("baz_foo") == nullptr);

@ -417,11 +417,7 @@ void DynamicMessage::SharedCtor(bool lock_factory) {
case FieldOptions::STRING: case FieldOptions::STRING:
if (!field->is_repeated()) { if (!field->is_repeated()) {
ArenaStringPtr* asp = new (field_ptr) ArenaStringPtr(); ArenaStringPtr* asp = new (field_ptr) ArenaStringPtr();
if (field->default_value_string().empty()) { asp->InitDefault();
asp->InitDefault();
} else {
asp->InitDefault(nullptr);
}
} else { } else {
new (field_ptr) new (field_ptr)
RepeatedPtrField<std::string>(GetArenaForAllocation()); RepeatedPtrField<std::string>(GetArenaForAllocation());
@ -522,13 +518,7 @@ DynamicMessage::~DynamicMessage() {
switch (field->options().ctype()) { switch (field->options().ctype()) {
default: default:
case FieldOptions::STRING: { case FieldOptions::STRING: {
// Oneof string fields are never set as a default instance. reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy();
// We just need to pass some arbitrary default string to make it
// work. This allows us to not have the real default accessible
// from reflection.
const std::string* default_value = nullptr;
reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(
default_value, nullptr);
break; break;
} }
} }
@ -582,13 +572,7 @@ DynamicMessage::~DynamicMessage() {
switch (field->options().ctype()) { switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps. default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: { case FieldOptions::STRING: {
const std::string* default_value = reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy();
reinterpret_cast<const ArenaStringPtr*>(
type_info_->prototype->OffsetToPointer(
type_info_->offsets[i]))
->GetPointer();
reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(default_value,
nullptr);
break; break;
} }
} }

@ -280,10 +280,9 @@ size_t Reflection::SpaceUsedLong(const Message& message) const {
total_size += GetUnknownFields(message).SpaceUsedExcludingSelfLong(); total_size += GetUnknownFields(message).SpaceUsedExcludingSelfLong();
// If this message owns an arena, add any unused space that's been allocated. // If this message owns an arena, add any unused space that's been allocated.
auto* arena = Arena::InternalHelper<Message>::GetArenaForAllocation(&message); auto* arena = Arena::InternalGetArenaForAllocation(&message);
if (arena != nullptr && if (arena != nullptr && Arena::InternalGetOwningArena(&message) == nullptr &&
Arena::InternalHelper<Message>::GetOwningArena(&message) == nullptr && arena->InternalIsMessageOwnedArena()) {
Arena::InternalHelper<Message>::IsMessageOwnedArena(arena)) {
total_size += arena->SpaceAllocated() - arena->SpaceUsed(); total_size += arena->SpaceAllocated() - arena->SpaceUsed();
} }
@ -354,31 +353,26 @@ size_t Reflection::SpaceUsedLong(const Message& message) const {
case FieldDescriptor::CPPTYPE_STRING: { case FieldDescriptor::CPPTYPE_STRING: {
switch (field->options().ctype()) { switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps. default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: { case FieldOptions::STRING:
if (IsInlined(field)) { if (IsInlined(field)) {
const std::string* ptr = const std::string* ptr =
&GetField<InlinedStringField>(message, field).GetNoArena(); &GetField<InlinedStringField>(message, field).GetNoArena();
total_size += StringSpaceUsedExcludingSelfLong(*ptr); total_size += StringSpaceUsedExcludingSelfLong(*ptr);
break; } else {
} // Initially, the string points to the default value stored
// in the prototype. Only count the string if it has been
const std::string* ptr = // changed from the default value.
GetField<ArenaStringPtr>(message, field).GetPointer(); // Except oneof fields, those never point to a default instance,
// and there is no default instance to point to.
// Initially, the string points to the default value stored const auto& str = GetField<ArenaStringPtr>(message, field);
// in the prototype. Only count the string if it has been if (!str.IsDefault() || schema_.InRealOneof(field)) {
// changed from the default value. // string fields are represented by just a pointer, so also
// Except oneof fields, those never point to a default instance, // include sizeof(string) as well.
// and there is no default instance to point to. total_size += sizeof(std::string) +
if (schema_.InRealOneof(field) || StringSpaceUsedExcludingSelfLong(str.Get());
ptr != DefaultRaw<ArenaStringPtr>(field).GetPointer()) { }
// string fields are represented by just a pointer, so also
// include sizeof(string) as well.
total_size +=
sizeof(*ptr) + StringSpaceUsedExcludingSelfLong(*ptr);
} }
break; break;
}
} }
break; break;
} }
@ -486,8 +480,7 @@ class SwapFieldHelper {
static void SwapStringField(const Reflection* r, Message* lhs, Message* rhs, static void SwapStringField(const Reflection* r, Message* lhs, Message* rhs,
const FieldDescriptor* field); const FieldDescriptor* field);
static void SwapArenaStringPtr(const std::string* default_ptr, static void SwapArenaStringPtr(ArenaStringPtr* lhs, Arena* lhs_arena,
ArenaStringPtr* lhs, Arena* lhs_arena,
ArenaStringPtr* rhs, Arena* rhs_arena); ArenaStringPtr* rhs, Arena* rhs_arena);
template <bool unsafe_shallow_swap> template <bool unsafe_shallow_swap>
@ -551,12 +544,11 @@ void SwapFieldHelper::SwapInlinedStrings(const Reflection* r, Message* lhs,
rhs_arena, rhs_arena_dtor_registered, rhs); rhs_arena, rhs_arena_dtor_registered, rhs);
} else { } else {
const std::string temp = lhs_string->Get(); const std::string temp = lhs_string->Get();
lhs_string->Set(nullptr, rhs_string->Get(), lhs_arena, lhs_string->Set(rhs_string->Get(), lhs_arena,
r->IsInlinedStringDonated(*lhs, field), lhs_state, mask, r->IsInlinedStringDonated(*lhs, field), lhs_state, mask,
lhs); lhs);
rhs_string->Set(nullptr, temp, rhs_arena, rhs_string->Set(temp, rhs_arena, r->IsInlinedStringDonated(*rhs, field),
r->IsInlinedStringDonated(*rhs, field), rhs_state, mask, rhs_state, mask, rhs);
rhs);
} }
} }
@ -570,8 +562,7 @@ void SwapFieldHelper::SwapNonInlinedStrings(const Reflection* r, Message* lhs,
ArenaStringPtr::UnsafeShallowSwap(lhs_string, rhs_string); ArenaStringPtr::UnsafeShallowSwap(lhs_string, rhs_string);
} else { } else {
SwapFieldHelper::SwapArenaStringPtr( SwapFieldHelper::SwapArenaStringPtr(
r->DefaultRaw<ArenaStringPtr>(field).GetPointer(), // lhs_string, lhs->GetArenaForAllocation(), //
lhs_string, lhs->GetArenaForAllocation(), //
rhs_string, rhs->GetArenaForAllocation()); rhs_string, rhs->GetArenaForAllocation());
} }
} }
@ -595,28 +586,27 @@ void SwapFieldHelper::SwapStringField(const Reflection* r, Message* lhs,
} }
} }
void SwapFieldHelper::SwapArenaStringPtr(const std::string* default_ptr, void SwapFieldHelper::SwapArenaStringPtr(ArenaStringPtr* lhs, Arena* lhs_arena,
ArenaStringPtr* lhs, Arena* lhs_arena,
ArenaStringPtr* rhs, ArenaStringPtr* rhs,
Arena* rhs_arena) { Arena* rhs_arena) {
if (lhs_arena == rhs_arena) { if (lhs_arena == rhs_arena) {
ArenaStringPtr::InternalSwap(default_ptr, lhs, lhs_arena, rhs, rhs_arena); ArenaStringPtr::InternalSwap(lhs, lhs_arena, rhs, rhs_arena);
} else if (lhs->IsDefault() && rhs->IsDefault()) { } else if (lhs->IsDefault() && rhs->IsDefault()) {
// Nothing to do. // Nothing to do.
} else if (lhs->IsDefault()) { } else if (lhs->IsDefault()) {
lhs->Set(default_ptr, rhs->Get(), lhs_arena); lhs->Set(rhs->Get(), lhs_arena);
// rhs needs to be destroyed before overwritten. // rhs needs to be destroyed before overwritten.
rhs->Destroy(default_ptr, rhs_arena); rhs->Destroy();
rhs->InitDefault(default_ptr); rhs->InitDefault();
} else if (rhs->IsDefault()) { } else if (rhs->IsDefault()) {
rhs->Set(default_ptr, lhs->Get(), rhs_arena); rhs->Set(lhs->Get(), rhs_arena);
// lhs needs to be destroyed before overwritten. // lhs needs to be destroyed before overwritten.
lhs->Destroy(default_ptr, lhs_arena); lhs->Destroy();
lhs->InitDefault(default_ptr); lhs->InitDefault();
} else { } else {
std::string temp = lhs->Get(); std::string temp = lhs->Get();
lhs->Set(default_ptr, rhs->Get(), lhs_arena); lhs->Set(rhs->Get(), lhs_arena);
rhs->Set(default_ptr, std::move(temp), rhs_arena); rhs->Set(std::move(temp), rhs_arena);
} }
} }
@ -1266,20 +1256,17 @@ void Reflection::ClearField(Message* message,
case FieldDescriptor::CPPTYPE_STRING: { case FieldDescriptor::CPPTYPE_STRING: {
switch (field->options().ctype()) { switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps. default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: { case FieldOptions::STRING:
if (IsInlined(field)) { if (IsInlined(field)) {
// Currently, string with default value can't be inlined. So we // Currently, string with default value can't be inlined. So we
// don't have to handle default value here. // don't have to handle default value here.
MutableRaw<InlinedStringField>(message, field)->ClearToEmpty(); MutableRaw<InlinedStringField>(message, field)->ClearToEmpty();
break; } else {
auto* str = MutableRaw<ArenaStringPtr>(message, field);
str->Destroy();
str->InitDefault();
} }
const std::string* default_ptr =
DefaultRaw<ArenaStringPtr>(field).GetPointer();
MutableRaw<ArenaStringPtr>(message, field)
->SetAllocated(default_ptr, nullptr,
message->GetArenaForAllocation());
break; break;
}
} }
break; break;
} }
@ -1658,17 +1645,13 @@ std::string Reflection::GetString(const Message& message,
} }
switch (field->options().ctype()) { switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps. default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: { case FieldOptions::STRING:
if (IsInlined(field)) { if (IsInlined(field)) {
return GetField<InlinedStringField>(message, field).GetNoArena(); return GetField<InlinedStringField>(message, field).GetNoArena();
} else {
const auto& str = GetField<ArenaStringPtr>(message, field);
return str.IsDefault() ? field->default_value_string() : str.Get();
} }
if (auto* value =
GetField<ArenaStringPtr>(message, field).GetPointer()) {
return *value;
}
return field->default_value_string();
}
} }
} }
} }
@ -1687,17 +1670,13 @@ const std::string& Reflection::GetStringReference(const Message& message,
} }
switch (field->options().ctype()) { switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps. default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: { case FieldOptions::STRING:
if (IsInlined(field)) { if (IsInlined(field)) {
return GetField<InlinedStringField>(message, field).GetNoArena(); return GetField<InlinedStringField>(message, field).GetNoArena();
} else {
const auto& str = GetField<ArenaStringPtr>(message, field);
return str.IsDefault() ? field->default_value_string() : str.Get();
} }
if (auto* value =
GetField<ArenaStringPtr>(message, field).GetPointer()) {
return *value;
}
return field->default_value_string();
}
} }
} }
} }
@ -1720,7 +1699,7 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
&MutableInlinedStringDonatedArray(message)[index / 32]; &MutableInlinedStringDonatedArray(message)[index / 32];
uint32_t mask = ~(static_cast<uint32_t>(1) << (index % 32)); uint32_t mask = ~(static_cast<uint32_t>(1) << (index % 32));
MutableField<InlinedStringField>(message, field) MutableField<InlinedStringField>(message, field)
->Set(nullptr, value, message->GetArenaForAllocation(), ->Set(value, message->GetArenaForAllocation(),
IsInlinedStringDonated(*message, field), states, mask, IsInlinedStringDonated(*message, field), states, mask,
message); message);
break; break;
@ -1730,18 +1709,12 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
// We just need to pass some arbitrary default string to make it work. // We just need to pass some arbitrary default string to make it work.
// This allows us to not have the real default accessible from // This allows us to not have the real default accessible from
// reflection. // reflection.
const std::string* default_ptr =
schema_.InRealOneof(field)
? nullptr
: DefaultRaw<ArenaStringPtr>(field).GetPointer();
if (schema_.InRealOneof(field) && !HasOneofField(*message, field)) { if (schema_.InRealOneof(field) && !HasOneofField(*message, field)) {
ClearOneof(message, field->containing_oneof()); ClearOneof(message, field->containing_oneof());
MutableField<ArenaStringPtr>(message, field) MutableField<ArenaStringPtr>(message, field)->InitDefault();
->InitDefault(default_ptr);
} }
MutableField<ArenaStringPtr>(message, field) MutableField<ArenaStringPtr>(message, field)
->Set(default_ptr, std::move(value), ->Set(std::move(value), message->GetArenaForAllocation());
message->GetArenaForAllocation());
break; break;
} }
} }
@ -2721,8 +2694,7 @@ void Reflection::ClearOneof(Message* message,
// We just need to pass some arbitrary default string to make it // We just need to pass some arbitrary default string to make it
// work. This allows us to not have the real default accessible // work. This allows us to not have the real default accessible
// from reflection. // from reflection.
MutableField<ArenaStringPtr>(message, field) MutableField<ArenaStringPtr>(message, field)->Destroy();
->Destroy(nullptr, message->GetArenaForAllocation());
break; break;
} }
} }

@ -265,45 +265,9 @@ class PROTOBUF_EXPORT TcParser final {
static const char* GenericFallback(PROTOBUF_TC_PARAM_DECL); static const char* GenericFallback(PROTOBUF_TC_PARAM_DECL);
static const char* GenericFallbackLite(PROTOBUF_TC_PARAM_DECL); static const char* GenericFallbackLite(PROTOBUF_TC_PARAM_DECL);
// Dispatch to the designated parse function static const char* ParseLoop(MessageLite* msg, const char* ptr,
inline PROTOBUF_ALWAYS_INLINE static const char* TagDispatch( ParseContext* ctx,
PROTOBUF_TC_PARAM_DECL) { const TcParseTableBase* table);
const auto coded_tag = UnalignedLoad<uint16_t>(ptr);
const size_t idx = coded_tag & table->fast_idx_mask;
PROTOBUF_ASSUME((idx & 7) == 0);
auto* fast_entry = table->fast_entry(idx >> 3);
data = fast_entry->bits;
data.data ^= coded_tag;
PROTOBUF_MUSTTAIL return fast_entry->target(PROTOBUF_TC_PARAM_PASS);
}
// We can only safely call from field to next field if the call is optimized
// to a proper tail call. Otherwise we blow through stack. Clang and gcc
// reliably do this optimization in opt mode, but do not perform this in debug
// mode. Luckily the structure of the algorithm is such that it's always
// possible to just return and use the enclosing parse loop as a trampoline.
static const char* ToTagDispatch(PROTOBUF_TC_PARAM_DECL) {
constexpr bool always_return = !PROTOBUF_TAILCALL;
if (always_return || !ctx->DataAvailable(ptr)) {
PROTOBUF_MUSTTAIL return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
}
PROTOBUF_MUSTTAIL return TagDispatch(PROTOBUF_TC_PARAM_PASS);
}
PROTOBUF_NOINLINE static const char* ParseLoop(
MessageLite* msg, const char* ptr, ParseContext* ctx,
const TcParseTableBase* table) {
ScopedArenaSwap saved(msg, ctx);
const uint32_t has_bits_offset = table->has_bits_offset;
while (!ctx->Done(&ptr)) {
uint64_t hasbits = 0;
if (has_bits_offset) hasbits = RefAt<uint32_t>(msg, has_bits_offset);
ptr = TagDispatch(msg, ptr, ctx, table, hasbits, {});
if (ptr == nullptr) break;
if (ctx->LastTag() != 1) break; // Ended on terminating tag
}
return ptr;
}
// Functions referenced by generated fast tables (numeric types): // Functions referenced by generated fast tables (numeric types):
// F: fixed V: varint Z: zigzag // F: fixed V: varint Z: zigzag
@ -424,16 +388,6 @@ class PROTOBUF_EXPORT TcParser final {
return *target; return *target;
} }
static inline PROTOBUF_ALWAYS_INLINE void SyncHasbits(
MessageLite* msg, uint64_t hasbits, const TcParseTableBase* table) {
const uint32_t has_bits_offset = table->has_bits_offset;
if (has_bits_offset) {
// Only the first 32 has-bits are updated. Nothing above those is stored,
// but e.g. messages without has-bits update the upper bits.
RefAt<uint32_t>(msg, has_bits_offset) = static_cast<uint32_t>(hasbits);
}
}
// Mini parsing: // Mini parsing:
// //
// This function parses a field from incoming data based on metadata stored in // This function parses a field from incoming data based on metadata stored in
@ -453,38 +407,24 @@ class PROTOBUF_EXPORT TcParser final {
template <typename TagType> template <typename TagType>
static inline const char* RepeatedParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL); static inline const char* RepeatedParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL);
static inline PROTOBUF_ALWAYS_INLINE const char* ToParseLoop( static inline PROTOBUF_ALWAYS_INLINE void SyncHasbits(
PROTOBUF_TC_PARAM_DECL) { MessageLite* msg, uint64_t hasbits, const TcParseTableBase* table) {
(void)data; const uint32_t has_bits_offset = table->has_bits_offset;
(void)ctx; if (has_bits_offset) {
SyncHasbits(msg, hasbits, table); // Only the first 32 has-bits are updated. Nothing above those is stored,
return ptr; // but e.g. messages without has-bits update the upper bits.
RefAt<uint32_t>(msg, has_bits_offset) = static_cast<uint32_t>(hasbits);
}
} }
static inline PROTOBUF_ALWAYS_INLINE const char* Error( static const char* TagDispatch(PROTOBUF_TC_PARAM_DECL);
PROTOBUF_TC_PARAM_DECL) { static const char* ToTagDispatch(PROTOBUF_TC_PARAM_DECL);
(void)data; static const char* ToParseLoop(PROTOBUF_TC_PARAM_DECL);
(void)ctx; static const char* Error(PROTOBUF_TC_PARAM_DECL);
(void)ptr;
SyncHasbits(msg, hasbits, table);
return nullptr;
}
static const char* FastUnknownEnumFallback(PROTOBUF_TC_PARAM_DECL); static const char* FastUnknownEnumFallback(PROTOBUF_TC_PARAM_DECL);
class ScopedArenaSwap final { class ScopedArenaSwap;
public:
ScopedArenaSwap(MessageLite* msg, ParseContext* ctx)
: ctx_(ctx), saved_(ctx->data().arena) {
ctx_->data().arena = msg->GetArenaForAllocation();
}
ScopedArenaSwap(const ScopedArenaSwap&) = delete;
~ScopedArenaSwap() { ctx_->data().arena = saved_; }
private:
ParseContext* const ctx_;
Arena* const saved_;
};
template <class MessageBaseT, class UnknownFieldsT> template <class MessageBaseT, class UnknownFieldsT>
static const char* GenericFallbackImpl(PROTOBUF_TC_PARAM_DECL) { static const char* GenericFallbackImpl(PROTOBUF_TC_PARAM_DECL) {
@ -555,6 +495,14 @@ class PROTOBUF_EXPORT TcParser final {
uint32_t field_num, ParseContext* ctx, uint32_t field_num, ParseContext* ctx,
MessageLite* msg); MessageLite* msg);
// UTF-8 validation:
static void ReportFastUtf8Error(uint16_t coded_tag,
const TcParseTableBase* table);
static bool MpVerifyUtf8(StringPiece wire_bytes,
const TcParseTableBase* table,
const TcParseTableBase::FieldEntry& entry,
uint16_t xform_val);
// For FindFieldEntry tests: // For FindFieldEntry tests:
friend class FindFieldEntryTest; friend class FindFieldEntryTest;
static constexpr const uint32_t kMtSmallScanSize = 4; static constexpr const uint32_t kMtSmallScanSize = 4;

@ -46,8 +46,14 @@ namespace google {
namespace protobuf { namespace protobuf {
namespace internal { namespace internal {
const uint32_t TcParser::kMtSmallScanSize;
using FieldEntry = TcParseTableBase::FieldEntry; using FieldEntry = TcParseTableBase::FieldEntry;
//////////////////////////////////////////////////////////////////////////////
// Template instantiations:
//////////////////////////////////////////////////////////////////////////////
#ifndef NDEBUG #ifndef NDEBUG
template void AlignFail<4>(uintptr_t); template void AlignFail<4>(uintptr_t);
template void AlignFail<8>(uintptr_t); template void AlignFail<8>(uintptr_t);
@ -57,6 +63,86 @@ const char* TcParser::GenericFallbackLite(PROTOBUF_TC_PARAM_DECL) {
return GenericFallbackImpl<MessageLite, std::string>(PROTOBUF_TC_PARAM_PASS); return GenericFallbackImpl<MessageLite, std::string>(PROTOBUF_TC_PARAM_PASS);
} }
//////////////////////////////////////////////////////////////////////////////
// Core fast parsing implementation:
//////////////////////////////////////////////////////////////////////////////
class TcParser::ScopedArenaSwap final {
public:
ScopedArenaSwap(MessageLite* msg, ParseContext* ctx)
: ctx_(ctx), saved_(ctx->data().arena) {
ctx_->data().arena = msg->GetArenaForAllocation();
}
ScopedArenaSwap(const ScopedArenaSwap&) = delete;
~ScopedArenaSwap() { ctx_->data().arena = saved_; }
private:
ParseContext* const ctx_;
Arena* const saved_;
};
PROTOBUF_NOINLINE const char* TcParser::ParseLoop(
MessageLite* msg, const char* ptr, ParseContext* ctx,
const TcParseTableBase* table) {
ScopedArenaSwap saved(msg, ctx);
const uint32_t has_bits_offset = table->has_bits_offset;
while (!ctx->Done(&ptr)) {
uint64_t hasbits = 0;
if (has_bits_offset) hasbits = RefAt<uint32_t>(msg, has_bits_offset);
ptr = TagDispatch(msg, ptr, ctx, table, hasbits, {});
if (ptr == nullptr) break;
if (ctx->LastTag() != 1) break; // Ended on terminating tag
}
return ptr;
}
// Dispatch to the designated parse function
inline PROTOBUF_ALWAYS_INLINE const char* TcParser::TagDispatch(
PROTOBUF_TC_PARAM_DECL) {
const auto coded_tag = UnalignedLoad<uint16_t>(ptr);
const size_t idx = coded_tag & table->fast_idx_mask;
PROTOBUF_ASSUME((idx & 7) == 0);
auto* fast_entry = table->fast_entry(idx >> 3);
data = fast_entry->bits;
data.data ^= coded_tag;
PROTOBUF_MUSTTAIL return fast_entry->target(PROTOBUF_TC_PARAM_PASS);
}
// We can only safely call from field to next field if the call is optimized
// to a proper tail call. Otherwise we blow through stack. Clang and gcc
// reliably do this optimization in opt mode, but do not perform this in debug
// mode. Luckily the structure of the algorithm is such that it's always
// possible to just return and use the enclosing parse loop as a trampoline.
inline PROTOBUF_ALWAYS_INLINE const char* TcParser::ToTagDispatch(
PROTOBUF_TC_PARAM_DECL) {
constexpr bool always_return = !PROTOBUF_TAILCALL;
if (always_return || !ctx->DataAvailable(ptr)) {
PROTOBUF_MUSTTAIL return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
}
PROTOBUF_MUSTTAIL return TagDispatch(PROTOBUF_TC_PARAM_PASS);
}
inline PROTOBUF_ALWAYS_INLINE const char* TcParser::ToParseLoop(
PROTOBUF_TC_PARAM_DECL) {
(void)data;
(void)ctx;
SyncHasbits(msg, hasbits, table);
return ptr;
}
inline PROTOBUF_ALWAYS_INLINE const char* TcParser::Error(
PROTOBUF_TC_PARAM_DECL) {
(void)data;
(void)ctx;
(void)ptr;
SyncHasbits(msg, hasbits, table);
return nullptr;
}
//////////////////////////////////////////////////////////////////////////////
// Core mini parsing implementation:
//////////////////////////////////////////////////////////////////////////////
// Returns the address of the field for `tag` in the table's field entries. // Returns the address of the field for `tag` in the table's field entries.
// Returns nullptr if the field was not found. // Returns nullptr if the field was not found.
const TcParseTableBase::FieldEntry* TcParser::FindFieldEntry( const TcParseTableBase::FieldEntry* TcParser::FindFieldEntry(
@ -886,6 +972,17 @@ void PrintUTF8ErrorLog(StringPiece message_name,
StringPiece field_name, const char* operation_str, StringPiece field_name, const char* operation_str,
bool emit_stacktrace); bool emit_stacktrace);
void TcParser::ReportFastUtf8Error(uint16_t coded_tag,
const TcParseTableBase* table) {
if (coded_tag > 127) {
coded_tag = (coded_tag & 0x7f) + ((coded_tag & 0xff00) >> 1);
}
uint32_t field_num = coded_tag >> 3;
const auto* entry = FindFieldEntry(table, field_num);
PrintUTF8ErrorLog(MessageName(table), FieldName(table, entry), "parsing",
false);
}
namespace { namespace {
PROTOBUF_NOINLINE PROTOBUF_NOINLINE
@ -893,8 +990,7 @@ const char* SingularStringParserFallback(ArenaStringPtr* s, const char* ptr,
EpsCopyInputStream* stream) { EpsCopyInputStream* stream) {
int size = ReadSize(&ptr); int size = ReadSize(&ptr);
if (!ptr) return nullptr; if (!ptr) return nullptr;
return stream->ReadString( return stream->ReadString(ptr, size, s->MutableNoCopy(nullptr));
ptr, size, s->MutableNoArenaNoDefault(&GetEmptyStringAlreadyInited()));
} }
} // namespace } // namespace
@ -905,6 +1001,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularString(
if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) { if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
} }
auto saved_tag = UnalignedLoad<TagType>(ptr);
ptr += sizeof(TagType); ptr += sizeof(TagType);
hasbits |= (uint64_t{1} << data.hasbit_idx()); hasbits |= (uint64_t{1} << data.hasbit_idx());
auto& field = RefAt<ArenaStringPtr>(msg, data.offset()); auto& field = RefAt<ArenaStringPtr>(msg, data.offset());
@ -925,7 +1022,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularString(
if (PROTOBUF_PREDICT_TRUE(IsStructurallyValidUTF8(field.Get()))) { if (PROTOBUF_PREDICT_TRUE(IsStructurallyValidUTF8(field.Get()))) {
return ToParseLoop(PROTOBUF_TC_PARAM_PASS); return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
} }
PrintUTF8ErrorLog("", "unknown", "parsing", false); ReportFastUtf8Error(saved_tag, table);
return utf8 == kUtf8 ? Error(PROTOBUF_TC_PARAM_PASS) return utf8 == kUtf8 ? Error(PROTOBUF_TC_PARAM_PASS)
: ToParseLoop(PROTOBUF_TC_PARAM_PASS); : ToParseLoop(PROTOBUF_TC_PARAM_PASS);
} }
@ -971,11 +1068,19 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedString(
if (ptr == nullptr) { if (ptr == nullptr) {
return Error(PROTOBUF_TC_PARAM_PASS); return Error(PROTOBUF_TC_PARAM_PASS);
} }
if (utf8 != kNoUtf8) { switch (utf8) {
if (PROTOBUF_PREDICT_FALSE(!IsStructurallyValidUTF8(*str))) { case kNoUtf8:
PrintUTF8ErrorLog("", "unknown", "parsing", false); #ifdef NDEBUG
case kUtf8ValidateOnly:
#endif
break;
default:
if (PROTOBUF_PREDICT_TRUE(IsStructurallyValidUTF8(*str))) {
break;
}
ReportFastUtf8Error(expected_tag, table);
if (utf8 == kUtf8) return Error(PROTOBUF_TC_PARAM_PASS); if (utf8 == kUtf8) return Error(PROTOBUF_TC_PARAM_PASS);
} break;
} }
if (!ctx->DataAvailable(ptr)) break; if (!ctx->DataAvailable(ptr)) break;
} while (UnalignedLoad<TagType>(ptr) == expected_tag); } while (UnalignedLoad<TagType>(ptr) == expected_tag);
@ -1058,11 +1163,10 @@ bool TcParser::ChangeOneof(const TcParseTableBase* table,
uint16_t current_kind = current_entry->type_card & field_layout::kFkMask; uint16_t current_kind = current_entry->type_card & field_layout::kFkMask;
uint16_t current_rep = current_entry->type_card & field_layout::kRepMask; uint16_t current_rep = current_entry->type_card & field_layout::kRepMask;
if (current_kind == field_layout::kFkString) { if (current_kind == field_layout::kFkString) {
Arena* arena = ctx->data().arena;
switch (current_rep) { switch (current_rep) {
case field_layout::kRepAString: { case field_layout::kRepAString: {
auto& field = RefAt<ArenaStringPtr>(msg, current_entry->offset); auto& field = RefAt<ArenaStringPtr>(msg, current_entry->offset);
field.Destroy(ArenaStringPtr::EmptyDefault{}, arena); field.Destroy();
break; break;
} }
case field_layout::kRepSString: case field_layout::kRepSString:
@ -1383,23 +1487,28 @@ const char* TcParser::MpPackedVarint(PROTOBUF_TC_PARAM_DECL) {
return Error(PROTOBUF_TC_PARAM_PASS); return Error(PROTOBUF_TC_PARAM_PASS);
} }
namespace { bool TcParser::MpVerifyUtf8(StringPiece wire_bytes,
const TcParseTableBase* table,
inline bool MpVerifyUtf8(StringPiece wire_bytes, const FieldEntry& entry, const FieldEntry& entry, uint16_t xform_val) {
uint16_t xform_val) {
if (xform_val == field_layout::kTvUtf8) { if (xform_val == field_layout::kTvUtf8) {
return VerifyUTF8(wire_bytes, "unknown"); if (!IsStructurallyValidUTF8(wire_bytes)) {
PrintUTF8ErrorLog(MessageName(table), FieldName(table, &entry), "parsing",
false);
return false;
}
return true;
} }
#ifndef NDEBUG #ifndef NDEBUG
if (xform_val == field_layout::kTvUtf8Debug) { if (xform_val == field_layout::kTvUtf8Debug) {
VerifyUTF8(wire_bytes, "unknown"); if (!IsStructurallyValidUTF8(wire_bytes)) {
PrintUTF8ErrorLog(MessageName(table), FieldName(table, &entry), "parsing",
false);
}
} }
#endif // NDEBUG #endif // NDEBUG
return true; return true;
} }
} // namespace
const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) { const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) {
const auto& entry = RefAt<FieldEntry>(table, data.entry_offset()); const auto& entry = RefAt<FieldEntry>(table, data.entry_offset());
const uint16_t type_card = entry.type_card; const uint16_t type_card = entry.type_card;
@ -1413,18 +1522,6 @@ const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_MUSTTAIL return MpRepeatedString(PROTOBUF_TC_PARAM_PASS); PROTOBUF_MUSTTAIL return MpRepeatedString(PROTOBUF_TC_PARAM_PASS);
} }
const uint16_t xform_val = type_card & field_layout::kTvMask; const uint16_t xform_val = type_card & field_layout::kTvMask;
// TODO(b/209516305): handle UTF-8 fields once field names are available.
if (
#ifdef NDEBUG
xform_val == field_layout::kTvUtf8
#else
xform_val != 0
#endif
) {
PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
}
const uint16_t rep = type_card & field_layout::kRepMask; const uint16_t rep = type_card & field_layout::kRepMask;
if (rep == field_layout::kRepIString) { if (rep == field_layout::kRepIString) {
// TODO(b/198211897): support InilnedStringField. // TODO(b/198211897): support InilnedStringField.
@ -1444,19 +1541,16 @@ const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) {
Arena* arena = ctx->data().arena; Arena* arena = ctx->data().arena;
switch (rep) { switch (rep) {
case field_layout::kRepAString: { case field_layout::kRepAString: {
const std::string* default_value =
RefAt<ArenaStringPtr>(table->default_instance, entry.offset)
.tagged_ptr_.Get();
auto& field = RefAt<ArenaStringPtr>(msg, entry.offset); auto& field = RefAt<ArenaStringPtr>(msg, entry.offset);
if (need_init) field.InitDefault(); if (need_init) field.InitDefault();
if (arena) { if (arena) {
ptr = ctx->ReadArenaString(ptr, &field, arena); ptr = ctx->ReadArenaString(ptr, &field, arena);
} else { } else {
std::string* str = field.MutableNoCopy(default_value, nullptr); std::string* str = field.MutableNoCopy(nullptr);
ptr = InlineGreedyStringParser(str, ptr, ctx); ptr = InlineGreedyStringParser(str, ptr, ctx);
} }
if (!ptr) break; if (!ptr) break;
is_valid = MpVerifyUtf8(field.Get(), entry, xform_val); is_valid = MpVerifyUtf8(field.Get(), table, entry, xform_val);
break; break;
} }
@ -1482,18 +1576,6 @@ const char* TcParser::MpRepeatedString(PROTOBUF_TC_PARAM_DECL) {
const uint16_t rep = type_card & field_layout::kRepMask; const uint16_t rep = type_card & field_layout::kRepMask;
const uint16_t xform_val = type_card & field_layout::kTvMask; const uint16_t xform_val = type_card & field_layout::kTvMask;
// TODO(b/209516305): handle UTF-8 fields once field names are available.
if (
#ifdef NDEBUG
xform_val == field_layout::kTvUtf8
#else
xform_val != 0
#endif
) {
PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
}
switch (rep) { switch (rep) {
case field_layout::kRepSString: { case field_layout::kRepSString: {
auto& field = RefAt<RepeatedPtrField<std::string>>(msg, entry.offset); auto& field = RefAt<RepeatedPtrField<std::string>>(msg, entry.offset);
@ -1503,8 +1585,9 @@ const char* TcParser::MpRepeatedString(PROTOBUF_TC_PARAM_DECL) {
ptr = ptr2; ptr = ptr2;
std::string* str = field.Add(); std::string* str = field.Add();
ptr = InlineGreedyStringParser(str, ptr, ctx); ptr = InlineGreedyStringParser(str, ptr, ctx);
if (PROTOBUF_PREDICT_FALSE(ptr == nullptr || if (PROTOBUF_PREDICT_FALSE(
!MpVerifyUtf8(*str, entry, xform_val))) { ptr == nullptr ||
!MpVerifyUtf8(*str, table, entry, xform_val))) {
return Error(PROTOBUF_TC_PARAM_PASS); return Error(PROTOBUF_TC_PARAM_PASS);
} }
if (!ctx->DataAvailable(ptr)) break; if (!ctx->DataAvailable(ptr)) break;

@ -88,11 +88,11 @@ TEST(IsEntryForFieldNumTest, Matcher) {
} // namespace } // namespace
class FindFieldEntryTest : public ::testing::Test { class FindFieldEntryTest : public ::testing::Test {
protected: public:
// Calls the private `FindFieldEntry` function. // Calls the private `FindFieldEntry` function.
template <size_t kFastTableSizeLog2, size_t kNumEntries, size_t kNumFieldAux, template <size_t kFastTableSizeLog2, size_t kNumEntries, size_t kNumFieldAux,
size_t kNameTableSize> size_t kNameTableSize>
const TcParseTableBase::FieldEntry* FindFieldEntry( static const TcParseTableBase::FieldEntry* FindFieldEntry(
const TcParseTable<kFastTableSizeLog2, kNumEntries, kNumFieldAux, const TcParseTable<kFastTableSizeLog2, kNumEntries, kNumFieldAux,
kNameTableSize>& table, kNameTableSize>& table,
uint32_t tag) { uint32_t tag) {
@ -102,7 +102,7 @@ class FindFieldEntryTest : public ::testing::Test {
// Calls the private `FieldName` function. // Calls the private `FieldName` function.
template <size_t kFastTableSizeLog2, size_t kNumEntries, size_t kNumFieldAux, template <size_t kFastTableSizeLog2, size_t kNumEntries, size_t kNumFieldAux,
size_t kNameTableSize> size_t kNameTableSize>
StringPiece FieldName( static StringPiece FieldName(
const TcParseTable<kFastTableSizeLog2, kNumEntries, kNumFieldAux, const TcParseTable<kFastTableSizeLog2, kNumEntries, kNumFieldAux,
kNameTableSize>& table, kNameTableSize>& table,
const TcParseTableBase::FieldEntry* entry) { const TcParseTableBase::FieldEntry* entry) {
@ -112,7 +112,7 @@ class FindFieldEntryTest : public ::testing::Test {
// Calls the private `MessageName` function. // Calls the private `MessageName` function.
template <size_t kFastTableSizeLog2, size_t kNumEntries, size_t kNumFieldAux, template <size_t kFastTableSizeLog2, size_t kNumEntries, size_t kNumFieldAux,
size_t kNameTableSize> size_t kNameTableSize>
StringPiece MessageName( static StringPiece MessageName(
const TcParseTable<kFastTableSizeLog2, kNumEntries, kNumFieldAux, const TcParseTable<kFastTableSizeLog2, kNumEntries, kNumFieldAux,
kNameTableSize>& table) { kNameTableSize>& table) {
return TcParser::MessageName(&table.header); return TcParser::MessageName(&table.header);
@ -293,196 +293,197 @@ TEST_F(FindFieldEntryTest, EmptyMessage) {
EXPECT_THAT(MessageName(table), Eq("MessageName")); EXPECT_THAT(MessageName(table), Eq("MessageName"));
} }
TEST_F(FindFieldEntryTest, BigMessage) { // Make a monster with lots of field numbers
// Make a monster with lots of field numbers // clang-format off
// clang-format off const TcParseTable<5, 134, 5, 2176> test_all_types_table = {
const TcParseTable<5, 134, 5, 2176> test_all_types_table = { // header:
// header: {
{ 0, 0, 0, 0, // has_bits_offset, extensions
0, 0, 0, 0, // has_bits_offset, extensions 418, 248, // max_field_number, fast_idx_mask
418, 248, // max_field_number, fast_idx_mask 14, 1, // num_sequential_fields, sequential_fields_start
14, 1, // num_sequential_fields, sequential_fields_start 135, // num_field_entries
135, // num_field_entries 5, // num_aux_entries
5, // num_aux_entries offsetof(decltype(test_all_types_table), aux_entries),
offsetof(decltype(test_all_types_table), aux_entries), nullptr, // default instance
nullptr, // default instance nullptr, // fallback function
nullptr, // fallback function },
},
{{
// tail-call table
}},
{{// field numbers
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 18, 19, 21, 22, 24,
25, 27, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 48, 49, 51,
52, 54, 55, 56, 57, 58, 59, 60, 61, 62,
63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
111, 112, 113, 114, 115, 116, 117, 118, 119, 201,
241, 242, 243, 244, 245, 246, 247, 248, 249, 250,
251, 252, 253, 254, 255, 321, 322, 401, 402, 403,
404, 405, 406, 407, 408, 409, 410, 411, 412, 413,
414, 415, 416, 417}},
{{ {{
// "mini" table // tail-call table
}},
{{ // auxiliary entries (not used in this test)
{-1, 4},
{-1, 4},
{-1, 4},
{-1, 4},
{-1, 4},
}}, {{ // name lengths
"\1" // message name
"\16\16\17\17\17\17\20\20\21\21\16\17\15\17\16\27\30\24\25\25"
"\15\21\16\16\17\17\17\17\20\20\21\21\16\17\15\17\16\27\30\24"
"\25\25\15\17\17\21\21\21\21\23\23\25\25\17\20\15\21\20\31\32"
"\26\27\14\14\15\15\15\15\16\16\17\17\14\15\13\22\16\16\17\17"
"\17\17\20\20\21\21\16\17\15\24\14\24\14\13\12\14\13\14\12\4"
"\15\15\16\16\16\16\17\17\20\20\15\16\14\16\15\25\25\12\13\14"
"\15\13\15\12\12\13\14\14\14\16\16\15\15\16\0"
// names
"M"
"optional_int32"
"optional_int64"
"optional_uint32"
"optional_uint64"
"optional_sint32"
"optional_sint64"
"optional_fixed32"
"optional_fixed64"
"optional_sfixed32"
"optional_sfixed64"
"optional_float"
"optional_double"
"optional_bool"
"optional_string"
"optional_bytes"
"optional_nested_message"
"optional_foreign_message"
"optional_nested_enum"
"optional_foreign_enum"
"optional_string_piece"
"optional_cord"
"recursive_message"
"repeated_int32"
"repeated_int64"
"repeated_uint32"
"repeated_uint64"
"repeated_sint32"
"repeated_sint64"
"repeated_fixed32"
"repeated_fixed64"
"repeated_sfixed32"
"repeated_sfixed64"
"repeated_float"
"repeated_double"
"repeated_bool"
"repeated_string"
"repeated_bytes"
"repeated_nested_message"
"repeated_foreign_message"
"repeated_nested_enum"
"repeated_foreign_enum"
"repeated_string_piece"
"repeated_cord"
"map_int32_int32"
"map_int64_int64"
"map_uint32_uint32"
"map_uint64_uint64"
"map_sint32_sint32"
"map_sint64_sint64"
"map_fixed32_fixed32"
"map_fixed64_fixed64"
"map_sfixed32_sfixed32"
"map_sfixed64_sfixed64"
"map_int32_float"
"map_int32_double"
"map_bool_bool"
"map_string_string"
"map_string_bytes"
"map_string_nested_message"
"map_string_foreign_message"
"map_string_nested_enum"
"map_string_foreign_enum"
"packed_int32"
"packed_int64"
"packed_uint32"
"packed_uint64"
"packed_sint32"
"packed_sint64"
"packed_fixed32"
"packed_fixed64"
"packed_sfixed32"
"packed_sfixed64"
"packed_float"
"packed_double"
"packed_bool"
"packed_nested_enum"
"unpacked_int32"
"unpacked_int64"
"unpacked_uint32"
"unpacked_uint64"
"unpacked_sint32"
"unpacked_sint64"
"unpacked_fixed32"
"unpacked_fixed64"
"unpacked_sfixed32"
"unpacked_sfixed64"
"unpacked_float"
"unpacked_double"
"unpacked_bool"
"unpacked_nested_enum"
"oneof_uint32"
"oneof_nested_message"
"oneof_string"
"oneof_bytes"
"oneof_bool"
"oneof_uint64"
"oneof_float"
"oneof_double"
"oneof_enum"
"data"
"default_int32"
"default_int64"
"default_uint32"
"default_uint64"
"default_sint32"
"default_sint64"
"default_fixed32"
"default_fixed64"
"default_sfixed32"
"default_sfixed64"
"default_float"
"default_double"
"default_bool"
"default_string"
"default_bytes"
"optional_lazy_message"
"repeated_lazy_message"
"fieldname1"
"field_name2"
"_field_name3"
"field__name4_"
"field0name5"
"field_0_name6"
"fieldName7"
"FieldName8"
"field_Name9"
"Field_Name10"
"FIELD_NAME11"
"FIELD_name12"
"__field_name13"
"__Field_name14"
"field__name15"
"field__Name16"
"field_name17__"
}}, }},
}; {{// field numbers
// clang-format on 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 18, 19, 21, 22, 24,
25, 27, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 48, 49, 51,
52, 54, 55, 56, 57, 58, 59, 60, 61, 62,
63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
111, 112, 113, 114, 115, 116, 117, 118, 119, 201,
241, 242, 243, 244, 245, 246, 247, 248, 249, 250,
251, 252, 253, 254, 255, 321, 322, 401, 402, 403,
404, 405, 406, 407, 408, 409, 410, 411, 412, 413,
414, 415, 416, 417}},
{{
// "mini" table
}},
{{ // auxiliary entries (not used in this test)
{-1, 4},
{-1, 4},
{-1, 4},
{-1, 4},
{-1, 4},
}}, {{ // name lengths
"\1" // message name
"\16\16\17\17\17\17\20\20\21\21\16\17\15\17\16\27\30\24\25\25"
"\15\21\16\16\17\17\17\17\20\20\21\21\16\17\15\17\16\27\30\24"
"\25\25\15\17\17\21\21\21\21\23\23\25\25\17\20\15\21\20\31\32"
"\26\27\14\14\15\15\15\15\16\16\17\17\14\15\13\22\16\16\17\17"
"\17\17\20\20\21\21\16\17\15\24\14\24\14\13\12\14\13\14\12\4"
"\15\15\16\16\16\16\17\17\20\20\15\16\14\16\15\25\25\12\13\14"
"\15\13\15\12\12\13\14\14\14\16\16\15\15\16\0"
// names
"M"
"optional_int32"
"optional_int64"
"optional_uint32"
"optional_uint64"
"optional_sint32"
"optional_sint64"
"optional_fixed32"
"optional_fixed64"
"optional_sfixed32"
"optional_sfixed64"
"optional_float"
"optional_double"
"optional_bool"
"optional_string"
"optional_bytes"
"optional_nested_message"
"optional_foreign_message"
"optional_nested_enum"
"optional_foreign_enum"
"optional_string_piece"
"optional_cord"
"recursive_message"
"repeated_int32"
"repeated_int64"
"repeated_uint32"
"repeated_uint64"
"repeated_sint32"
"repeated_sint64"
"repeated_fixed32"
"repeated_fixed64"
"repeated_sfixed32"
"repeated_sfixed64"
"repeated_float"
"repeated_double"
"repeated_bool"
"repeated_string"
"repeated_bytes"
"repeated_nested_message"
"repeated_foreign_message"
"repeated_nested_enum"
"repeated_foreign_enum"
"repeated_string_piece"
"repeated_cord"
"map_int32_int32"
"map_int64_int64"
"map_uint32_uint32"
"map_uint64_uint64"
"map_sint32_sint32"
"map_sint64_sint64"
"map_fixed32_fixed32"
"map_fixed64_fixed64"
"map_sfixed32_sfixed32"
"map_sfixed64_sfixed64"
"map_int32_float"
"map_int32_double"
"map_bool_bool"
"map_string_string"
"map_string_bytes"
"map_string_nested_message"
"map_string_foreign_message"
"map_string_nested_enum"
"map_string_foreign_enum"
"packed_int32"
"packed_int64"
"packed_uint32"
"packed_uint64"
"packed_sint32"
"packed_sint64"
"packed_fixed32"
"packed_fixed64"
"packed_sfixed32"
"packed_sfixed64"
"packed_float"
"packed_double"
"packed_bool"
"packed_nested_enum"
"unpacked_int32"
"unpacked_int64"
"unpacked_uint32"
"unpacked_uint64"
"unpacked_sint32"
"unpacked_sint64"
"unpacked_fixed32"
"unpacked_fixed64"
"unpacked_sfixed32"
"unpacked_sfixed64"
"unpacked_float"
"unpacked_double"
"unpacked_bool"
"unpacked_nested_enum"
"oneof_uint32"
"oneof_nested_message"
"oneof_string"
"oneof_bytes"
"oneof_bool"
"oneof_uint64"
"oneof_float"
"oneof_double"
"oneof_enum"
"data"
"default_int32"
"default_int64"
"default_uint32"
"default_uint64"
"default_sint32"
"default_sint64"
"default_fixed32"
"default_fixed64"
"default_sfixed32"
"default_sfixed64"
"default_float"
"default_double"
"default_bool"
"default_string"
"default_bytes"
"optional_lazy_message"
"repeated_lazy_message"
"fieldname1"
"field_name2"
"_field_name3"
"field__name4_"
"field0name5"
"field_0_name6"
"fieldName7"
"FieldName8"
"field_Name9"
"Field_Name10"
"FIELD_NAME11"
"FIELD_name12"
"__field_name13"
"__Field_name14"
"field__name15"
"field__Name16"
"field_name17__"
}},
};
// clang-format on
TEST_F(FindFieldEntryTest, BigMessage) {
EXPECT_THAT(MessageName(test_all_types_table), Eq("M")); EXPECT_THAT(MessageName(test_all_types_table), Eq("M"));
for (int field_num : for (int field_num :
{1, 12, 31, 42, 57, 68, 79, 90, 101, 119, 249, 402, 412}) { {1, 12, 31, 42, 57, 68, 79, 90, 101, 119, 249, 402, 412}) {

@ -389,8 +389,7 @@ void GenericSwap(MessageLite* m1, MessageLite* m2) {
MessageLite* GetOwnedMessageInternal(Arena* message_arena, MessageLite* GetOwnedMessageInternal(Arena* message_arena,
MessageLite* submessage, MessageLite* submessage,
Arena* submessage_arena) { Arena* submessage_arena) {
GOOGLE_DCHECK(Arena::InternalHelper<MessageLite>::GetOwningArena(submessage) == GOOGLE_DCHECK(Arena::InternalGetOwningArena(submessage) == submessage_arena);
submessage_arena);
GOOGLE_DCHECK(message_arena != submessage_arena); GOOGLE_DCHECK(message_arena != submessage_arena);
GOOGLE_DCHECK_EQ(submessage_arena, nullptr); GOOGLE_DCHECK_EQ(submessage_arena, nullptr);
if (message_arena != nullptr && submessage_arena == nullptr) { if (message_arena != nullptr && submessage_arena == nullptr) {

@ -55,8 +55,7 @@ std::string* InlinedStringField::Mutable(const LazyString& /*default_value*/,
return MutableSlow(arena, donated, donating_states, mask, msg); return MutableSlow(arena, donated, donating_states, mask, msg);
} }
std::string* InlinedStringField::Mutable(ArenaStringPtr::EmptyDefault, std::string* InlinedStringField::Mutable(Arena* arena, bool donated,
Arena* arena, bool donated,
uint32_t* donating_states, uint32_t* donating_states,
uint32_t mask, MessageLite* msg) { uint32_t mask, MessageLite* msg) {
if (arena == nullptr || !donated) { if (arena == nullptr || !donated) {
@ -83,27 +82,28 @@ void InlinedStringField::SetAllocated(const std::string* default_value,
SetAllocatedNoArena(default_value, value); SetAllocatedNoArena(default_value, value);
} }
void InlinedStringField::Set(const std::string* default_value, void InlinedStringField::Set(std::string&& value, Arena* arena, bool donated,
std::string&& value, Arena* arena, bool donated,
uint32_t* donating_states, uint32_t mask, uint32_t* donating_states, uint32_t mask,
MessageLite* msg) { MessageLite* msg) {
(void)donating_states; (void)donating_states;
(void)mask; (void)mask;
(void)msg; (void)msg;
SetNoArena(default_value, std::move(value)); SetNoArena(std::move(value));
} }
std::string* InlinedStringField::Release(const std::string* default_value, std::string* InlinedStringField::Release() {
Arena* arena, bool donated) { auto* released = new std::string(std::move(*get_mutable()));
if (arena == nullptr && !donated) { get_mutable()->clear();
return ReleaseNonDefaultNoArena(default_value); return released;
}
return ReleaseNonDefault(default_value, arena);
} }
std::string* InlinedStringField::ReleaseNonDefault( std::string* InlinedStringField::Release(Arena* arena, bool donated) {
const std::string* default_value, Arena* arena) { // We can not steal donated arena strings.
return ReleaseNonDefaultNoArena(default_value); std::string* released = (arena != nullptr && donated)
? new std::string(*get_mutable())
: new std::string(std::move(*get_mutable()));
get_mutable()->clear();
return released;
} }
void InlinedStringField::ClearToDefault(const LazyString& default_value, void InlinedStringField::ClearToDefault(const LazyString& default_value,

@ -130,63 +130,45 @@ class PROTOBUF_EXPORT InlinedStringField {
// `donated == ((donating_states & ~mask) != 0)` // `donated == ((donating_states & ~mask) != 0)`
// //
// This method never changes the `donating_states`. // This method never changes the `donating_states`.
void Set(const std::string* default_value, ConstStringParam value, void Set(ConstStringParam value, Arena* arena, bool donated,
Arena* arena, bool donated, uint32_t* /*donating_states*/, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
uint32_t /*mask*/, MessageLite* /*msg*/) {
(void)arena;
(void)donated;
SetNoArena(default_value, value);
}
// Rvalue Set. If this field is donated, this method will undonate this field // Rvalue Set. If this field is donated, this method will undonate this field
// by mutating the `donating_states` according to `mask`. // by mutating the `donating_states` according to `mask`.
void Set(const std::string* default_value, std::string&& value, Arena* arena, void Set(std::string&& value, Arena* arena, bool donated,
bool donated, uint32_t* donating_states, uint32_t mask, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
MessageLite* msg);
template <typename FirstParam> void Set(const char* str, ::google::protobuf::Arena* arena, bool donated,
void Set(FirstParam p1, const char* str, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
uint32_t* donating_states, uint32_t mask, MessageLite* msg) {
Set(p1, ConstStringParam(str), arena, donated, donating_states, mask, msg);
}
template <typename FirstParam> void Set(const char* str, size_t size, ::google::protobuf::Arena* arena, bool donated,
void Set(FirstParam p1, const char* str, size_t size, ::google::protobuf::Arena* arena, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
bool donated, uint32_t* donating_states, uint32_t mask,
MessageLite* msg) {
ConstStringParam sp{str, size}; // for string_view and `const string &`
Set(p1, sp, arena, donated, donating_states, mask, msg);
}
template <typename FirstParam, typename RefWrappedType> template <typename RefWrappedType>
void Set(FirstParam p1, void Set(std::reference_wrapper<RefWrappedType> const_string_ref,
std::reference_wrapper<RefWrappedType> const_string_ref,
::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states,
uint32_t mask, MessageLite* msg) { uint32_t mask, MessageLite* msg);
Set(p1, const_string_ref.get(), arena, donated, donating_states, mask, msg);
} void SetBytes(ConstStringParam value, Arena* arena, bool donated,
uint32_t* donating_states, uint32_t mask, MessageLite* msg);
template <typename FirstParam, typename SecondParam> void SetBytes(std::string&& value, Arena* arena, bool donated,
void SetBytes(FirstParam p1, SecondParam&& p2, ::google::protobuf::Arena* arena, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
void SetBytes(const char* str, ::google::protobuf::Arena* arena, bool donated,
uint32_t* donating_states, uint32_t mask, MessageLite* msg);
void SetBytes(const void* p, size_t size, ::google::protobuf::Arena* arena,
bool donated, uint32_t* donating_states, uint32_t mask, bool donated, uint32_t* donating_states, uint32_t mask,
MessageLite* msg) { MessageLite* msg);
Set(p1, static_cast<SecondParam&&>(p2), arena, donated, donating_states,
mask, msg);
}
template <typename FirstParam> template <typename RefWrappedType>
void SetBytes(FirstParam p1, const void* str, size_t size, void SetBytes(std::reference_wrapper<RefWrappedType> const_string_ref,
::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states,
uint32_t mask, MessageLite* msg) { uint32_t mask, MessageLite* msg);
// Must work whether ConstStringParam is string_view or `const string &`
ConstStringParam sp{static_cast<const char*>(str), size};
Set(p1, sp, arena, donated, donating_states, mask, msg);
}
PROTOBUF_NDEBUG_INLINE void SetNoArena(const std::string* default_value, PROTOBUF_NDEBUG_INLINE void SetNoArena(StringPiece value);
StringPiece value); PROTOBUF_NDEBUG_INLINE void SetNoArena(std::string&& value);
PROTOBUF_NDEBUG_INLINE void SetNoArena(const std::string* default_value,
std::string&& value);
// Basic accessors. // Basic accessors.
PROTOBUF_NDEBUG_INLINE const std::string& Get() const { return GetNoArena(); } PROTOBUF_NDEBUG_INLINE const std::string& Get() const { return GetNoArena(); }
@ -196,22 +178,17 @@ class PROTOBUF_EXPORT InlinedStringField {
// field is donated, this method undonates this field by mutating the // field is donated, this method undonates this field by mutating the
// `donating_states` according to `mask`, and copies the content of the // `donating_states` according to `mask`, and copies the content of the
// original string to the returning string. // original string to the returning string.
std::string* Mutable(Arena* arena, bool donated, uint32_t* donating_states,
uint32_t mask, MessageLite* msg);
std::string* Mutable(const LazyString& default_value, Arena* arena, std::string* Mutable(const LazyString& default_value, Arena* arena,
bool donated, uint32_t* donating_states, uint32_t mask, bool donated, uint32_t* donating_states, uint32_t mask,
MessageLite* msg); MessageLite* msg);
std::string* Mutable(ArenaStringPtr::EmptyDefault, Arena* arena, bool donated,
uint32_t* donating_states, uint32_t mask,
MessageLite* msg);
// Release returns a std::string* instance that is heap-allocated and is not // Mutable(nullptr_t) is an overload to explicitly support Mutable(nullptr)
// Own()'d by any arena. If the field is not set, this returns nullptr. The // calls used by the internal parser logic. This provides API equivalence with
// caller retains ownership. Clears this field back to nullptr state. Used to // ArenaStringPtr, while still protecting against calls with arena pointers.
// implement release_<field>() methods on generated classes. std::string* Mutable(std::nullptr_t);
PROTOBUF_NODISCARD std::string* Release(const std::string* default_value, std::string* MutableNoCopy(std::nullptr_t);
Arena* arena, bool donated);
PROTOBUF_NODISCARD std::string* ReleaseNonDefault(
const std::string* default_value, Arena* arena);
std::string* ReleaseNonDefaultNoArena(const std::string* default_value);
// Takes a std::string that is heap-allocated, and takes ownership. The // Takes a std::string that is heap-allocated, and takes ownership. The
// std::string's destructor is registered with the arena. Used to implement // std::string's destructor is registered with the arena. Used to implement
@ -226,6 +203,120 @@ class PROTOBUF_EXPORT InlinedStringField {
void SetAllocatedNoArena(const std::string* default_value, void SetAllocatedNoArena(const std::string* default_value,
std::string* value); std::string* value);
// Release returns a std::string* instance that is heap-allocated and is not
// Own()'d by any arena. If the field is not set, this returns nullptr. The
// caller retains ownership. Clears this field back to nullptr state. Used to
// implement release_<field>() methods on generated classes.
PROTOBUF_NODISCARD std::string* Release(Arena* arena, bool donated);
PROTOBUF_NODISCARD std::string* Release();
// --------------------------------------------------------
// Below functions will be removed in subsequent code change
// --------------------------------------------------------
#ifdef DEPRECATED_METHODS_TO_BE_DELETED
PROTOBUF_NODISCARD std::string* Release(const std::string*, Arena* arena,
bool donated) {
return Release(arena, donated);
}
PROTOBUF_NODISCARD std::string* ReleaseNonDefault(const std::string*,
Arena* arena) {
return Release();
}
std::string* ReleaseNonDefaultNoArena(const std::string* default_value) {
return Release();
}
void Set(const std::string*, ConstStringParam value, Arena* arena,
bool donated, uint32_t* donating_states, uint32_t mask,
MessageLite* msg) {
Set(value, arena, donated, donating_states, mask, msg);
}
void Set(const std::string*, std::string&& value, Arena* arena, bool donated,
uint32_t* donating_states, uint32_t mask, MessageLite* msg) {
Set(std::move(value), arena, donated, donating_states, mask, msg);
}
template <typename FirstParam>
void Set(FirstParam, const char* str, ::google::protobuf::Arena* arena, bool donated,
uint32_t* donating_states, uint32_t mask, MessageLite* msg) {
Set(str, arena, donated, donating_states, mask, msg);
}
template <typename FirstParam>
void Set(FirstParam p1, const char* str, size_t size, ::google::protobuf::Arena* arena,
bool donated, uint32_t* donating_states, uint32_t mask,
MessageLite* msg) {
Set(str, size, arena, donated, donating_states, mask, msg);
}
template <typename FirstParam, typename RefWrappedType>
void Set(FirstParam p1,
std::reference_wrapper<RefWrappedType> const_string_ref,
::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states,
uint32_t mask, MessageLite* msg) {
Set(const_string_ref, arena, donated, donating_states, mask, msg);
}
void SetBytes(const std::string*, ConstStringParam value, Arena* arena,
bool donated, uint32_t* donating_states, uint32_t mask,
MessageLite* msg) {
Set(value, arena, donated, donating_states, mask, msg);
}
void SetBytes(const std::string*, std::string&& value, Arena* arena,
bool donated, uint32_t* donating_states, uint32_t mask,
MessageLite* msg) {
Set(std::move(value), arena, donated, donating_states, mask, msg);
}
template <typename FirstParam>
void SetBytes(FirstParam p1, const char* str, ::google::protobuf::Arena* arena,
bool donated, uint32_t* donating_states, uint32_t mask,
MessageLite* msg) {
SetBytes(str, arena, donated, donating_states, mask, msg);
}
template <typename FirstParam>
void SetBytes(FirstParam p1, const void* p, size_t size,
::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states,
uint32_t mask, MessageLite* msg) {
SetBytes(p, size, arena, donated, donating_states, mask, msg);
}
template <typename FirstParam, typename RefWrappedType>
void SetBytes(FirstParam p1,
std::reference_wrapper<RefWrappedType> const_string_ref,
::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states,
uint32_t mask, MessageLite* msg) {
SetBytes(const_string_ref.get(), arena, donated, donating_states, mask,
msg);
}
void SetNoArena(const std::string*, StringPiece value) {
SetNoArena(value);
}
void SetNoArena(const std::string*, std::string&& value) {
SetNoArena(std::move(value));
}
std::string* Mutable(ArenaStringPtr::EmptyDefault, Arena* arena, bool donated,
uint32_t* donating_states, uint32_t mask,
MessageLite* msg) {
return Mutable(arena, donated, donating_states, mask, msg);
}
PROTOBUF_NDEBUG_INLINE std::string* MutableNoArenaNoDefault(
const std::string* /*default_value*/) {
return MutableNoCopy(nullptr);
}
#endif // DEPRECATED_METHODS_TO_BE_DELETED
// Arena-safety semantics: this is guarded by the logic in // Arena-safety semantics: this is guarded by the logic in
// Swap()/UnsafeArenaSwap() at the message level, so this method is // Swap()/UnsafeArenaSwap() at the message level, so this method is
// 'unsafe' if called directly. // 'unsafe' if called directly.
@ -258,17 +349,12 @@ class PROTOBUF_EXPORT InlinedStringField {
void ClearToDefault(const LazyString& default_value, Arena* arena, void ClearToDefault(const LazyString& default_value, Arena* arena,
bool donated); bool donated);
// Returns a mutable pointer, but doesn't initialize the string to the
// default value.
PROTOBUF_NDEBUG_INLINE std::string* MutableNoArenaNoDefault(
const std::string* /*default_value*/);
// Generated code / reflection only! Returns a mutable pointer to the string. // Generated code / reflection only! Returns a mutable pointer to the string.
PROTOBUF_NDEBUG_INLINE std::string* UnsafeMutablePointer(); PROTOBUF_NDEBUG_INLINE std::string* UnsafeMutablePointer();
// InlinedStringField doesn't have things like the `default_value` pointer in // InlinedStringField doesn't have things like the `default_value` pointer in
// ArenaStringPtr. // ArenaStringPtr.
static constexpr bool IsDefault() { return false; } static constexpr bool IsDefault() { return false; }
static constexpr bool IsDefault(const std::string*) { return false; } static constexpr bool IsDefault(const std::string*) { return false; }
private: private:
@ -327,21 +413,11 @@ inline void InlinedStringField::DestroyNoArena(const std::string*) {
this->~InlinedStringField(); this->~InlinedStringField();
} }
inline std::string* InlinedStringField::ReleaseNonDefaultNoArena( inline void InlinedStringField::SetNoArena(StringPiece value) {
const std::string* /*default_value*/) {
// Currently, inlined string field can't have non empty default.
auto* released = new std::string();
get_mutable()->swap(*released);
return released;
}
inline void InlinedStringField::SetNoArena(const std::string* /*default_value*/,
StringPiece value) {
get_mutable()->assign(value.data(), value.length()); get_mutable()->assign(value.data(), value.length());
} }
inline void InlinedStringField::SetNoArena(const std::string* /*default_value*/, inline void InlinedStringField::SetNoArena(std::string&& value) {
std::string&& value) {
get_mutable()->assign(std::move(value)); get_mutable()->assign(std::move(value));
} }
@ -369,15 +445,84 @@ inline PROTOBUF_NDEBUG_INLINE void InlinedStringField::InternalSwap(
#endif #endif
} }
inline std::string* InlinedStringField::MutableNoArenaNoDefault( inline void InlinedStringField::Set(ConstStringParam value, Arena* arena,
const std::string*) { bool donated, uint32_t* /*donating_states*/,
return get_mutable(); uint32_t /*mask*/, MessageLite* /*msg*/) {
(void)arena;
(void)donated;
SetNoArena(value);
}
inline void InlinedStringField::Set(const char* str, ::google::protobuf::Arena* arena,
bool donated, uint32_t* donating_states,
uint32_t mask, MessageLite* msg) {
Set(ConstStringParam(str), arena, donated, donating_states, mask, msg);
}
inline void InlinedStringField::Set(const char* str, size_t size,
::google::protobuf::Arena* arena, bool donated,
uint32_t* donating_states, uint32_t mask,
MessageLite* msg) {
Set(ConstStringParam{str, size}, arena, donated, donating_states, mask, msg);
}
inline void InlinedStringField::SetBytes(ConstStringParam value, Arena* arena,
bool donated,
uint32_t* donating_states,
uint32_t mask, MessageLite* msg) {
Set(value, arena, donated, donating_states, mask, msg);
}
inline void InlinedStringField::SetBytes(std::string&& value, Arena* arena,
bool donated,
uint32_t* donating_states,
uint32_t mask, MessageLite* msg) {
Set(std::move(value), arena, donated, donating_states, mask, msg);
}
inline void InlinedStringField::SetBytes(const char* str,
::google::protobuf::Arena* arena, bool donated,
uint32_t* donating_states,
uint32_t mask, MessageLite* msg) {
Set(str, arena, donated, donating_states, mask, msg);
}
inline void InlinedStringField::SetBytes(const void* p, size_t size,
::google::protobuf::Arena* arena, bool donated,
uint32_t* donating_states,
uint32_t mask, MessageLite* msg) {
Set(static_cast<const char*>(p), size, arena, donated, donating_states, mask,
msg);
}
template <typename RefWrappedType>
inline void InlinedStringField::Set(
std::reference_wrapper<RefWrappedType> const_string_ref,
::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states,
uint32_t mask, MessageLite* msg) {
Set(const_string_ref.get(), arena, donated, donating_states, mask, msg);
}
template <typename RefWrappedType>
inline void InlinedStringField::SetBytes(
std::reference_wrapper<RefWrappedType> const_string_ref,
::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states,
uint32_t mask, MessageLite* msg) {
Set(const_string_ref.get(), arena, donated, donating_states, mask, msg);
} }
inline std::string* InlinedStringField::UnsafeMutablePointer() { inline std::string* InlinedStringField::UnsafeMutablePointer() {
return get_mutable(); return get_mutable();
} }
inline std::string* InlinedStringField::Mutable(std::nullptr_t) {
return get_mutable();
}
inline std::string* InlinedStringField::MutableNoCopy(std::nullptr_t) {
return get_mutable();
}
} // namespace internal } // namespace internal
} // namespace protobuf } // namespace protobuf
} // namespace google } // namespace google

@ -35,6 +35,7 @@
#include <cstring> #include <cstring>
#include <memory> #include <memory>
#include <string> #include <string>
#include <utility>
#include <vector> #include <vector>
#include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/logging.h>

@ -580,12 +580,12 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::IsInitialized(
template <typename Type> \ template <typename Type> \
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Merge( \ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Merge( \
const MapEntryAccessorType& from, TypeOnMemory* to, Arena* arena) { \ const MapEntryAccessorType& from, TypeOnMemory* to, Arena* arena) { \
to->Set(&internal::GetEmptyStringAlreadyInited(), from, arena); \ to->Set(from, arena); \
} \ } \
template <typename Type> \ template <typename Type> \
void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::DeleteNoArena( \ void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::DeleteNoArena( \
TypeOnMemory& value) { \ TypeOnMemory& value) { \
value.DestroyNoArena(&internal::GetEmptyStringAlreadyInited()); \ value.Destroy(); \
} \ } \
template <typename Type> \ template <typename Type> \
constexpr auto \ constexpr auto \
@ -598,7 +598,7 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::IsInitialized(
Type>::MapEntryAccessorType* \ Type>::MapEntryAccessorType* \
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::EnsureMutable( \ MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::EnsureMutable( \
TypeOnMemory* value, Arena* arena) { \ TypeOnMemory* value, Arena* arena) { \
return value->Mutable(ArenaStringPtr::EmptyDefault{}, arena); \ return value->Mutable(arena); \
} \ } \
template <typename Type> \ template <typename Type> \
inline const typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ inline const typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \

@ -41,7 +41,6 @@
#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/stubs/stringprintf.h>
#include <google/protobuf/parse_context.h> #include <google/protobuf/parse_context.h>
#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream.h>
@ -230,7 +229,7 @@ bool MessageLite::MergeFromImpl(io::CodedInputStream* input,
if (PROTOBUF_PREDICT_FALSE(!ptr)) return false; if (PROTOBUF_PREDICT_FALSE(!ptr)) return false;
ctx.BackUp(ptr); ctx.BackUp(ptr);
if (!ctx.EndedAtEndOfStream()) { if (!ctx.EndedAtEndOfStream()) {
GOOGLE_DCHECK(ctx.LastTag() != 1); // We can't end on a pushed limit. GOOGLE_DCHECK_NE(ctx.LastTag(), 1); // We can't end on a pushed limit.
if (ctx.IsExceedingLimit(ptr)) return false; if (ctx.IsExceedingLimit(ptr)) return false;
input->SetLastTag(ctx.LastTag()); input->SetLastTag(ctx.LastTag());
} else { } else {

@ -419,6 +419,29 @@ TEST(MESSAGE_TEST_NAME, ParseStrictlyBoundedStream) {
TestUtil::ExpectAllFieldsSet(p.child().payload()); TestUtil::ExpectAllFieldsSet(p.child().payload());
} }
TEST(MESSAGE_TEST_NAME, AllSetMethodsOnStringField) {
UNITTEST::TestAllTypes msg;
msg.set_optional_string("Asciiz");
EXPECT_EQ(msg.optional_string(), "Asciiz");
msg.set_optional_string("Length delimited", 6);
EXPECT_EQ(msg.optional_string(), "Length");
std::string value = "std::string value 1";
msg.set_optional_string(value);
EXPECT_EQ(msg.optional_string(), "std::string value 1");
value = "std::string value 2";
msg.set_optional_string(std::cref(value));
EXPECT_EQ(msg.optional_string(), "std::string value 2");
value = "std::string value 3";
msg.set_optional_string(std::move(value));
EXPECT_EQ(msg.optional_string(), "std::string value 3");
}
TEST(MESSAGE_TEST_NAME, SuccessAfterParsingFailure) { TEST(MESSAGE_TEST_NAME, SuccessAfterParsingFailure) {
UNITTEST::NestedTestAllTypes o, p, q; UNITTEST::NestedTestAllTypes o, p, q;
constexpr int kDepth = 5; constexpr int kDepth = 5;

@ -30,7 +30,6 @@
#include <google/protobuf/parse_context.h> #include <google/protobuf/parse_context.h>
#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/arenastring.h> #include <google/protobuf/arenastring.h>
@ -51,8 +50,8 @@ namespace {
// Only call if at start of tag. // Only call if at start of tag.
bool ParseEndsInSlopRegion(const char* begin, int overrun, int depth) { bool ParseEndsInSlopRegion(const char* begin, int overrun, int depth) {
constexpr int kSlopBytes = EpsCopyInputStream::kSlopBytes; constexpr int kSlopBytes = EpsCopyInputStream::kSlopBytes;
GOOGLE_DCHECK(overrun >= 0); GOOGLE_DCHECK_GE(overrun, 0);
GOOGLE_DCHECK(overrun <= kSlopBytes); GOOGLE_DCHECK_LE(overrun, kSlopBytes);
auto ptr = begin + overrun; auto ptr = begin + overrun;
auto end = begin + kSlopBytes; auto end = begin + kSlopBytes;
while (ptr < end) { while (ptr < end) {
@ -181,17 +180,17 @@ std::pair<const char*, bool> EpsCopyInputStream::DoneFallback(int overrun,
// if (ptr < limit_end_) return {ptr, false}; // if (ptr < limit_end_) return {ptr, false};
GOOGLE_DCHECK(limit_end_ == buffer_end_ + (std::min)(0, limit_)); GOOGLE_DCHECK(limit_end_ == buffer_end_ + (std::min)(0, limit_));
// At this point we know the following assertion holds. // At this point we know the following assertion holds.
GOOGLE_DCHECK(limit_ > 0); GOOGLE_DCHECK_GT(limit_, 0);
GOOGLE_DCHECK(limit_end_ == buffer_end_); // because limit_ > 0 GOOGLE_DCHECK(limit_end_ == buffer_end_); // because limit_ > 0
const char* p; const char* p;
do { do {
// We are past the end of buffer_end_, in the slop region. // We are past the end of buffer_end_, in the slop region.
GOOGLE_DCHECK(overrun >= 0); GOOGLE_DCHECK_GE(overrun, 0);
p = NextBuffer(overrun, depth); p = NextBuffer(overrun, depth);
if (p == nullptr) { if (p == nullptr) {
// We are at the end of the stream // We are at the end of the stream
if (PROTOBUF_PREDICT_FALSE(overrun != 0)) return {nullptr, true}; if (PROTOBUF_PREDICT_FALSE(overrun != 0)) return {nullptr, true};
GOOGLE_DCHECK(limit_ > 0); GOOGLE_DCHECK_GT(limit_, 0);
limit_end_ = buffer_end_; limit_end_ = buffer_end_;
// Distinguish ending on a pushed limit or ending on end-of-stream. // Distinguish ending on a pushed limit or ending on end-of-stream.
SetEndOfStream(); SetEndOfStream();

@ -423,16 +423,16 @@ void ReflectionOps::FindInitializationErrors(const Message& message,
void GenericSwap(Message* lhs, Message* rhs) { void GenericSwap(Message* lhs, Message* rhs) {
#ifndef PROTOBUF_FORCE_COPY_IN_SWAP #ifndef PROTOBUF_FORCE_COPY_IN_SWAP
GOOGLE_DCHECK(Arena::InternalHelper<Message>::GetOwningArena(lhs) != GOOGLE_DCHECK(Arena::InternalGetOwningArena(lhs) !=
Arena::InternalHelper<Message>::GetOwningArena(rhs)); Arena::InternalGetOwningArena(rhs));
GOOGLE_DCHECK(Arena::InternalHelper<Message>::GetOwningArena(lhs) != nullptr || GOOGLE_DCHECK(Arena::InternalGetOwningArena(lhs) != nullptr ||
Arena::InternalHelper<Message>::GetOwningArena(rhs) != nullptr); Arena::InternalGetOwningArena(rhs) != nullptr);
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP #endif // !PROTOBUF_FORCE_COPY_IN_SWAP
// At least one of these must have an arena, so make `rhs` point to it. // At least one of these must have an arena, so make `rhs` point to it.
Arena* arena = Arena::InternalHelper<Message>::GetOwningArena(rhs); Arena* arena = Arena::InternalGetOwningArena(rhs);
if (arena == nullptr) { if (arena == nullptr) {
std::swap(lhs, rhs); std::swap(lhs, rhs);
arena = Arena::InternalHelper<Message>::GetOwningArena(rhs); arena = Arena::InternalGetOwningArena(rhs);
} }
// Improve efficiency by placing the temporary on an arena so that messages // Improve efficiency by placing the temporary on an arena so that messages

@ -97,10 +97,10 @@ SourceContext::SourceContext(const SourceContext& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
file_name_.InitDefault(); file_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
file_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); file_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_file_name().empty()) { if (!from._internal_file_name().empty()) {
file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_file_name(), file_name_.Set(from._internal_file_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
// @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext) // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext)
@ -109,7 +109,7 @@ SourceContext::SourceContext(const SourceContext& from)
inline void SourceContext::SharedCtor() { inline void SourceContext::SharedCtor() {
file_name_.InitDefault(); file_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
file_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); file_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
} }
@ -124,7 +124,7 @@ SourceContext::~SourceContext() {
inline void SourceContext::SharedDtor() { inline void SourceContext::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
file_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); file_name_.Destroy();
} }
void SourceContext::SetCachedSize(int size) const { void SourceContext::SetCachedSize(int size) const {
@ -264,7 +264,6 @@ void SourceContext::InternalSwap(SourceContext* other) {
auto* rhs_arena = other->GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&file_name_, lhs_arena, &file_name_, lhs_arena,
&other->file_name_, rhs_arena &other->file_name_, rhs_arena
); );

@ -225,7 +225,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void SourceContext::set_file_name(ArgT0&& arg0, ArgT... args) { void SourceContext::set_file_name(ArgT0&& arg0, ArgT... args) {
file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); file_name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name) // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name)
} }
inline std::string* SourceContext::mutable_file_name() { inline std::string* SourceContext::mutable_file_name() {
@ -238,15 +238,15 @@ inline const std::string& SourceContext::_internal_file_name() const {
} }
inline void SourceContext::_internal_set_file_name(const std::string& value) { inline void SourceContext::_internal_set_file_name(const std::string& value) {
file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); file_name_.Set(value, GetArenaForAllocation());
} }
inline std::string* SourceContext::_internal_mutable_file_name() { inline std::string* SourceContext::_internal_mutable_file_name() {
return file_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return file_name_.Mutable(GetArenaForAllocation());
} }
inline std::string* SourceContext::release_file_name() { inline std::string* SourceContext::release_file_name() {
// @@protoc_insertion_point(field_release:google.protobuf.SourceContext.file_name) // @@protoc_insertion_point(field_release:google.protobuf.SourceContext.file_name)
return file_name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return file_name_.Release();
} }
inline void SourceContext::set_allocated_file_name(std::string* file_name) { inline void SourceContext::set_allocated_file_name(std::string* file_name) {
if (file_name != nullptr) { if (file_name != nullptr) {
@ -254,11 +254,10 @@ inline void SourceContext::set_allocated_file_name(std::string* file_name) {
} else { } else {
} }
file_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), file_name, file_name_.SetAllocated(file_name, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (file_name_.IsDefault()) { if (file_name_.IsDefault()) {
file_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); file_name_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name)

@ -416,7 +416,7 @@ void Value::set_allocated_struct_value(::PROTOBUF_NAMESPACE_ID::Struct* struct_v
clear_kind(); clear_kind();
if (struct_value) { if (struct_value) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::Struct>::GetOwningArena(struct_value); ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(struct_value);
if (message_arena != submessage_arena) { if (message_arena != submessage_arena) {
struct_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( struct_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, struct_value, submessage_arena); message_arena, struct_value, submessage_arena);
@ -431,7 +431,7 @@ void Value::set_allocated_list_value(::PROTOBUF_NAMESPACE_ID::ListValue* list_va
clear_kind(); clear_kind();
if (list_value) { if (list_value) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::ListValue>::GetOwningArena(list_value); ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(list_value);
if (message_arena != submessage_arena) { if (message_arena != submessage_arena) {
list_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( list_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, list_value, submessage_arena); message_arena, list_value, submessage_arena);
@ -519,7 +519,7 @@ void Value::clear_kind() {
break; break;
} }
case kStringValue: { case kStringValue: {
kind_.string_value_.Destroy(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); kind_.string_value_.Destroy();
break; break;
} }
case kBoolValue: { case kBoolValue: {

@ -828,7 +828,7 @@ inline void Value::set_has_string_value() {
} }
inline void Value::clear_string_value() { inline void Value::clear_string_value() {
if (_internal_has_string_value()) { if (_internal_has_string_value()) {
kind_.string_value_.Destroy(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); kind_.string_value_.Destroy();
clear_has_kind(); clear_has_kind();
} }
} }
@ -843,7 +843,7 @@ inline void Value::set_string_value(ArgT0&& arg0, ArgT... args) {
set_has_string_value(); set_has_string_value();
kind_.string_value_.InitDefault(); kind_.string_value_.InitDefault();
} }
kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); kind_.string_value_.Set( static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value)
} }
inline std::string* Value::mutable_string_value() { inline std::string* Value::mutable_string_value() {
@ -863,7 +863,7 @@ inline void Value::_internal_set_string_value(const std::string& value) {
set_has_string_value(); set_has_string_value();
kind_.string_value_.InitDefault(); kind_.string_value_.InitDefault();
} }
kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); kind_.string_value_.Set(value, GetArenaForAllocation());
} }
inline std::string* Value::_internal_mutable_string_value() { inline std::string* Value::_internal_mutable_string_value() {
if (!_internal_has_string_value()) { if (!_internal_has_string_value()) {
@ -871,14 +871,13 @@ inline std::string* Value::_internal_mutable_string_value() {
set_has_string_value(); set_has_string_value();
kind_.string_value_.InitDefault(); kind_.string_value_.InitDefault();
} }
return kind_.string_value_.Mutable( return kind_.string_value_.Mutable( GetArenaForAllocation());
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
} }
inline std::string* Value::release_string_value() { inline std::string* Value::release_string_value() {
// @@protoc_insertion_point(field_release:google.protobuf.Value.string_value) // @@protoc_insertion_point(field_release:google.protobuf.Value.string_value)
if (_internal_has_string_value()) { if (_internal_has_string_value()) {
clear_has_kind(); clear_has_kind();
return kind_.string_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return kind_.string_value_.Release();
} else { } else {
return nullptr; return nullptr;
} }

@ -376,10 +376,10 @@ Type::Type(const Type& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
if (from._internal_has_source_context()) { if (from._internal_has_source_context()) {
@ -394,7 +394,7 @@ Type::Type(const Type& from)
inline void Type::SharedCtor() { inline void Type::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&source_context_) - reinterpret_cast<char*>(this)), reinterpret_cast<char*>(&source_context_) - reinterpret_cast<char*>(this)),
@ -413,7 +413,7 @@ Type::~Type() {
inline void Type::SharedDtor() { inline void Type::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
if (this != internal_default_instance()) delete source_context_; if (this != internal_default_instance()) delete source_context_;
} }
@ -707,7 +707,6 @@ void Type::InternalSwap(Type* other) {
oneofs_.InternalSwap(&other->oneofs_); oneofs_.InternalSwap(&other->oneofs_);
options_.InternalSwap(&other->options_); options_.InternalSwap(&other->options_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
@ -744,34 +743,34 @@ Field::Field(const Field& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
type_url_.InitDefault(); type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_type_url().empty()) { if (!from._internal_type_url().empty()) {
type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_url(), type_url_.Set(from._internal_type_url(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
json_name_.InitDefault(); json_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); json_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_json_name().empty()) { if (!from._internal_json_name().empty()) {
json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_json_name(), json_name_.Set(from._internal_json_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
default_value_.InitDefault(); default_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); default_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_default_value().empty()) { if (!from._internal_default_value().empty()) {
default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_default_value(), default_value_.Set(from._internal_default_value(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
::memcpy(&kind_, &from.kind_, ::memcpy(&kind_, &from.kind_,
@ -783,19 +782,19 @@ Field::Field(const Field& from)
inline void Field::SharedCtor() { inline void Field::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
type_url_.InitDefault(); type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); type_url_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
json_name_.InitDefault(); json_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); json_name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
default_value_.InitDefault(); default_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); default_value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&kind_) - reinterpret_cast<char*>(this)), reinterpret_cast<char*>(&kind_) - reinterpret_cast<char*>(this)),
@ -814,10 +813,10 @@ Field::~Field() {
inline void Field::SharedDtor() { inline void Field::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); type_url_.Destroy();
json_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); json_name_.Destroy();
default_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); default_value_.Destroy();
} }
void Field::SetCachedSize(int size) const { void Field::SetCachedSize(int size) const {
@ -1200,22 +1199,18 @@ void Field::InternalSwap(Field* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
options_.InternalSwap(&other->options_); options_.InternalSwap(&other->options_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&type_url_, lhs_arena, &type_url_, lhs_arena,
&other->type_url_, rhs_arena &other->type_url_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&json_name_, lhs_arena, &json_name_, lhs_arena,
&other->json_name_, rhs_arena &other->json_name_, rhs_arena
); );
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&default_value_, lhs_arena, &default_value_, lhs_arena,
&other->default_value_, rhs_arena &other->default_value_, rhs_arena
); );
@ -1265,10 +1260,10 @@ Enum::Enum(const Enum& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
if (from._internal_has_source_context()) { if (from._internal_has_source_context()) {
@ -1283,7 +1278,7 @@ Enum::Enum(const Enum& from)
inline void Enum::SharedCtor() { inline void Enum::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&source_context_) - reinterpret_cast<char*>(this)), reinterpret_cast<char*>(&source_context_) - reinterpret_cast<char*>(this)),
@ -1302,7 +1297,7 @@ Enum::~Enum() {
inline void Enum::SharedDtor() { inline void Enum::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
if (this != internal_default_instance()) delete source_context_; if (this != internal_default_instance()) delete source_context_;
} }
@ -1560,7 +1555,6 @@ void Enum::InternalSwap(Enum* other) {
enumvalue_.InternalSwap(&other->enumvalue_); enumvalue_.InternalSwap(&other->enumvalue_);
options_.InternalSwap(&other->options_); options_.InternalSwap(&other->options_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
@ -1597,10 +1591,10 @@ EnumValue::EnumValue(const EnumValue& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
number_ = from.number_; number_ = from.number_;
@ -1610,7 +1604,7 @@ EnumValue::EnumValue(const EnumValue& from)
inline void EnumValue::SharedCtor() { inline void EnumValue::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
number_ = 0; number_ = 0;
} }
@ -1626,7 +1620,7 @@ EnumValue::~EnumValue() {
inline void EnumValue::SharedDtor() { inline void EnumValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
} }
void EnumValue::SetCachedSize(int size) const { void EnumValue::SetCachedSize(int size) const {
@ -1820,7 +1814,6 @@ void EnumValue::InternalSwap(EnumValue* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
options_.InternalSwap(&other->options_); options_.InternalSwap(&other->options_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );
@ -1861,10 +1854,10 @@ Option::Option(const Option& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) { if (!from._internal_name().empty()) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), name_.Set(from._internal_name(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
if (from._internal_has_value()) { if (from._internal_has_value()) {
@ -1878,7 +1871,7 @@ Option::Option(const Option& from)
inline void Option::SharedCtor() { inline void Option::SharedCtor() {
name_.InitDefault(); name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
value_ = nullptr; value_ = nullptr;
} }
@ -1894,7 +1887,7 @@ Option::~Option() {
inline void Option::SharedDtor() { inline void Option::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); name_.Destroy();
if (this != internal_default_instance()) delete value_; if (this != internal_default_instance()) delete value_;
} }
@ -2064,7 +2057,6 @@ void Option::InternalSwap(Option* other) {
auto* rhs_arena = other->GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&name_, lhs_arena, &name_, lhs_arena,
&other->name_, rhs_arena &other->name_, rhs_arena
); );

@ -1370,7 +1370,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Type::set_name(ArgT0&& arg0, ArgT... args) { void Type::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Type.name) // @@protoc_insertion_point(field_set:google.protobuf.Type.name)
} }
inline std::string* Type::mutable_name() { inline std::string* Type::mutable_name() {
@ -1383,15 +1383,15 @@ inline const std::string& Type::_internal_name() const {
} }
inline void Type::_internal_set_name(const std::string& value) { inline void Type::_internal_set_name(const std::string& value) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); name_.Set(value, GetArenaForAllocation());
} }
inline std::string* Type::_internal_mutable_name() { inline std::string* Type::_internal_mutable_name() {
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return name_.Mutable(GetArenaForAllocation());
} }
inline std::string* Type::release_name() { inline std::string* Type::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Type.name) // @@protoc_insertion_point(field_release:google.protobuf.Type.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return name_.Release();
} }
inline void Type::set_allocated_name(std::string* name) { inline void Type::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -1399,11 +1399,10 @@ inline void Type::set_allocated_name(std::string* name) {
} else { } else {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(name, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (name_.IsDefault()) { if (name_.IsDefault()) {
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.name)
@ -1635,8 +1634,7 @@ inline void Type::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceCo
} }
if (source_context) { if (source_context) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper< ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(
::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena(
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context)); reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context));
if (message_arena != submessage_arena) { if (message_arena != submessage_arena) {
source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
@ -1746,7 +1744,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Field::set_name(ArgT0&& arg0, ArgT... args) { void Field::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.name) // @@protoc_insertion_point(field_set:google.protobuf.Field.name)
} }
inline std::string* Field::mutable_name() { inline std::string* Field::mutable_name() {
@ -1759,15 +1757,15 @@ inline const std::string& Field::_internal_name() const {
} }
inline void Field::_internal_set_name(const std::string& value) { inline void Field::_internal_set_name(const std::string& value) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); name_.Set(value, GetArenaForAllocation());
} }
inline std::string* Field::_internal_mutable_name() { inline std::string* Field::_internal_mutable_name() {
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return name_.Mutable(GetArenaForAllocation());
} }
inline std::string* Field::release_name() { inline std::string* Field::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.name) // @@protoc_insertion_point(field_release:google.protobuf.Field.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return name_.Release();
} }
inline void Field::set_allocated_name(std::string* name) { inline void Field::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -1775,11 +1773,10 @@ inline void Field::set_allocated_name(std::string* name) {
} else { } else {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(name, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (name_.IsDefault()) { if (name_.IsDefault()) {
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.name)
@ -1797,7 +1794,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Field::set_type_url(ArgT0&& arg0, ArgT... args) { void Field::set_type_url(ArgT0&& arg0, ArgT... args) {
type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.type_url) // @@protoc_insertion_point(field_set:google.protobuf.Field.type_url)
} }
inline std::string* Field::mutable_type_url() { inline std::string* Field::mutable_type_url() {
@ -1810,15 +1807,15 @@ inline const std::string& Field::_internal_type_url() const {
} }
inline void Field::_internal_set_type_url(const std::string& value) { inline void Field::_internal_set_type_url(const std::string& value) {
type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); type_url_.Set(value, GetArenaForAllocation());
} }
inline std::string* Field::_internal_mutable_type_url() { inline std::string* Field::_internal_mutable_type_url() {
return type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return type_url_.Mutable(GetArenaForAllocation());
} }
inline std::string* Field::release_type_url() { inline std::string* Field::release_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.type_url) // @@protoc_insertion_point(field_release:google.protobuf.Field.type_url)
return type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return type_url_.Release();
} }
inline void Field::set_allocated_type_url(std::string* type_url) { inline void Field::set_allocated_type_url(std::string* type_url) {
if (type_url != nullptr) { if (type_url != nullptr) {
@ -1826,11 +1823,10 @@ inline void Field::set_allocated_type_url(std::string* type_url) {
} else { } else {
} }
type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_url, type_url_.SetAllocated(type_url, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (type_url_.IsDefault()) { if (type_url_.IsDefault()) {
type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); type_url_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.type_url) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.type_url)
@ -1928,7 +1924,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Field::set_json_name(ArgT0&& arg0, ArgT... args) { void Field::set_json_name(ArgT0&& arg0, ArgT... args) {
json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); json_name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.json_name) // @@protoc_insertion_point(field_set:google.protobuf.Field.json_name)
} }
inline std::string* Field::mutable_json_name() { inline std::string* Field::mutable_json_name() {
@ -1941,15 +1937,15 @@ inline const std::string& Field::_internal_json_name() const {
} }
inline void Field::_internal_set_json_name(const std::string& value) { inline void Field::_internal_set_json_name(const std::string& value) {
json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); json_name_.Set(value, GetArenaForAllocation());
} }
inline std::string* Field::_internal_mutable_json_name() { inline std::string* Field::_internal_mutable_json_name() {
return json_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return json_name_.Mutable(GetArenaForAllocation());
} }
inline std::string* Field::release_json_name() { inline std::string* Field::release_json_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.json_name) // @@protoc_insertion_point(field_release:google.protobuf.Field.json_name)
return json_name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return json_name_.Release();
} }
inline void Field::set_allocated_json_name(std::string* json_name) { inline void Field::set_allocated_json_name(std::string* json_name) {
if (json_name != nullptr) { if (json_name != nullptr) {
@ -1957,11 +1953,10 @@ inline void Field::set_allocated_json_name(std::string* json_name) {
} else { } else {
} }
json_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), json_name, json_name_.SetAllocated(json_name, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (json_name_.IsDefault()) { if (json_name_.IsDefault()) {
json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); json_name_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name)
@ -1979,7 +1974,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Field::set_default_value(ArgT0&& arg0, ArgT... args) { void Field::set_default_value(ArgT0&& arg0, ArgT... args) {
default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); default_value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.default_value) // @@protoc_insertion_point(field_set:google.protobuf.Field.default_value)
} }
inline std::string* Field::mutable_default_value() { inline std::string* Field::mutable_default_value() {
@ -1992,15 +1987,15 @@ inline const std::string& Field::_internal_default_value() const {
} }
inline void Field::_internal_set_default_value(const std::string& value) { inline void Field::_internal_set_default_value(const std::string& value) {
default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); default_value_.Set(value, GetArenaForAllocation());
} }
inline std::string* Field::_internal_mutable_default_value() { inline std::string* Field::_internal_mutable_default_value() {
return default_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return default_value_.Mutable(GetArenaForAllocation());
} }
inline std::string* Field::release_default_value() { inline std::string* Field::release_default_value() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.default_value) // @@protoc_insertion_point(field_release:google.protobuf.Field.default_value)
return default_value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return default_value_.Release();
} }
inline void Field::set_allocated_default_value(std::string* default_value) { inline void Field::set_allocated_default_value(std::string* default_value) {
if (default_value != nullptr) { if (default_value != nullptr) {
@ -2008,11 +2003,10 @@ inline void Field::set_allocated_default_value(std::string* default_value) {
} else { } else {
} }
default_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), default_value, default_value_.SetAllocated(default_value, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (default_value_.IsDefault()) { if (default_value_.IsDefault()) {
default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); default_value_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.default_value) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.default_value)
@ -2034,7 +2028,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Enum::set_name(ArgT0&& arg0, ArgT... args) { void Enum::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Enum.name) // @@protoc_insertion_point(field_set:google.protobuf.Enum.name)
} }
inline std::string* Enum::mutable_name() { inline std::string* Enum::mutable_name() {
@ -2047,15 +2041,15 @@ inline const std::string& Enum::_internal_name() const {
} }
inline void Enum::_internal_set_name(const std::string& value) { inline void Enum::_internal_set_name(const std::string& value) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); name_.Set(value, GetArenaForAllocation());
} }
inline std::string* Enum::_internal_mutable_name() { inline std::string* Enum::_internal_mutable_name() {
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return name_.Mutable(GetArenaForAllocation());
} }
inline std::string* Enum::release_name() { inline std::string* Enum::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Enum.name) // @@protoc_insertion_point(field_release:google.protobuf.Enum.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return name_.Release();
} }
inline void Enum::set_allocated_name(std::string* name) { inline void Enum::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -2063,11 +2057,10 @@ inline void Enum::set_allocated_name(std::string* name) {
} else { } else {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(name, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (name_.IsDefault()) { if (name_.IsDefault()) {
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.name)
@ -2224,8 +2217,7 @@ inline void Enum::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceCo
} }
if (source_context) { if (source_context) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper< ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(
::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena(
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context)); reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context));
if (message_arena != submessage_arena) { if (message_arena != submessage_arena) {
source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
@ -2275,7 +2267,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void EnumValue::set_name(ArgT0&& arg0, ArgT... args) { void EnumValue::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name) // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name)
} }
inline std::string* EnumValue::mutable_name() { inline std::string* EnumValue::mutable_name() {
@ -2288,15 +2280,15 @@ inline const std::string& EnumValue::_internal_name() const {
} }
inline void EnumValue::_internal_set_name(const std::string& value) { inline void EnumValue::_internal_set_name(const std::string& value) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); name_.Set(value, GetArenaForAllocation());
} }
inline std::string* EnumValue::_internal_mutable_name() { inline std::string* EnumValue::_internal_mutable_name() {
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return name_.Mutable(GetArenaForAllocation());
} }
inline std::string* EnumValue::release_name() { inline std::string* EnumValue::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.EnumValue.name) // @@protoc_insertion_point(field_release:google.protobuf.EnumValue.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return name_.Release();
} }
inline void EnumValue::set_allocated_name(std::string* name) { inline void EnumValue::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -2304,11 +2296,10 @@ inline void EnumValue::set_allocated_name(std::string* name) {
} else { } else {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(name, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (name_.IsDefault()) { if (name_.IsDefault()) {
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name)
@ -2390,7 +2381,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void Option::set_name(ArgT0&& arg0, ArgT... args) { void Option::set_name(ArgT0&& arg0, ArgT... args) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Option.name) // @@protoc_insertion_point(field_set:google.protobuf.Option.name)
} }
inline std::string* Option::mutable_name() { inline std::string* Option::mutable_name() {
@ -2403,15 +2394,15 @@ inline const std::string& Option::_internal_name() const {
} }
inline void Option::_internal_set_name(const std::string& value) { inline void Option::_internal_set_name(const std::string& value) {
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); name_.Set(value, GetArenaForAllocation());
} }
inline std::string* Option::_internal_mutable_name() { inline std::string* Option::_internal_mutable_name() {
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return name_.Mutable(GetArenaForAllocation());
} }
inline std::string* Option::release_name() { inline std::string* Option::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Option.name) // @@protoc_insertion_point(field_release:google.protobuf.Option.name)
return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return name_.Release();
} }
inline void Option::set_allocated_name(std::string* name) { inline void Option::set_allocated_name(std::string* name) {
if (name != nullptr) { if (name != nullptr) {
@ -2419,11 +2410,10 @@ inline void Option::set_allocated_name(std::string* name) {
} else { } else {
} }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, name_.SetAllocated(name, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (name_.IsDefault()) { if (name_.IsDefault()) {
name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); name_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.name) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.name)
@ -2500,8 +2490,7 @@ inline void Option::set_allocated_value(::PROTOBUF_NAMESPACE_ID::Any* value) {
} }
if (value) { if (value) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper< ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(
::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena(
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(value)); reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(value));
if (message_arena != submessage_arena) { if (message_arena != submessage_arena) {
value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(

@ -41,10 +41,10 @@
#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/stubs/stringprintf.h>
#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h> #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/stubs/stringprintf.h>
// Must be included last. // Must be included last.

@ -1492,10 +1492,10 @@ StringValue::StringValue(const StringValue& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
value_.InitDefault(); value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_value().empty()) { if (!from._internal_value().empty()) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(), value_.Set(from._internal_value(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
// @@protoc_insertion_point(copy_constructor:google.protobuf.StringValue) // @@protoc_insertion_point(copy_constructor:google.protobuf.StringValue)
@ -1504,7 +1504,7 @@ StringValue::StringValue(const StringValue& from)
inline void StringValue::SharedCtor() { inline void StringValue::SharedCtor() {
value_.InitDefault(); value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
} }
@ -1519,7 +1519,7 @@ StringValue::~StringValue() {
inline void StringValue::SharedDtor() { inline void StringValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); value_.Destroy();
} }
void StringValue::SetCachedSize(int size) const { void StringValue::SetCachedSize(int size) const {
@ -1659,7 +1659,6 @@ void StringValue::InternalSwap(StringValue* other) {
auto* rhs_arena = other->GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&value_, lhs_arena, &value_, lhs_arena,
&other->value_, rhs_arena &other->value_, rhs_arena
); );
@ -1688,10 +1687,10 @@ BytesValue::BytesValue(const BytesValue& from)
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
value_.InitDefault(); value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_value().empty()) { if (!from._internal_value().empty()) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(), value_.Set(from._internal_value(),
GetArenaForAllocation()); GetArenaForAllocation());
} }
// @@protoc_insertion_point(copy_constructor:google.protobuf.BytesValue) // @@protoc_insertion_point(copy_constructor:google.protobuf.BytesValue)
@ -1700,7 +1699,7 @@ BytesValue::BytesValue(const BytesValue& from)
inline void BytesValue::SharedCtor() { inline void BytesValue::SharedCtor() {
value_.InitDefault(); value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); value_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
} }
@ -1715,7 +1714,7 @@ BytesValue::~BytesValue() {
inline void BytesValue::SharedDtor() { inline void BytesValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); value_.Destroy();
} }
void BytesValue::SetCachedSize(int size) const { void BytesValue::SetCachedSize(int size) const {
@ -1850,7 +1849,6 @@ void BytesValue::InternalSwap(BytesValue* other) {
auto* rhs_arena = other->GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&value_, lhs_arena, &value_, lhs_arena,
&other->value_, rhs_arena &other->value_, rhs_arena
); );

@ -1574,7 +1574,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void StringValue::set_value(ArgT0&& arg0, ArgT... args) { void StringValue::set_value(ArgT0&& arg0, ArgT... args) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.StringValue.value) // @@protoc_insertion_point(field_set:google.protobuf.StringValue.value)
} }
inline std::string* StringValue::mutable_value() { inline std::string* StringValue::mutable_value() {
@ -1587,15 +1587,15 @@ inline const std::string& StringValue::_internal_value() const {
} }
inline void StringValue::_internal_set_value(const std::string& value) { inline void StringValue::_internal_set_value(const std::string& value) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); value_.Set(value, GetArenaForAllocation());
} }
inline std::string* StringValue::_internal_mutable_value() { inline std::string* StringValue::_internal_mutable_value() {
return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return value_.Mutable(GetArenaForAllocation());
} }
inline std::string* StringValue::release_value() { inline std::string* StringValue::release_value() {
// @@protoc_insertion_point(field_release:google.protobuf.StringValue.value) // @@protoc_insertion_point(field_release:google.protobuf.StringValue.value)
return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return value_.Release();
} }
inline void StringValue::set_allocated_value(std::string* value) { inline void StringValue::set_allocated_value(std::string* value) {
if (value != nullptr) { if (value != nullptr) {
@ -1603,11 +1603,10 @@ inline void StringValue::set_allocated_value(std::string* value) {
} else { } else {
} }
value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, value_.SetAllocated(value, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (value_.IsDefault()) { if (value_.IsDefault()) {
value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); value_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.StringValue.value) // @@protoc_insertion_point(field_set_allocated:google.protobuf.StringValue.value)
@ -1629,7 +1628,7 @@ template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE inline PROTOBUF_ALWAYS_INLINE
void BytesValue::set_value(ArgT0&& arg0, ArgT... args) { void BytesValue::set_value(ArgT0&& arg0, ArgT... args) {
value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); value_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.BytesValue.value) // @@protoc_insertion_point(field_set:google.protobuf.BytesValue.value)
} }
inline std::string* BytesValue::mutable_value() { inline std::string* BytesValue::mutable_value() {
@ -1642,15 +1641,15 @@ inline const std::string& BytesValue::_internal_value() const {
} }
inline void BytesValue::_internal_set_value(const std::string& value) { inline void BytesValue::_internal_set_value(const std::string& value) {
value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); value_.Set(value, GetArenaForAllocation());
} }
inline std::string* BytesValue::_internal_mutable_value() { inline std::string* BytesValue::_internal_mutable_value() {
return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); return value_.Mutable(GetArenaForAllocation());
} }
inline std::string* BytesValue::release_value() { inline std::string* BytesValue::release_value() {
// @@protoc_insertion_point(field_release:google.protobuf.BytesValue.value) // @@protoc_insertion_point(field_release:google.protobuf.BytesValue.value)
return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); return value_.Release();
} }
inline void BytesValue::set_allocated_value(std::string* value) { inline void BytesValue::set_allocated_value(std::string* value) {
if (value != nullptr) { if (value != nullptr) {
@ -1658,11 +1657,10 @@ inline void BytesValue::set_allocated_value(std::string* value) {
} else { } else {
} }
value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, value_.SetAllocated(value, GetArenaForAllocation());
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (value_.IsDefault()) { if (value_.IsDefault()) {
value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); value_.Set("", GetArenaForAllocation());
} }
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.BytesValue.value) // @@protoc_insertion_point(field_set_allocated:google.protobuf.BytesValue.value)

Loading…
Cancel
Save