Browse Source

Merge branch 'master' into 3.15.x

Adam Cozzette 4 years ago
parent
commit
673971834c
100 changed files with 1529 additions and 1815 deletions
  1. 15 0
      CHANGES.txt
  2. 3 1
      cmake/install.cmake
  3. 1 1
      conformance/binary_json_conformance_suite.cc
  4. 3 0
      conformance/conformance_cpp.cc
  5. 2 2
      conformance/conformance_test_runner.cc
  6. 1 1
      csharp/install_dotnet_sdk.ps1
  7. 1 1
      csharp/src/Google.Protobuf.Benchmarks/Google.Protobuf.Benchmarks.csproj
  8. 192 40
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs
  9. 6 6
      csharp/src/Google.Protobuf.Test/Buffers/ArrayBufferWriter.cs
  10. 50 11
      csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs
  11. 1 1
      csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
  12. 4 0
      csharp/src/Google.Protobuf.Test/JsonParserTest.cs
  13. 4 0
      csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs
  14. 1 1
      csharp/src/Google.Protobuf.Test/LegacyGeneratedCodeTest.cs
  15. 3 3
      csharp/src/Google.Protobuf.Test/MessageParsingHelpers.cs
  16. BIN
      csharp/src/Google.Protobuf.Test/testprotos.pb
  17. 12 4
      csharp/src/Google.Protobuf/Google.Protobuf.csproj
  18. 110 7
      csharp/src/Google.Protobuf/WritingPrimitives.cs
  19. 18 0
      docs/jvm_aot.md
  20. 2 2
      docs/options.md
  21. 1 1
      global.json
  22. 2 2
      java/README.md
  23. 43 4
      java/core/src/main/java/com/google/protobuf/CodedInputStream.java
  24. 1 1
      java/core/src/main/java/com/google/protobuf/FieldSet.java
  25. 18 3
      java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
  26. 23 0
      java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java
  27. 1 1
      java/core/src/main/java/com/google/protobuf/UnsafeUtil.java
  28. 1 0
      java/lite/generate-test-sources-build.xml
  29. 156 0
      java/lite/src/test/java/com/google/protobuf/LiteTest.java
  30. 2 2
      java/pom.xml
  31. 7 3
      kokoro/linux/dockerfile/test/csharp/Dockerfile
  32. 0 17
      kokoro/linux/python/build.sh
  33. 0 11
      kokoro/linux/python/continuous.cfg
  34. 0 11
      kokoro/linux/python/presubmit.cfg
  35. 25 24
      objectivec/GPBExtensionRegistry.m
  36. 2 2
      php/README.md
  37. 5 5
      php/src/Google/Protobuf/Internal/RepeatedField.php
  38. 1 8
      python/google/protobuf/internal/message_test.py
  39. 0 6
      python/google/protobuf/internal/python_message.py
  40. 1 1
      python/google/protobuf/pyext/descriptor.cc
  41. 2 2
      python/google/protobuf/pyext/descriptor_pool.cc
  42. 4 4
      python/google/protobuf/pyext/map_container.cc
  43. 11 11
      python/google/protobuf/pyext/message.cc
  44. 1 1
      python/google/protobuf/pyext/message.h
  45. 2 2
      python/google/protobuf/pyext/message_factory.cc
  46. 0 2
      python/setup.py
  47. 3 4
      python/tox.ini
  48. 5 6
      src/google/protobuf/any.pb.cc
  49. 16 59
      src/google/protobuf/any.pb.h
  50. 11 10
      src/google/protobuf/api.pb.cc
  51. 55 200
      src/google/protobuf/api.pb.h
  52. 28 0
      src/google/protobuf/arenastring.h
  53. 1 20
      src/google/protobuf/compiler/command_line_interface.cc
  54. 0 8
      src/google/protobuf/compiler/command_line_interface.h
  55. 0 1
      src/google/protobuf/compiler/command_line_interface_unittest.cc
  56. 15 15
      src/google/protobuf/compiler/cpp/cpp_file.cc
  57. 14 25
      src/google/protobuf/compiler/cpp/cpp_message.cc
  58. 0 8
      src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc
  59. 19 99
      src/google/protobuf/compiler/cpp/cpp_string_field.cc
  60. 1 0
      src/google/protobuf/compiler/java/java_context.cc
  61. 6 2
      src/google/protobuf/compiler/java/java_map_field_lite.cc
  62. 1 0
      src/google/protobuf/compiler/java/java_message.cc
  63. 2 1
      src/google/protobuf/compiler/java/java_primitive_field_lite.cc
  64. 2 1
      src/google/protobuf/compiler/java/java_string_field_lite.cc
  65. 14 12
      src/google/protobuf/compiler/plugin.pb.cc
  66. 50 183
      src/google/protobuf/compiler/plugin.pb.h
  67. 83 58
      src/google/protobuf/descriptor.pb.cc
  68. 108 307
      src/google/protobuf/descriptor.pb.h
  69. 5 6
      src/google/protobuf/duration.pb.cc
  70. 2 9
      src/google/protobuf/duration.pb.h
  71. 5 6
      src/google/protobuf/empty.pb.cc
  72. 2 9
      src/google/protobuf/empty.pb.h
  73. 5 6
      src/google/protobuf/field_mask.pb.cc
  74. 2 9
      src/google/protobuf/field_mask.pb.h
  75. 11 0
      src/google/protobuf/generated_message_reflection.cc
  76. 8 0
      src/google/protobuf/generated_message_reflection.h
  77. 12 11
      src/google/protobuf/io/coded_stream.h
  78. 4 2
      src/google/protobuf/metadata_lite.h
  79. 0 1
      src/google/protobuf/parse_context.h
  80. 6 4
      src/google/protobuf/port_def.inc
  81. 29 0
      src/google/protobuf/proto3_arena_unittest.cc
  82. 9 0
      src/google/protobuf/repeated_field.cc
  83. 37 28
      src/google/protobuf/repeated_field.h
  84. 5 6
      src/google/protobuf/source_context.pb.cc
  85. 9 34
      src/google/protobuf/source_context.pb.h
  86. 14 11
      src/google/protobuf/struct.pb.cc
  87. 16 73
      src/google/protobuf/struct.pb.h
  88. 2 0
      src/google/protobuf/stubs/port.h
  89. 0 43
      src/google/protobuf/stubs/stringpiece.h
  90. 0 3
      src/google/protobuf/stubs/strutil.h
  91. 5 6
      src/google/protobuf/timestamp.pb.cc
  92. 2 9
      src/google/protobuf/timestamp.pb.h
  93. 17 14
      src/google/protobuf/type.pb.cc
  94. 66 241
      src/google/protobuf/type.pb.h
  95. 5 0
      src/google/protobuf/unittest_lite.proto
  96. 12 0
      src/google/protobuf/unittest_proto3_optional.proto
  97. 7 5
      src/google/protobuf/util/internal/constants.h
  98. 28 25
      src/google/protobuf/util/internal/datapiece.cc
  99. 17 18
      src/google/protobuf/util/internal/datapiece.h
  100. 15 12
      src/google/protobuf/util/internal/default_value_objectwriter.cc

+ 15 - 0
CHANGES.txt

@@ -1,3 +1,18 @@
+Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
+
+  C++
+  * Allow MessageDifferencer::TreatAsSet() (and friends) to override previous
+    calls instead of crashing.
+  * Reduce the size of generated proto headers for protos with `string` or
+    `bytes` fields.
+  * Move arena() operation on uncommon path to out-of-line routine
+  * For iterator-pair function parameter types, take both iterators by value.
+  * Code-space savings and perhaps some modest performance improvements in
+    RepeatedPtrField.
+
+  Java:
+  * Exceptions thrown while reading from an InputStream in parseFrom are now included as causes.
+
 2021-03-04 version 3.15.5 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
 2021-03-04 version 3.15.5 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
 
 
   Ruby
   Ruby

+ 3 - 1
cmake/install.cmake

@@ -30,7 +30,9 @@ endforeach()
 
 
 if (protobuf_BUILD_PROTOC_BINARIES)
 if (protobuf_BUILD_PROTOC_BINARIES)
   install(TARGETS protoc EXPORT protobuf-targets
   install(TARGETS protoc EXPORT protobuf-targets
-    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc)
+    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+    BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
+    COMPONENT protoc)
   if (UNIX AND NOT APPLE)
   if (UNIX AND NOT APPLE)
     set_property(TARGET protoc
     set_property(TARGET protoc
       PROPERTY INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
       PROPERTY INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")

+ 1 - 1
conformance/binary_json_conformance_suite.cc

@@ -300,7 +300,7 @@ const FieldDescriptor* GetFieldForOneofType(FieldDescriptor::Type type,
 }
 }
 
 
 string UpperCase(string str) {
 string UpperCase(string str) {
-  for (int i = 0; i < str.size(); i++) {
+  for (size_t i = 0; i < str.size(); i++) {
     str[i] = toupper(str[i]);
     str[i] = toupper(str[i]);
   }
   }
   return str;
   return str;

+ 3 - 0
conformance/conformance_cpp.cc

@@ -55,6 +55,7 @@ using google::protobuf::util::JsonToBinaryString;
 using google::protobuf::util::NewTypeResolverForDescriptorPool;
 using google::protobuf::util::NewTypeResolverForDescriptorPool;
 using google::protobuf::util::TypeResolver;
 using google::protobuf::util::TypeResolver;
 using protobuf_test_messages::proto3::TestAllTypesProto3;
 using protobuf_test_messages::proto3::TestAllTypesProto3;
+using protobuf_test_messages::proto2::TestAllTypesProto2;
 using std::string;
 using std::string;
 
 
 static const char kTypeUrlPrefix[] = "type.googleapis.com";
 static const char kTypeUrlPrefix[] = "type.googleapis.com";
@@ -102,6 +103,8 @@ void CheckedWrite(int fd, const void *buf, size_t len) {
 
 
 void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
 void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
   Message *test_message;
   Message *test_message;
+  google::protobuf::LinkMessageReflection<TestAllTypesProto2>();
+  google::protobuf::LinkMessageReflection<TestAllTypesProto3>();
   const Descriptor *descriptor = DescriptorPool::generated_pool()->FindMessageTypeByName(
   const Descriptor *descriptor = DescriptorPool::generated_pool()->FindMessageTypeByName(
       request.message_type());
       request.message_type());
   if (!descriptor) {
   if (!descriptor) {

+ 2 - 2
conformance/conformance_test_runner.cc

@@ -297,7 +297,7 @@ void ForkPipeRunner::SpawnTestProgram() {
 
 
     std::vector<const char *> argv;
     std::vector<const char *> argv;
     argv.push_back(executable.get());
     argv.push_back(executable.get());
-    for (int i = 0; i < executable_args_.size(); ++i) {
+    for (size_t i = 0; i < executable_args_.size(); ++i) {
       argv.push_back(executable_args_[i].c_str());
       argv.push_back(executable_args_[i].c_str());
     }
     }
     argv.push_back(nullptr);
     argv.push_back(nullptr);
@@ -307,7 +307,7 @@ void ForkPipeRunner::SpawnTestProgram() {
 }
 }
 
 
 void ForkPipeRunner::CheckedWrite(int fd, const void *buf, size_t len) {
 void ForkPipeRunner::CheckedWrite(int fd, const void *buf, size_t len) {
-  if (write(fd, buf, len) != len) {
+  if (static_cast<size_t>(write(fd, buf, len)) != len) {
     GOOGLE_LOG(FATAL) << current_test_name_
     GOOGLE_LOG(FATAL) << current_test_name_
                << ": error writing to test program: " << strerror(errno);
                << ": error writing to test program: " << strerror(errno);
   }
   }

+ 1 - 1
csharp/install_dotnet_sdk.ps1

@@ -17,4 +17,4 @@ Invoke-WebRequest -Uri $InstallScriptUrl -OutFile $InstallScriptPath
 # The SDK versions to install should be kept in sync with versions
 # The SDK versions to install should be kept in sync with versions
 # installed by kokoro/linux/dockerfile/test/csharp/Dockerfile
 # installed by kokoro/linux/dockerfile/test/csharp/Dockerfile
 &$InstallScriptPath -Version 2.1.802
 &$InstallScriptPath -Version 2.1.802
-&$InstallScriptPath -Version 3.1.301
+&$InstallScriptPath -Version 5.0.102

+ 1 - 1
csharp/src/Google.Protobuf.Benchmarks/Google.Protobuf.Benchmarks.csproj

@@ -2,7 +2,7 @@
 
 
   <PropertyGroup>
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <OutputType>Exe</OutputType>
-    <TargetFramework>netcoreapp3.1</TargetFramework>
+    <TargetFramework>net5.0</TargetFramework>
     <AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
     <AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
     <SignAssembly>true</SignAssembly>
     <SignAssembly>true</SignAssembly>
     <IsPackable>False</IsPackable>
     <IsPackable>False</IsPackable>

+ 192 - 40
csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs

@@ -25,49 +25,54 @@ namespace ProtobufUnittest {
       byte[] descriptorData = global::System.Convert.FromBase64String(
       byte[] descriptorData = global::System.Convert.FromBase64String(
           string.Concat(
           string.Concat(
             "Ci5nb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfcHJvdG8zX29wdGlvbmFsLnBy",
             "Ci5nb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfcHJvdG8zX29wdGlvbmFsLnBy",
-            "b3RvEhFwcm90b2J1Zl91bml0dGVzdCKxCgoSVGVzdFByb3RvM09wdGlvbmFs",
-            "EhsKDm9wdGlvbmFsX2ludDMyGAEgASgFSACIAQESGwoOb3B0aW9uYWxfaW50",
-            "NjQYAiABKANIAYgBARIcCg9vcHRpb25hbF91aW50MzIYAyABKA1IAogBARIc",
-            "Cg9vcHRpb25hbF91aW50NjQYBCABKARIA4gBARIcCg9vcHRpb25hbF9zaW50",
-            "MzIYBSABKBFIBIgBARIcCg9vcHRpb25hbF9zaW50NjQYBiABKBJIBYgBARId",
-            "ChBvcHRpb25hbF9maXhlZDMyGAcgASgHSAaIAQESHQoQb3B0aW9uYWxfZml4",
-            "ZWQ2NBgIIAEoBkgHiAEBEh4KEW9wdGlvbmFsX3NmaXhlZDMyGAkgASgPSAiI",
-            "AQESHgoRb3B0aW9uYWxfc2ZpeGVkNjQYCiABKBBICYgBARIbCg5vcHRpb25h",
-            "bF9mbG9hdBgLIAEoAkgKiAEBEhwKD29wdGlvbmFsX2RvdWJsZRgMIAEoAUgL",
-            "iAEBEhoKDW9wdGlvbmFsX2Jvb2wYDSABKAhIDIgBARIcCg9vcHRpb25hbF9z",
-            "dHJpbmcYDiABKAlIDYgBARIbCg5vcHRpb25hbF9ieXRlcxgPIAEoDEgOiAEB",
-            "Eh4KDW9wdGlvbmFsX2NvcmQYECABKAlCAggBSA+IAQESWQoXb3B0aW9uYWxf",
-            "bmVzdGVkX21lc3NhZ2UYEiABKAsyMy5wcm90b2J1Zl91bml0dGVzdC5UZXN0",
-            "UHJvdG8zT3B0aW9uYWwuTmVzdGVkTWVzc2FnZUgQiAEBElkKE2xhenlfbmVz",
-            "dGVkX21lc3NhZ2UYEyABKAsyMy5wcm90b2J1Zl91bml0dGVzdC5UZXN0UHJv",
-            "dG8zT3B0aW9uYWwuTmVzdGVkTWVzc2FnZUICKAFIEYgBARJTChRvcHRpb25h",
-            "bF9uZXN0ZWRfZW51bRgVIAEoDjIwLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQ",
-            "cm90bzNPcHRpb25hbC5OZXN0ZWRFbnVtSBKIAQESFgoOc2luZ3VsYXJfaW50",
-            "MzIYFiABKAUSFgoOc2luZ3VsYXJfaW50NjQYFyABKAMaJwoNTmVzdGVkTWVz",
-            "c2FnZRIPCgJiYhgBIAEoBUgAiAEBQgUKA19iYiJKCgpOZXN0ZWRFbnVtEg8K",
-            "C1VOU1BFQ0lGSUVEEAASBwoDRk9PEAESBwoDQkFSEAISBwoDQkFaEAMSEAoD",
-            "TkVHEP///////////wFCEQoPX29wdGlvbmFsX2ludDMyQhEKD19vcHRpb25h",
-            "bF9pbnQ2NEISChBfb3B0aW9uYWxfdWludDMyQhIKEF9vcHRpb25hbF91aW50",
-            "NjRCEgoQX29wdGlvbmFsX3NpbnQzMkISChBfb3B0aW9uYWxfc2ludDY0QhMK",
-            "EV9vcHRpb25hbF9maXhlZDMyQhMKEV9vcHRpb25hbF9maXhlZDY0QhQKEl9v",
-            "cHRpb25hbF9zZml4ZWQzMkIUChJfb3B0aW9uYWxfc2ZpeGVkNjRCEQoPX29w",
-            "dGlvbmFsX2Zsb2F0QhIKEF9vcHRpb25hbF9kb3VibGVCEAoOX29wdGlvbmFs",
-            "X2Jvb2xCEgoQX29wdGlvbmFsX3N0cmluZ0IRCg9fb3B0aW9uYWxfYnl0ZXNC",
-            "EAoOX29wdGlvbmFsX2NvcmRCGgoYX29wdGlvbmFsX25lc3RlZF9tZXNzYWdl",
-            "QhYKFF9sYXp5X25lc3RlZF9tZXNzYWdlQhcKFV9vcHRpb25hbF9uZXN0ZWRf",
-            "ZW51bSKJAgoZVGVzdFByb3RvM09wdGlvbmFsTWVzc2FnZRJSCg5uZXN0ZWRf",
-            "bWVzc2FnZRgBIAEoCzI6LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQcm90bzNP",
-            "cHRpb25hbE1lc3NhZ2UuTmVzdGVkTWVzc2FnZRJgChdvcHRpb25hbF9uZXN0",
-            "ZWRfbWVzc2FnZRgCIAEoCzI6LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQcm90",
-            "bzNPcHRpb25hbE1lc3NhZ2UuTmVzdGVkTWVzc2FnZUgAiAEBGhoKDU5lc3Rl",
-            "ZE1lc3NhZ2USCQoBcxgBIAEoCUIaChhfb3B0aW9uYWxfbmVzdGVkX21lc3Nh",
-            "Z2VCJQohY29tLmdvb2dsZS5wcm90b2J1Zi50ZXN0aW5nLnByb3RvUAFiBnBy",
-            "b3RvMw=="));
+            "b3RvEhFwcm90b2J1Zl91bml0dGVzdBogZ29vZ2xlL3Byb3RvYnVmL2Rlc2Ny",
+            "aXB0b3IucHJvdG8isQoKElRlc3RQcm90bzNPcHRpb25hbBIbCg5vcHRpb25h",
+            "bF9pbnQzMhgBIAEoBUgAiAEBEhsKDm9wdGlvbmFsX2ludDY0GAIgASgDSAGI",
+            "AQESHAoPb3B0aW9uYWxfdWludDMyGAMgASgNSAKIAQESHAoPb3B0aW9uYWxf",
+            "dWludDY0GAQgASgESAOIAQESHAoPb3B0aW9uYWxfc2ludDMyGAUgASgRSASI",
+            "AQESHAoPb3B0aW9uYWxfc2ludDY0GAYgASgSSAWIAQESHQoQb3B0aW9uYWxf",
+            "Zml4ZWQzMhgHIAEoB0gGiAEBEh0KEG9wdGlvbmFsX2ZpeGVkNjQYCCABKAZI",
+            "B4gBARIeChFvcHRpb25hbF9zZml4ZWQzMhgJIAEoD0gIiAEBEh4KEW9wdGlv",
+            "bmFsX3NmaXhlZDY0GAogASgQSAmIAQESGwoOb3B0aW9uYWxfZmxvYXQYCyAB",
+            "KAJICogBARIcCg9vcHRpb25hbF9kb3VibGUYDCABKAFIC4gBARIaCg1vcHRp",
+            "b25hbF9ib29sGA0gASgISAyIAQESHAoPb3B0aW9uYWxfc3RyaW5nGA4gASgJ",
+            "SA2IAQESGwoOb3B0aW9uYWxfYnl0ZXMYDyABKAxIDogBARIeCg1vcHRpb25h",
+            "bF9jb3JkGBAgASgJQgIIAUgPiAEBElkKF29wdGlvbmFsX25lc3RlZF9tZXNz",
+            "YWdlGBIgASgLMjMucHJvdG9idWZfdW5pdHRlc3QuVGVzdFByb3RvM09wdGlv",
+            "bmFsLk5lc3RlZE1lc3NhZ2VIEIgBARJZChNsYXp5X25lc3RlZF9tZXNzYWdl",
+            "GBMgASgLMjMucHJvdG9idWZfdW5pdHRlc3QuVGVzdFByb3RvM09wdGlvbmFs",
+            "Lk5lc3RlZE1lc3NhZ2VCAigBSBGIAQESUwoUb3B0aW9uYWxfbmVzdGVkX2Vu",
+            "dW0YFSABKA4yMC5wcm90b2J1Zl91bml0dGVzdC5UZXN0UHJvdG8zT3B0aW9u",
+            "YWwuTmVzdGVkRW51bUgSiAEBEhYKDnNpbmd1bGFyX2ludDMyGBYgASgFEhYK",
+            "DnNpbmd1bGFyX2ludDY0GBcgASgDGicKDU5lc3RlZE1lc3NhZ2USDwoCYmIY",
+            "ASABKAVIAIgBAUIFCgNfYmIiSgoKTmVzdGVkRW51bRIPCgtVTlNQRUNJRklF",
+            "RBAAEgcKA0ZPTxABEgcKA0JBUhACEgcKA0JBWhADEhAKA05FRxD/////////",
+            "//8BQhEKD19vcHRpb25hbF9pbnQzMkIRCg9fb3B0aW9uYWxfaW50NjRCEgoQ",
+            "X29wdGlvbmFsX3VpbnQzMkISChBfb3B0aW9uYWxfdWludDY0QhIKEF9vcHRp",
+            "b25hbF9zaW50MzJCEgoQX29wdGlvbmFsX3NpbnQ2NEITChFfb3B0aW9uYWxf",
+            "Zml4ZWQzMkITChFfb3B0aW9uYWxfZml4ZWQ2NEIUChJfb3B0aW9uYWxfc2Zp",
+            "eGVkMzJCFAoSX29wdGlvbmFsX3NmaXhlZDY0QhEKD19vcHRpb25hbF9mbG9h",
+            "dEISChBfb3B0aW9uYWxfZG91YmxlQhAKDl9vcHRpb25hbF9ib29sQhIKEF9v",
+            "cHRpb25hbF9zdHJpbmdCEQoPX29wdGlvbmFsX2J5dGVzQhAKDl9vcHRpb25h",
+            "bF9jb3JkQhoKGF9vcHRpb25hbF9uZXN0ZWRfbWVzc2FnZUIWChRfbGF6eV9u",
+            "ZXN0ZWRfbWVzc2FnZUIXChVfb3B0aW9uYWxfbmVzdGVkX2VudW0iiQIKGVRl",
+            "c3RQcm90bzNPcHRpb25hbE1lc3NhZ2USUgoObmVzdGVkX21lc3NhZ2UYASAB",
+            "KAsyOi5wcm90b2J1Zl91bml0dGVzdC5UZXN0UHJvdG8zT3B0aW9uYWxNZXNz",
+            "YWdlLk5lc3RlZE1lc3NhZ2USYAoXb3B0aW9uYWxfbmVzdGVkX21lc3NhZ2UY",
+            "AiABKAsyOi5wcm90b2J1Zl91bml0dGVzdC5UZXN0UHJvdG8zT3B0aW9uYWxN",
+            "ZXNzYWdlLk5lc3RlZE1lc3NhZ2VIAIgBARoaCg1OZXN0ZWRNZXNzYWdlEgkK",
+            "AXMYASABKAlCGgoYX29wdGlvbmFsX25lc3RlZF9tZXNzYWdlIqkBChhQcm90",
+            "bzNPcHRpb25hbEV4dGVuc2lvbnMyPAoPZXh0X25vX29wdGlvbmFsEh8uZ29v",
+            "Z2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRpb25zGIjN2akBIAEoBTJBChFleHRf",
+            "d2l0aF9vcHRpb25hbBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9u",
+            "cxiJzdmpASABKAWIAQE6DMDozM0KCMjozM0KEEIlCiFjb20uZ29vZ2xlLnBy",
+            "b3RvYnVmLnRlc3RpbmcucHJvdG9QAWIGcHJvdG8z"));
       descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
       descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
-          new pbr::FileDescriptor[] { },
+          new pbr::FileDescriptor[] { global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor, },
           new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
           new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
             new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.TestProto3Optional), global::ProtobufUnittest.TestProto3Optional.Parser, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalCord", "OptionalNestedMessage", "LazyNestedMessage", "OptionalNestedEnum", "SingularInt32", "SingularInt64" }, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalCord", "OptionalNestedMessage", "LazyNestedMessage", "OptionalNestedEnum" }, new[]{ typeof(global::ProtobufUnittest.TestProto3Optional.Types.NestedEnum) }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.TestProto3Optional.Types.NestedMessage), global::ProtobufUnittest.TestProto3Optional.Types.NestedMessage.Parser, new[]{ "Bb" }, new[]{ "Bb" }, null, null, null)}),
             new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.TestProto3Optional), global::ProtobufUnittest.TestProto3Optional.Parser, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalCord", "OptionalNestedMessage", "LazyNestedMessage", "OptionalNestedEnum", "SingularInt32", "SingularInt64" }, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalCord", "OptionalNestedMessage", "LazyNestedMessage", "OptionalNestedEnum" }, new[]{ typeof(global::ProtobufUnittest.TestProto3Optional.Types.NestedEnum) }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.TestProto3Optional.Types.NestedMessage), global::ProtobufUnittest.TestProto3Optional.Types.NestedMessage.Parser, new[]{ "Bb" }, new[]{ "Bb" }, null, null, null)}),
-            new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.TestProto3OptionalMessage), global::ProtobufUnittest.TestProto3OptionalMessage.Parser, new[]{ "NestedMessage", "OptionalNestedMessage" }, new[]{ "OptionalNestedMessage" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage), global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage.Parser, new[]{ "S" }, null, null, null, null)})
+            new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.TestProto3OptionalMessage), global::ProtobufUnittest.TestProto3OptionalMessage.Parser, new[]{ "NestedMessage", "OptionalNestedMessage" }, new[]{ "OptionalNestedMessage" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage), global::ProtobufUnittest.TestProto3OptionalMessage.Types.NestedMessage.Parser, new[]{ "S" }, null, null, null, null)}),
+            new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufUnittest.Proto3OptionalExtensions), global::ProtobufUnittest.Proto3OptionalExtensions.Parser, null, null, null, new pb::Extension[] { global::ProtobufUnittest.Proto3OptionalExtensions.Extensions.ExtNoOptional, global::ProtobufUnittest.Proto3OptionalExtensions.Extensions.ExtWithOptional }, null)
           }));
           }));
     }
     }
     #endregion
     #endregion
@@ -1789,6 +1794,153 @@ namespace ProtobufUnittest {
 
 
   }
   }
 
 
+  public sealed partial class Proto3OptionalExtensions : pb::IMessage<Proto3OptionalExtensions>
+  #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
+      , pb::IBufferMessage
+  #endif
+  {
+    private static readonly pb::MessageParser<Proto3OptionalExtensions> _parser = new pb::MessageParser<Proto3OptionalExtensions>(() => new Proto3OptionalExtensions());
+    private pb::UnknownFieldSet _unknownFields;
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    public static pb::MessageParser<Proto3OptionalExtensions> Parser { get { return _parser; } }
+
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    public static pbr::MessageDescriptor Descriptor {
+      get { return global::ProtobufUnittest.UnittestProto3OptionalReflection.Descriptor.MessageTypes[2]; }
+    }
+
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    pbr::MessageDescriptor pb::IMessage.Descriptor {
+      get { return Descriptor; }
+    }
+
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    public Proto3OptionalExtensions() {
+      OnConstruction();
+    }
+
+    partial void OnConstruction();
+
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    public Proto3OptionalExtensions(Proto3OptionalExtensions other) : this() {
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
+    }
+
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    public Proto3OptionalExtensions Clone() {
+      return new Proto3OptionalExtensions(this);
+    }
+
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    public override bool Equals(object other) {
+      return Equals(other as Proto3OptionalExtensions);
+    }
+
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    public bool Equals(Proto3OptionalExtensions other) {
+      if (ReferenceEquals(other, null)) {
+        return false;
+      }
+      if (ReferenceEquals(other, this)) {
+        return true;
+      }
+      return Equals(_unknownFields, other._unknownFields);
+    }
+
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    public override int GetHashCode() {
+      int hash = 1;
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
+      return hash;
+    }
+
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    public override string ToString() {
+      return pb::JsonFormatter.ToDiagnosticString(this);
+    }
+
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    public void WriteTo(pb::CodedOutputStream output) {
+    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
+      output.WriteRawMessage(this);
+    #else
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
+    #endif
+    }
+
+    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(ref output);
+      }
+    }
+    #endif
+
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    public int CalculateSize() {
+      int size = 0;
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
+      return size;
+    }
+
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    public void MergeFrom(Proto3OptionalExtensions other) {
+      if (other == null) {
+        return;
+      }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
+    }
+
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    public void MergeFrom(pb::CodedInputStream input) {
+    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
+      input.ReadRawMessage(this);
+    #else
+      uint tag;
+      while ((tag = input.ReadTag()) != 0) {
+        switch(tag) {
+          default:
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
+            break;
+        }
+      }
+    #endif
+    }
+
+    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
+      uint tag;
+      while ((tag = input.ReadTag()) != 0) {
+        switch(tag) {
+          default:
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
+            break;
+        }
+      }
+    }
+    #endif
+
+    #region Extensions
+    /// <summary>Container for extensions for other messages declared in the Proto3OptionalExtensions message type.</summary>
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+    public static partial class Extensions {
+      public static readonly pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, int> ExtNoOptional =
+        new pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, int>(355886728, pb::FieldCodec.ForInt32(2847093824, 0));
+      public static readonly pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, int> ExtWithOptional =
+        new pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, int>(355886729, pb::FieldCodec.ForInt32(2847093832, 0));
+    }
+    #endregion
+
+  }
+
   #endregion
   #endregion
 
 
 }
 }

+ 6 - 6
csharp/src/Google.Protobuf.Test/Buffers/ArrayBufferWriter.cs

@@ -42,7 +42,7 @@ namespace Google.Protobuf.Buffers
     /// ArrayBufferWriter is originally from corefx, and has been contributed to Protobuf
     /// ArrayBufferWriter is originally from corefx, and has been contributed to Protobuf
     /// https://github.com/dotnet/runtime/blob/071da4c41aa808c949a773b92dca6f88de9d11f3/src/libraries/Common/src/System/Buffers/ArrayBufferWriter.cs
     /// https://github.com/dotnet/runtime/blob/071da4c41aa808c949a773b92dca6f88de9d11f3/src/libraries/Common/src/System/Buffers/ArrayBufferWriter.cs
     /// </summary>
     /// </summary>
-    internal sealed class ArrayBufferWriter<T> : IBufferWriter<T>
+    internal sealed class TestArrayBufferWriter<T> : IBufferWriter<T>
     {
     {
         private T[] _buffer;
         private T[] _buffer;
         private int _index;
         private int _index;
@@ -50,10 +50,10 @@ namespace Google.Protobuf.Buffers
         private const int DefaultInitialBufferSize = 256;
         private const int DefaultInitialBufferSize = 256;
 
 
         /// <summary>
         /// <summary>
-        /// Creates an instance of an <see cref="ArrayBufferWriter{T}"/>, in which data can be written to,
+        /// Creates an instance of an <see cref="TestArrayBufferWriter{T}"/>, in which data can be written to,
         /// with the default initial capacity.
         /// with the default initial capacity.
         /// </summary>
         /// </summary>
-        public ArrayBufferWriter()
+        public TestArrayBufferWriter()
         {
         {
             _buffer = new T[0];
             _buffer = new T[0];
             _index = 0;
             _index = 0;
@@ -66,14 +66,14 @@ namespace Google.Protobuf.Buffers
         public int? MaxGrowBy { get; set; }
         public int? MaxGrowBy { get; set; }
 
 
         /// <summary>
         /// <summary>
-        /// Creates an instance of an <see cref="ArrayBufferWriter{T}"/>, in which data can be written to,
+        /// Creates an instance of an <see cref="TestArrayBufferWriter{T}"/>, in which data can be written to,
         /// with an initial capacity specified.
         /// with an initial capacity specified.
         /// </summary>
         /// </summary>
         /// <param name="initialCapacity">The minimum capacity with which to initialize the underlying buffer.</param>
         /// <param name="initialCapacity">The minimum capacity with which to initialize the underlying buffer.</param>
         /// <exception cref="ArgumentException">
         /// <exception cref="ArgumentException">
         /// Thrown when <paramref name="initialCapacity"/> is not positive (i.e. less than or equal to 0).
         /// Thrown when <paramref name="initialCapacity"/> is not positive (i.e. less than or equal to 0).
         /// </exception>
         /// </exception>
-        public ArrayBufferWriter(int initialCapacity)
+        public TestArrayBufferWriter(int initialCapacity)
         {
         {
             if (initialCapacity <= 0)
             if (initialCapacity <= 0)
                 throw new ArgumentException(nameof(initialCapacity));
                 throw new ArgumentException(nameof(initialCapacity));
@@ -111,7 +111,7 @@ namespace Google.Protobuf.Buffers
         /// Clears the data written to the underlying buffer.
         /// Clears the data written to the underlying buffer.
         /// </summary>
         /// </summary>
         /// <remarks>
         /// <remarks>
-        /// You must clear the <see cref="ArrayBufferWriter{T}"/> before trying to re-use it.
+        /// You must clear the <see cref="TestArrayBufferWriter{T}"/> before trying to re-use it.
         /// </remarks>
         /// </remarks>
         public void Clear()
         public void Clear()
         {
         {

+ 50 - 11
csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs

@@ -58,7 +58,7 @@ namespace Google.Protobuf
                 Assert.AreEqual(data, rawOutput.ToArray());
                 Assert.AreEqual(data, rawOutput.ToArray());
 
 
                 // IBufferWriter
                 // IBufferWriter
-                var bufferWriter = new ArrayBufferWriter<byte>();
+                var bufferWriter = new TestArrayBufferWriter<byte>();
                 WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                 WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                 ctx.WriteUInt32((uint) value);
                 ctx.WriteUInt32((uint) value);
                 ctx.Flush();
                 ctx.Flush();
@@ -77,7 +77,7 @@ namespace Google.Protobuf
                 Assert.AreEqual(data, rawOutput.ToArray());
                 Assert.AreEqual(data, rawOutput.ToArray());
 
 
                 // IBufferWriter
                 // IBufferWriter
-                var bufferWriter = new ArrayBufferWriter<byte>();
+                var bufferWriter = new TestArrayBufferWriter<byte>();
                 WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                 WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                 ctx.WriteUInt64(value);
                 ctx.WriteUInt64(value);
                 ctx.Flush();
                 ctx.Flush();
@@ -100,7 +100,7 @@ namespace Google.Protobuf
                     output.Flush();
                     output.Flush();
                     Assert.AreEqual(data, rawOutput.ToArray());
                     Assert.AreEqual(data, rawOutput.ToArray());
 
 
-                    var bufferWriter = new ArrayBufferWriter<byte>();
+                    var bufferWriter = new TestArrayBufferWriter<byte>();
                     bufferWriter.MaxGrowBy = bufferSize;
                     bufferWriter.MaxGrowBy = bufferSize;
                     WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                     WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                     ctx.WriteUInt32((uint) value);
                     ctx.WriteUInt32((uint) value);
@@ -115,7 +115,7 @@ namespace Google.Protobuf
                     output.Flush();
                     output.Flush();
                     Assert.AreEqual(data, rawOutput.ToArray());
                     Assert.AreEqual(data, rawOutput.ToArray());
 
 
-                    var bufferWriter = new ArrayBufferWriter<byte>();
+                    var bufferWriter = new TestArrayBufferWriter<byte>();
                     bufferWriter.MaxGrowBy = bufferSize;
                     bufferWriter.MaxGrowBy = bufferSize;
                     WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                     WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                     ctx.WriteUInt64(value);
                     ctx.WriteUInt64(value);
@@ -174,7 +174,7 @@ namespace Google.Protobuf
                 output.Flush();
                 output.Flush();
                 Assert.AreEqual(data, rawOutput.ToArray());
                 Assert.AreEqual(data, rawOutput.ToArray());
 
 
-                var bufferWriter = new ArrayBufferWriter<byte>();
+                var bufferWriter = new TestArrayBufferWriter<byte>();
                 WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                 WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                 ctx.WriteFixed32(value);
                 ctx.WriteFixed32(value);
                 ctx.Flush();
                 ctx.Flush();
@@ -190,7 +190,7 @@ namespace Google.Protobuf
                 output.Flush();
                 output.Flush();
                 Assert.AreEqual(data, rawOutput.ToArray());
                 Assert.AreEqual(data, rawOutput.ToArray());
 
 
-                var bufferWriter = new ArrayBufferWriter<byte>();
+                var bufferWriter = new TestArrayBufferWriter<byte>();
                 bufferWriter.MaxGrowBy = bufferSize;
                 bufferWriter.MaxGrowBy = bufferSize;
                 WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                 WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                 ctx.WriteFixed32(value);
                 ctx.WriteFixed32(value);
@@ -212,7 +212,7 @@ namespace Google.Protobuf
                 output.Flush();
                 output.Flush();
                 Assert.AreEqual(data, rawOutput.ToArray());
                 Assert.AreEqual(data, rawOutput.ToArray());
 
 
-                var bufferWriter = new ArrayBufferWriter<byte>();
+                var bufferWriter = new TestArrayBufferWriter<byte>();
                 WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                 WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                 ctx.WriteFixed64(value);
                 ctx.WriteFixed64(value);
                 ctx.Flush();
                 ctx.Flush();
@@ -228,7 +228,7 @@ namespace Google.Protobuf
                 output.Flush();
                 output.Flush();
                 Assert.AreEqual(data, rawOutput.ToArray());
                 Assert.AreEqual(data, rawOutput.ToArray());
 
 
-                var bufferWriter = new ArrayBufferWriter<byte>();
+                var bufferWriter = new TestArrayBufferWriter<byte>();
                 bufferWriter.MaxGrowBy = blockSize;
                 bufferWriter.MaxGrowBy = blockSize;
                 WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                 WriteContext.Initialize(bufferWriter, out WriteContext ctx);
                 ctx.WriteFixed64(value);
                 ctx.WriteFixed64(value);
@@ -270,7 +270,7 @@ namespace Google.Protobuf
                 output.Flush();
                 output.Flush();
                 Assert.AreEqual(rawBytes, rawOutput.ToArray());
                 Assert.AreEqual(rawBytes, rawOutput.ToArray());
 
 
-                var bufferWriter = new ArrayBufferWriter<byte>();
+                var bufferWriter = new TestArrayBufferWriter<byte>();
                 bufferWriter.MaxGrowBy = blockSize;
                 bufferWriter.MaxGrowBy = blockSize;
                 message.WriteTo(bufferWriter);
                 message.WriteTo(bufferWriter);
                 Assert.AreEqual(rawBytes, bufferWriter.WrittenSpan.ToArray()); 
                 Assert.AreEqual(rawBytes, bufferWriter.WrittenSpan.ToArray()); 
@@ -292,7 +292,7 @@ namespace Google.Protobuf
             output.Flush();
             output.Flush();
             byte[] expectedBytes2 = expectedOutput.ToArray();
             byte[] expectedBytes2 = expectedOutput.ToArray();
 
 
-            var bufferWriter = new ArrayBufferWriter<byte>();
+            var bufferWriter = new TestArrayBufferWriter<byte>();
             WriteContext.Initialize(bufferWriter, out WriteContext ctx);
             WriteContext.Initialize(bufferWriter, out WriteContext ctx);
             ctx.WriteMessage(message);
             ctx.WriteMessage(message);
             ctx.Flush();
             ctx.Flush();
@@ -519,7 +519,21 @@ namespace Google.Protobuf
         }
         }
 
 
         [Test]
         [Test]
-        public void WriteStringsOfDifferentSizes()
+        public void WriteString_AsciiSmall_MaxUtf8SizeExceedsBuffer()
+        {
+            var buffer = new byte[5];
+            var output = new CodedOutputStream(buffer);
+            output.WriteString("ABC");
+
+            output.Flush();
+
+            // Verify written content
+            var input = new CodedInputStream(buffer);
+            Assert.AreEqual("ABC", input.ReadString());
+        }
+
+        [Test]
+        public void WriteStringsOfDifferentSizes_Ascii()
         {
         {
             for (int i = 1; i <= 1024; i++)
             for (int i = 1; i <= 1024; i++)
             {
             {
@@ -540,5 +554,30 @@ namespace Google.Protobuf
                 Assert.AreEqual(s, input.ReadString());
                 Assert.AreEqual(s, input.ReadString());
             }
             }
         }
         }
+
+        [Test]
+        public void WriteStringsOfDifferentSizes_Unicode()
+        {
+            for (int i = 1; i <= 1024; i++)
+            {
+                var buffer = new byte[4096];
+                var output = new CodedOutputStream(buffer);
+                var sb = new StringBuilder();
+                for (int j = 0; j < i; j++)
+                {
+                    char c = (char)((j % 10) + 10112);
+                    sb.Append(c.ToString()); // incrementing unicode numbers, repeating
+                }
+                var s = sb.ToString();
+                output.WriteString(s);
+
+                output.Flush();
+
+                // Verify written content
+                var input = new CodedInputStream(buffer);
+
+                Assert.AreEqual(s, input.ReadString());
+            }
+        }
     }
     }
 }
 }

+ 1 - 1
csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 <Project Sdk="Microsoft.NET.Sdk">
 
 
   <PropertyGroup>
   <PropertyGroup>
-    <TargetFrameworks>net451;netcoreapp2.1</TargetFrameworks>
+    <TargetFrameworks>net451;netcoreapp2.1;net50</TargetFrameworks>
     <AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
     <AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
     <SignAssembly>true</SignAssembly>
     <SignAssembly>true</SignAssembly>
     <IsPackable>False</IsPackable>
     <IsPackable>False</IsPackable>

+ 4 - 0
csharp/src/Google.Protobuf.Test/JsonParserTest.cs

@@ -551,9 +551,13 @@ namespace Google.Protobuf
         }
         }
 
 
         [Test]
         [Test]
+        // Skip these test cases in .NET 5 because floating point parsing supports bigger values.
+        // These big values won't throw an error in the test.
+#if !NET5_0
         [TestCase("1.7977e308")]
         [TestCase("1.7977e308")]
         [TestCase("-1.7977e308")]
         [TestCase("-1.7977e308")]
         [TestCase("1e309")]
         [TestCase("1e309")]
+#endif
         [TestCase("1,0")]
         [TestCase("1,0")]
         [TestCase("1.0.0")]
         [TestCase("1.0.0")]
         [TestCase("+1")]
         [TestCase("+1")]

+ 4 - 0
csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs

@@ -199,8 +199,12 @@ namespace Google.Protobuf
         [TestCase("1e-")]
         [TestCase("1e-")]
         [TestCase("--")]
         [TestCase("--")]
         [TestCase("--1")]
         [TestCase("--1")]
+        // Skip these test cases in .NET 5 because floating point parsing supports bigger values.
+        // These big values won't throw an error in the test.
+#if !NET5_0
         [TestCase("-1.7977e308")]
         [TestCase("-1.7977e308")]
         [TestCase("1.7977e308")]
         [TestCase("1.7977e308")]
+#endif
         public void InvalidNumberValue(string json)
         public void InvalidNumberValue(string json)
         {
         {
             AssertThrowsAfter(json);
             AssertThrowsAfter(json);

+ 1 - 1
csharp/src/Google.Protobuf.Test/LegacyGeneratedCodeTest.cs

@@ -141,7 +141,7 @@ namespace Google.Protobuf
             };
             };
             var exception = Assert.Throws<InvalidProtocolBufferException>(() =>
             var exception = Assert.Throws<InvalidProtocolBufferException>(() =>
             {
             {
-                WriteContext.Initialize(new ArrayBufferWriter<byte>(), out WriteContext writeCtx);
+                WriteContext.Initialize(new TestArrayBufferWriter<byte>(), out WriteContext writeCtx);
                 ((IBufferMessage)message).InternalWriteTo(ref writeCtx);
                 ((IBufferMessage)message).InternalWriteTo(ref writeCtx);
             });
             });
             Assert.AreEqual($"Message {typeof(LegacyGeneratedCodeMessageA).Name} doesn't provide the generated method that enables WriteContext-based serialization. You might need to regenerate the generated protobuf code.", exception.Message);
             Assert.AreEqual($"Message {typeof(LegacyGeneratedCodeMessageA).Name} doesn't provide the generated method that enables WriteContext-based serialization. You might need to regenerate the generated protobuf code.", exception.Message);

+ 3 - 3
csharp/src/Google.Protobuf.Test/MessageParsingHelpers.cs

@@ -83,7 +83,7 @@ namespace Google.Protobuf
             var bytes = message.ToByteArray();
             var bytes = message.ToByteArray();
 
 
             // also serialize using IBufferWriter and check it leads to the same data
             // also serialize using IBufferWriter and check it leads to the same data
-            var bufferWriter = new ArrayBufferWriter<byte>();
+            var bufferWriter = new TestArrayBufferWriter<byte>();
             message.WriteTo(bufferWriter);
             message.WriteTo(bufferWriter);
             Assert.AreEqual(bytes, bufferWriter.WrittenSpan.ToArray(), "Both serialization approaches need to result in the same data.");
             Assert.AreEqual(bytes, bufferWriter.WrittenSpan.ToArray(), "Both serialization approaches need to result in the same data.");
 
 
@@ -112,7 +112,7 @@ namespace Google.Protobuf
             Assert.AreEqual(message.CalculateSize(), bytes.Length);
             Assert.AreEqual(message.CalculateSize(), bytes.Length);
 
 
             // serialize using IBufferWriter and check it leads to the same output
             // serialize using IBufferWriter and check it leads to the same output
-            var bufferWriter = new ArrayBufferWriter<byte>();
+            var bufferWriter = new TestArrayBufferWriter<byte>();
             message.WriteTo(bufferWriter);
             message.WriteTo(bufferWriter);
             Assert.AreEqual(bytes, bufferWriter.WrittenSpan.ToArray());
             Assert.AreEqual(bytes, bufferWriter.WrittenSpan.ToArray());
 
 
@@ -124,7 +124,7 @@ namespace Google.Protobuf
             // test for different IBufferWriter.GetSpan() segment sizes
             // test for different IBufferWriter.GetSpan() segment sizes
             for (int blockSize = 1; blockSize < 256; blockSize *= 2)
             for (int blockSize = 1; blockSize < 256; blockSize *= 2)
             {
             {
-                var segmentedBufferWriter = new ArrayBufferWriter<byte>();
+                var segmentedBufferWriter = new TestArrayBufferWriter<byte>();
                 segmentedBufferWriter.MaxGrowBy = blockSize;
                 segmentedBufferWriter.MaxGrowBy = blockSize;
                 message.WriteTo(segmentedBufferWriter);
                 message.WriteTo(segmentedBufferWriter);
                 Assert.AreEqual(bytes, segmentedBufferWriter.WrittenSpan.ToArray());
                 Assert.AreEqual(bytes, segmentedBufferWriter.WrittenSpan.ToArray());

BIN
csharp/src/Google.Protobuf.Test/testprotos.pb


+ 12 - 4
csharp/src/Google.Protobuf/Google.Protobuf.csproj

@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
 
 
   <PropertyGroup>
   <PropertyGroup>
     <Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
     <Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
@@ -8,7 +8,7 @@
     <!-- C# 7.2 is required for Span/BufferWriter/ReadOnlySequence -->
     <!-- C# 7.2 is required for Span/BufferWriter/ReadOnlySequence -->
     <LangVersion>7.2</LangVersion>
     <LangVersion>7.2</LangVersion>
     <Authors>Google Inc.</Authors>
     <Authors>Google Inc.</Authors>
-    <TargetFrameworks>netstandard1.1;netstandard2.0;net45</TargetFrameworks>
+    <TargetFrameworks>netstandard1.1;netstandard2.0;net45;net50</TargetFrameworks>
     <GenerateDocumentationFile>true</GenerateDocumentationFile>
     <GenerateDocumentationFile>true</GenerateDocumentationFile>
     <AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
     <AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
     <SignAssembly>true</SignAssembly>
     <SignAssembly>true</SignAssembly>
@@ -27,15 +27,23 @@
     <DefineConstants>$(DefineConstants);GOOGLE_PROTOBUF_SUPPORT_FAST_STRING</DefineConstants>
     <DefineConstants>$(DefineConstants);GOOGLE_PROTOBUF_SUPPORT_FAST_STRING</DefineConstants>
   </PropertyGroup>
   </PropertyGroup>
 
 
+  <PropertyGroup Condition=" '$(TargetFramework)' == 'net50' ">
+    <DefineConstants>$(DefineConstants);GOOGLE_PROTOBUF_SUPPORT_FAST_STRING;GOOGLE_PROTOBUF_SIMD</DefineConstants>
+  </PropertyGroup>
+
   <ItemGroup>
   <ItemGroup>
-    <PackageReference Include="System.Memory" Version="4.5.3"/>
     <PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" Version="1.0.0"/>
     <PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" Version="1.0.0"/>
     <!-- Needed for the net45 build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
     <!-- Needed for the net45 build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
     <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0"/>
     <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0"/>
   </ItemGroup>
   </ItemGroup>
 
 
-  <!-- Needed for netcoreapp2.1 to work correctly. .NET is not able to load the assembly without this -->
+  <ItemGroup Condition=" '$(TargetFramework)' == 'net45' OR '$(TargetFramework)' == 'netstandard1.1' ">
+    <PackageReference Include="System.Memory" Version="4.5.3"/>
+  </ItemGroup>
+
   <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
   <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
+    <PackageReference Include="System.Memory" Version="4.5.3"/>
+    <!-- Needed for netcoreapp2.1 to work correctly. .NET is not able to load the assembly without this -->
     <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.2"/>
     <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.2"/>
   </ItemGroup>
   </ItemGroup>
 
 

+ 110 - 7
csharp/src/Google.Protobuf/WritingPrimitives.cs

@@ -32,8 +32,14 @@
 
 
 using System;
 using System;
 using System.Buffers.Binary;
 using System.Buffers.Binary;
+using System.Diagnostics;
 using System.Runtime.CompilerServices;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Runtime.InteropServices;
+#if GOOGLE_PROTOBUF_SIMD
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.Arm;
+using System.Runtime.Intrinsics.X86;
+#endif
 using System.Security;
 using System.Security;
 using System.Text;
 using System.Text;
 
 
@@ -45,8 +51,11 @@ namespace Google.Protobuf
     [SecuritySafeCritical]
     [SecuritySafeCritical]
     internal static class WritingPrimitives
     internal static class WritingPrimitives
     {
     {
-        // "Local" copy of Encoding.UTF8, for efficiency. (Yes, it makes a difference.)
-        internal static readonly Encoding Utf8Encoding = Encoding.UTF8;
+#if NET5_0
+        internal static Encoding Utf8Encoding => Encoding.UTF8; // allows JIT to devirtualize
+#else
+        internal static readonly Encoding Utf8Encoding = Encoding.UTF8; // "Local" copy of Encoding.UTF8, for efficiency. (Yes, it makes a difference.)
+#endif
 
 
         #region Writing of values (not including tags)
         #region Writing of values (not including tags)
 
 
@@ -186,11 +195,7 @@ namespace Google.Protobuf
             {
             {
                 if (length == value.Length) // Must be all ASCII...
                 if (length == value.Length) // Must be all ASCII...
                 {
                 {
-                    for (int i = 0; i < length; i++)
-                    {
-                        buffer[state.position + i] = (byte)value[i];
-                    }
-                    state.position += length;
+                    WriteAsciiStringToBuffer(buffer, ref state, value, length);
                 }
                 }
                 else
                 else
                 {
                 {
@@ -208,6 +213,104 @@ namespace Google.Protobuf
             }
             }
         }
         }
 
 
+        // Calling this method with non-ASCII content will break.
+        // Content must be verified to be all ASCII before using this method.
+        private static void WriteAsciiStringToBuffer(Span<byte> buffer, ref WriterInternalState state, string value, int length)
+        {
+            ref char sourceChars = ref MemoryMarshal.GetReference(value.AsSpan());
+            ref byte destinationBytes = ref MemoryMarshal.GetReference(buffer.Slice(state.position));
+
+            int currentIndex = 0;
+            // If 64bit, process 4 chars at a time.
+            // The logic inside this check will be elided by JIT in 32bit programs.
+            if (IntPtr.Size == 8)
+            {
+                // Need at least 4 chars available to use this optimization. 
+                if (length >= 4)
+                {
+                    ref byte sourceBytes = ref Unsafe.As<char, byte>(ref sourceChars);
+
+                    // Process 4 chars at a time until there are less than 4 remaining.
+                    // We already know all characters are ASCII so there is no need to validate the source.
+                    int lastIndexWhereCanReadFourChars = value.Length - 4;
+                    do
+                    {
+                        NarrowFourUtf16CharsToAsciiAndWriteToBuffer(
+                            ref Unsafe.AddByteOffset(ref destinationBytes, (IntPtr)currentIndex),
+                            Unsafe.ReadUnaligned<ulong>(ref Unsafe.AddByteOffset(ref sourceBytes, (IntPtr)(currentIndex * 2))));
+
+                    } while ((currentIndex += 4) <= lastIndexWhereCanReadFourChars);
+                }
+            }
+
+            // Process any remaining, 1 char at a time.
+            // Avoid bounds checking with ref + Unsafe
+            for (; currentIndex < length; currentIndex++)
+            {
+                Unsafe.AddByteOffset(ref destinationBytes, (IntPtr)currentIndex) = (byte)Unsafe.AddByteOffset(ref sourceChars, (IntPtr)(currentIndex * 2));
+            }
+
+            state.position += length;
+        }
+
+        // Copied with permission from https://github.com/dotnet/runtime/blob/1cdafd27e4afd2c916af5df949c13f8b373c4335/src/libraries/System.Private.CoreLib/src/System/Text/ASCIIUtility.cs#L1119-L1171
+        //
+        /// <summary>
+        /// Given a QWORD which represents a buffer of 4 ASCII chars in machine-endian order,
+        /// narrows each WORD to a BYTE, then writes the 4-byte result to the output buffer
+        /// also in machine-endian order.
+        /// </summary>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        private static void NarrowFourUtf16CharsToAsciiAndWriteToBuffer(ref byte outputBuffer, ulong value)
+        {
+#if GOOGLE_PROTOBUF_SIMD
+            if (Sse2.X64.IsSupported)
+            {
+                // Narrows a vector of words [ w0 w1 w2 w3 ] to a vector of bytes
+                // [ b0 b1 b2 b3 b0 b1 b2 b3 ], then writes 4 bytes (32 bits) to the destination.
+
+                Vector128<short> vecWide = Sse2.X64.ConvertScalarToVector128UInt64(value).AsInt16();
+                Vector128<uint> vecNarrow = Sse2.PackUnsignedSaturate(vecWide, vecWide).AsUInt32();
+                Unsafe.WriteUnaligned<uint>(ref outputBuffer, Sse2.ConvertToUInt32(vecNarrow));
+            }
+            else if (AdvSimd.IsSupported)
+            {
+                // Narrows a vector of words [ w0 w1 w2 w3 ] to a vector of bytes
+                // [ b0 b1 b2 b3 * * * * ], then writes 4 bytes (32 bits) to the destination.
+
+                Vector128<short> vecWide = Vector128.CreateScalarUnsafe(value).AsInt16();
+                Vector64<byte> lower = AdvSimd.ExtractNarrowingSaturateUnsignedLower(vecWide);
+                Unsafe.WriteUnaligned<uint>(ref outputBuffer, lower.AsUInt32().ToScalar());
+            }
+            else
+#endif
+            {
+                // Fallback to non-SIMD approach when SIMD is not available.
+                // This could happen either because the APIs are not available, or hardware doesn't support it.
+                // Processing 4 chars at a time in this fallback is still faster than casting one char at a time.
+                if (BitConverter.IsLittleEndian)
+                {
+                    outputBuffer = (byte)value;
+                    value >>= 16;
+                    Unsafe.Add(ref outputBuffer, 1) = (byte)value;
+                    value >>= 16;
+                    Unsafe.Add(ref outputBuffer, 2) = (byte)value;
+                    value >>= 16;
+                    Unsafe.Add(ref outputBuffer, 3) = (byte)value;
+                }
+                else
+                {
+                    Unsafe.Add(ref outputBuffer, 3) = (byte)value;
+                    value >>= 16;
+                    Unsafe.Add(ref outputBuffer, 2) = (byte)value;
+                    value >>= 16;
+                    Unsafe.Add(ref outputBuffer, 1) = (byte)value;
+                    value >>= 16;
+                    outputBuffer = (byte)value;
+                }
+            }
+        }
+
         private static int WriteStringToBuffer(Span<byte> buffer, ref WriterInternalState state, string value)
         private static int WriteStringToBuffer(Span<byte> buffer, ref WriterInternalState state, string value)
         {
         {
 #if NETSTANDARD1_1
 #if NETSTANDARD1_1

+ 18 - 0
docs/jvm_aot.md

@@ -0,0 +1,18 @@
+# Ahead Of Time (AOT) compilation for the Java Virtual Machine (JVM)"
+
+Ahead Of Time (AOT) compilation build tools such as those provided by [GraalVM's `native-image`](https://www.graalvm.org/reference-manual/native-image/) can require some configuration when using protobuf.
+Protobuf for the JVM uses reflection and some of its target classes are not possible to determine in advance.
+Historically, there were good reasons to use reflection based on APIs that were published effectively requiring them, and this situation is unlikely to change.
+
+[The Lite version of protobuf for the JVM](https://github.com/protocolbuffers/protobuf/blob/master/java/lite.md)
+avoids reflection and may be better suited for use with AOT compilation tooling. This Lite version was originally targeted for use on Android which has similar AOT compilation
+goals as GraalVM's native-image tool.
+
+## GraalVM native-image
+
+This section addresses GraalVM's `native-image` configuration specifically as this AOT compilation tool due to its popularity. The `native-image` tool can be configured
+with respect to: the [Java Native Interface](https://en.wikipedia.org/wiki/Java_Native_Interface) (JNI), http proxying, reflection, and other resources. While these
+considerations can be manually declared as JSON files, we recommend that a JVM application is exercised along with 
+[the assisted configuration agent](https://www.graalvm.org/reference-manual/native-image/BuildConfiguration/#assisted-configuration-of-native-image-builds). The agent
+will generate files that you can then subsequently point at when invoking `native-image`. We recommend that the generated files are retained with a project's source
+code.

+ 2 - 2
docs/options.md

@@ -263,8 +263,8 @@ with info about your project (name and website) so we can add an entry for you.
 
 
 1. Protoc-gen-psql
 1. Protoc-gen-psql
    * Website: https://github.com/Intrinsec/protoc-gen-psql
    * Website: https://github.com/Intrinsec/protoc-gen-psql
-   * Extension: 1091
+   * Extension: 1091-1101
 
 
 1. Protoc-gen-sanitize
 1. Protoc-gen-sanitize
    * Website: https://github.com/Intrinsec/protoc-gen-sanitize
    * Website: https://github.com/Intrinsec/protoc-gen-sanitize
-   * Extension: 1092
+   * Extension: 1102-1106

+ 1 - 1
global.json

@@ -1,6 +1,6 @@
 {
 {
   "sdk": {
   "sdk": {
-    "version": "3.0.100",
+    "version": "5.0.102",
     "rollForward": "latestMinor"
     "rollForward": "latestMinor"
   }
   }
 }
 }

+ 2 - 2
java/README.md

@@ -23,7 +23,7 @@ If you are using Maven, use the following:
 <dependency>
 <dependency>
   <groupId>com.google.protobuf</groupId>
   <groupId>com.google.protobuf</groupId>
   <artifactId>protobuf-java</artifactId>
   <artifactId>protobuf-java</artifactId>
-  <version>3.11.0</version>
+  <version>3.15.3</version>
 </dependency>
 </dependency>
 ```
 ```
 
 
@@ -37,7 +37,7 @@ protobuf-java-util package:
 <dependency>
 <dependency>
   <groupId>com.google.protobuf</groupId>
   <groupId>com.google.protobuf</groupId>
   <artifactId>protobuf-java-util</artifactId>
   <artifactId>protobuf-java-util</artifactId>
-  <version>3.11.0</version>
+  <version>3.15.3</version>
 </dependency>
 </dependency>
 ```
 ```
 
 

+ 43 - 4
java/core/src/main/java/com/google/protobuf/CodedInputStream.java

@@ -2055,6 +2055,44 @@ public abstract class CodedInputStream {
       totalBytesRetired = 0;
       totalBytesRetired = 0;
     }
     }
 
 
+    /*
+     * The following wrapper methods exist so that InvalidProtocolBufferExceptions thrown by the
+     * InputStream can be differentiated from ones thrown by CodedInputStream itself. Each call to
+     * an InputStream method that can throw IOException must be wrapped like this. We do this
+     * because we sometimes need to modify IPBE instances after they are thrown far away from where
+     * they are thrown (ex. to add unfinished messages) and we use this signal elsewhere in the
+     * exception catch chain to know when to perform these operations directly or to wrap the
+     * exception in their own IPBE so the extra information can be communicated without trampling
+     * downstream information.
+     */
+    private static int read(InputStream input, byte[] data, int offset, int length)
+        throws IOException {
+      try {
+        return input.read(data, offset, length);
+      } catch (InvalidProtocolBufferException e) {
+        e.setThrownFromInputStream();
+        throw e;
+      }
+    }
+
+    private static long skip(InputStream input, long length) throws IOException {
+      try {
+        return input.skip(length);
+      } catch (InvalidProtocolBufferException e) {
+        e.setThrownFromInputStream();
+        throw e;
+      }
+    }
+
+    private static int available(InputStream input) throws IOException {
+      try {
+        return input.available();
+      } catch (InvalidProtocolBufferException e) {
+        e.setThrownFromInputStream();
+        throw e;
+      }
+    }
+
     @Override
     @Override
     public int readTag() throws IOException {
     public int readTag() throws IOException {
       if (isAtEnd()) {
       if (isAtEnd()) {
@@ -2783,7 +2821,8 @@ public abstract class CodedInputStream {
 
 
       // Here we should refill the buffer as many bytes as possible.
       // Here we should refill the buffer as many bytes as possible.
       int bytesRead =
       int bytesRead =
-          input.read(
+          read(
+              input,
               buffer,
               buffer,
               bufferSize,
               bufferSize,
               Math.min(
               Math.min(
@@ -2905,7 +2944,7 @@ public abstract class CodedInputStream {
       // Determine the number of bytes we need to read from the input stream.
       // Determine the number of bytes we need to read from the input stream.
       int sizeLeft = size - bufferedBytes;
       int sizeLeft = size - bufferedBytes;
       // TODO(nathanmittler): Consider using a value larger than DEFAULT_BUFFER_SIZE.
       // TODO(nathanmittler): Consider using a value larger than DEFAULT_BUFFER_SIZE.
-      if (sizeLeft < DEFAULT_BUFFER_SIZE || sizeLeft <= input.available()) {
+      if (sizeLeft < DEFAULT_BUFFER_SIZE || sizeLeft <= available(input)) {
         // Either the bytes we need are known to be available, or the required buffer is
         // Either the bytes we need are known to be available, or the required buffer is
         // within an allowed threshold - go ahead and allocate the buffer now.
         // within an allowed threshold - go ahead and allocate the buffer now.
         final byte[] bytes = new byte[size];
         final byte[] bytes = new byte[size];
@@ -2919,7 +2958,7 @@ public abstract class CodedInputStream {
         // Fill the remaining bytes from the input stream.
         // Fill the remaining bytes from the input stream.
         int tempPos = bufferedBytes;
         int tempPos = bufferedBytes;
         while (tempPos < bytes.length) {
         while (tempPos < bytes.length) {
-          int n = input.read(bytes, tempPos, size - tempPos);
+          int n = read(input, bytes, tempPos, size - tempPos);
           if (n == -1) {
           if (n == -1) {
             throw InvalidProtocolBufferException.truncatedMessage();
             throw InvalidProtocolBufferException.truncatedMessage();
           }
           }
@@ -3047,7 +3086,7 @@ public abstract class CodedInputStream {
         try {
         try {
           while (totalSkipped < size) {
           while (totalSkipped < size) {
             int toSkip = size - totalSkipped;
             int toSkip = size - totalSkipped;
-            long skipped = input.skip(toSkip);
+            long skipped = skip(input, toSkip);
             if (skipped < 0 || skipped > toSkip) {
             if (skipped < 0 || skipped > toSkip) {
               throw new IllegalStateException(
               throw new IllegalStateException(
                   input.getClass()
                   input.getClass()

+ 1 - 1
java/core/src/main/java/com/google/protobuf/FieldSet.java

@@ -282,7 +282,7 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
 
 
       // Wrap the contents in a new list so that the caller cannot change
       // Wrap the contents in a new list so that the caller cannot change
       // the list's contents after setting it.
       // the list's contents after setting it.
-      final List newList = new ArrayList();
+      final List newList = new ArrayList<>();
       newList.addAll((List) value);
       newList.addAll((List) value);
       for (final Object element : newList) {
       for (final Object element : newList) {
         verifyType(descriptor, element);
         verifyType(descriptor, element);

+ 18 - 3
java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java

@@ -1537,11 +1537,16 @@ public abstract class GeneratedMessageLite<
       Schema<T> schema = Protobuf.getInstance().schemaFor(result);
       Schema<T> schema = Protobuf.getInstance().schemaFor(result);
       schema.mergeFrom(result, CodedInputStreamReader.forCodedInput(input), extensionRegistry);
       schema.mergeFrom(result, CodedInputStreamReader.forCodedInput(input), extensionRegistry);
       schema.makeImmutable(result);
       schema.makeImmutable(result);
+    } catch (InvalidProtocolBufferException e) {
+      if (e.getThrownFromInputStream()) {
+        e = new InvalidProtocolBufferException(e);
+      }
+      throw e.setUnfinishedMessage(result);
     } catch (IOException e) {
     } catch (IOException e) {
       if (e.getCause() instanceof InvalidProtocolBufferException) {
       if (e.getCause() instanceof InvalidProtocolBufferException) {
         throw (InvalidProtocolBufferException) e.getCause();
         throw (InvalidProtocolBufferException) e.getCause();
       }
       }
-      throw new InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(result);
+      throw new InvalidProtocolBufferException(e).setUnfinishedMessage(result);
     } catch (RuntimeException e) {
     } catch (RuntimeException e) {
       if (e.getCause() instanceof InvalidProtocolBufferException) {
       if (e.getCause() instanceof InvalidProtocolBufferException) {
         throw (InvalidProtocolBufferException) e.getCause();
         throw (InvalidProtocolBufferException) e.getCause();
@@ -1565,11 +1570,16 @@ public abstract class GeneratedMessageLite<
       if (result.memoizedHashCode != 0) {
       if (result.memoizedHashCode != 0) {
         throw new RuntimeException();
         throw new RuntimeException();
       }
       }
+    } catch (InvalidProtocolBufferException e) {
+      if (e.getThrownFromInputStream()) {
+        e = new InvalidProtocolBufferException(e);
+      }
+      throw e.setUnfinishedMessage(result);
     } catch (IOException e) {
     } catch (IOException e) {
       if (e.getCause() instanceof InvalidProtocolBufferException) {
       if (e.getCause() instanceof InvalidProtocolBufferException) {
         throw (InvalidProtocolBufferException) e.getCause();
         throw (InvalidProtocolBufferException) e.getCause();
       }
       }
-      throw new InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(result);
+      throw new InvalidProtocolBufferException(e).setUnfinishedMessage(result);
     } catch (IndexOutOfBoundsException e) {
     } catch (IndexOutOfBoundsException e) {
       throw InvalidProtocolBufferException.truncatedMessage().setUnfinishedMessage(result);
       throw InvalidProtocolBufferException.truncatedMessage().setUnfinishedMessage(result);
     }
     }
@@ -1727,8 +1737,13 @@ public abstract class GeneratedMessageLite<
         return null;
         return null;
       }
       }
       size = CodedInputStream.readRawVarint32(firstByte, input);
       size = CodedInputStream.readRawVarint32(firstByte, input);
+    } catch (InvalidProtocolBufferException e) {
+      if (e.getThrownFromInputStream()) {
+        e = new InvalidProtocolBufferException(e);
+      }
+      throw e;
     } catch (IOException e) {
     } catch (IOException e) {
-      throw new InvalidProtocolBufferException(e.getMessage());
+      throw new InvalidProtocolBufferException(e);
     }
     }
     InputStream limitedInput = new LimitedInputStream(input, size);
     InputStream limitedInput = new LimitedInputStream(input, size);
     CodedInputStream codedInput = CodedInputStream.newInstance(limitedInput);
     CodedInputStream codedInput = CodedInputStream.newInstance(limitedInput);

+ 23 - 0
java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java

@@ -41,6 +41,7 @@ import java.io.IOException;
 public class InvalidProtocolBufferException extends IOException {
 public class InvalidProtocolBufferException extends IOException {
   private static final long serialVersionUID = -1616151763072450476L;
   private static final long serialVersionUID = -1616151763072450476L;
   private MessageLite unfinishedMessage = null;
   private MessageLite unfinishedMessage = null;
+  private boolean wasThrownFromInputStream;
 
 
   public InvalidProtocolBufferException(final String description) {
   public InvalidProtocolBufferException(final String description) {
     super(description);
     super(description);
@@ -72,6 +73,28 @@ public class InvalidProtocolBufferException extends IOException {
     return unfinishedMessage;
     return unfinishedMessage;
   }
   }
 
 
+  /** Set by CodedInputStream */
+  void setThrownFromInputStream() {
+    /* This write can be racy if the same exception is stored and then thrown by multiple custom
+     * InputStreams on different threads. But since it only ever moves from false->true, there's no
+     * problem. A thread checking this condition after catching this exception from a delegate
+     * stream of CodedInputStream is guaranteed to always observe true, because a write on the same
+     * thread set the value when the exception left the delegate. A thread checking the same
+     * condition with an exception created by CodedInputStream is guaranteed to always see false,
+     * because the exception has not been exposed to any code that could publish it to other threads
+     * and cause a write.
+     */
+    wasThrownFromInputStream = true;
+  }
+
+  /**
+   * Allows code catching IOException from CodedInputStream to tell whether this instance was thrown
+   * by a delegate InputStream, rather than directly by a parse failure.
+   */
+  boolean getThrownFromInputStream() {
+    return wasThrownFromInputStream;
+  }
+
   /**
   /**
    * Unwraps the underlying {@link IOException} if this exception was caused by an I/O problem.
    * Unwraps the underlying {@link IOException} if this exception was caused by an I/O problem.
    * Otherwise, returns {@code this}.
    * Otherwise, returns {@code this}.

+ 1 - 1
java/core/src/main/java/com/google/protobuf/UnsafeUtil.java

@@ -346,7 +346,7 @@ final class UnsafeUtil {
     return MEMORY_ACCESSOR.supportsUnsafeByteBufferOperations();
     return MEMORY_ACCESSOR.supportsUnsafeByteBufferOperations();
   }
   }
 
 
-  private static boolean determineAndroidSupportByAddressSize(Class<?> addressClass) {
+  static boolean determineAndroidSupportByAddressSize(Class<?> addressClass) {
     if (!Android.isOnAndroidDevice()) {
     if (!Android.isOnAndroidDevice()) {
       return false;
       return false;
     }
     }

+ 1 - 0
java/lite/generate-test-sources-build.xml

@@ -4,6 +4,7 @@
         <arg value="--java_out=lite:${generated.testsources.dir}"/>
         <arg value="--java_out=lite:${generated.testsources.dir}"/>
         <arg value="--proto_path=${protobuf.source.dir}"/>
         <arg value="--proto_path=${protobuf.source.dir}"/>
         <arg value="--proto_path=${protobuf.basedir}/java/core/${test.proto.dir}"/>
         <arg value="--proto_path=${protobuf.basedir}/java/core/${test.proto.dir}"/>
+        <arg value="${protobuf.source.dir}/google/protobuf/descriptor.proto"/>
         <arg value="${protobuf.source.dir}/google/protobuf/unittest.proto"/>
         <arg value="${protobuf.source.dir}/google/protobuf/unittest.proto"/>
         <arg value="${protobuf.source.dir}/google/protobuf/unittest_import.proto"/>
         <arg value="${protobuf.source.dir}/google/protobuf/unittest_import.proto"/>
         <arg value="${protobuf.source.dir}/google/protobuf/unittest_import_lite.proto"/>
         <arg value="${protobuf.source.dir}/google/protobuf/unittest_import_lite.proto"/>

+ 156 - 0
java/lite/src/test/java/com/google/protobuf/LiteTest.java

@@ -38,6 +38,7 @@ import com.google.protobuf.UnittestImportLite.ImportEnumLite;
 import com.google.protobuf.UnittestImportPublicLite.PublicImportMessageLite;
 import com.google.protobuf.UnittestImportPublicLite.PublicImportMessageLite;
 import com.google.protobuf.UnittestLite.ForeignEnumLite;
 import com.google.protobuf.UnittestLite.ForeignEnumLite;
 import com.google.protobuf.UnittestLite.ForeignMessageLite;
 import com.google.protobuf.UnittestLite.ForeignMessageLite;
+import com.google.protobuf.UnittestLite.RecursiveMessage;
 import com.google.protobuf.UnittestLite.TestAllExtensionsLite;
 import com.google.protobuf.UnittestLite.TestAllExtensionsLite;
 import com.google.protobuf.UnittestLite.TestAllTypesLite;
 import com.google.protobuf.UnittestLite.TestAllTypesLite;
 import com.google.protobuf.UnittestLite.TestAllTypesLite.NestedEnum;
 import com.google.protobuf.UnittestLite.TestAllTypesLite.NestedEnum;
@@ -61,6 +62,7 @@ import protobuf_unittest.lite_equals_and_hash.LiteEqualsAndHash.TestRecursiveOne
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.OutputStream;
 import java.lang.reflect.Field;
 import java.lang.reflect.Field;
 import java.nio.ByteBuffer;
 import java.nio.ByteBuffer;
@@ -1638,6 +1640,160 @@ public class LiteTest extends TestCase {
     }
     }
   }
   }
 
 
+  public void testParseFromStream_IOExceptionNotLost() throws Exception {
+    final IOException readException = new IOException();
+    try {
+      TestAllTypesLite.parseFrom(
+          CodedInputStream.newInstance(
+              new InputStream() {
+                @Override
+                public int read() throws IOException {
+                  throw readException;
+                }
+              }));
+      fail();
+    } catch (InvalidProtocolBufferException expected) {
+      boolean found = false;
+      for (Throwable exception = expected; exception != null; exception = exception.getCause()) {
+        if (exception == readException) {
+          found = true;
+          break;
+        }
+      }
+      if (!found) {
+        throw new AssertionError("Lost cause of parsing error", expected);
+      }
+    }
+  }
+
+  public void testParseDelimitedFromStream_IOExceptionNotLost() throws Exception {
+    final IOException readException = new IOException();
+    try {
+      TestAllTypesLite.parseDelimitedFrom(
+          new InputStream() {
+            @Override
+            public int read() throws IOException {
+              throw readException;
+            }
+          });
+      fail();
+    } catch (InvalidProtocolBufferException expected) {
+      boolean found = false;
+      for (Throwable exception = expected; exception != null; exception = exception.getCause()) {
+        if (exception == readException) {
+          found = true;
+          break;
+        }
+      }
+      if (!found) {
+        throw new AssertionError("Lost cause of parsing error", expected);
+      }
+    }
+  }
+
+  public void testParseFromArray_manyNestedMessagesError() throws Exception {
+    RecursiveMessage.Builder recursiveMessage =
+        RecursiveMessage.newBuilder().setPayload(ByteString.copyFrom(new byte[1]));
+    for (int i = 0; i < 20; i++) {
+      recursiveMessage = RecursiveMessage.newBuilder().setRecurse(recursiveMessage.build());
+    }
+    byte[] result = recursiveMessage.build().toByteArray();
+    result[
+            result.length
+                - CodedOutputStream.computeTagSize(RecursiveMessage.PAYLOAD_FIELD_NUMBER)
+                - CodedOutputStream.computeLengthDelimitedFieldSize(1)] =
+        0; // Set invalid tag
+    try {
+      RecursiveMessage.parseFrom(result);
+      fail("Result was: " + Arrays.toString(result));
+    } catch (InvalidProtocolBufferException expected) {
+      boolean found = false;
+      int exceptionCount = 0;
+      for (Throwable exception = expected; exception != null; exception = exception.getCause()) {
+        if (exception instanceof InvalidProtocolBufferException) {
+          exceptionCount++;
+        }
+        for (StackTraceElement element : exception.getStackTrace()) {
+          if (InvalidProtocolBufferException.class.getName().equals(element.getClassName())
+              && "invalidTag".equals(element.getMethodName())) {
+            found = true;
+          } else if (Android.isOnAndroidDevice()
+              && "decodeUnknownField".equals(element.getMethodName())) {
+            // Android is missing the first element of the stack trace - b/181147885
+            found = true;
+          }
+        }
+      }
+      if (!found) {
+        throw new AssertionError("Lost cause of parsing error", expected);
+      }
+      if (exceptionCount > 1) {
+        throw new AssertionError(exceptionCount + " nested parsing exceptions", expected);
+      }
+    }
+  }
+
+  public void testParseFromStream_manyNestedMessagesError() throws Exception {
+    RecursiveMessage.Builder recursiveMessage =
+        RecursiveMessage.newBuilder().setPayload(ByteString.copyFrom(new byte[1]));
+    for (int i = 0; i < 20; i++) {
+      recursiveMessage = RecursiveMessage.newBuilder().setRecurse(recursiveMessage.build());
+    }
+    byte[] result = recursiveMessage.build().toByteArray();
+    result[
+            result.length
+                - CodedOutputStream.computeTagSize(RecursiveMessage.PAYLOAD_FIELD_NUMBER)
+                - CodedOutputStream.computeLengthDelimitedFieldSize(1)] =
+        0; // Set invalid tag
+    try {
+      RecursiveMessage.parseFrom(CodedInputStream.newInstance(new ByteArrayInputStream(result)));
+      fail("Result was: " + Arrays.toString(result));
+    } catch (InvalidProtocolBufferException expected) {
+      boolean found = false;
+      int exceptionCount = 0;
+      for (Throwable exception = expected; exception != null; exception = exception.getCause()) {
+        if (exception instanceof InvalidProtocolBufferException) {
+          exceptionCount++;
+        }
+        for (StackTraceElement element : exception.getStackTrace()) {
+          if (InvalidProtocolBufferException.class.getName().equals(element.getClassName())
+              && "invalidTag".equals(element.getMethodName())) {
+            found = true;
+          } else if (Android.isOnAndroidDevice() && "readTag".equals(element.getMethodName())) {
+            // Android is missing the first element of the stack trace - b/181147885
+            found = true;
+          }
+        }
+      }
+      if (!found) {
+        throw new AssertionError("Lost cause of parsing error", expected);
+      }
+      if (exceptionCount > 1) {
+        throw new AssertionError(exceptionCount + " nested parsing exceptions", expected);
+      }
+    }
+  }
+
+  public void testParseFromStream_sneakyNestedException() throws Exception {
+    final InvalidProtocolBufferException sketchy =
+        new InvalidProtocolBufferException("Created in a sketchy way!")
+            .setUnfinishedMessage(TestAllTypesLite.getDefaultInstance());
+    try {
+      RecursiveMessage.parseFrom(
+          CodedInputStream.newInstance(
+              new InputStream() {
+                @Override
+                public int read() throws IOException {
+                  throw sketchy;
+                }
+              }));
+      fail();
+    } catch (InvalidProtocolBufferException expected) {
+      assertNotSame(expected, sketchy);
+    }
+    assertEquals(sketchy.getUnfinishedMessage(), TestAllTypesLite.getDefaultInstance());
+  }
+
   public void testMergeFrom_sanity() throws Exception {
   public void testMergeFrom_sanity() throws Exception {
     TestAllTypesLite one = TestUtilLite.getAllLiteSetBuilder().build();
     TestAllTypesLite one = TestUtilLite.getAllLiteSetBuilder().build();
     byte[] bytes = one.toByteArray();
     byte[] bytes = one.toByteArray();

+ 2 - 2
java/pom.xml

@@ -93,12 +93,12 @@
       <dependency>
       <dependency>
         <groupId>com.google.guava</groupId>
         <groupId>com.google.guava</groupId>
         <artifactId>guava</artifactId>
         <artifactId>guava</artifactId>
-        <version>30.0-android</version>
+        <version>30.1-android</version>
       </dependency>
       </dependency>
       <dependency>
       <dependency>
         <groupId>com.google.guava</groupId>
         <groupId>com.google.guava</groupId>
         <artifactId>guava-testlib</artifactId>
         <artifactId>guava-testlib</artifactId>
-        <version>30.0-android</version>
+        <version>30.1-android</version>
         <scope>test</scope>
         <scope>test</scope>
       </dependency>
       </dependency>
       <dependency>
       <dependency>

+ 7 - 3
kokoro/linux/dockerfile/test/csharp/Dockerfile

@@ -1,4 +1,4 @@
-FROM debian:stretch
+FROM debian:buster
 
 
 # Install dependencies.  We start with the basic ones require to build protoc
 # Install dependencies.  We start with the basic ones require to build protoc
 # and the C++ build
 # and the C++ build
@@ -22,14 +22,18 @@ RUN apt-get update && apt-get install -y \
   wget \
   wget \
   && apt-get clean
   && apt-get clean
 
 
+# Update ca-certificates to fix known buster + .NET 5 issue
+# https://github.com/NuGet/Announcements/issues/49
+RUN apt-get update && apt-get install -y ca-certificates && apt-get clean
+
 # dotnet SDK prerequisites
 # dotnet SDK prerequisites
-RUN apt-get update && apt-get install -y libunwind8 libicu57 && apt-get clean
+RUN apt-get update && apt-get install -y libunwind8 libicu63 && apt-get clean
 
 
 # Install dotnet SDK via install script
 # Install dotnet SDK via install script
 RUN wget -q https://dot.net/v1/dotnet-install.sh && \
 RUN wget -q https://dot.net/v1/dotnet-install.sh && \
     chmod u+x dotnet-install.sh && \
     chmod u+x dotnet-install.sh && \
     ./dotnet-install.sh --version 2.1.802 && \
     ./dotnet-install.sh --version 2.1.802 && \
-    ./dotnet-install.sh --version 3.1.301 && \
+    ./dotnet-install.sh --version 5.0.102 && \
     ln -s /root/.dotnet/dotnet /usr/local/bin
     ln -s /root/.dotnet/dotnet /usr/local/bin
 
 
 RUN wget -q www.nuget.org/NuGet.exe -O /usr/local/bin/nuget.exe
 RUN wget -q www.nuget.org/NuGet.exe -O /usr/local/bin/nuget.exe

+ 0 - 17
kokoro/linux/python/build.sh

@@ -1,17 +0,0 @@
-#!/bin/bash
-#
-# This is the top-level script we give to Kokoro as the entry point for
-# running the "pull request" project:
-#
-# This script selects a specific Dockerfile (for building a Docker image) and
-# a script to run inside that image.  Then we delegate to the general
-# build_and_run_docker.sh script.
-
-# Change to repo root
-cd $(dirname $0)/../../..
-
-export DOCKERFILE_DIR=kokoro/linux/64-bit
-export DOCKER_RUN_SCRIPT=kokoro/linux/pull_request_in_docker.sh
-export OUTPUT_DIR=testoutput
-export TEST_SET="python"
-./kokoro/linux/build_and_run_docker.sh

+ 0 - 11
kokoro/linux/python/continuous.cfg

@@ -1,11 +0,0 @@
-# Config file for running tests in Kokoro
-
-# Location of the build script in repository
-build_file: "protobuf/kokoro/linux/python/build.sh"
-timeout_mins: 120
-
-action {
-  define_artifacts {
-    regex: "**/sponge_log.xml"
-  }
-}

+ 0 - 11
kokoro/linux/python/presubmit.cfg

@@ -1,11 +0,0 @@
-# Config file for running tests in Kokoro
-
-# Location of the build script in repository
-build_file: "protobuf/kokoro/linux/python/build.sh"
-timeout_mins: 120
-
-action {
-  define_artifacts {
-    regex: "**/sponge_log.xml"
-  }
-}

+ 25 - 24
objectivec/GPBExtensionRegistry.m

@@ -34,18 +34,20 @@
 #import "GPBDescriptor.h"
 #import "GPBDescriptor.h"
 
 
 @implementation GPBExtensionRegistry {
 @implementation GPBExtensionRegistry {
-  NSMutableDictionary *mutableClassMap_;
+  CFMutableDictionaryRef mutableClassMap_;
 }
 }
 
 
 - (instancetype)init {
 - (instancetype)init {
   if ((self = [super init])) {
   if ((self = [super init])) {
-    mutableClassMap_ = [[NSMutableDictionary alloc] init];
+    // The keys are ObjC classes, so straight up ptr comparisons are fine.
+    mutableClassMap_ = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL,
+                                             &kCFTypeDictionaryValueCallBacks);
   }
   }
   return self;
   return self;
 }
 }
 
 
 - (void)dealloc {
 - (void)dealloc {
-  [mutableClassMap_ release];
+  CFRelease(mutableClassMap_);
   [super dealloc];
   [super dealloc];
 }
 }
 
 
@@ -68,14 +70,13 @@
 
 
   Class containingMessageClass = extension.containingMessageClass;
   Class containingMessageClass = extension.containingMessageClass;
   CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef)
   CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef)
-      [mutableClassMap_ objectForKey:containingMessageClass];
+      CFDictionaryGetValue(mutableClassMap_, containingMessageClass);
   if (extensionMap == nil) {
   if (extensionMap == nil) {
     // Use a custom dictionary here because the keys are numbers and conversion
     // Use a custom dictionary here because the keys are numbers and conversion
     // back and forth from NSNumber isn't worth the cost.
     // back and forth from NSNumber isn't worth the cost.
     extensionMap = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL,
     extensionMap = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL,
                                              &kCFTypeDictionaryValueCallBacks);
                                              &kCFTypeDictionaryValueCallBacks);
-    [mutableClassMap_ setObject:(id)extensionMap
-                         forKey:(id<NSCopying>)containingMessageClass];
+    CFDictionarySetValue(mutableClassMap_, containingMessageClass, extensionMap);
     CFRelease(extensionMap);
     CFRelease(extensionMap);
   }
   }
 
 
@@ -87,7 +88,7 @@
                                        fieldNumber:(NSInteger)fieldNumber {
                                        fieldNumber:(NSInteger)fieldNumber {
   Class messageClass = descriptor.messageClass;
   Class messageClass = descriptor.messageClass;
   CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef)
   CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef)
-      [mutableClassMap_ objectForKey:messageClass];
+      CFDictionaryGetValue(mutableClassMap_, messageClass);
   ssize_t key = fieldNumber;
   ssize_t key = fieldNumber;
   GPBExtensionDescriptor *result =
   GPBExtensionDescriptor *result =
       (extensionMap
       (extensionMap
@@ -101,28 +102,28 @@ static void CopyKeyValue(const void *key, const void *value, void *context) {
   CFDictionarySetValue(extensionMap, key, value);
   CFDictionarySetValue(extensionMap, key, value);
 }
 }
 
 
+static void CopySubDictionary(const void *key, const void *value, void *context) {
+  CFMutableDictionaryRef mutableClassMap = (CFMutableDictionaryRef)context;
+  Class containingMessageClass = key;
+  CFMutableDictionaryRef otherExtensionMap = (CFMutableDictionaryRef)value;
+
+  CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef)
+      CFDictionaryGetValue(mutableClassMap, containingMessageClass);
+  if (extensionMap == nil) {
+    extensionMap = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, otherExtensionMap);
+    CFDictionarySetValue(mutableClassMap, containingMessageClass, extensionMap);
+    CFRelease(extensionMap);
+  } else {
+    CFDictionaryApplyFunction(otherExtensionMap, CopyKeyValue, extensionMap);
+  }
+}
+
 - (void)addExtensions:(GPBExtensionRegistry *)registry {
 - (void)addExtensions:(GPBExtensionRegistry *)registry {
   if (registry == nil) {
   if (registry == nil) {
     // In the case where there are no extensions just ignore.
     // In the case where there are no extensions just ignore.
     return;
     return;
   }
   }
-  NSMutableDictionary *otherClassMap = registry->mutableClassMap_;
-  [otherClassMap enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL * stop) {
-#pragma unused(stop)
-    Class containingMessageClass = key;
-    CFMutableDictionaryRef otherExtensionMap = (CFMutableDictionaryRef)value;
-
-    CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef)
-        [mutableClassMap_ objectForKey:containingMessageClass];
-    if (extensionMap == nil) {
-      extensionMap = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, otherExtensionMap);
-      [mutableClassMap_ setObject:(id)extensionMap
-                           forKey:(id<NSCopying>)containingMessageClass];
-      CFRelease(extensionMap);
-    } else {
-      CFDictionaryApplyFunction(otherExtensionMap, CopyKeyValue, extensionMap);
-    }
-  }];
+  CFDictionaryApplyFunction(registry->mutableClassMap_, CopySubDictionary, mutableClassMap_);
 }
 }
 
 
 #pragma clang diagnostic pop
 #pragma clang diagnostic pop

+ 2 - 2
php/README.md

@@ -16,8 +16,8 @@ generation functionality.
 
 
 To use PHP runtime library requires:
 To use PHP runtime library requires:
 
 
-- C extension: PHP 5.5, 5.6, or 7.
-- [PHP package](http://php.net/downloads.php): PHP 5.5, 5.6 or 7.
+- C extension: PHP 7.x, 8.0
+- [PHP package](http://php.net/downloads.php): PHP 5.5, 5.6, 7.x, or 8.0.
 
 
 ## Installation
 ## Installation
 
 

+ 5 - 5
php/src/Google/Protobuf/Internal/RepeatedField.php

@@ -67,7 +67,7 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
     /**
     /**
      * Constructs an instance of RepeatedField.
      * Constructs an instance of RepeatedField.
      *
      *
-     * @param long $type Type of the stored element.
+     * @param integer $type Type of the stored element.
      * @param string $klass Message/Enum class name (message/enum fields only).
      * @param string $klass Message/Enum class name (message/enum fields only).
      * @ignore
      * @ignore
      */
      */
@@ -116,7 +116,7 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
      *
      *
      * This will also be called for: $ele = $arr[0]
      * This will also be called for: $ele = $arr[0]
      *
      *
-     * @param long $offset The index of the element to be fetched.
+     * @param integer $offset The index of the element to be fetched.
      * @return object The stored element at given index.
      * @return object The stored element at given index.
      * @throws \ErrorException Invalid type for index.
      * @throws \ErrorException Invalid type for index.
      * @throws \ErrorException Non-existing index.
      * @throws \ErrorException Non-existing index.
@@ -131,7 +131,7 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
      *
      *
      * This will also be called for: $arr []= $ele and $arr[0] = ele
      * This will also be called for: $arr []= $ele and $arr[0] = ele
      *
      *
-     * @param long $offset The index of the element to be assigned.
+     * @param integer $offset The index of the element to be assigned.
      * @param object $value The element to be assigned.
      * @param object $value The element to be assigned.
      * @return void
      * @return void
      * @throws \ErrorException Invalid type for index.
      * @throws \ErrorException Invalid type for index.
@@ -204,7 +204,7 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
      *
      *
      * This will also be called for: unset($arr)
      * This will also be called for: unset($arr)
      *
      *
-     * @param long $offset The index of the element to be removed.
+     * @param integer $offset The index of the element to be removed.
      * @return void
      * @return void
      * @throws \ErrorException Invalid type for index.
      * @throws \ErrorException Invalid type for index.
      * @throws \ErrorException The element to be removed is not at the end of the
      * @throws \ErrorException The element to be removed is not at the end of the
@@ -227,7 +227,7 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
      *
      *
      * This will also be called for: isset($arr)
      * This will also be called for: isset($arr)
      *
      *
-     * @param long $offset The index of the element to be removed.
+     * @param integer $offset The index of the element to be removed.
      * @return bool True if the element at the given offset exists.
      * @return bool True if the element at the given offset exists.
      * @throws \ErrorException Invalid type for index.
      * @throws \ErrorException Invalid type for index.
      */
      */

+ 1 - 8
python/google/protobuf/internal/message_test.py

@@ -841,8 +841,7 @@ class MessageTest(unittest.TestCase):
     m1.MergeFromString(m2.SerializeToString())
     m1.MergeFromString(m2.SerializeToString())
     self.assertEqual(1, m1.optional_nested_message.bb)
     self.assertEqual(1, m1.optional_nested_message.bb)
 
 
-  @unittest.skipIf(six.PY2, 'memoryview objects are not supported on py2')
-  def testMergeFromStringUsingMemoryViewWorksInPy3(self, message_module):
+  def testMergeFromStringUsingMemoryView(self, message_module):
     m2 = message_module.TestAllTypes()
     m2 = message_module.TestAllTypes()
     m2.optional_string = 'scalar string'
     m2.optional_string = 'scalar string'
     m2.repeated_string.append('repeated string')
     m2.repeated_string.append('repeated string')
@@ -864,12 +863,6 @@ class MessageTest(unittest.TestCase):
     self.assertIsInstance(m1.optional_string, six.text_type)
     self.assertIsInstance(m1.optional_string, six.text_type)
     self.assertIsInstance(m1.repeated_string[0], six.text_type)
     self.assertIsInstance(m1.repeated_string[0], six.text_type)
 
 
-  @unittest.skipIf(six.PY3, 'memoryview is supported by py3')
-  def testMergeFromStringUsingMemoryViewIsPy2Error(self, message_module):
-    memview = memoryview(b'')
-    with self.assertRaises(TypeError):
-      message_module.TestAllTypes.FromString(memview)
-
   def testMergeFromEmpty(self, message_module):
   def testMergeFromEmpty(self, message_module):
     m1 = message_module.TestAllTypes()
     m1 = message_module.TestAllTypes()
     # Cpp extension will lazily create a sub message which is immutable.
     # Cpp extension will lazily create a sub message which is immutable.

+ 0 - 6
python/google/protobuf/internal/python_message.py

@@ -1133,12 +1133,6 @@ def _AddSerializePartialToStringMethod(message_descriptor, cls):
 def _AddMergeFromStringMethod(message_descriptor, cls):
 def _AddMergeFromStringMethod(message_descriptor, cls):
   """Helper for _AddMessageMethods()."""
   """Helper for _AddMessageMethods()."""
   def MergeFromString(self, serialized):
   def MergeFromString(self, serialized):
-    if isinstance(serialized, memoryview) and six.PY2:
-      raise TypeError(
-          'memoryview not supported in Python 2 with the pure Python proto '
-          'implementation: this is to maintain compatibility with the C++ '
-          'implementation')
-
     serialized = memoryview(serialized)
     serialized = memoryview(serialized)
     length = len(serialized)
     length = len(serialized)
     try:
     try:

+ 1 - 1
python/google/protobuf/pyext/descriptor.cc

@@ -248,7 +248,7 @@ static PyObject* GetOrBuildOptions(const DescriptorClass *descriptor) {
     return NULL;
     return NULL;
   }
   }
   ScopedPyObjectPtr value(
   ScopedPyObjectPtr value(
-      PyEval_CallObject(message_class->AsPyObject(), NULL));
+      PyObject_Call(message_class->AsPyObject(), NULL, NULL));
   Py_DECREF(message_class);
   Py_DECREF(message_class);
   if (value == NULL) {
   if (value == NULL) {
     return NULL;
     return NULL;

+ 2 - 2
python/google/protobuf/pyext/descriptor_pool.cc

@@ -176,9 +176,9 @@ static PyDescriptorPool* PyDescriptorPool_NewWithDatabase(
 // The public DescriptorPool constructor.
 // The public DescriptorPool constructor.
 static PyObject* New(PyTypeObject* type,
 static PyObject* New(PyTypeObject* type,
                      PyObject* args, PyObject* kwargs) {
                      PyObject* args, PyObject* kwargs) {
-  static char* kwlist[] = {"descriptor_db", 0};
+  static const char* kwlist[] = {"descriptor_db", 0};
   PyObject* py_database = NULL;
   PyObject* py_database = NULL;
-  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", kwlist, &py_database)) {
+  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", const_cast<char**>(kwlist), &py_database)) {
     return NULL;
     return NULL;
   }
   }
   DescriptorDatabase* database = NULL;
   DescriptorDatabase* database = NULL;

+ 4 - 4
python/google/protobuf/pyext/map_container.cc

@@ -462,10 +462,10 @@ int MapReflectionFriend::ScalarMapSetItem(PyObject* _self, PyObject* key,
 
 
 static PyObject* ScalarMapGet(PyObject* self, PyObject* args,
 static PyObject* ScalarMapGet(PyObject* self, PyObject* args,
                               PyObject* kwargs) {
                               PyObject* kwargs) {
-  static char* kwlist[] = {"key", "default", nullptr};
+  static const char* kwlist[] = {"key", "default", nullptr};
   PyObject* key;
   PyObject* key;
   PyObject* default_value = NULL;
   PyObject* default_value = NULL;
-  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", kwlist, &key,
+  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", const_cast<char**>(kwlist), &key,
                                    &default_value)) {
                                    &default_value)) {
     return NULL;
     return NULL;
   }
   }
@@ -757,10 +757,10 @@ PyObject* MapReflectionFriend::MessageMapToStr(PyObject* _self) {
 }
 }
 
 
 PyObject* MessageMapGet(PyObject* self, PyObject* args, PyObject* kwargs) {
 PyObject* MessageMapGet(PyObject* self, PyObject* args, PyObject* kwargs) {
-  static char* kwlist[] = {"key", "default", nullptr};
+  static const char* kwlist[] = {"key", "default", nullptr};
   PyObject* key;
   PyObject* key;
   PyObject* default_value = NULL;
   PyObject* default_value = NULL;
-  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", kwlist, &key,
+  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", const_cast<char**>(kwlist), &key,
                                    &default_value)) {
                                    &default_value)) {
     return NULL;
     return NULL;
   }
   }

+ 11 - 11
python/google/protobuf/pyext/message.cc

@@ -196,12 +196,12 @@ static int AddDescriptors(PyObject* cls, const Descriptor* descriptor) {
 }
 }
 
 
 static PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
 static PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
-  static char *kwlist[] = {"name", "bases", "dict", 0};
+  static const char *kwlist[] = {"name", "bases", "dict", 0};
   PyObject *bases, *dict;
   PyObject *bases, *dict;
   const char* name;
   const char* name;
 
 
   // Check arguments: (name, bases, dict)
   // Check arguments: (name, bases, dict)
-  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO!O!:type", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO!O!:type", const_cast<char**>(kwlist),
                                    &name,
                                    &name,
                                    &PyTuple_Type, &bases,
                                    &PyTuple_Type, &bases,
                                    &PyDict_Type, &dict)) {
                                    &PyDict_Type, &dict)) {
@@ -546,7 +546,7 @@ PyObject* PickleError_class;
 
 
 // Format an error message for unexpected types.
 // Format an error message for unexpected types.
 // Always return with an exception set.
 // Always return with an exception set.
-void FormatTypeError(PyObject* arg, char* expected_types) {
+void FormatTypeError(PyObject* arg, const char* expected_types) {
   // This function is often called with an exception set.
   // This function is often called with an exception set.
   // Clear it to call PyObject_Repr() in good conditions.
   // Clear it to call PyObject_Repr() in good conditions.
   PyErr_Clear();
   PyErr_Clear();
@@ -1679,9 +1679,9 @@ static PyObject* InternalSerializeToString(
     CMessage* self, PyObject* args, PyObject* kwargs,
     CMessage* self, PyObject* args, PyObject* kwargs,
     bool require_initialized) {
     bool require_initialized) {
   // Parse the "deterministic" kwarg; defaults to False.
   // Parse the "deterministic" kwarg; defaults to False.
-  static char* kwlist[] = { "deterministic", 0 };
+  static const char* kwlist[] = { "deterministic", 0 };
   PyObject* deterministic_obj = Py_None;
   PyObject* deterministic_obj = Py_None;
-  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", const_cast<char**>(kwlist),
                                    &deterministic_obj)) {
                                    &deterministic_obj)) {
     return NULL;
     return NULL;
   }
   }
@@ -1927,9 +1927,8 @@ PyObject* SetAllowOversizeProtos(PyObject* m, PyObject* arg) {
 }
 }
 
 
 static PyObject* MergeFromString(CMessage* self, PyObject* arg) {
 static PyObject* MergeFromString(CMessage* self, PyObject* arg) {
-  const void* data;
-  Py_ssize_t data_length;
-  if (PyObject_AsReadBuffer(arg, &data, &data_length) < 0) {
+  Py_buffer data;
+  if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) < 0) {
     return NULL;
     return NULL;
   }
   }
 
 
@@ -1942,7 +1941,8 @@ static PyObject* MergeFromString(CMessage* self, PyObject* arg) {
   const char* ptr;
   const char* ptr;
   internal::ParseContext ctx(
   internal::ParseContext ctx(
       depth, false, &ptr,
       depth, false, &ptr,
-      StringPiece(static_cast<const char*>(data), data_length));
+      StringPiece(static_cast<const char*>(data.buf), data.len));
+  PyBuffer_Release(&data);
   ctx.data().pool = factory->pool->pool;
   ctx.data().pool = factory->pool->pool;
   ctx.data().factory = factory->message_factory;
   ctx.data().factory = factory->message_factory;
 
 
@@ -1968,9 +1968,9 @@ static PyObject* MergeFromString(CMessage* self, PyObject* arg) {
     // TODO(jieluo): Raise error and return NULL instead.
     // TODO(jieluo): Raise error and return NULL instead.
     // b/27494216
     // b/27494216
     PyErr_Warn(nullptr, "Unexpected end-group tag: Not all data was converted");
     PyErr_Warn(nullptr, "Unexpected end-group tag: Not all data was converted");
-    return PyInt_FromLong(data_length - ctx.BytesUntilLimit(ptr));
+    return PyInt_FromLong(data.len - ctx.BytesUntilLimit(ptr));
   }
   }
-  return PyInt_FromLong(data_length);
+  return PyInt_FromLong(data.len);
 }
 }
 
 
 static PyObject* ParseFromString(CMessage* self, PyObject* arg) {
 static PyObject* ParseFromString(CMessage* self, PyObject* arg) {

+ 1 - 1
python/google/protobuf/pyext/message.h

@@ -329,7 +329,7 @@ PyObject* SetAllowOversizeProtos(PyObject* m, PyObject* arg);
 
 
 #define FULL_MODULE_NAME "google.protobuf.pyext._message"
 #define FULL_MODULE_NAME "google.protobuf.pyext._message"
 
 
-void FormatTypeError(PyObject* arg, char* expected_types);
+void FormatTypeError(PyObject* arg, const char* expected_types);
 template<class T>
 template<class T>
 bool CheckAndGetInteger(PyObject* arg, T* value);
 bool CheckAndGetInteger(PyObject* arg, T* value);
 bool CheckAndGetDouble(PyObject* arg, double* value);
 bool CheckAndGetDouble(PyObject* arg, double* value);

+ 2 - 2
python/google/protobuf/pyext/message_factory.cc

@@ -77,9 +77,9 @@ PyMessageFactory* NewMessageFactory(PyTypeObject* type, PyDescriptorPool* pool)
 }
 }
 
 
 PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
 PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
-  static char* kwlist[] = {"pool", 0};
+  static const char* kwlist[] = {"pool", 0};
   PyObject* pool = NULL;
   PyObject* pool = NULL;
-  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", kwlist, &pool)) {
+  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", const_cast<char**>(kwlist), &pool)) {
     return NULL;
     return NULL;
   }
   }
   ScopedPyObjectPtr owned_pool;
   ScopedPyObjectPtr owned_pool;

+ 0 - 2
python/setup.py

@@ -279,8 +279,6 @@ if __name__ == '__main__':
         "Programming Language :: Python :: 3.5",
         "Programming Language :: Python :: 3.5",
         "Programming Language :: Python :: 3.6",
         "Programming Language :: Python :: 3.6",
         "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.7",
-        "Programming Language :: Python :: 3.8",
-        "Programming Language :: Python :: 3.9",
         ],
         ],
       namespace_packages=['google'],
       namespace_packages=['google'],
       packages=find_packages(
       packages=find_packages(

+ 3 - 4
python/tox.ini

@@ -14,10 +14,9 @@ setenv =
 commands =
 commands =
     python setup.py -q build_py
     python setup.py -q build_py
     python: python setup.py -q build
     python: python setup.py -q build
-    # --warnings_as_errors disabled until we update the Python C extension. See:
-    # https://github.com/protocolbuffers/protobuf/issues/7930
-    # cpp: python setup.py -q build --cpp_implementation --warnings_as_errors --compile_static_extension
-    cpp: python setup.py -q build --cpp_implementation --compile_static_extension
+    # --warnings_as_errors disabled for Python 2.7 because _POSIX_C_SOURCE and _XOPEN_SOURCE are redefined
+    py27-cpp: python setup.py -q build --cpp_implementation --compile_static_extension
+    py{33,34,35,36,37,38,39}-cpp: python setup.py -q build --cpp_implementation --warnings_as_errors --compile_static_extension
     python: python setup.py -q test -q
     python: python setup.py -q test -q
     cpp: python setup.py -q test -q --cpp_implementation
     cpp: python setup.py -q test -q --cpp_implementation
     python: python setup.py -q test_conformance
     python: python setup.py -q test_conformance

+ 5 - 6
src/google/protobuf/any.pb.cc

@@ -68,10 +68,8 @@ const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fany_2eproto::offsets,
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fany_2eproto::offsets,
   file_level_metadata_google_2fprotobuf_2fany_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto, file_level_service_descriptors_google_2fprotobuf_2fany_2eproto,
   file_level_metadata_google_2fprotobuf_2fany_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto, file_level_service_descriptors_google_2fprotobuf_2fany_2eproto,
 };
 };
-PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata
-descriptor_table_google_2fprotobuf_2fany_2eproto_metadata_getter(int index) {
-  ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fany_2eproto);
-  return descriptor_table_google_2fprotobuf_2fany_2eproto.file_level_metadata[index];
+PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fany_2eproto_getter() {
+  return &descriptor_table_google_2fprotobuf_2fany_2eproto;
 }
 }
 
 
 // Force running AddDescriptors() at dynamic initialization time.
 // Force running AddDescriptors() at dynamic initialization time.
@@ -323,10 +321,11 @@ void Any::InternalSwap(Any* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata Any::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata Any::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fany_2eproto_getter, &descriptor_table_google_2fprotobuf_2fany_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fany_2eproto[0]);
 }
 }
 
 
-
 // @@protoc_insertion_point(namespace_scope)
 // @@protoc_insertion_point(namespace_scope)
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN

+ 16 - 59
src/google/protobuf/any.pb.h

@@ -53,7 +53,6 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fany_2eproto {
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
 };
 };
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fany_2eproto;
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fany_2eproto;
-PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fany_2eproto_metadata_getter(int index);
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN
 class Any;
 class Any;
 struct AnyDefaultTypeInternal;
 struct AnyDefaultTypeInternal;
@@ -96,10 +95,10 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const Any& default_instance() {
   static const Any& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -200,12 +199,6 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2fany_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -218,10 +211,8 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL :
   // string type_url = 1;
   // string type_url = 1;
   void clear_type_url();
   void clear_type_url();
   const std::string& type_url() const;
   const std::string& type_url() const;
-  void set_type_url(const std::string& value);
-  void set_type_url(std::string&& value);
-  void set_type_url(const char* value);
-  void set_type_url(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_type_url(ArgT0&& arg0, ArgT... args);
   std::string* mutable_type_url();
   std::string* mutable_type_url();
   std::string* release_type_url();
   std::string* release_type_url();
   void set_allocated_type_url(std::string* type_url);
   void set_allocated_type_url(std::string* type_url);
@@ -234,10 +225,8 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL :
   // bytes value = 2;
   // bytes value = 2;
   void clear_value();
   void clear_value();
   const std::string& value() const;
   const std::string& value() const;
-  void set_value(const std::string& value);
-  void set_value(std::string&& value);
-  void set_value(const char* value);
-  void set_value(const void* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_value(ArgT0&& arg0, ArgT... args);
   std::string* mutable_value();
   std::string* mutable_value();
   std::string* release_value();
   std::string* release_value();
   void set_allocated_value(std::string* value);
   void set_allocated_value(std::string* value);
@@ -279,8 +268,11 @@ inline const std::string& Any::type_url() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Any.type_url)
   // @@protoc_insertion_point(field_get:google.protobuf.Any.type_url)
   return _internal_type_url();
   return _internal_type_url();
 }
 }
-inline void Any::set_type_url(const std::string& value) {
-  _internal_set_type_url(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Any::set_type_url(ArgT0&& arg0, ArgT... args) {
+ 
+ type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -294,25 +286,6 @@ inline void Any::_internal_set_type_url(const std::string& value) {
   
   
   type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Any::set_type_url(std::string&& value) {
-  
-  type_url_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.type_url)
-}
-inline void Any::set_type_url(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Any.type_url)
-}
-inline void Any::set_type_url(const char* value,
-    size_t size) {
-  
-  type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.type_url)
-}
 inline std::string* Any::_internal_mutable_type_url() {
 inline std::string* Any::_internal_mutable_type_url() {
   
   
   return type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -340,8 +313,11 @@ inline const std::string& Any::value() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Any.value)
   // @@protoc_insertion_point(field_get:google.protobuf.Any.value)
   return _internal_value();
   return _internal_value();
 }
 }
-inline void Any::set_value(const std::string& value) {
-  _internal_set_value(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Any::set_value(ArgT0&& arg0, ArgT... args) {
+ 
+ value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -355,25 +331,6 @@ inline void Any::_internal_set_value(const std::string& value) {
   
   
   value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Any::set_value(std::string&& value) {
-  
-  value_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.value)
-}
-inline void Any::set_value(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Any.value)
-}
-inline void Any::set_value(const void* value,
-    size_t size) {
-  
-  value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.value)
-}
 inline std::string* Any::_internal_mutable_value() {
 inline std::string* Any::_internal_mutable_value() {
   
   
   return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());

+ 11 - 10
src/google/protobuf/api.pb.cc

@@ -150,10 +150,8 @@ const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fapi_2eproto::offsets,
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fapi_2eproto::offsets,
   file_level_metadata_google_2fprotobuf_2fapi_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto, file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto,
   file_level_metadata_google_2fprotobuf_2fapi_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto, file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto,
 };
 };
-PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata
-descriptor_table_google_2fprotobuf_2fapi_2eproto_metadata_getter(int index) {
-  ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fapi_2eproto);
-  return descriptor_table_google_2fprotobuf_2fapi_2eproto.file_level_metadata[index];
+PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fapi_2eproto_getter() {
+  return &descriptor_table_google_2fprotobuf_2fapi_2eproto;
 }
 }
 
 
 // Force running AddDescriptors() at dynamic initialization time.
 // Force running AddDescriptors() at dynamic initialization time.
@@ -575,10 +573,11 @@ void Api::InternalSwap(Api* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata Api::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata Api::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fapi_2eproto[0]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class Method::_Internal {
 class Method::_Internal {
@@ -968,10 +967,11 @@ void Method::InternalSwap(Method* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata Method::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata Method::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fapi_2eproto[1]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class Mixin::_Internal {
 class Mixin::_Internal {
@@ -1206,10 +1206,11 @@ void Mixin::InternalSwap(Mixin* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata Mixin::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata Mixin::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fapi_2eproto[2]);
 }
 }
 
 
-
 // @@protoc_insertion_point(namespace_scope)
 // @@protoc_insertion_point(namespace_scope)
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN

+ 55 - 200
src/google/protobuf/api.pb.h

@@ -55,7 +55,6 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fapi_2eproto {
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
 };
 };
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fapi_2eproto;
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fapi_2eproto;
-PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fapi_2eproto_metadata_getter(int index);
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN
 class Api;
 class Api;
 struct ApiDefaultTypeInternal;
 struct ApiDefaultTypeInternal;
@@ -106,10 +105,10 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const Api& default_instance() {
   static const Api& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -177,12 +176,6 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2fapi_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -254,10 +247,8 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
   // string name = 1;
   // string name = 1;
   void clear_name();
   void clear_name();
   const std::string& name() const;
   const std::string& name() const;
-  void set_name(const std::string& value);
-  void set_name(std::string&& value);
-  void set_name(const char* value);
-  void set_name(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_name(ArgT0&& arg0, ArgT... args);
   std::string* mutable_name();
   std::string* mutable_name();
   std::string* release_name();
   std::string* release_name();
   void set_allocated_name(std::string* name);
   void set_allocated_name(std::string* name);
@@ -270,10 +261,8 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
   // string version = 4;
   // string version = 4;
   void clear_version();
   void clear_version();
   const std::string& version() const;
   const std::string& version() const;
-  void set_version(const std::string& value);
-  void set_version(std::string&& value);
-  void set_version(const char* value);
-  void set_version(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_version(ArgT0&& arg0, ArgT... args);
   std::string* mutable_version();
   std::string* mutable_version();
   std::string* release_version();
   std::string* release_version();
   void set_allocated_version(std::string* version);
   void set_allocated_version(std::string* version);
@@ -359,10 +348,10 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const Method& default_instance() {
   static const Method& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -430,12 +419,6 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2fapi_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -471,10 +454,8 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
   // string name = 1;
   // string name = 1;
   void clear_name();
   void clear_name();
   const std::string& name() const;
   const std::string& name() const;
-  void set_name(const std::string& value);
-  void set_name(std::string&& value);
-  void set_name(const char* value);
-  void set_name(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_name(ArgT0&& arg0, ArgT... args);
   std::string* mutable_name();
   std::string* mutable_name();
   std::string* release_name();
   std::string* release_name();
   void set_allocated_name(std::string* name);
   void set_allocated_name(std::string* name);
@@ -487,10 +468,8 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
   // string request_type_url = 2;
   // string request_type_url = 2;
   void clear_request_type_url();
   void clear_request_type_url();
   const std::string& request_type_url() const;
   const std::string& request_type_url() const;
-  void set_request_type_url(const std::string& value);
-  void set_request_type_url(std::string&& value);
-  void set_request_type_url(const char* value);
-  void set_request_type_url(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_request_type_url(ArgT0&& arg0, ArgT... args);
   std::string* mutable_request_type_url();
   std::string* mutable_request_type_url();
   std::string* release_request_type_url();
   std::string* release_request_type_url();
   void set_allocated_request_type_url(std::string* request_type_url);
   void set_allocated_request_type_url(std::string* request_type_url);
@@ -503,10 +482,8 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
   // string response_type_url = 4;
   // string response_type_url = 4;
   void clear_response_type_url();
   void clear_response_type_url();
   const std::string& response_type_url() const;
   const std::string& response_type_url() const;
-  void set_response_type_url(const std::string& value);
-  void set_response_type_url(std::string&& value);
-  void set_response_type_url(const char* value);
-  void set_response_type_url(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_response_type_url(ArgT0&& arg0, ArgT... args);
   std::string* mutable_response_type_url();
   std::string* mutable_response_type_url();
   std::string* release_response_type_url();
   std::string* release_response_type_url();
   void set_allocated_response_type_url(std::string* response_type_url);
   void set_allocated_response_type_url(std::string* response_type_url);
@@ -592,10 +569,10 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const Mixin& default_instance() {
   static const Mixin& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -663,12 +640,6 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2fapi_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -681,10 +652,8 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
   // string name = 1;
   // string name = 1;
   void clear_name();
   void clear_name();
   const std::string& name() const;
   const std::string& name() const;
-  void set_name(const std::string& value);
-  void set_name(std::string&& value);
-  void set_name(const char* value);
-  void set_name(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_name(ArgT0&& arg0, ArgT... args);
   std::string* mutable_name();
   std::string* mutable_name();
   std::string* release_name();
   std::string* release_name();
   void set_allocated_name(std::string* name);
   void set_allocated_name(std::string* name);
@@ -697,10 +666,8 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
   // string root = 2;
   // string root = 2;
   void clear_root();
   void clear_root();
   const std::string& root() const;
   const std::string& root() const;
-  void set_root(const std::string& value);
-  void set_root(std::string&& value);
-  void set_root(const char* value);
-  void set_root(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_root(ArgT0&& arg0, ArgT... args);
   std::string* mutable_root();
   std::string* mutable_root();
   std::string* release_root();
   std::string* release_root();
   void set_allocated_root(std::string* root);
   void set_allocated_root(std::string* root);
@@ -741,8 +708,11 @@ inline const std::string& Api::name() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Api.name)
   // @@protoc_insertion_point(field_get:google.protobuf.Api.name)
   return _internal_name();
   return _internal_name();
 }
 }
-inline void Api::set_name(const std::string& value) {
-  _internal_set_name(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Api::set_name(ArgT0&& arg0, ArgT... args) {
+ 
+ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -756,25 +726,6 @@ inline void Api::_internal_set_name(const std::string& value) {
   
   
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Api::set_name(std::string&& value) {
-  
-  name_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.name)
-}
-inline void Api::set_name(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Api.name)
-}
-inline void Api::set_name(const char* value,
-    size_t size) {
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.name)
-}
 inline std::string* Api::_internal_mutable_name() {
 inline std::string* Api::_internal_mutable_name() {
   
   
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -877,8 +828,11 @@ inline const std::string& Api::version() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Api.version)
   // @@protoc_insertion_point(field_get:google.protobuf.Api.version)
   return _internal_version();
   return _internal_version();
 }
 }
-inline void Api::set_version(const std::string& value) {
-  _internal_set_version(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Api::set_version(ArgT0&& arg0, ArgT... args) {
+ 
+ version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -892,25 +846,6 @@ inline void Api::_internal_set_version(const std::string& value) {
   
   
   version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Api::set_version(std::string&& value) {
-  
-  version_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.version)
-}
-inline void Api::set_version(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Api.version)
-}
-inline void Api::set_version(const char* value,
-    size_t size) {
-  
-  version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.version)
-}
 inline std::string* Api::_internal_mutable_version() {
 inline std::string* Api::_internal_mutable_version() {
   
   
   return version_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return version_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -1078,8 +1013,11 @@ inline const std::string& Method::name() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Method.name)
   // @@protoc_insertion_point(field_get:google.protobuf.Method.name)
   return _internal_name();
   return _internal_name();
 }
 }
-inline void Method::set_name(const std::string& value) {
-  _internal_set_name(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Method::set_name(ArgT0&& arg0, ArgT... args) {
+ 
+ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -1093,25 +1031,6 @@ inline void Method::_internal_set_name(const std::string& value) {
   
   
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Method::set_name(std::string&& value) {
-  
-  name_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.name)
-}
-inline void Method::set_name(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Method.name)
-}
-inline void Method::set_name(const char* value,
-    size_t size) {
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.name)
-}
 inline std::string* Method::_internal_mutable_name() {
 inline std::string* Method::_internal_mutable_name() {
   
   
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -1139,8 +1058,11 @@ inline const std::string& Method::request_type_url() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url)
   // @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url)
   return _internal_request_type_url();
   return _internal_request_type_url();
 }
 }
-inline void Method::set_request_type_url(const std::string& value) {
-  _internal_set_request_type_url(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Method::set_request_type_url(ArgT0&& arg0, ArgT... args) {
+ 
+ request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -1154,25 +1076,6 @@ inline void Method::_internal_set_request_type_url(const std::string& value) {
   
   
   request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Method::set_request_type_url(std::string&& value) {
-  
-  request_type_url_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.request_type_url)
-}
-inline void Method::set_request_type_url(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Method.request_type_url)
-}
-inline void Method::set_request_type_url(const char* value,
-    size_t size) {
-  
-  request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.request_type_url)
-}
 inline std::string* Method::_internal_mutable_request_type_url() {
 inline std::string* Method::_internal_mutable_request_type_url() {
   
   
   return request_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return request_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -1220,8 +1123,11 @@ inline const std::string& Method::response_type_url() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url)
   // @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url)
   return _internal_response_type_url();
   return _internal_response_type_url();
 }
 }
-inline void Method::set_response_type_url(const std::string& value) {
-  _internal_set_response_type_url(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Method::set_response_type_url(ArgT0&& arg0, ArgT... args) {
+ 
+ response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -1235,25 +1141,6 @@ inline void Method::_internal_set_response_type_url(const std::string& value) {
   
   
   response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Method::set_response_type_url(std::string&& value) {
-  
-  response_type_url_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.response_type_url)
-}
-inline void Method::set_response_type_url(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Method.response_type_url)
-}
-inline void Method::set_response_type_url(const char* value,
-    size_t size) {
-  
-  response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.response_type_url)
-}
 inline std::string* Method::_internal_mutable_response_type_url() {
 inline std::string* Method::_internal_mutable_response_type_url() {
   
   
   return response_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return response_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -1361,8 +1248,11 @@ inline const std::string& Mixin::name() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Mixin.name)
   // @@protoc_insertion_point(field_get:google.protobuf.Mixin.name)
   return _internal_name();
   return _internal_name();
 }
 }
-inline void Mixin::set_name(const std::string& value) {
-  _internal_set_name(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Mixin::set_name(ArgT0&& arg0, ArgT... args) {
+ 
+ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -1376,25 +1266,6 @@ inline void Mixin::_internal_set_name(const std::string& value) {
   
   
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Mixin::set_name(std::string&& value) {
-  
-  name_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.name)
-}
-inline void Mixin::set_name(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.name)
-}
-inline void Mixin::set_name(const char* value,
-    size_t size) {
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.name)
-}
 inline std::string* Mixin::_internal_mutable_name() {
 inline std::string* Mixin::_internal_mutable_name() {
   
   
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -1422,8 +1293,11 @@ inline const std::string& Mixin::root() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Mixin.root)
   // @@protoc_insertion_point(field_get:google.protobuf.Mixin.root)
   return _internal_root();
   return _internal_root();
 }
 }
-inline void Mixin::set_root(const std::string& value) {
-  _internal_set_root(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Mixin::set_root(ArgT0&& arg0, ArgT... args) {
+ 
+ root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -1437,25 +1311,6 @@ inline void Mixin::_internal_set_root(const std::string& value) {
   
   
   root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Mixin::set_root(std::string&& value) {
-  
-  root_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.root)
-}
-inline void Mixin::set_root(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.root)
-}
-inline void Mixin::set_root(const char* value,
-    size_t size) {
-  
-  root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.root)
-}
 inline std::string* Mixin::_internal_mutable_root() {
 inline std::string* Mixin::_internal_mutable_root() {
   
   
   return root_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return root_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());

+ 28 - 0
src/google/protobuf/arenastring.h

@@ -193,6 +193,34 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
   void Set(EmptyDefault, std::string&& value, ::google::protobuf::Arena* arena);
   void Set(EmptyDefault, std::string&& value, ::google::protobuf::Arena* arena);
   void Set(NonEmptyDefault, ConstStringParam value, ::google::protobuf::Arena* arena);
   void Set(NonEmptyDefault, ConstStringParam value, ::google::protobuf::Arena* arena);
   void Set(NonEmptyDefault, std::string&& value, ::google::protobuf::Arena* arena);
   void Set(NonEmptyDefault, std::string&& value, ::google::protobuf::Arena* arena);
+  template <typename FirstParam>
+  void Set(FirstParam p1, const char* str, ::google::protobuf::Arena* arena) {
+    Set(p1, ConstStringParam(str), arena);
+  }
+  template <typename FirstParam>
+  void Set(FirstParam p1, const char* str, size_t size,
+           ::google::protobuf::Arena* arena) {
+    ConstStringParam sp{str, size};  // for string_view and `const string &`
+    Set(p1, sp, arena);
+  }
+  template <typename FirstParam, typename RefWrappedType>
+  void Set(FirstParam p1,
+           std::reference_wrapper<RefWrappedType> const_string_ref,
+           ::google::protobuf::Arena* arena) {
+    Set(p1, const_string_ref.get(), arena);
+  }
+
+  template <typename FirstParam, typename SecondParam>
+  void SetBytes(FirstParam p1, SecondParam&& p2, ::google::protobuf::Arena* arena) {
+    Set(p1, static_cast<SecondParam&&>(p2), arena);
+  }
+  template <typename FirstParam>
+  void SetBytes(FirstParam p1, const void* str, size_t size,
+                ::google::protobuf::Arena* arena) {
+    // must work whether ConstStringParam is string_view or `const string &`
+    ConstStringParam sp{static_cast<const char*>(str), size};
+    Set(p1, sp, arena);
+  }
 
 
   // Basic accessors.
   // Basic accessors.
   const std::string& Get() const PROTOBUF_NDEBUG_INLINE {
   const std::string& Get() const PROTOBUF_NDEBUG_INLINE {

+ 1 - 20
src/google/protobuf/compiler/command_line_interface.cc

@@ -1036,16 +1036,6 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
   }
   }
 
 
 
 
-  for (auto fd : parsed_files) {
-    if (!AllowProto3Optional(*fd) && ContainsProto3Optional(fd)) {
-      std::cerr << fd->name()
-                << ": This file contains proto3 optional fields, but "
-                   "--experimental_allow_proto3_optional was not set."
-                << std::endl;
-      return 1;
-    }
-  }
-
   // We construct a separate GeneratorContext for each output location.  Note
   // We construct a separate GeneratorContext for each output location.  Note
   // that two code generators may output to the same location, in which case
   // that two code generators may output to the same location, in which case
   // they should share a single GeneratorContext so that OpenForInsert() works.
   // they should share a single GeneratorContext so that OpenForInsert() works.
@@ -1214,13 +1204,6 @@ PopulateSingleSimpleDescriptorDatabase(const std::string& descriptor_set_name) {
 
 
 }  // namespace
 }  // namespace
 
 
-bool CommandLineInterface::AllowProto3Optional(
-    const FileDescriptor& file) const {
-  // Proto3 optional is enabled by default now, the experimental flag is no
-  // longer required.
-  return true;
-}
-
 
 
 bool CommandLineInterface::VerifyInputFilesInDescriptors(
 bool CommandLineInterface::VerifyInputFilesInDescriptors(
     DescriptorDatabase* database) {
     DescriptorDatabase* database) {
@@ -1337,7 +1320,6 @@ void CommandLineInterface::Clear() {
   source_info_in_descriptor_set_ = false;
   source_info_in_descriptor_set_ = false;
   disallow_services_ = false;
   disallow_services_ = false;
   direct_dependencies_explicitly_set_ = false;
   direct_dependencies_explicitly_set_ = false;
-  allow_proto3_optional_ = false;
   deterministic_output_ = false;
   deterministic_output_ = false;
 }
 }
 
 
@@ -1857,8 +1839,7 @@ CommandLineInterface::InterpretArgument(const std::string& name,
 
 
 
 
   } else if (name == "--experimental_allow_proto3_optional") {
   } else if (name == "--experimental_allow_proto3_optional") {
-    allow_proto3_optional_ = true;
-
+    // Flag is no longer observed, but we allow it for backward compat.
   } else if (name == "--encode" || name == "--decode" ||
   } else if (name == "--encode" || name == "--decode" ||
              name == "--decode_raw") {
              name == "--decode_raw") {
     if (mode_ != MODE_COMPILE) {
     if (mode_ != MODE_COMPILE) {

+ 0 - 8
src/google/protobuf/compiler/command_line_interface.h

@@ -226,11 +226,6 @@ class PROTOC_EXPORT CommandLineInterface {
   bool MakeInputsBeProtoPathRelative(DiskSourceTree* source_tree,
   bool MakeInputsBeProtoPathRelative(DiskSourceTree* source_tree,
                                      DescriptorDatabase* fallback_database);
                                      DescriptorDatabase* fallback_database);
 
 
-  // Is this .proto file whitelisted, or do we have a command-line flag allowing
-  // us to use proto3 optional? This is a temporary control to avoid people from
-  // using proto3 optional until code generators have implemented it.
-  bool AllowProto3Optional(const FileDescriptor& file) const;
-
   // Fails if these files use proto3 optional and the code generator doesn't
   // Fails if these files use proto3 optional and the code generator doesn't
   // support it. This is a permanent check.
   // support it. This is a permanent check.
   bool EnforceProto3OptionalSupport(
   bool EnforceProto3OptionalSupport(
@@ -448,9 +443,6 @@ class PROTOC_EXPORT CommandLineInterface {
   // Was the --disallow_services flag used?
   // Was the --disallow_services flag used?
   bool disallow_services_ = false;
   bool disallow_services_ = false;
 
 
-  // Was the --experimental_allow_proto3_optional flag used?
-  bool allow_proto3_optional_ = false;
-
   // When using --encode, this will be passed to SetSerializationDeterministic.
   // When using --encode, this will be passed to SetSerializationDeterministic.
   bool deterministic_output_ = false;
   bool deterministic_output_ = false;
 
 

+ 0 - 1
src/google/protobuf/compiler/command_line_interface_unittest.cc

@@ -2378,7 +2378,6 @@ TEST_F(CommandLineInterfaceTest, MissingValueAtEndError) {
   ExpectErrorText("Missing value for flag: --test_out\n");
   ExpectErrorText("Missing value for flag: --test_out\n");
 }
 }
 
 
-
 TEST_F(CommandLineInterfaceTest, Proto3OptionalDisallowedNoCodegenSupport) {
 TEST_F(CommandLineInterfaceTest, Proto3OptionalDisallowedNoCodegenSupport) {
   CreateTempFile("google/foo.proto",
   CreateTempFile("google/foo.proto",
                  "syntax = \"proto3\";\n"
                  "syntax = \"proto3\";\n"

+ 15 - 15
src/google/protobuf/compiler/cpp/cpp_file.cc

@@ -694,10 +694,6 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
   if (!message_generators_.empty()) {
   if (!message_generators_.empty()) {
     format("static ::$proto_ns$::Metadata $file_level_metadata$[$1$];\n",
     format("static ::$proto_ns$::Metadata $file_level_metadata$[$1$];\n",
            message_generators_.size());
            message_generators_.size());
-  } else {
-    format(
-        "static "
-        "constexpr ::$proto_ns$::Metadata* $file_level_metadata$ = nullptr;\n");
   }
   }
   if (!enum_generators_.empty()) {
   if (!enum_generators_.empty()) {
     format(
     format(
@@ -855,24 +851,30 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
       "  false, $1$, $2$, $3$, \"$filename$\", \n"
       "  false, $1$, $2$, $3$, \"$filename$\", \n"
       "  &$desc_table$_once, $4$, $5$, $6$,\n"
       "  &$desc_table$_once, $4$, $5$, $6$,\n"
       "  schemas, file_default_instances, $tablename$::offsets,\n"
       "  schemas, file_default_instances, $tablename$::offsets,\n"
-      "  $file_level_metadata$, $file_level_enum_descriptors$, "
+      "  $7$, $file_level_enum_descriptors$, "
       "$file_level_service_descriptors$,\n"
       "$file_level_service_descriptors$,\n"
       "};\n"
       "};\n"
       // This function exists to be marked as weak.
       // This function exists to be marked as weak.
-      // It can significantly speed up compilation by breaking up the SCC.
+      // It can significantly speed up compilation by breaking up LLVM's SCC in
+      // the .pb.cc translation units. Large translation units see a reduction
+      // of more than 35% of walltime for optimized builds.
       // Without the weak attribute all the messages in the file, including all
       // Without the weak attribute all the messages in the file, including all
-      // the vtables and everything they use become part of the same SCC.
+      // the vtables and everything they use become part of the same SCC through
+      // a cycle like:
+      // GetMetadata -> descriptor table -> default instances ->
+      //   vtables -> GetMetadata
       // By adding a weak function here we break the connection from the
       // By adding a weak function here we break the connection from the
       // individual vtables back into the descriptor table.
       // individual vtables back into the descriptor table.
-      "PROTOBUF_ATTRIBUTE_WEAK ::$proto_ns$::Metadata\n"
-      "$desc_table$_metadata_getter(int index) {\n"
-      "  ::$proto_ns$::internal::AssignDescriptors(&$desc_table$);\n"
-      "  return $desc_table$.file_level_metadata[index];\n"
+      "PROTOBUF_ATTRIBUTE_WEAK const ::$proto_ns$::internal::DescriptorTable* "
+      "$desc_table$_getter() {\n"
+      "  return &$desc_table$;\n"
       "}\n"
       "}\n"
       "\n",
       "\n",
       eager ? "true" : "false", file_data.size(), protodef_name,
       eager ? "true" : "false", file_data.size(), protodef_name,
       num_deps == 0 ? "nullptr" : variables_["desc_table"] + "_deps", num_deps,
       num_deps == 0 ? "nullptr" : variables_["desc_table"] + "_deps", num_deps,
-      message_generators_.size());
+      message_generators_.size(),
+      message_generators_.empty() ? "nullptr"
+                                  : variables_["file_level_metadata"]);
 
 
   // For descriptor.proto we want to avoid doing any dynamic initialization,
   // For descriptor.proto we want to avoid doing any dynamic initialization,
   // because in some situations that would otherwise pull in a lot of
   // because in some situations that would otherwise pull in a lot of
@@ -1288,9 +1290,7 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations(
   if (HasDescriptorMethods(file_, options_)) {
   if (HasDescriptorMethods(file_, options_)) {
     format(
     format(
         "extern $dllexport_decl $const ::$proto_ns$::internal::DescriptorTable "
         "extern $dllexport_decl $const ::$proto_ns$::internal::DescriptorTable "
-        "$desc_table$;\n"
-        "$dllexport_decl $::$proto_ns$::Metadata "
-        "$desc_table$_metadata_getter(int index);\n");
+        "$desc_table$;\n");
   }
   }
 }
 }
 
 

+ 14 - 25
src/google/protobuf/compiler/cpp/cpp_message.cc

@@ -1076,19 +1076,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
     if (HasDescriptorMethods(descriptor_->file(), options_)) {
     if (HasDescriptorMethods(descriptor_->file(), options_)) {
       format(
       format(
           "  void MergeFrom(const ::$proto_ns$::Message& other) final;\n"
           "  void MergeFrom(const ::$proto_ns$::Message& other) final;\n"
-          "  ::$proto_ns$::Metadata GetMetadata() const final;\n"
-          "  private:\n"
-          "  static ::$proto_ns$::Metadata GetMetadataStatic() {\n"
-          "    ::$proto_ns$::internal::AssignDescriptors(&::$desc_table$);\n"
-          "    return ::$desc_table$.file_level_metadata[$1$];\n"
-          "  }\n"
-          "\n"
-          "  public:\n"
-          "};\n",
-          index_in_file_messages_);
-    } else {
-      format("};\n");
+          "  ::$proto_ns$::Metadata GetMetadata() const final;\n");
     }
     }
+    format("};\n");
     return;
     return;
   }
   }
 
 
@@ -1168,10 +1158,10 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
     // separately.
     // separately.
     format(
     format(
         "static const ::$proto_ns$::Descriptor* GetDescriptor() {\n"
         "static const ::$proto_ns$::Descriptor* GetDescriptor() {\n"
-        "  return GetMetadataStatic().descriptor;\n"
+        "  return default_instance().GetMetadata().descriptor;\n"
         "}\n"
         "}\n"
         "static const ::$proto_ns$::Reflection* GetReflection() {\n"
         "static const ::$proto_ns$::Reflection* GetReflection() {\n"
-        "  return GetMetadataStatic().reflection;\n"
+        "  return default_instance().GetMetadata().reflection;\n"
         "}\n");
         "}\n");
   }
   }
 
 
@@ -1380,12 +1370,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
   if (HasDescriptorMethods(descriptor_->file(), options_)) {
   if (HasDescriptorMethods(descriptor_->file(), options_)) {
     format(
     format(
         "::$proto_ns$::Metadata GetMetadata() const final;\n"
         "::$proto_ns$::Metadata GetMetadata() const final;\n"
-        "private:\n"
-        "static ::$proto_ns$::Metadata GetMetadataStatic() {\n"
-        "  return ::$desc_table$_metadata_getter(kIndexInFileMessages);\n"
-        "}\n"
-        "\n"
-        "public:\n"
         "\n");
         "\n");
   } else {
   } else {
     format(
     format(
@@ -1889,8 +1873,11 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
     if (HasDescriptorMethods(descriptor_->file(), options_)) {
     if (HasDescriptorMethods(descriptor_->file(), options_)) {
       format(
       format(
           "::$proto_ns$::Metadata $classname$::GetMetadata() const {\n"
           "::$proto_ns$::Metadata $classname$::GetMetadata() const {\n"
-          "  return GetMetadataStatic();\n"
-          "}\n");
+          "  return ::$proto_ns$::internal::AssignDescriptors(\n"
+          "      &$desc_table$_getter, &$desc_table$_once,\n"
+          "      $file_level_metadata$[$1$]);\n"
+          "}\n",
+          index_in_file_messages_);
       format(
       format(
           "void $classname$::MergeFrom(\n"
           "void $classname$::MergeFrom(\n"
           "    const ::$proto_ns$::Message& other) {\n"
           "    const ::$proto_ns$::Message& other) {\n"
@@ -2029,9 +2016,11 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
   if (HasDescriptorMethods(descriptor_->file(), options_)) {
   if (HasDescriptorMethods(descriptor_->file(), options_)) {
     format(
     format(
         "::$proto_ns$::Metadata $classname$::GetMetadata() const {\n"
         "::$proto_ns$::Metadata $classname$::GetMetadata() const {\n"
-        "  return GetMetadataStatic();\n"
-        "}\n"
-        "\n");
+        "  return ::$proto_ns$::internal::AssignDescriptors(\n"
+        "      &$desc_table$_getter, &$desc_table$_once,\n"
+        "      $file_level_metadata$[$1$]);\n"
+        "}\n",
+        index_in_file_messages_);
   } else {
   } else {
     format(
     format(
         "std::string $classname$::GetTypeName() const {\n"
         "std::string $classname$::GetTypeName() const {\n"

+ 0 - 8
src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc

@@ -80,13 +80,9 @@ class TestGenerator : public CodeGenerator {
     // Check field accessors for a required string:
     // Check field accessors for a required string:
     TryInsert("test.pb.h", "field_get:foo.Bar.requiredString", context);
     TryInsert("test.pb.h", "field_get:foo.Bar.requiredString", context);
     TryInsert("test.pb.h", "field_set:foo.Bar.requiredString", context);
     TryInsert("test.pb.h", "field_set:foo.Bar.requiredString", context);
-    TryInsert("test.pb.h", "field_set_char:foo.Bar.requiredString", context);
-    TryInsert("test.pb.h", "field_set_pointer:foo.Bar.requiredString", context);
     TryInsert("test.pb.h", "field_mutable:foo.Bar.requiredString", context);
     TryInsert("test.pb.h", "field_mutable:foo.Bar.requiredString", context);
     TryInsert("test.pb.h", "field_set_allocated:foo.Bar.requiredString",
     TryInsert("test.pb.h", "field_set_allocated:foo.Bar.requiredString",
               context);
               context);
-    TryInsert("test.pb.h", "field_set_char:foo.Bar.requiredString", context);
-    TryInsert("test.pb.h", "field_set_pointer:foo.Bar.requiredString", context);
 
 
     // Check field accessors for a repeated string:
     // Check field accessors for a repeated string:
     TryInsert("test.pb.h", "field_get:foo.Bar.repeatedString", context);
     TryInsert("test.pb.h", "field_get:foo.Bar.repeatedString", context);
@@ -104,12 +100,8 @@ class TestGenerator : public CodeGenerator {
     // Check field accessors for a string inside oneof{}:
     // Check field accessors for a string inside oneof{}:
     TryInsert("test.pb.h", "field_get:foo.Bar.oneOfString", context);
     TryInsert("test.pb.h", "field_get:foo.Bar.oneOfString", context);
     TryInsert("test.pb.h", "field_set:foo.Bar.oneOfString", context);
     TryInsert("test.pb.h", "field_set:foo.Bar.oneOfString", context);
-    TryInsert("test.pb.h", "field_set_char:foo.Bar.oneOfString", context);
-    TryInsert("test.pb.h", "field_set_pointer:foo.Bar.oneOfString", context);
     TryInsert("test.pb.h", "field_mutable:foo.Bar.oneOfString", context);
     TryInsert("test.pb.h", "field_mutable:foo.Bar.oneOfString", context);
     TryInsert("test.pb.h", "field_set_allocated:foo.Bar.oneOfString", context);
     TryInsert("test.pb.h", "field_set_allocated:foo.Bar.oneOfString", context);
-    TryInsert("test.pb.h", "field_set_char:foo.Bar.oneOfString", context);
-    TryInsert("test.pb.h", "field_set_pointer:foo.Bar.oneOfString", context);
 
 
     // Check field accessors for an optional message:
     // Check field accessors for an optional message:
     TryInsert("test.pb.h", "field_get:foo.Bar.optMessage", context);
     TryInsert("test.pb.h", "field_get:foo.Bar.optMessage", context);

+ 19 - 99
src/google/protobuf/compiler/cpp/cpp_string_field.cc

@@ -82,6 +82,8 @@ void SetStringVariables(const FieldDescriptor* descriptor,
                        : "lazy_variable"];
                        : "lazy_variable"];
   (*variables)["pointer_type"] =
   (*variables)["pointer_type"] =
       descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char";
       descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char";
+  (*variables)["setter"] =
+      descriptor->type() == FieldDescriptor::TYPE_BYTES ? "SetBytes" : "Set";
   (*variables)["null_check"] = (*variables)["DCHK"] + "(value != nullptr);\n";
   (*variables)["null_check"] = (*variables)["DCHK"] + "(value != nullptr);\n";
   // NOTE: Escaped here to unblock proto1->proto2 migration.
   // NOTE: Escaped here to unblock proto1->proto2 migration.
   // TODO(liujisi): Extend this to apply for other conflicting methods.
   // TODO(liujisi): Extend this to apply for other conflicting methods.
@@ -155,19 +157,10 @@ void StringFieldGenerator::GenerateAccessorDeclarations(
 
 
   format(
   format(
       "$deprecated_attr$const std::string& ${1$$name$$}$() const;\n"
       "$deprecated_attr$const std::string& ${1$$name$$}$() const;\n"
-      "$deprecated_attr$void ${1$set_$name$$}$(const std::string& value);\n"
-      "$deprecated_attr$void ${1$set_$name$$}$(std::string&& value);\n"
-      "$deprecated_attr$void ${1$set_$name$$}$(const char* value);\n",
+      "template <typename ArgT0 = const std::string&, typename... ArgT>\n"
+      "$deprecated_attr$void ${1$set_$name$$}$(ArgT0&& arg0, ArgT... args);\n",
       descriptor_);
       descriptor_);
-  if (!options_.opensource_runtime) {
-    format(
-        "$deprecated_attr$void ${1$set_$name$$}$(::StringPiece value);\n",
-        descriptor_);
-  }
   format(
   format(
-      "$deprecated_attr$void ${1$set_$name$$}$(const $pointer_type$* "
-      "value, size_t size)"
-      ";\n"
       "$deprecated_attr$std::string* ${1$mutable_$name$$}$();\n"
       "$deprecated_attr$std::string* ${1$mutable_$name$$}$();\n"
       "$deprecated_attr$std::string* ${1$$release_name$$}$();\n"
       "$deprecated_attr$std::string* ${1$$release_name$$}$();\n"
       "$deprecated_attr$void ${1$set_allocated_$name$$}$(std::string* "
       "$deprecated_attr$void ${1$set_allocated_$name$$}$(std::string* "
@@ -202,9 +195,13 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
   format(
   format(
       "  return _internal_$name$();\n"
       "  return _internal_$name$();\n"
       "}\n"
       "}\n"
-      "inline void $classname$::set_$name$(const std::string& value) {\n"
+      "template <typename ArgT0, typename... ArgT>\n"
+      "PROTOBUF_ALWAYS_INLINE\n"
+      "inline void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n"
       "$annotate_accessor$"
       "$annotate_accessor$"
-      "  _internal_set_$name$(value);\n"
+      " $set_hasbit$\n"
+      " $name$_.$setter$($default_value_tag$, static_cast<ArgT0 &&>(arg0),"
+      " args..., GetArena());\n"
       "  // @@protoc_insertion_point(field_set:$full_name$)\n"
       "  // @@protoc_insertion_point(field_set:$full_name$)\n"
       "}\n"
       "}\n"
       "inline std::string* $classname$::mutable_$name$() {\n"
       "inline std::string* $classname$::mutable_$name$() {\n"
@@ -219,40 +216,8 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
       "value) {\n"
       "value) {\n"
       "  $set_hasbit$\n"
       "  $set_hasbit$\n"
       "  $name$_.Set($default_value_tag$, value, GetArena());\n"
       "  $name$_.Set($default_value_tag$, value, GetArena());\n"
-      "}\n"
-      "inline void $classname$::set_$name$(std::string&& value) {\n"
-      "$annotate_accessor$"
-      "  $set_hasbit$\n"
-      "  $name$_.Set(\n"
-      "    $default_value_tag$, ::std::move(value), GetArena());\n"
-      "  // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n"
-      "}\n"
-      "inline void $classname$::set_$name$(const char* value) {\n"
-      "$annotate_accessor$"
-      "  $null_check$"
-      "  $set_hasbit$\n"
-      "  $name$_.Set($default_value_tag$, $string_piece$(value), GetArena());\n"
-      "  // @@protoc_insertion_point(field_set_char:$full_name$)\n"
       "}\n");
       "}\n");
-  if (!options_.opensource_runtime) {
-    format(
-        "inline void $classname$::set_$name$(::StringPiece value) {\n"
-        "$annotate_accessor$"
-        "  $set_hasbit$\n"
-        "  $name$_.Set($default_value_tag$, value,GetArena());\n"
-        "  // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n"
-        "}\n");
-  }
   format(
   format(
-      "inline "
-      "void $classname$::set_$name$(const $pointer_type$* value,\n"
-      "    size_t size) {\n"
-      "$annotate_accessor$"
-      "  $set_hasbit$\n"
-      "  $name$_.Set($default_value_tag$, $string_piece$(\n"
-      "      reinterpret_cast<const char*>(value), size), GetArena());\n"
-      "  // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
-      "}\n"
       "inline std::string* $classname$::_internal_mutable_$name$() {\n"
       "inline std::string* $classname$::_internal_mutable_$name$() {\n"
       "  $set_hasbit$\n"
       "  $set_hasbit$\n"
       "  return $name$_.Mutable($default_variable_or_tag$, GetArena());\n"
       "  return $name$_.Mutable($default_variable_or_tag$, GetArena());\n"
@@ -431,9 +396,16 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
       "  // @@protoc_insertion_point(field_get:$full_name$)\n"
       "  // @@protoc_insertion_point(field_get:$full_name$)\n"
       "  return _internal_$name$();\n"
       "  return _internal_$name$();\n"
       "}\n"
       "}\n"
-      "inline void $classname$::set_$name$(const std::string& value) {\n"
+      "template <typename ArgT0, typename... ArgT>\n"
+      "inline void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n"
       "$annotate_accessor$"
       "$annotate_accessor$"
-      "  _internal_set_$name$(value);\n"
+      "  if (!_internal_has_$name$()) {\n"
+      "    clear_$oneof_name$();\n"
+      "    set_has_$name$();\n"
+      "    $field_member$.UnsafeSetDefault($init_value$);\n"
+      "  }\n"
+      "  $field_member$.$setter$($default_value_tag$,"
+      " static_cast<ArgT0 &&>(arg0), args..., GetArena());\n"
       "  // @@protoc_insertion_point(field_set:$full_name$)\n"
       "  // @@protoc_insertion_point(field_set:$full_name$)\n"
       "}\n"
       "}\n"
       "inline std::string* $classname$::mutable_$name$() {\n"
       "inline std::string* $classname$::mutable_$name$() {\n"
@@ -455,60 +427,8 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
       "    $field_member$.UnsafeSetDefault($init_value$);\n"
       "    $field_member$.UnsafeSetDefault($init_value$);\n"
       "  }\n"
       "  }\n"
       "  $field_member$.Set($default_value_tag$, value, GetArena());\n"
       "  $field_member$.Set($default_value_tag$, value, GetArena());\n"
-      "}\n"
-      "inline void $classname$::set_$name$(std::string&& value) {\n"
-      "$annotate_accessor$"
-      "  // @@protoc_insertion_point(field_set:$full_name$)\n"
-      "  if (!_internal_has_$name$()) {\n"
-      "    clear_$oneof_name$();\n"
-      "    set_has_$name$();\n"
-      "    $field_member$.UnsafeSetDefault($init_value$);\n"
-      "  }\n"
-      "  $field_member$.Set(\n"
-      "    $default_value_tag$, ::std::move(value), GetArena());\n"
-      "  // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n"
-      "}\n"
-      "inline void $classname$::set_$name$(const char* value) {\n"
-      "$annotate_accessor$"
-      "  $null_check$"
-      "  if (!_internal_has_$name$()) {\n"
-      "    clear_$oneof_name$();\n"
-      "    set_has_$name$();\n"
-      "    $field_member$.UnsafeSetDefault($init_value$);\n"
-      "  }\n"
-      "  $field_member$.Set($default_value_tag$,\n"
-      "      $string_piece$(value), GetArena());\n"
-      "  // @@protoc_insertion_point(field_set_char:$full_name$)\n"
       "}\n");
       "}\n");
-  if (!options_.opensource_runtime) {
-    format(
-        "inline void $classname$::set_$name$(::StringPiece value) {\n"
-        "$annotate_accessor$"
-        "  if (!_internal_has_$name$()) {\n"
-        "    clear_$oneof_name$();\n"
-        "    set_has_$name$();\n"
-        "    $field_member$.UnsafeSetDefault($init_value$);\n"
-        "  }\n"
-        "  $field_member$.Set($default_value_tag$, value, GetArena());\n"
-        "  // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n"
-        "}\n");
-  }
   format(
   format(
-      "inline "
-      "void $classname$::set_$name$(const $pointer_type$* value,\n"
-      "                             size_t size) {\n"
-      "$annotate_accessor$"
-      "  if (!_internal_has_$name$()) {\n"
-      "    clear_$oneof_name$();\n"
-      "    set_has_$name$();\n"
-      "    $field_member$.UnsafeSetDefault($init_value$);\n"
-      "  }\n"
-      "  $field_member$.Set(\n"
-      "      $default_value_tag$, $string_piece$(\n"
-      "      reinterpret_cast<const char*>(value), size),\n"
-      "      GetArena());\n"
-      "  // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
-      "}\n"
       "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"

+ 1 - 0
src/google/protobuf/compiler/java/java_context.cc

@@ -108,6 +108,7 @@ void Context::InitializeFieldGeneratorInfoForMessage(
     InitializeFieldGeneratorInfoForMessage(message->nested_type(i));
     InitializeFieldGeneratorInfoForMessage(message->nested_type(i));
   }
   }
   std::vector<const FieldDescriptor*> fields;
   std::vector<const FieldDescriptor*> fields;
+  fields.reserve(message->field_count());
   for (int i = 0; i < message->field_count(); ++i) {
   for (int i = 0; i < message->field_count(); ++i) {
     fields.push_back(message->field(i));
     fields.push_back(message->field(i));
   }
   }

+ 6 - 2
src/google/protobuf/compiler/java/java_map_field_lite.cc

@@ -95,9 +95,13 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
   // We use `x.getClass()` as a null check because it generates less bytecode
   // We use `x.getClass()` as a null check because it generates less bytecode
   // than an `if (x == null) { throw ... }` statement.
   // than an `if (x == null) { throw ... }` statement.
   (*variables)["key_null_check"] =
   (*variables)["key_null_check"] =
-      IsReferenceType(keyJavaType) ? "key.getClass();" : "";
+      IsReferenceType(keyJavaType)
+          ? "java.lang.Class<?> keyClass = key.getClass();"
+          : "";
   (*variables)["value_null_check"] =
   (*variables)["value_null_check"] =
-      IsReferenceType(valueJavaType) ? "value.getClass();" : "";
+      IsReferenceType(valueJavaType)
+          ? "java.lang.Class<?> valueClass = value.getClass();"
+          : "";
 
 
   if (GetJavaType(value) == JAVATYPE_ENUM) {
   if (GetJavaType(value) == JAVATYPE_ENUM) {
     // We store enums as Integers internally.
     // We store enums as Integers internally.

+ 1 - 0
src/google/protobuf/compiler/java/java_message.cc

@@ -571,6 +571,7 @@ void ImmutableMessageGenerator::GenerateMessageSerializationMethods(
       SortFieldsByNumber(descriptor_));
       SortFieldsByNumber(descriptor_));
 
 
   std::vector<const Descriptor::ExtensionRange*> sorted_extensions;
   std::vector<const Descriptor::ExtensionRange*> sorted_extensions;
+  sorted_extensions.reserve(descriptor_->extension_range_count());
   for (int i = 0; i < descriptor_->extension_range_count(); ++i) {
   for (int i = 0; i < descriptor_->extension_range_count(); ++i) {
     sorted_extensions.push_back(descriptor_->extension_range(i));
     sorted_extensions.push_back(descriptor_->extension_range(i));
   }
   }

+ 2 - 1
src/google/protobuf/compiler/java/java_primitive_field_lite.cc

@@ -127,7 +127,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
   if (IsReferenceType(javaType)) {
   if (IsReferenceType(javaType)) {
     // We use `x.getClass()` as a null check because it generates less bytecode
     // We use `x.getClass()` as a null check because it generates less bytecode
     // than an `if (x == null) { throw ... }` statement.
     // than an `if (x == null) { throw ... }` statement.
-    (*variables)["null_check"] = "  value.getClass();\n";
+    (*variables)["null_check"] =
+        "  java.lang.Class<?> valueClass = value.getClass();\n";
   } else {
   } else {
     (*variables)["null_check"] = "";
     (*variables)["null_check"] = "";
   }
   }

+ 2 - 1
src/google/protobuf/compiler/java/java_string_field_lite.cc

@@ -77,7 +77,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
       WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
       WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
   // We use `x.getClass()` as a null check because it generates less bytecode
   // We use `x.getClass()` as a null check because it generates less bytecode
   // than an `if (x == null) { throw ... }` statement.
   // than an `if (x == null) { throw ... }` statement.
-  (*variables)["null_check"] = "  value.getClass();\n";
+  (*variables)["null_check"] =
+      "  java.lang.Class<?> valueClass = value.getClass();\n";
 
 
   // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
   // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
   // by the proto compiler
   // by the proto compiler

+ 14 - 12
src/google/protobuf/compiler/plugin.pb.cc

@@ -181,10 +181,8 @@ const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets,
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets,
   file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto,
   file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto,
 };
 };
-PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata
-descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(int index) {
-  ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto);
-  return descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto.file_level_metadata[index];
+PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter() {
+  return &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
 }
 }
 
 
 // Force running AddDescriptors() at dynamic initialization time.
 // Force running AddDescriptors() at dynamic initialization time.
@@ -530,10 +528,11 @@ void Version::InternalSwap(Version* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata Version::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata Version::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[0]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class CodeGeneratorRequest::_Internal {
 class CodeGeneratorRequest::_Internal {
@@ -873,10 +872,11 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorRequest::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorRequest::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class CodeGeneratorResponse_File::_Internal {
 class CodeGeneratorResponse_File::_Internal {
@@ -1235,10 +1235,11 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other)
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse_File::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse_File::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[2]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class CodeGeneratorResponse::_Internal {
 class CodeGeneratorResponse::_Internal {
@@ -1520,10 +1521,11 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[3]);
 }
 }
 
 
-
 // @@protoc_insertion_point(namespace_scope)
 // @@protoc_insertion_point(namespace_scope)
 }  // namespace compiler
 }  // namespace compiler
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_CLOSE

+ 50 - 183
src/google/protobuf/compiler/plugin.pb.h

@@ -61,7 +61,6 @@ struct PROTOC_EXPORT TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto {
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
 };
 };
 extern PROTOC_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
 extern PROTOC_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
-PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(int index);
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN
 namespace compiler {
 namespace compiler {
 class CodeGeneratorRequest;
 class CodeGeneratorRequest;
@@ -149,10 +148,10 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const Version& default_instance() {
   static const Version& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -220,12 +219,6 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -244,10 +237,8 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL :
   public:
   public:
   void clear_suffix();
   void clear_suffix();
   const std::string& suffix() const;
   const std::string& suffix() const;
-  void set_suffix(const std::string& value);
-  void set_suffix(std::string&& value);
-  void set_suffix(const char* value);
-  void set_suffix(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_suffix(ArgT0&& arg0, ArgT... args);
   std::string* mutable_suffix();
   std::string* mutable_suffix();
   std::string* release_suffix();
   std::string* release_suffix();
   void set_allocated_suffix(std::string* suffix);
   void set_allocated_suffix(std::string* suffix);
@@ -350,10 +341,10 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const CodeGeneratorRequest& default_instance() {
   static const CodeGeneratorRequest& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -421,12 +412,6 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -487,10 +472,8 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL :
   public:
   public:
   void clear_parameter();
   void clear_parameter();
   const std::string& parameter() const;
   const std::string& parameter() const;
-  void set_parameter(const std::string& value);
-  void set_parameter(std::string&& value);
-  void set_parameter(const char* value);
-  void set_parameter(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_parameter(ArgT0&& arg0, ArgT... args);
   std::string* mutable_parameter();
   std::string* mutable_parameter();
   std::string* release_parameter();
   std::string* release_parameter();
   void set_allocated_parameter(std::string* parameter);
   void set_allocated_parameter(std::string* parameter);
@@ -572,10 +555,10 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const CodeGeneratorResponse_File& default_instance() {
   static const CodeGeneratorResponse_File& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -643,12 +626,6 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -667,10 +644,8 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
   public:
   public:
   void clear_name();
   void clear_name();
   const std::string& name() const;
   const std::string& name() const;
-  void set_name(const std::string& value);
-  void set_name(std::string&& value);
-  void set_name(const char* value);
-  void set_name(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_name(ArgT0&& arg0, ArgT... args);
   std::string* mutable_name();
   std::string* mutable_name();
   std::string* release_name();
   std::string* release_name();
   void set_allocated_name(std::string* name);
   void set_allocated_name(std::string* name);
@@ -687,10 +662,8 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
   public:
   public:
   void clear_insertion_point();
   void clear_insertion_point();
   const std::string& insertion_point() const;
   const std::string& insertion_point() const;
-  void set_insertion_point(const std::string& value);
-  void set_insertion_point(std::string&& value);
-  void set_insertion_point(const char* value);
-  void set_insertion_point(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_insertion_point(ArgT0&& arg0, ArgT... args);
   std::string* mutable_insertion_point();
   std::string* mutable_insertion_point();
   std::string* release_insertion_point();
   std::string* release_insertion_point();
   void set_allocated_insertion_point(std::string* insertion_point);
   void set_allocated_insertion_point(std::string* insertion_point);
@@ -707,10 +680,8 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
   public:
   public:
   void clear_content();
   void clear_content();
   const std::string& content() const;
   const std::string& content() const;
-  void set_content(const std::string& value);
-  void set_content(std::string&& value);
-  void set_content(const char* value);
-  void set_content(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_content(ArgT0&& arg0, ArgT... args);
   std::string* mutable_content();
   std::string* mutable_content();
   std::string* release_content();
   std::string* release_content();
   void set_allocated_content(std::string* content);
   void set_allocated_content(std::string* content);
@@ -792,10 +763,10 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const CodeGeneratorResponse& default_instance() {
   static const CodeGeneratorResponse& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -863,12 +834,6 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -936,10 +901,8 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL :
   public:
   public:
   void clear_error();
   void clear_error();
   const std::string& error() const;
   const std::string& error() const;
-  void set_error(const std::string& value);
-  void set_error(std::string&& value);
-  void set_error(const char* value);
-  void set_error(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_error(ArgT0&& arg0, ArgT... args);
   std::string* mutable_error();
   std::string* mutable_error();
   std::string* release_error();
   std::string* release_error();
   void set_allocated_error(std::string* error);
   void set_allocated_error(std::string* error);
@@ -1087,8 +1050,11 @@ inline const std::string& Version::suffix() const {
   // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix)
   // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix)
   return _internal_suffix();
   return _internal_suffix();
 }
 }
-inline void Version::set_suffix(const std::string& value) {
-  _internal_set_suffix(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Version::set_suffix(ArgT0&& arg0, ArgT... args) {
+ _has_bits_[0] |= 0x00000001u;
+ suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -1102,25 +1068,6 @@ inline void Version::_internal_set_suffix(const std::string& value) {
   _has_bits_[0] |= 0x00000001u;
   _has_bits_[0] |= 0x00000001u;
   suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Version::set_suffix(std::string&& value) {
-  _has_bits_[0] |= 0x00000001u;
-  suffix_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.Version.suffix)
-}
-inline void Version::set_suffix(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  _has_bits_[0] |= 0x00000001u;
-  suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.Version.suffix)
-}
-inline void Version::set_suffix(const char* value,
-    size_t size) {
-  _has_bits_[0] |= 0x00000001u;
-  suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.Version.suffix)
-}
 inline std::string* Version::_internal_mutable_suffix() {
 inline std::string* Version::_internal_mutable_suffix() {
   _has_bits_[0] |= 0x00000001u;
   _has_bits_[0] |= 0x00000001u;
   return suffix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return suffix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -1238,8 +1185,11 @@ inline const std::string& CodeGeneratorRequest::parameter() const {
   // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter)
   // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter)
   return _internal_parameter();
   return _internal_parameter();
 }
 }
-inline void CodeGeneratorRequest::set_parameter(const std::string& value) {
-  _internal_set_parameter(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void CodeGeneratorRequest::set_parameter(ArgT0&& arg0, ArgT... args) {
+ _has_bits_[0] |= 0x00000001u;
+ parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -1253,25 +1203,6 @@ inline void CodeGeneratorRequest::_internal_set_parameter(const std::string& val
   _has_bits_[0] |= 0x00000001u;
   _has_bits_[0] |= 0x00000001u;
   parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void CodeGeneratorRequest::set_parameter(std::string&& value) {
-  _has_bits_[0] |= 0x00000001u;
-  parameter_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorRequest.parameter)
-}
-inline void CodeGeneratorRequest::set_parameter(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  _has_bits_[0] |= 0x00000001u;
-  parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.parameter)
-}
-inline void CodeGeneratorRequest::set_parameter(const char* value,
-    size_t size) {
-  _has_bits_[0] |= 0x00000001u;
-  parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.parameter)
-}
 inline std::string* CodeGeneratorRequest::_internal_mutable_parameter() {
 inline std::string* CodeGeneratorRequest::_internal_mutable_parameter() {
   _has_bits_[0] |= 0x00000001u;
   _has_bits_[0] |= 0x00000001u;
   return parameter_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return parameter_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -1434,8 +1365,11 @@ inline const std::string& CodeGeneratorResponse_File::name() const {
   // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name)
   // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name)
   return _internal_name();
   return _internal_name();
 }
 }
-inline void CodeGeneratorResponse_File::set_name(const std::string& value) {
-  _internal_set_name(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void CodeGeneratorResponse_File::set_name(ArgT0&& arg0, ArgT... args) {
+ _has_bits_[0] |= 0x00000001u;
+ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -1449,25 +1383,6 @@ inline void CodeGeneratorResponse_File::_internal_set_name(const std::string& va
   _has_bits_[0] |= 0x00000001u;
   _has_bits_[0] |= 0x00000001u;
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void CodeGeneratorResponse_File::set_name(std::string&& value) {
-  _has_bits_[0] |= 0x00000001u;
-  name_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.name)
-}
-inline void CodeGeneratorResponse_File::set_name(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  _has_bits_[0] |= 0x00000001u;
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.name)
-}
-inline void CodeGeneratorResponse_File::set_name(const char* value,
-    size_t size) {
-  _has_bits_[0] |= 0x00000001u;
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.name)
-}
 inline std::string* CodeGeneratorResponse_File::_internal_mutable_name() {
 inline std::string* CodeGeneratorResponse_File::_internal_mutable_name() {
   _has_bits_[0] |= 0x00000001u;
   _has_bits_[0] |= 0x00000001u;
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -1507,8 +1422,11 @@ inline const std::string& CodeGeneratorResponse_File::insertion_point() const {
   // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
   // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
   return _internal_insertion_point();
   return _internal_insertion_point();
 }
 }
-inline void CodeGeneratorResponse_File::set_insertion_point(const std::string& value) {
-  _internal_set_insertion_point(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void CodeGeneratorResponse_File::set_insertion_point(ArgT0&& arg0, ArgT... args) {
+ _has_bits_[0] |= 0x00000002u;
+ insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -1522,25 +1440,6 @@ inline void CodeGeneratorResponse_File::_internal_set_insertion_point(const std:
   _has_bits_[0] |= 0x00000002u;
   _has_bits_[0] |= 0x00000002u;
   insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void CodeGeneratorResponse_File::set_insertion_point(std::string&& value) {
-  _has_bits_[0] |= 0x00000002u;
-  insertion_point_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
-}
-inline void CodeGeneratorResponse_File::set_insertion_point(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  _has_bits_[0] |= 0x00000002u;
-  insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
-}
-inline void CodeGeneratorResponse_File::set_insertion_point(const char* value,
-    size_t size) {
-  _has_bits_[0] |= 0x00000002u;
-  insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
-}
 inline std::string* CodeGeneratorResponse_File::_internal_mutable_insertion_point() {
 inline std::string* CodeGeneratorResponse_File::_internal_mutable_insertion_point() {
   _has_bits_[0] |= 0x00000002u;
   _has_bits_[0] |= 0x00000002u;
   return insertion_point_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return insertion_point_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -1580,8 +1479,11 @@ inline const std::string& CodeGeneratorResponse_File::content() const {
   // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content)
   // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content)
   return _internal_content();
   return _internal_content();
 }
 }
-inline void CodeGeneratorResponse_File::set_content(const std::string& value) {
-  _internal_set_content(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void CodeGeneratorResponse_File::set_content(ArgT0&& arg0, ArgT... args) {
+ _has_bits_[0] |= 0x00000004u;
+ content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -1595,25 +1497,6 @@ inline void CodeGeneratorResponse_File::_internal_set_content(const std::string&
   _has_bits_[0] |= 0x00000004u;
   _has_bits_[0] |= 0x00000004u;
   content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void CodeGeneratorResponse_File::set_content(std::string&& value) {
-  _has_bits_[0] |= 0x00000004u;
-  content_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.content)
-}
-inline void CodeGeneratorResponse_File::set_content(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  _has_bits_[0] |= 0x00000004u;
-  content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.content)
-}
-inline void CodeGeneratorResponse_File::set_content(const char* value,
-    size_t size) {
-  _has_bits_[0] |= 0x00000004u;
-  content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.content)
-}
 inline std::string* CodeGeneratorResponse_File::_internal_mutable_content() {
 inline std::string* CodeGeneratorResponse_File::_internal_mutable_content() {
   _has_bits_[0] |= 0x00000004u;
   _has_bits_[0] |= 0x00000004u;
   return content_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return content_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -1736,8 +1619,11 @@ inline const std::string& CodeGeneratorResponse::error() const {
   // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error)
   // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error)
   return _internal_error();
   return _internal_error();
 }
 }
-inline void CodeGeneratorResponse::set_error(const std::string& value) {
-  _internal_set_error(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void CodeGeneratorResponse::set_error(ArgT0&& arg0, ArgT... args) {
+ _has_bits_[0] |= 0x00000001u;
+ error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -1751,25 +1637,6 @@ inline void CodeGeneratorResponse::_internal_set_error(const std::string& value)
   _has_bits_[0] |= 0x00000001u;
   _has_bits_[0] |= 0x00000001u;
   error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void CodeGeneratorResponse::set_error(std::string&& value) {
-  _has_bits_[0] |= 0x00000001u;
-  error_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.error)
-}
-inline void CodeGeneratorResponse::set_error(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  _has_bits_[0] |= 0x00000001u;
-  error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.error)
-}
-inline void CodeGeneratorResponse::set_error(const char* value,
-    size_t size) {
-  _has_bits_[0] |= 0x00000001u;
-  error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.error)
-}
 inline std::string* CodeGeneratorResponse::_internal_mutable_error() {
 inline std::string* CodeGeneratorResponse::_internal_mutable_error() {
   _has_bits_[0] |= 0x00000001u;
   _has_bits_[0] |= 0x00000001u;
   return error_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return error_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());

+ 83 - 58
src/google/protobuf/descriptor.pb.cc

@@ -1055,10 +1055,8 @@ const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets,
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets,
   file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto,
   file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto,
 };
 };
-PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata
-descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(int index) {
-  ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto);
-  return descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[index];
+PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter() {
+  return &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto;
 }
 }
 
 
 // Force running AddDescriptors() at dynamic initialization time.
 // Force running AddDescriptors() at dynamic initialization time.
@@ -1424,10 +1422,11 @@ void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata FileDescriptorSet::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata FileDescriptorSet::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[0]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class FileDescriptorProto::_Internal {
 class FileDescriptorProto::_Internal {
@@ -2077,10 +2076,11 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata FileDescriptorProto::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata FileDescriptorProto::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[1]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class DescriptorProto_ExtensionRange::_Internal {
 class DescriptorProto_ExtensionRange::_Internal {
@@ -2372,10 +2372,11 @@ void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto_ExtensionRange::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto_ExtensionRange::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[2]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class DescriptorProto_ReservedRange::_Internal {
 class DescriptorProto_ReservedRange::_Internal {
@@ -2621,10 +2622,11 @@ void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange*
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto_ReservedRange::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto_ReservedRange::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[3]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class DescriptorProto::_Internal {
 class DescriptorProto::_Internal {
@@ -3161,10 +3163,11 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[4]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class ExtensionRangeOptions::_Internal {
 class ExtensionRangeOptions::_Internal {
@@ -3377,10 +3380,11 @@ void ExtensionRangeOptions::InternalSwap(ExtensionRangeOptions* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata ExtensionRangeOptions::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata ExtensionRangeOptions::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[5]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class FieldDescriptorProto::_Internal {
 class FieldDescriptorProto::_Internal {
@@ -4000,10 +4004,11 @@ void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata FieldDescriptorProto::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata FieldDescriptorProto::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[6]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class OneofDescriptorProto::_Internal {
 class OneofDescriptorProto::_Internal {
@@ -4271,10 +4276,11 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata OneofDescriptorProto::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata OneofDescriptorProto::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[7]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class EnumDescriptorProto_EnumReservedRange::_Internal {
 class EnumDescriptorProto_EnumReservedRange::_Internal {
@@ -4520,10 +4526,11 @@ void EnumDescriptorProto_EnumReservedRange::InternalSwap(EnumDescriptorProto_Enu
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata EnumDescriptorProto_EnumReservedRange::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata EnumDescriptorProto_EnumReservedRange::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[8]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class EnumDescriptorProto::_Internal {
 class EnumDescriptorProto::_Internal {
@@ -4895,10 +4902,11 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata EnumDescriptorProto::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata EnumDescriptorProto::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[9]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class EnumValueDescriptorProto::_Internal {
 class EnumValueDescriptorProto::_Internal {
@@ -5204,10 +5212,11 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata EnumValueDescriptorProto::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata EnumValueDescriptorProto::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[10]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class ServiceDescriptorProto::_Internal {
 class ServiceDescriptorProto::_Internal {
@@ -5508,10 +5517,11 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata ServiceDescriptorProto::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata ServiceDescriptorProto::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[11]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class MethodDescriptorProto::_Internal {
 class MethodDescriptorProto::_Internal {
@@ -5934,10 +5944,11 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata MethodDescriptorProto::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata MethodDescriptorProto::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[12]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class FileOptions::_Internal {
 class FileOptions::_Internal {
@@ -6913,10 +6924,11 @@ void FileOptions::InternalSwap(FileOptions* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata FileOptions::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata FileOptions::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[13]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class MessageOptions::_Internal {
 class MessageOptions::_Internal {
@@ -7259,10 +7271,11 @@ void MessageOptions::InternalSwap(MessageOptions* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata MessageOptions::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata MessageOptions::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[14]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class FieldOptions::_Internal {
 class FieldOptions::_Internal {
@@ -7670,10 +7683,11 @@ void FieldOptions::InternalSwap(FieldOptions* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata FieldOptions::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata FieldOptions::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[15]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class OneofOptions::_Internal {
 class OneofOptions::_Internal {
@@ -7886,10 +7900,11 @@ void OneofOptions::InternalSwap(OneofOptions* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata OneofOptions::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata OneofOptions::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[16]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class EnumOptions::_Internal {
 class EnumOptions::_Internal {
@@ -8182,10 +8197,11 @@ void EnumOptions::InternalSwap(EnumOptions* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata EnumOptions::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata EnumOptions::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[17]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class EnumValueOptions::_Internal {
 class EnumValueOptions::_Internal {
@@ -8435,10 +8451,11 @@ void EnumValueOptions::InternalSwap(EnumValueOptions* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata EnumValueOptions::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata EnumValueOptions::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[18]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class ServiceOptions::_Internal {
 class ServiceOptions::_Internal {
@@ -8688,10 +8705,11 @@ void ServiceOptions::InternalSwap(ServiceOptions* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata ServiceOptions::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata ServiceOptions::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[19]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class MethodOptions::_Internal {
 class MethodOptions::_Internal {
@@ -8993,10 +9011,11 @@ void MethodOptions::InternalSwap(MethodOptions* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata MethodOptions::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata MethodOptions::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[20]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class UninterpretedOption_NamePart::_Internal {
 class UninterpretedOption_NamePart::_Internal {
@@ -9263,10 +9282,11 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata UninterpretedOption_NamePart::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata UninterpretedOption_NamePart::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[21]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class UninterpretedOption::_Internal {
 class UninterpretedOption::_Internal {
@@ -9700,10 +9720,11 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata UninterpretedOption::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata UninterpretedOption::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[22]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class SourceCodeInfo_Location::_Internal {
 class SourceCodeInfo_Location::_Internal {
@@ -10085,10 +10106,11 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo_Location::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo_Location::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[23]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class SourceCodeInfo::_Internal {
 class SourceCodeInfo::_Internal {
@@ -10279,10 +10301,11 @@ void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[24]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class GeneratedCodeInfo_Annotation::_Internal {
 class GeneratedCodeInfo_Annotation::_Internal {
@@ -10612,10 +10635,11 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata GeneratedCodeInfo_Annotation::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata GeneratedCodeInfo_Annotation::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[25]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class GeneratedCodeInfo::_Internal {
 class GeneratedCodeInfo::_Internal {
@@ -10806,10 +10830,11 @@ void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata GeneratedCodeInfo::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata GeneratedCodeInfo::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[26]);
 }
 }
 
 
-
 // @@protoc_insertion_point(namespace_scope)
 // @@protoc_insertion_point(namespace_scope)
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN

File diff suppressed because it is too large
+ 108 - 307
src/google/protobuf/descriptor.pb.h


+ 5 - 6
src/google/protobuf/duration.pb.cc

@@ -67,10 +67,8 @@ const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fduration_2eproto::offsets,
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fduration_2eproto::offsets,
   file_level_metadata_google_2fprotobuf_2fduration_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto, file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto,
   file_level_metadata_google_2fprotobuf_2fduration_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto, file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto,
 };
 };
-PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata
-descriptor_table_google_2fprotobuf_2fduration_2eproto_metadata_getter(int index) {
-  ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fduration_2eproto);
-  return descriptor_table_google_2fprotobuf_2fduration_2eproto.file_level_metadata[index];
+PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fduration_2eproto_getter() {
+  return &descriptor_table_google_2fprotobuf_2fduration_2eproto;
 }
 }
 
 
 // Force running AddDescriptors() at dynamic initialization time.
 // Force running AddDescriptors() at dynamic initialization time.
@@ -297,10 +295,11 @@ void Duration::InternalSwap(Duration* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata Duration::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata Duration::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fduration_2eproto_getter, &descriptor_table_google_2fprotobuf_2fduration_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fduration_2eproto[0]);
 }
 }
 
 
-
 // @@protoc_insertion_point(namespace_scope)
 // @@protoc_insertion_point(namespace_scope)
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN

+ 2 - 9
src/google/protobuf/duration.pb.h

@@ -53,7 +53,6 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fduration_2eproto {
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
 };
 };
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fduration_2eproto;
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fduration_2eproto;
-PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fduration_2eproto_metadata_getter(int index);
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN
 class Duration;
 class Duration;
 struct DurationDefaultTypeInternal;
 struct DurationDefaultTypeInternal;
@@ -96,10 +95,10 @@ class PROTOBUF_EXPORT Duration PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const Duration& default_instance() {
   static const Duration& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -167,12 +166,6 @@ class PROTOBUF_EXPORT Duration PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2fduration_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 

+ 5 - 6
src/google/protobuf/empty.pb.cc

@@ -62,10 +62,8 @@ const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fempty_2eproto::offsets,
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fempty_2eproto::offsets,
   file_level_metadata_google_2fprotobuf_2fempty_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto, file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto,
   file_level_metadata_google_2fprotobuf_2fempty_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto, file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto,
 };
 };
-PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata
-descriptor_table_google_2fprotobuf_2fempty_2eproto_metadata_getter(int index) {
-  ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fempty_2eproto);
-  return descriptor_table_google_2fprotobuf_2fempty_2eproto.file_level_metadata[index];
+PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fempty_2eproto_getter() {
+  return &descriptor_table_google_2fprotobuf_2fempty_2eproto;
 }
 }
 
 
 // Force running AddDescriptors() at dynamic initialization time.
 // Force running AddDescriptors() at dynamic initialization time.
@@ -225,10 +223,11 @@ void Empty::InternalSwap(Empty* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata Empty::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata Empty::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fempty_2eproto_getter, &descriptor_table_google_2fprotobuf_2fempty_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fempty_2eproto[0]);
 }
 }
 
 
-
 // @@protoc_insertion_point(namespace_scope)
 // @@protoc_insertion_point(namespace_scope)
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN

+ 2 - 9
src/google/protobuf/empty.pb.h

@@ -53,7 +53,6 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fempty_2eproto {
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
 };
 };
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fempty_2eproto;
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fempty_2eproto;
-PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fempty_2eproto_metadata_getter(int index);
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN
 class Empty;
 class Empty;
 struct EmptyDefaultTypeInternal;
 struct EmptyDefaultTypeInternal;
@@ -96,10 +95,10 @@ class PROTOBUF_EXPORT Empty PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const Empty& default_instance() {
   static const Empty& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -167,12 +166,6 @@ class PROTOBUF_EXPORT Empty PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2fempty_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 

+ 5 - 6
src/google/protobuf/field_mask.pb.cc

@@ -65,10 +65,8 @@ const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets,
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets,
   file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto,
   file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto,
 };
 };
-PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata
-descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_metadata_getter(int index) {
-  ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto);
-  return descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto.file_level_metadata[index];
+PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_getter() {
+  return &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto;
 }
 }
 
 
 // Force running AddDescriptors() at dynamic initialization time.
 // Force running AddDescriptors() at dynamic initialization time.
@@ -270,10 +268,11 @@ void FieldMask::InternalSwap(FieldMask* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata FieldMask::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata FieldMask::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_getter, &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto[0]);
 }
 }
 
 
-
 // @@protoc_insertion_point(namespace_scope)
 // @@protoc_insertion_point(namespace_scope)
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN

+ 2 - 9
src/google/protobuf/field_mask.pb.h

@@ -53,7 +53,6 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto {
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
 };
 };
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto;
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto;
-PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_metadata_getter(int index);
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN
 class FieldMask;
 class FieldMask;
 struct FieldMaskDefaultTypeInternal;
 struct FieldMaskDefaultTypeInternal;
@@ -96,10 +95,10 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const FieldMask& default_instance() {
   static const FieldMask& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -167,12 +166,6 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 

+ 11 - 0
src/google/protobuf/generated_message_reflection.cc

@@ -2520,6 +2520,17 @@ void RegisterAllTypesInternal(const Metadata* file_level_metadata, int size) {
 
 
 namespace internal {
 namespace internal {
 
 
+Metadata AssignDescriptors(const DescriptorTable* (*table)(),
+                           internal::once_flag* once,
+                           const Metadata& metadata) {
+  call_once(*once, [=] {
+    auto* t = table();
+    AssignDescriptorsImpl(t, t->is_eager);
+  });
+
+  return metadata;
+}
+
 void AssignDescriptors(const DescriptorTable* table, bool eager) {
 void AssignDescriptors(const DescriptorTable* table, bool eager) {
   if (!eager) eager = table->is_eager;
   if (!eager) eager = table->is_eager;
   call_once(*table->once, AssignDescriptorsImpl, table, eager);
   call_once(*table->once, AssignDescriptorsImpl, table, eager);

+ 8 - 0
src/google/protobuf/generated_message_reflection.h

@@ -290,6 +290,14 @@ enum {
 void PROTOBUF_EXPORT AssignDescriptors(const DescriptorTable* table,
 void PROTOBUF_EXPORT AssignDescriptors(const DescriptorTable* table,
                                        bool eager = false);
                                        bool eager = false);
 
 
+// Overload used to implement GetMetadataStatic in the generated code.
+// See comments in compiler/cpp/internal/file.cc as to why.
+// It takes a `Metadata` and returns it to allow for tail calls and reduce
+// binary size.
+Metadata PROTOBUF_EXPORT AssignDescriptors(const DescriptorTable* (*table)(),
+                                           internal::once_flag* once,
+                                           const Metadata& metadata);
+
 // These cannot be in lite so we put them in the reflection.
 // These cannot be in lite so we put them in the reflection.
 PROTOBUF_EXPORT void UnknownFieldSetSerializer(const uint8* base, uint32 offset,
 PROTOBUF_EXPORT void UnknownFieldSetSerializer(const uint8* base, uint32 offset,
                                                uint32 tag, uint32 has_offset,
                                                uint32 tag, uint32 has_offset,

+ 12 - 11
src/google/protobuf/io/coded_stream.h

@@ -133,6 +133,8 @@
 #else
 #else
 #ifdef __APPLE__
 #ifdef __APPLE__
 #include <machine/endian.h>  // __BYTE_ORDER
 #include <machine/endian.h>  // __BYTE_ORDER
+#elif defined(__FreeBSD__)
+#include <sys/endian.h>  // __BYTE_ORDER
 #else
 #else
 #include <endian.h>  // __BYTE_ORDER
 #include <endian.h>  // __BYTE_ORDER
 #endif
 #endif
@@ -851,11 +853,11 @@ class PROTOBUF_EXPORT EpsCopyOutputStream {
   }
   }
 
 
   static constexpr int TagSize(uint32 tag) {
   static constexpr int TagSize(uint32 tag) {
-    return (tag < (1 << 7))
-               ? 1
-               : (tag < (1 << 14))
-                     ? 2
-                     : (tag < (1 << 21)) ? 3 : (tag < (1 << 28)) ? 4 : 5;
+    return (tag < (1 << 7))    ? 1
+           : (tag < (1 << 14)) ? 2
+           : (tag < (1 << 21)) ? 3
+           : (tag < (1 << 28)) ? 4
+                               : 5;
   }
   }
 
 
   PROTOBUF_ALWAYS_INLINE uint8* WriteTag(uint32 num, uint32 wt, uint8* ptr) {
   PROTOBUF_ALWAYS_INLINE uint8* WriteTag(uint32 num, uint32 wt, uint8* ptr) {
@@ -1181,12 +1183,11 @@ class PROTOBUF_EXPORT CodedOutputStream {
   // Compile-time equivalent of VarintSize32().
   // Compile-time equivalent of VarintSize32().
   template <uint32 Value>
   template <uint32 Value>
   struct StaticVarintSize32 {
   struct StaticVarintSize32 {
-    static const size_t value =
-        (Value < (1 << 7))
-            ? 1
-            : (Value < (1 << 14))
-                  ? 2
-                  : (Value < (1 << 21)) ? 3 : (Value < (1 << 28)) ? 4 : 5;
+    static const size_t value = (Value < (1 << 7))    ? 1
+                                : (Value < (1 << 14)) ? 2
+                                : (Value < (1 << 21)) ? 3
+                                : (Value < (1 << 28)) ? 4
+                                                      : 5;
   };
   };
 
 
   // Returns the total number of bytes written since this object was created.
   // Returns the total number of bytes written since this object was created.

+ 4 - 2
src/google/protobuf/metadata_lite.h

@@ -67,7 +67,7 @@ class InternalMetadata {
   template <typename T>
   template <typename T>
   void Delete() {
   void Delete() {
     // Note that Delete<> should be called not more than once.
     // Note that Delete<> should be called not more than once.
-    if (have_unknown_fields() && arena() == NULL) {
+    if (have_unknown_fields()) {
       DeleteOutOfLineHelper<T>();
       DeleteOutOfLineHelper<T>();
     }
     }
   }
   }
@@ -204,7 +204,9 @@ class InternalMetadata {
 
 
   template <typename T>
   template <typename T>
   PROTOBUF_NOINLINE void DeleteOutOfLineHelper() {
   PROTOBUF_NOINLINE void DeleteOutOfLineHelper() {
-    delete PtrValue<Container<T>>();
+    if (arena() == NULL) {
+      delete PtrValue<Container<T>>();
+    }
   }
   }
 
 
   template <typename T>
   template <typename T>

+ 0 - 1
src/google/protobuf/parse_context.h

@@ -348,7 +348,6 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
     if (ptr - buffer_end_ > limit_) return nullptr;
     if (ptr - buffer_end_ > limit_) return nullptr;
     while (limit_ > kSlopBytes) {
     while (limit_ > kSlopBytes) {
       size_t chunk_size = buffer_end_ + kSlopBytes - ptr;
       size_t chunk_size = buffer_end_ + kSlopBytes - ptr;
-      GOOGLE_DCHECK_GE(chunk_size, static_cast<size_t>(0));
       append(ptr, chunk_size);
       append(ptr, chunk_size);
       ptr = Next();
       ptr = Next();
       if (ptr == nullptr) return limit_end_;
       if (ptr == nullptr) return limit_end_;

+ 6 - 4
src/google/protobuf/port_def.inc

@@ -198,22 +198,24 @@
 //   You can #define these annotations yourself if the default implementation
 //   You can #define these annotations yourself if the default implementation
 //   is not right for you.
 //   is not right for you.
 
 
+#ifndef PROTOBUF_NO_INLINE
 #ifdef GOOGLE_ATTRIBUTE_ALWAYS_INLINE
 #ifdef GOOGLE_ATTRIBUTE_ALWAYS_INLINE
 #define PROTOBUF_ALWAYS_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE
 #define PROTOBUF_ALWAYS_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE
 #define PROTOBUF_NDEBUG_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE
 #define PROTOBUF_NDEBUG_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE
-#else
-#if defined(__GNUC__) && \
+#elif defined(__GNUC__) && \
     (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
     (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
 // For functions we want to force inline.
 // For functions we want to force inline.
 // Introduced in gcc 3.1.
 // Introduced in gcc 3.1.
 #define PROTOBUF_ALWAYS_INLINE __attribute__((always_inline))
 #define PROTOBUF_ALWAYS_INLINE __attribute__((always_inline))
 #define PROTOBUF_NDEBUG_INLINE __attribute__((always_inline))
 #define PROTOBUF_NDEBUG_INLINE __attribute__((always_inline))
-#else
+#endif
+#endif
+
+#ifndef PROTOBUF_ALWAYS_INLINE
 // Other compilers will have to figure it out for themselves.
 // Other compilers will have to figure it out for themselves.
 #define PROTOBUF_ALWAYS_INLINE
 #define PROTOBUF_ALWAYS_INLINE
 #define PROTOBUF_NDEBUG_INLINE
 #define PROTOBUF_NDEBUG_INLINE
 #endif
 #endif
-#endif
 
 
 #ifdef GOOGLE_ATTRIBUTE_NOINLINE
 #ifdef GOOGLE_ATTRIBUTE_NOINLINE
 #define PROTOBUF_NOINLINE GOOGLE_ATTRIBUTE_NOINLINE
 #define PROTOBUF_NOINLINE GOOGLE_ATTRIBUTE_NOINLINE

+ 29 - 0
src/google/protobuf/proto3_arena_unittest.cc

@@ -317,6 +317,35 @@ TEST(Proto3OptionalTest, OptionalFieldDescriptor) {
   }
   }
 }
 }
 
 
+TEST(Proto3OptionalTest, Extensions) {
+  const DescriptorPool* p = DescriptorPool::generated_pool();
+  const FieldDescriptor* no_optional = p->FindExtensionByName(
+      "protobuf_unittest.Proto3OptionalExtensions.ext_no_optional");
+  const FieldDescriptor* with_optional = p->FindExtensionByName(
+      "protobuf_unittest.Proto3OptionalExtensions.ext_with_optional");
+  GOOGLE_CHECK(no_optional);
+  GOOGLE_CHECK(with_optional);
+  EXPECT_FALSE(no_optional->has_optional_keyword());
+  EXPECT_TRUE(with_optional->has_optional_keyword());
+
+  const Descriptor* d = protobuf_unittest::Proto3OptionalExtensions::descriptor();
+  EXPECT_TRUE(d->options().HasExtension(
+      protobuf_unittest::Proto3OptionalExtensions::ext_no_optional));
+  EXPECT_TRUE(d->options().HasExtension(
+      protobuf_unittest::Proto3OptionalExtensions::ext_with_optional));
+  EXPECT_EQ(8, d->options().GetExtension(
+                   protobuf_unittest::Proto3OptionalExtensions::ext_no_optional));
+  EXPECT_EQ(16,
+            d->options().GetExtension(
+                protobuf_unittest::Proto3OptionalExtensions::ext_with_optional));
+
+  const Descriptor* d2 = protobuf_unittest::TestProto3Optional::descriptor();
+  EXPECT_FALSE(d2->options().HasExtension(
+      protobuf_unittest::Proto3OptionalExtensions::ext_no_optional));
+  EXPECT_FALSE(d2->options().HasExtension(
+      protobuf_unittest::Proto3OptionalExtensions::ext_with_optional));
+}
+
 TEST(Proto3OptionalTest, OptionalField) {
 TEST(Proto3OptionalTest, OptionalField) {
   protobuf_unittest::TestProto3Optional msg;
   protobuf_unittest::TestProto3Optional msg;
   EXPECT_FALSE(msg.has_optional_int32());
   EXPECT_FALSE(msg.has_optional_int32());

+ 9 - 0
src/google/protobuf/repeated_field.cc

@@ -98,6 +98,15 @@ void RepeatedPtrFieldBase::Reserve(int new_size) {
   }
   }
 }
 }
 
 
+void* RepeatedPtrFieldBase::AddOutOfLineHelper(void* obj) {
+  if (!rep_ || rep_->allocated_size == total_size_) {
+    InternalExtend(1);  // Equivalent to "Reserve(total_size_ + 1)"
+  }
+  ++rep_->allocated_size;
+  rep_->elements[current_size_++] = obj;
+  return obj;
+}
+
 void RepeatedPtrFieldBase::CloseGap(int start, int num) {
 void RepeatedPtrFieldBase::CloseGap(int start, int num) {
   if (rep_ == NULL) return;
   if (rep_ == NULL) return;
   // Close up a gap of "num" elements starting at offset "start".
   // Close up a gap of "num" elements starting at offset "start".

+ 37 - 28
src/google/protobuf/repeated_field.h

@@ -171,9 +171,14 @@ class RepeatedField final {
  public:
  public:
   constexpr RepeatedField();
   constexpr RepeatedField();
   explicit RepeatedField(Arena* arena);
   explicit RepeatedField(Arena* arena);
+
   RepeatedField(const RepeatedField& other);
   RepeatedField(const RepeatedField& other);
-  template <typename Iter>
-  RepeatedField(Iter begin, const Iter& end);
+
+  template <typename Iter,
+            typename = typename std::enable_if<std::is_constructible<
+                Element, decltype(*std::declval<Iter>())>::value>::type>
+  RepeatedField(Iter begin, Iter end);
+
   ~RepeatedField();
   ~RepeatedField();
 
 
   RepeatedField& operator=(const RepeatedField& other);
   RepeatedField& operator=(const RepeatedField& other);
@@ -769,6 +774,11 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
   // Reserve() and MergeFrom() to reduce code size. |extend_amount| must be > 0.
   // Reserve() and MergeFrom() to reduce code size. |extend_amount| must be > 0.
   void** InternalExtend(int extend_amount);
   void** InternalExtend(int extend_amount);
 
 
+  // Internal helper for Add: add "obj" as the next element in the
+  // array, including potentially resizing the array with Reserve if
+  // needed
+  void* AddOutOfLineHelper(void* obj);
+
   // The reflection implementation needs to call protected methods directly,
   // The reflection implementation needs to call protected methods directly,
   // reinterpreting pointers as being to Message instead of a specific Message
   // reinterpreting pointers as being to Message instead of a specific Message
   // subclass.
   // subclass.
@@ -923,8 +933,12 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase {
   explicit RepeatedPtrField(Arena* arena);
   explicit RepeatedPtrField(Arena* arena);
 
 
   RepeatedPtrField(const RepeatedPtrField& other);
   RepeatedPtrField(const RepeatedPtrField& other);
-  template <typename Iter>
-  RepeatedPtrField(Iter begin, const Iter& end);
+
+  template <typename Iter,
+            typename = typename std::enable_if<std::is_constructible<
+                Element, decltype(*std::declval<Iter>())>::value>::type>
+  RepeatedPtrField(Iter begin, Iter end);
+
   ~RepeatedPtrField();
   ~RepeatedPtrField();
 
 
   RepeatedPtrField& operator=(const RepeatedPtrField& other);
   RepeatedPtrField& operator=(const RepeatedPtrField& other);
@@ -1197,8 +1211,8 @@ inline RepeatedField<Element>::RepeatedField(const RepeatedField& other)
 }
 }
 
 
 template <typename Element>
 template <typename Element>
-template <typename Iter>
-RepeatedField<Element>::RepeatedField(Iter begin, const Iter& end)
+template <typename Iter, typename>
+RepeatedField<Element>::RepeatedField(Iter begin, Iter end)
     : current_size_(0), total_size_(0), arena_or_elements_(nullptr) {
     : current_size_(0), total_size_(0), arena_or_elements_(nullptr) {
   Add(begin, end);
   Add(begin, end);
 }
 }
@@ -1747,14 +1761,10 @@ inline typename TypeHandler::Type* RepeatedPtrFieldBase::Add(
   if (rep_ != NULL && current_size_ < rep_->allocated_size) {
   if (rep_ != NULL && current_size_ < rep_->allocated_size) {
     return cast<TypeHandler>(rep_->elements[current_size_++]);
     return cast<TypeHandler>(rep_->elements[current_size_++]);
   }
   }
-  if (!rep_ || rep_->allocated_size == total_size_) {
-    Reserve(total_size_ + 1);
-  }
-  ++rep_->allocated_size;
   typename TypeHandler::Type* result =
   typename TypeHandler::Type* result =
       TypeHandler::NewFromPrototype(prototype, arena_);
       TypeHandler::NewFromPrototype(prototype, arena_);
-  rep_->elements[current_size_++] = result;
-  return result;
+  return reinterpret_cast<typename TypeHandler::Type*>(
+      AddOutOfLineHelper(result));
 }
 }
 
 
 template <typename TypeHandler,
 template <typename TypeHandler,
@@ -1828,9 +1838,19 @@ template <typename TypeHandler>
 void RepeatedPtrFieldBase::MergeFromInnerLoop(void** our_elems,
 void RepeatedPtrFieldBase::MergeFromInnerLoop(void** our_elems,
                                               void** other_elems, int length,
                                               void** other_elems, int length,
                                               int already_allocated) {
                                               int already_allocated) {
-  // Split into two loops, over ranges [0, allocated) and [allocated, length),
-  // to avoid a branch within the loop.
-  for (int i = 0; i < already_allocated && i < length; i++) {
+  if (already_allocated < length) {
+    Arena* arena = GetArena();
+    typename TypeHandler::Type* elem_prototype =
+        reinterpret_cast<typename TypeHandler::Type*>(other_elems[0]);
+    for (int i = already_allocated; i < length; i++) {
+      // Allocate a new empty element that we'll merge into below
+      typename TypeHandler::Type* new_elem =
+          TypeHandler::NewFromPrototype(elem_prototype, arena);
+      our_elems[i] = new_elem;
+    }
+  }
+  // Main loop that does the actual merging
+  for (int i = 0; i < length; i++) {
     // Already allocated: use existing element.
     // Already allocated: use existing element.
     typename TypeHandler::Type* other_elem =
     typename TypeHandler::Type* other_elem =
         reinterpret_cast<typename TypeHandler::Type*>(other_elems[i]);
         reinterpret_cast<typename TypeHandler::Type*>(other_elems[i]);
@@ -1838,16 +1858,6 @@ void RepeatedPtrFieldBase::MergeFromInnerLoop(void** our_elems,
         reinterpret_cast<typename TypeHandler::Type*>(our_elems[i]);
         reinterpret_cast<typename TypeHandler::Type*>(our_elems[i]);
     TypeHandler::Merge(*other_elem, new_elem);
     TypeHandler::Merge(*other_elem, new_elem);
   }
   }
-  Arena* arena = GetArena();
-  for (int i = already_allocated; i < length; i++) {
-    // Not allocated: alloc a new element first, then merge it.
-    typename TypeHandler::Type* other_elem =
-        reinterpret_cast<typename TypeHandler::Type*>(other_elems[i]);
-    typename TypeHandler::Type* new_elem =
-        TypeHandler::NewFromPrototype(other_elem, arena);
-    TypeHandler::Merge(*other_elem, new_elem);
-    our_elems[i] = new_elem;
-  }
 }
 }
 
 
 template <typename TypeHandler>
 template <typename TypeHandler>
@@ -2110,9 +2120,8 @@ inline RepeatedPtrField<Element>::RepeatedPtrField(
 }
 }
 
 
 template <typename Element>
 template <typename Element>
-template <typename Iter>
-inline RepeatedPtrField<Element>::RepeatedPtrField(Iter begin,
-                                                   const Iter& end) {
+template <typename Iter, typename>
+inline RepeatedPtrField<Element>::RepeatedPtrField(Iter begin, Iter end) {
   int reserve = internal::CalculateReserve(begin, end);
   int reserve = internal::CalculateReserve(begin, end);
   if (reserve != -1) {
   if (reserve != -1) {
     Reserve(reserve);
     Reserve(reserve);

+ 5 - 6
src/google/protobuf/source_context.pb.cc

@@ -65,10 +65,8 @@ const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets,
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets,
   file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto,
   file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto,
 };
 };
-PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata
-descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_metadata_getter(int index) {
-  ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto);
-  return descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto.file_level_metadata[index];
+PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_getter() {
+  return &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto;
 }
 }
 
 
 // Force running AddDescriptors() at dynamic initialization time.
 // Force running AddDescriptors() at dynamic initialization time.
@@ -271,10 +269,11 @@ void SourceContext::InternalSwap(SourceContext* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata SourceContext::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata SourceContext::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_getter, &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto[0]);
 }
 }
 
 
-
 // @@protoc_insertion_point(namespace_scope)
 // @@protoc_insertion_point(namespace_scope)
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN

+ 9 - 34
src/google/protobuf/source_context.pb.h

@@ -53,7 +53,6 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
 };
 };
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto;
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto;
-PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_metadata_getter(int index);
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN
 class SourceContext;
 class SourceContext;
 struct SourceContextDefaultTypeInternal;
 struct SourceContextDefaultTypeInternal;
@@ -96,10 +95,10 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const SourceContext& default_instance() {
   static const SourceContext& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -167,12 +166,6 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -184,10 +177,8 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL :
   // string file_name = 1;
   // string file_name = 1;
   void clear_file_name();
   void clear_file_name();
   const std::string& file_name() const;
   const std::string& file_name() const;
-  void set_file_name(const std::string& value);
-  void set_file_name(std::string&& value);
-  void set_file_name(const char* value);
-  void set_file_name(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_file_name(ArgT0&& arg0, ArgT... args);
   std::string* mutable_file_name();
   std::string* mutable_file_name();
   std::string* release_file_name();
   std::string* release_file_name();
   void set_allocated_file_name(std::string* file_name);
   void set_allocated_file_name(std::string* file_name);
@@ -227,8 +218,11 @@ inline const std::string& SourceContext::file_name() const {
   // @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name)
   // @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name)
   return _internal_file_name();
   return _internal_file_name();
 }
 }
-inline void SourceContext::set_file_name(const std::string& value) {
-  _internal_set_file_name(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void SourceContext::set_file_name(ArgT0&& arg0, ArgT... args) {
+ 
+ file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -242,25 +236,6 @@ inline void SourceContext::_internal_set_file_name(const std::string& value) {
   
   
   file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void SourceContext::set_file_name(std::string&& value) {
-  
-  file_name_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceContext.file_name)
-}
-inline void SourceContext::set_file_name(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.SourceContext.file_name)
-}
-inline void SourceContext::set_file_name(const char* value,
-    size_t size) {
-  
-  file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceContext.file_name)
-}
 inline std::string* SourceContext::_internal_mutable_file_name() {
 inline std::string* SourceContext::_internal_mutable_file_name() {
   
   
   return file_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return file_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());

+ 14 - 11
src/google/protobuf/struct.pb.cc

@@ -143,10 +143,8 @@ const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets,
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets,
   file_level_metadata_google_2fprotobuf_2fstruct_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto, file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto,
   file_level_metadata_google_2fprotobuf_2fstruct_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto, file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto,
 };
 };
-PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata
-descriptor_table_google_2fprotobuf_2fstruct_2eproto_metadata_getter(int index) {
-  ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fstruct_2eproto);
-  return descriptor_table_google_2fprotobuf_2fstruct_2eproto.file_level_metadata[index];
+PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter() {
+  return &descriptor_table_google_2fprotobuf_2fstruct_2eproto;
 }
 }
 
 
 // Force running AddDescriptors() at dynamic initialization time.
 // Force running AddDescriptors() at dynamic initialization time.
@@ -175,7 +173,9 @@ void Struct_FieldsEntry_DoNotUse::MergeFrom(const Struct_FieldsEntry_DoNotUse& o
   MergeFromInternal(other);
   MergeFromInternal(other);
 }
 }
 ::PROTOBUF_NAMESPACE_ID::Metadata Struct_FieldsEntry_DoNotUse::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata Struct_FieldsEntry_DoNotUse::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fstruct_2eproto[0]);
 }
 }
 void Struct_FieldsEntry_DoNotUse::MergeFrom(
 void Struct_FieldsEntry_DoNotUse::MergeFrom(
     const ::PROTOBUF_NAMESPACE_ID::Message& other) {
     const ::PROTOBUF_NAMESPACE_ID::Message& other) {
@@ -408,10 +408,11 @@ void Struct::InternalSwap(Struct* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata Struct::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata Struct::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fstruct_2eproto[1]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class Value::_Internal {
 class Value::_Internal {
@@ -847,10 +848,11 @@ void Value::InternalSwap(Value* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata Value::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata Value::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fstruct_2eproto[2]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class ListValue::_Internal {
 class ListValue::_Internal {
@@ -1041,10 +1043,11 @@ void ListValue::InternalSwap(ListValue* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata ListValue::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata ListValue::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2fstruct_2eproto[3]);
 }
 }
 
 
-
 // @@protoc_insertion_point(namespace_scope)
 // @@protoc_insertion_point(namespace_scope)
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN

+ 16 - 73
src/google/protobuf/struct.pb.h

@@ -57,7 +57,6 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fstruct_2eproto {
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
 };
 };
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fstruct_2eproto;
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fstruct_2eproto;
-PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fstruct_2eproto_metadata_getter(int index);
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN
 class ListValue;
 class ListValue;
 struct ListValueDefaultTypeInternal;
 struct ListValueDefaultTypeInternal;
@@ -127,13 +126,6 @@ public:
   static bool ValidateValue(void*) { return true; }
   static bool ValidateValue(void*) { return true; }
   void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& other) final;
   void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& other) final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fstruct_2eproto);
-    return ::descriptor_table_google_2fprotobuf_2fstruct_2eproto.file_level_metadata[0];
-  }
-
-  public:
 };
 };
 
 
 // -------------------------------------------------------------------
 // -------------------------------------------------------------------
@@ -168,10 +160,10 @@ class PROTOBUF_EXPORT Struct PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const Struct& default_instance() {
   static const Struct& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -239,12 +231,6 @@ class PROTOBUF_EXPORT Struct PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2fstruct_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -318,10 +304,10 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const Value& default_instance() {
   static const Value& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -399,12 +385,6 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2fstruct_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -451,10 +431,8 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL :
   public:
   public:
   void clear_string_value();
   void clear_string_value();
   const std::string& string_value() const;
   const std::string& string_value() const;
-  void set_string_value(const std::string& value);
-  void set_string_value(std::string&& value);
-  void set_string_value(const char* value);
-  void set_string_value(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_string_value(ArgT0&& arg0, ArgT... args);
   std::string* mutable_string_value();
   std::string* mutable_string_value();
   std::string* release_string_value();
   std::string* release_string_value();
   void set_allocated_string_value(std::string* string_value);
   void set_allocated_string_value(std::string* string_value);
@@ -578,10 +556,10 @@ class PROTOBUF_EXPORT ListValue PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const ListValue& default_instance() {
   static const ListValue& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -649,12 +627,6 @@ class PROTOBUF_EXPORT ListValue PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2fstruct_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -834,8 +806,14 @@ inline const std::string& Value::string_value() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Value.string_value)
   // @@protoc_insertion_point(field_get:google.protobuf.Value.string_value)
   return _internal_string_value();
   return _internal_string_value();
 }
 }
-inline void Value::set_string_value(const std::string& value) {
-  _internal_set_string_value(value);
+template <typename ArgT0, typename... ArgT>
+inline void Value::set_string_value(ArgT0&& arg0, ArgT... args) {
+  if (!_internal_has_string_value()) {
+    clear_kind();
+    set_has_string_value();
+    kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
+  }
+  kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -856,41 +834,6 @@ inline void Value::_internal_set_string_value(const std::string& value) {
   }
   }
   kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Value::set_string_value(std::string&& value) {
-  // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value)
-  if (!_internal_has_string_value()) {
-    clear_kind();
-    set_has_string_value();
-    kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
-  }
-  kind_.string_value_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Value.string_value)
-}
-inline void Value::set_string_value(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  if (!_internal_has_string_value()) {
-    clear_kind();
-    set_has_string_value();
-    kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
-  }
-  kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{},
-      ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Value.string_value)
-}
-inline void Value::set_string_value(const char* value,
-                             size_t size) {
-  if (!_internal_has_string_value()) {
-    clear_kind();
-    set_has_string_value();
-    kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
-  }
-  kind_.string_value_.Set(
-      ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size),
-      GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Value.string_value)
-}
 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()) {
     clear_kind();
     clear_kind();

+ 2 - 0
src/google/protobuf/stubs/port.h

@@ -59,6 +59,8 @@
 #else
 #else
 #ifdef __APPLE__
 #ifdef __APPLE__
 #include <machine/endian.h>  // __BYTE_ORDER
 #include <machine/endian.h>  // __BYTE_ORDER
+#elif defined(__FreeBSD__)
+#include <sys/endian.h>  // __BYTE_ORDER
 #else
 #else
 #include <endian.h>  // __BYTE_ORDER
 #include <endian.h>  // __BYTE_ORDER
 #endif
 #endif

+ 0 - 43
src/google/protobuf/stubs/stringpiece.h

@@ -426,49 +426,6 @@ inline bool operator>=(StringPiece x, StringPiece y) {
 // allow StringPiece to be logged
 // allow StringPiece to be logged
 extern std::ostream& operator<<(std::ostream& o, StringPiece piece);
 extern std::ostream& operator<<(std::ostream& o, StringPiece piece);
 
 
-namespace internal {
-// StringPiece is not a POD and can not be used in an union (pre C++11). We
-// need a POD version of it.
-struct StringPiecePod {
-  // Create from a StringPiece.
-  static StringPiecePod CreateFromStringPiece(StringPiece str) {
-    StringPiecePod pod;
-    pod.data_ = str.data();
-    pod.size_ = str.size();
-    return pod;
-  }
-
-  // Cast to StringPiece.
-  operator StringPiece() const { return StringPiece(data_, size_); }
-
-  bool operator==(const char* value) const {
-    return StringPiece(data_, size_) == StringPiece(value);
-  }
-
-  char operator[](stringpiece_ssize_type i) const {
-    assert(0 <= i);
-    assert(i < size_);
-    return data_[i];
-  }
-
-  const char* data() const { return data_; }
-
-  stringpiece_ssize_type size() const {
-    return size_;
-  }
-
-  std::string ToString() const {
-    return std::string(data_, static_cast<size_t>(size_));
-  }
-
-  explicit operator std::string() const { return ToString(); }
-
- private:
-  const char* data_;
-  stringpiece_ssize_type size_;
-};
-
-}  // namespace internal
 }  // namespace protobuf
 }  // namespace protobuf
 }  // namespace google
 }  // namespace google
 
 

+ 0 - 3
src/google/protobuf/stubs/strutil.h

@@ -664,9 +664,6 @@ struct PROTOBUF_EXPORT AlphaNum {
   AlphaNum(StringPiece str)
   AlphaNum(StringPiece str)
       : piece_data_(str.data()), piece_size_(str.size()) {}
       : piece_data_(str.data()), piece_size_(str.size()) {}
 
 
-  AlphaNum(internal::StringPiecePod str)
-      : piece_data_(str.data()), piece_size_(str.size()) {}
-
   size_t size() const { return piece_size_; }
   size_t size() const { return piece_size_; }
   const char *data() const { return piece_data_; }
   const char *data() const { return piece_data_; }
 
 

+ 5 - 6
src/google/protobuf/timestamp.pb.cc

@@ -67,10 +67,8 @@ const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets,
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets,
   file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto,
   file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto,
 };
 };
-PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata
-descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_metadata_getter(int index) {
-  ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2ftimestamp_2eproto);
-  return descriptor_table_google_2fprotobuf_2ftimestamp_2eproto.file_level_metadata[index];
+PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_getter() {
+  return &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto;
 }
 }
 
 
 // Force running AddDescriptors() at dynamic initialization time.
 // Force running AddDescriptors() at dynamic initialization time.
@@ -297,10 +295,11 @@ void Timestamp::InternalSwap(Timestamp* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata Timestamp::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata Timestamp::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto[0]);
 }
 }
 
 
-
 // @@protoc_insertion_point(namespace_scope)
 // @@protoc_insertion_point(namespace_scope)
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN

+ 2 - 9
src/google/protobuf/timestamp.pb.h

@@ -53,7 +53,6 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ftimestamp_2eproto {
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
 };
 };
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftimestamp_2eproto;
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftimestamp_2eproto;
-PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_metadata_getter(int index);
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN
 class Timestamp;
 class Timestamp;
 struct TimestampDefaultTypeInternal;
 struct TimestampDefaultTypeInternal;
@@ -96,10 +95,10 @@ class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const Timestamp& default_instance() {
   static const Timestamp& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -167,12 +166,6 @@ class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 

+ 17 - 14
src/google/protobuf/type.pb.cc

@@ -229,10 +229,8 @@ const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftype_2eproto::offsets,
   schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftype_2eproto::offsets,
   file_level_metadata_google_2fprotobuf_2ftype_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftype_2eproto,
   file_level_metadata_google_2fprotobuf_2ftype_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftype_2eproto,
 };
 };
-PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata
-descriptor_table_google_2fprotobuf_2ftype_2eproto_metadata_getter(int index) {
-  ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2ftype_2eproto);
-  return descriptor_table_google_2fprotobuf_2ftype_2eproto.file_level_metadata[index];
+PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2ftype_2eproto_getter() {
+  return &descriptor_table_google_2fprotobuf_2ftype_2eproto;
 }
 }
 
 
 // Force running AddDescriptors() at dynamic initialization time.
 // Force running AddDescriptors() at dynamic initialization time.
@@ -712,10 +710,11 @@ void Type::InternalSwap(Type* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata Type::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata Type::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2ftype_2eproto[0]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class Field::_Internal {
 class Field::_Internal {
@@ -1189,10 +1188,11 @@ void Field::InternalSwap(Field* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata Field::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata Field::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2ftype_2eproto[1]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class Enum::_Internal {
 class Enum::_Internal {
@@ -1535,10 +1535,11 @@ void Enum::InternalSwap(Enum* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata Enum::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata Enum::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2ftype_2eproto[2]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class EnumValue::_Internal {
 class EnumValue::_Internal {
@@ -1794,10 +1795,11 @@ void EnumValue::InternalSwap(EnumValue* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata EnumValue::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata EnumValue::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2ftype_2eproto[3]);
 }
 }
 
 
-
 // ===================================================================
 // ===================================================================
 
 
 class Option::_Internal {
 class Option::_Internal {
@@ -2042,10 +2044,11 @@ void Option::InternalSwap(Option* other) {
 }
 }
 
 
 ::PROTOBUF_NAMESPACE_ID::Metadata Option::GetMetadata() const {
 ::PROTOBUF_NAMESPACE_ID::Metadata Option::GetMetadata() const {
-  return GetMetadataStatic();
+  return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
+      &descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once,
+      file_level_metadata_google_2fprotobuf_2ftype_2eproto[4]);
 }
 }
 
 
-
 // @@protoc_insertion_point(namespace_scope)
 // @@protoc_insertion_point(namespace_scope)
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_CLOSE
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN

+ 66 - 241
src/google/protobuf/type.pb.h

@@ -56,7 +56,6 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ftype_2eproto {
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
   static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
 };
 };
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftype_2eproto;
 extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftype_2eproto;
-PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2ftype_2eproto_metadata_getter(int index);
 PROTOBUF_NAMESPACE_OPEN
 PROTOBUF_NAMESPACE_OPEN
 class Enum;
 class Enum;
 struct EnumDefaultTypeInternal;
 struct EnumDefaultTypeInternal;
@@ -209,10 +208,10 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const Type& default_instance() {
   static const Type& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -280,12 +279,6 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2ftype_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -362,10 +355,8 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL :
   // string name = 1;
   // string name = 1;
   void clear_name();
   void clear_name();
   const std::string& name() const;
   const std::string& name() const;
-  void set_name(const std::string& value);
-  void set_name(std::string&& value);
-  void set_name(const char* value);
-  void set_name(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_name(ArgT0&& arg0, ArgT... args);
   std::string* mutable_name();
   std::string* mutable_name();
   std::string* release_name();
   std::string* release_name();
   void set_allocated_name(std::string* name);
   void set_allocated_name(std::string* name);
@@ -450,10 +441,10 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const Field& default_instance() {
   static const Field& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -521,12 +512,6 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2ftype_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -663,10 +648,8 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
   // string name = 4;
   // string name = 4;
   void clear_name();
   void clear_name();
   const std::string& name() const;
   const std::string& name() const;
-  void set_name(const std::string& value);
-  void set_name(std::string&& value);
-  void set_name(const char* value);
-  void set_name(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_name(ArgT0&& arg0, ArgT... args);
   std::string* mutable_name();
   std::string* mutable_name();
   std::string* release_name();
   std::string* release_name();
   void set_allocated_name(std::string* name);
   void set_allocated_name(std::string* name);
@@ -679,10 +662,8 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
   // string type_url = 6;
   // string type_url = 6;
   void clear_type_url();
   void clear_type_url();
   const std::string& type_url() const;
   const std::string& type_url() const;
-  void set_type_url(const std::string& value);
-  void set_type_url(std::string&& value);
-  void set_type_url(const char* value);
-  void set_type_url(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_type_url(ArgT0&& arg0, ArgT... args);
   std::string* mutable_type_url();
   std::string* mutable_type_url();
   std::string* release_type_url();
   std::string* release_type_url();
   void set_allocated_type_url(std::string* type_url);
   void set_allocated_type_url(std::string* type_url);
@@ -695,10 +676,8 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
   // string json_name = 10;
   // string json_name = 10;
   void clear_json_name();
   void clear_json_name();
   const std::string& json_name() const;
   const std::string& json_name() const;
-  void set_json_name(const std::string& value);
-  void set_json_name(std::string&& value);
-  void set_json_name(const char* value);
-  void set_json_name(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_json_name(ArgT0&& arg0, ArgT... args);
   std::string* mutable_json_name();
   std::string* mutable_json_name();
   std::string* release_json_name();
   std::string* release_json_name();
   void set_allocated_json_name(std::string* json_name);
   void set_allocated_json_name(std::string* json_name);
@@ -711,10 +690,8 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
   // string default_value = 11;
   // string default_value = 11;
   void clear_default_value();
   void clear_default_value();
   const std::string& default_value() const;
   const std::string& default_value() const;
-  void set_default_value(const std::string& value);
-  void set_default_value(std::string&& value);
-  void set_default_value(const char* value);
-  void set_default_value(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_default_value(ArgT0&& arg0, ArgT... args);
   std::string* mutable_default_value();
   std::string* mutable_default_value();
   std::string* release_default_value();
   std::string* release_default_value();
   void set_allocated_default_value(std::string* default_value);
   void set_allocated_default_value(std::string* default_value);
@@ -821,10 +798,10 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const Enum& default_instance() {
   static const Enum& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -892,12 +869,6 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2ftype_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -949,10 +920,8 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL :
   // string name = 1;
   // string name = 1;
   void clear_name();
   void clear_name();
   const std::string& name() const;
   const std::string& name() const;
-  void set_name(const std::string& value);
-  void set_name(std::string&& value);
-  void set_name(const char* value);
-  void set_name(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_name(ArgT0&& arg0, ArgT... args);
   std::string* mutable_name();
   std::string* mutable_name();
   std::string* release_name();
   std::string* release_name();
   void set_allocated_name(std::string* name);
   void set_allocated_name(std::string* name);
@@ -1036,10 +1005,10 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const EnumValue& default_instance() {
   static const EnumValue& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -1107,12 +1076,6 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2ftype_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -1144,10 +1107,8 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL :
   // string name = 1;
   // string name = 1;
   void clear_name();
   void clear_name();
   const std::string& name() const;
   const std::string& name() const;
-  void set_name(const std::string& value);
-  void set_name(std::string&& value);
-  void set_name(const char* value);
-  void set_name(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_name(ArgT0&& arg0, ArgT... args);
   std::string* mutable_name();
   std::string* mutable_name();
   std::string* release_name();
   std::string* release_name();
   void set_allocated_name(std::string* name);
   void set_allocated_name(std::string* name);
@@ -1211,10 +1172,10 @@ class PROTOBUF_EXPORT Option PROTOBUF_FINAL :
     return GetDescriptor();
     return GetDescriptor();
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
   static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
-    return GetMetadataStatic().descriptor;
+    return default_instance().GetMetadata().descriptor;
   }
   }
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
   static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
-    return GetMetadataStatic().reflection;
+    return default_instance().GetMetadata().reflection;
   }
   }
   static const Option& default_instance() {
   static const Option& default_instance() {
     return *internal_default_instance();
     return *internal_default_instance();
@@ -1282,12 +1243,6 @@ class PROTOBUF_EXPORT Option PROTOBUF_FINAL :
   public:
   public:
 
 
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
   ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
-  private:
-  static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
-    return ::descriptor_table_google_2fprotobuf_2ftype_2eproto_metadata_getter(kIndexInFileMessages);
-  }
-
-  public:
 
 
   // nested types ----------------------------------------------------
   // nested types ----------------------------------------------------
 
 
@@ -1300,10 +1255,8 @@ class PROTOBUF_EXPORT Option PROTOBUF_FINAL :
   // string name = 1;
   // string name = 1;
   void clear_name();
   void clear_name();
   const std::string& name() const;
   const std::string& name() const;
-  void set_name(const std::string& value);
-  void set_name(std::string&& value);
-  void set_name(const char* value);
-  void set_name(const char* value, size_t size);
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_name(ArgT0&& arg0, ArgT... args);
   std::string* mutable_name();
   std::string* mutable_name();
   std::string* release_name();
   std::string* release_name();
   void set_allocated_name(std::string* name);
   void set_allocated_name(std::string* name);
@@ -1362,8 +1315,11 @@ inline const std::string& Type::name() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Type.name)
   // @@protoc_insertion_point(field_get:google.protobuf.Type.name)
   return _internal_name();
   return _internal_name();
 }
 }
-inline void Type::set_name(const std::string& value) {
-  _internal_set_name(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Type::set_name(ArgT0&& arg0, ArgT... args) {
+ 
+ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -1377,25 +1333,6 @@ inline void Type::_internal_set_name(const std::string& value) {
   
   
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Type::set_name(std::string&& value) {
-  
-  name_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Type.name)
-}
-inline void Type::set_name(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Type.name)
-}
-inline void Type::set_name(const char* value,
-    size_t size) {
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.name)
-}
 inline std::string* Type::_internal_mutable_name() {
 inline std::string* Type::_internal_mutable_name() {
   
   
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -1736,8 +1673,11 @@ inline const std::string& Field::name() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Field.name)
   // @@protoc_insertion_point(field_get:google.protobuf.Field.name)
   return _internal_name();
   return _internal_name();
 }
 }
-inline void Field::set_name(const std::string& value) {
-  _internal_set_name(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Field::set_name(ArgT0&& arg0, ArgT... args) {
+ 
+ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -1751,25 +1691,6 @@ inline void Field::_internal_set_name(const std::string& value) {
   
   
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Field::set_name(std::string&& value) {
-  
-  name_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.name)
-}
-inline void Field::set_name(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Field.name)
-}
-inline void Field::set_name(const char* value,
-    size_t size) {
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.name)
-}
 inline std::string* Field::_internal_mutable_name() {
 inline std::string* Field::_internal_mutable_name() {
   
   
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -1797,8 +1718,11 @@ inline const std::string& Field::type_url() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Field.type_url)
   // @@protoc_insertion_point(field_get:google.protobuf.Field.type_url)
   return _internal_type_url();
   return _internal_type_url();
 }
 }
-inline void Field::set_type_url(const std::string& value) {
-  _internal_set_type_url(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Field::set_type_url(ArgT0&& arg0, ArgT... args) {
+ 
+ type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -1812,25 +1736,6 @@ inline void Field::_internal_set_type_url(const std::string& value) {
   
   
   type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Field::set_type_url(std::string&& value) {
-  
-  type_url_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.type_url)
-}
-inline void Field::set_type_url(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Field.type_url)
-}
-inline void Field::set_type_url(const char* value,
-    size_t size) {
-  
-  type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.type_url)
-}
 inline std::string* Field::_internal_mutable_type_url() {
 inline std::string* Field::_internal_mutable_type_url() {
   
   
   return type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -1937,8 +1842,11 @@ inline const std::string& Field::json_name() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Field.json_name)
   // @@protoc_insertion_point(field_get:google.protobuf.Field.json_name)
   return _internal_json_name();
   return _internal_json_name();
 }
 }
-inline void Field::set_json_name(const std::string& value) {
-  _internal_set_json_name(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Field::set_json_name(ArgT0&& arg0, ArgT... args) {
+ 
+ json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -1952,25 +1860,6 @@ inline void Field::_internal_set_json_name(const std::string& value) {
   
   
   json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Field::set_json_name(std::string&& value) {
-  
-  json_name_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.json_name)
-}
-inline void Field::set_json_name(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Field.json_name)
-}
-inline void Field::set_json_name(const char* value,
-    size_t size) {
-  
-  json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.json_name)
-}
 inline std::string* Field::_internal_mutable_json_name() {
 inline std::string* Field::_internal_mutable_json_name() {
   
   
   return json_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return json_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -1998,8 +1887,11 @@ inline const std::string& Field::default_value() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Field.default_value)
   // @@protoc_insertion_point(field_get:google.protobuf.Field.default_value)
   return _internal_default_value();
   return _internal_default_value();
 }
 }
-inline void Field::set_default_value(const std::string& value) {
-  _internal_set_default_value(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Field::set_default_value(ArgT0&& arg0, ArgT... args) {
+ 
+ default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -2013,25 +1905,6 @@ inline void Field::_internal_set_default_value(const std::string& value) {
   
   
   default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Field::set_default_value(std::string&& value) {
-  
-  default_value_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Field.default_value)
-}
-inline void Field::set_default_value(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Field.default_value)
-}
-inline void Field::set_default_value(const char* value,
-    size_t size) {
-  
-  default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.default_value)
-}
 inline std::string* Field::_internal_mutable_default_value() {
 inline std::string* Field::_internal_mutable_default_value() {
   
   
   return default_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return default_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -2063,8 +1936,11 @@ inline const std::string& Enum::name() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Enum.name)
   // @@protoc_insertion_point(field_get:google.protobuf.Enum.name)
   return _internal_name();
   return _internal_name();
 }
 }
-inline void Enum::set_name(const std::string& value) {
-  _internal_set_name(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Enum::set_name(ArgT0&& arg0, ArgT... args) {
+ 
+ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -2078,25 +1954,6 @@ inline void Enum::_internal_set_name(const std::string& value) {
   
   
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Enum::set_name(std::string&& value) {
-  
-  name_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Enum.name)
-}
-inline void Enum::set_name(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Enum.name)
-}
-inline void Enum::set_name(const char* value,
-    size_t size) {
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Enum.name)
-}
 inline std::string* Enum::_internal_mutable_name() {
 inline std::string* Enum::_internal_mutable_name() {
   
   
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -2303,8 +2160,11 @@ inline const std::string& EnumValue::name() const {
   // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name)
   // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name)
   return _internal_name();
   return _internal_name();
 }
 }
-inline void EnumValue::set_name(const std::string& value) {
-  _internal_set_name(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void EnumValue::set_name(ArgT0&& arg0, ArgT... args) {
+ 
+ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -2318,25 +2178,6 @@ inline void EnumValue::_internal_set_name(const std::string& value) {
   
   
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void EnumValue::set_name(std::string&& value) {
-  
-  name_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumValue.name)
-}
-inline void EnumValue::set_name(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.EnumValue.name)
-}
-inline void EnumValue::set_name(const char* value,
-    size_t size) {
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValue.name)
-}
 inline std::string* EnumValue::_internal_mutable_name() {
 inline std::string* EnumValue::_internal_mutable_name() {
   
   
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
@@ -2427,8 +2268,11 @@ inline const std::string& Option::name() const {
   // @@protoc_insertion_point(field_get:google.protobuf.Option.name)
   // @@protoc_insertion_point(field_get:google.protobuf.Option.name)
   return _internal_name();
   return _internal_name();
 }
 }
-inline void Option::set_name(const std::string& value) {
-  _internal_set_name(value);
+template <typename ArgT0, typename... ArgT>
+PROTOBUF_ALWAYS_INLINE
+inline void Option::set_name(ArgT0&& arg0, ArgT... args) {
+ 
+ name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArena());
   // @@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() {
@@ -2442,25 +2286,6 @@ inline void Option::_internal_set_name(const std::string& value) {
   
   
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
   name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena());
 }
 }
-inline void Option::set_name(std::string&& value) {
-  
-  name_.Set(
-    ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena());
-  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Option.name)
-}
-inline void Option::set_name(const char* value) {
-  GOOGLE_DCHECK(value != nullptr);
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena());
-  // @@protoc_insertion_point(field_set_char:google.protobuf.Option.name)
-}
-inline void Option::set_name(const char* value,
-    size_t size) {
-  
-  name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(
-      reinterpret_cast<const char*>(value), size), GetArena());
-  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Option.name)
-}
 inline std::string* Option::_internal_mutable_name() {
 inline std::string* Option::_internal_mutable_name() {
   
   
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());
   return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena());

+ 5 - 0
src/google/protobuf/unittest_lite.proto

@@ -494,3 +494,8 @@ message DupEnum {
     BAR2 = 2;
     BAR2 = 2;
   }
   }
 }
 }
+
+message RecursiveMessage {
+  optional RecursiveMessage recurse = 1;
+  optional bytes payload = 2;
+}

+ 12 - 0
src/google/protobuf/unittest_proto3_optional.proto

@@ -32,6 +32,8 @@ syntax = "proto3";
 
 
 package protobuf_unittest;
 package protobuf_unittest;
 
 
+import "google/protobuf/descriptor.proto";
+
 option java_multiple_files = true;
 option java_multiple_files = true;
 option java_package = "com.google.protobuf.testing.proto";
 option java_package = "com.google.protobuf.testing.proto";
 
 
@@ -86,3 +88,13 @@ message TestProto3OptionalMessage {
   NestedMessage nested_message = 1;
   NestedMessage nested_message = 1;
   optional NestedMessage optional_nested_message = 2;
   optional NestedMessage optional_nested_message = 2;
 }
 }
+
+message Proto3OptionalExtensions {
+  option (protobuf_unittest.Proto3OptionalExtensions.ext_no_optional) = 8;
+  option (protobuf_unittest.Proto3OptionalExtensions.ext_with_optional) = 16;
+
+  extend google.protobuf.MessageOptions {
+    int32 ext_no_optional = 355886728;
+    optional int32 ext_with_optional = 355886729;
+  }
+}

+ 7 - 5
src/google/protobuf/util/internal/constants.h

@@ -31,6 +31,8 @@
 #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__
 #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__
 #define GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__
 #define GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__
 
 
+#include <cstdint>
+
 #include <google/protobuf/stubs/common.h>
 #include <google/protobuf/stubs/common.h>
 
 
 // This file contains constants used by //net/proto2/util/converter.
 // This file contains constants used by //net/proto2/util/converter.
@@ -50,19 +52,19 @@ const char kRfc3339TimeFormat[] = "%E4Y-%m-%dT%H:%M:%S";
 const char kRfc3339TimeFormatNoPadding[] = "%Y-%m-%dT%H:%M:%S";
 const char kRfc3339TimeFormatNoPadding[] = "%Y-%m-%dT%H:%M:%S";
 
 
 // Minimum seconds allowed in a google.protobuf.Timestamp value.
 // Minimum seconds allowed in a google.protobuf.Timestamp value.
-const int64 kTimestampMinSeconds = -62135596800LL;
+const int64_t kTimestampMinSeconds = -62135596800LL;
 
 
 // Maximum seconds allowed in a google.protobuf.Timestamp value.
 // Maximum seconds allowed in a google.protobuf.Timestamp value.
-const int64 kTimestampMaxSeconds = 253402300799LL;
+const int64_t kTimestampMaxSeconds = 253402300799LL;
 
 
 // Minimum seconds allowed in a google.protobuf.Duration value.
 // Minimum seconds allowed in a google.protobuf.Duration value.
-const int64 kDurationMinSeconds = -315576000000LL;
+const int64_t kDurationMinSeconds = -315576000000LL;
 
 
 // Maximum seconds allowed in a google.protobuf.Duration value.
 // Maximum seconds allowed in a google.protobuf.Duration value.
-const int64 kDurationMaxSeconds = 315576000000LL;
+const int64_t kDurationMaxSeconds = 315576000000LL;
 
 
 // Nano seconds in a second.
 // Nano seconds in a second.
-const int32 kNanosPerSecond = 1000000000;
+const int32_t kNanosPerSecond = 1000000000;
 
 
 // Type url representing NULL values in google.protobuf.Struct type.
 // Type url representing NULL values in google.protobuf.Struct type.
 const char kStructNullValueTypeUrl[] =
 const char kStructNullValueTypeUrl[] =

+ 28 - 25
src/google/protobuf/util/internal/datapiece.cc

@@ -31,6 +31,7 @@
 #include <google/protobuf/util/internal/datapiece.h>
 #include <google/protobuf/util/internal/datapiece.h>
 
 
 #include <cmath>
 #include <cmath>
+#include <cstdint>
 #include <limits>
 #include <limits>
 
 
 #include <google/protobuf/struct.pb.h>
 #include <google/protobuf/struct.pb.h>
@@ -114,54 +115,56 @@ util::StatusOr<float> DoubleToFloat(double before) {
 
 
 }  // namespace
 }  // namespace
 
 
-util::StatusOr<int32> DataPiece::ToInt32() const {
-  if (type_ == TYPE_STRING) return StringToNumber<int32>(safe_strto32);
+util::StatusOr<int32_t> DataPiece::ToInt32() const {
+  if (type_ == TYPE_STRING)
+    return StringToNumber<int32_t>(safe_strto32);
 
 
   if (type_ == TYPE_DOUBLE)
   if (type_ == TYPE_DOUBLE)
-    return FloatingPointToIntConvertAndCheck<int32, double>(double_);
+    return FloatingPointToIntConvertAndCheck<int32_t, double>(double_);
 
 
   if (type_ == TYPE_FLOAT)
   if (type_ == TYPE_FLOAT)
-    return FloatingPointToIntConvertAndCheck<int32, float>(float_);
+    return FloatingPointToIntConvertAndCheck<int32_t, float>(float_);
 
 
-  return GenericConvert<int32>();
+  return GenericConvert<int32_t>();
 }
 }
 
 
-util::StatusOr<uint32> DataPiece::ToUint32() const {
+util::StatusOr<uint32_t> DataPiece::ToUint32() const {
   if (type_ == TYPE_STRING)
   if (type_ == TYPE_STRING)
-    return StringToNumber<uint32>(safe_strtou32);
+    return StringToNumber<uint32_t>(safe_strtou32);
 
 
   if (type_ == TYPE_DOUBLE)
   if (type_ == TYPE_DOUBLE)
-    return FloatingPointToIntConvertAndCheck<uint32, double>(double_);
+    return FloatingPointToIntConvertAndCheck<uint32_t, double>(double_);
 
 
   if (type_ == TYPE_FLOAT)
   if (type_ == TYPE_FLOAT)
-    return FloatingPointToIntConvertAndCheck<uint32, float>(float_);
+    return FloatingPointToIntConvertAndCheck<uint32_t, float>(float_);
 
 
-  return GenericConvert<uint32>();
+  return GenericConvert<uint32_t>();
 }
 }
 
 
-util::StatusOr<int64> DataPiece::ToInt64() const {
-  if (type_ == TYPE_STRING) return StringToNumber<int64>(safe_strto64);
+util::StatusOr<int64_t> DataPiece::ToInt64() const {
+  if (type_ == TYPE_STRING)
+    return StringToNumber<int64_t>(safe_strto64);
 
 
   if (type_ == TYPE_DOUBLE)
   if (type_ == TYPE_DOUBLE)
-    return FloatingPointToIntConvertAndCheck<int64, double>(double_);
+    return FloatingPointToIntConvertAndCheck<int64_t, double>(double_);
 
 
   if (type_ == TYPE_FLOAT)
   if (type_ == TYPE_FLOAT)
-    return FloatingPointToIntConvertAndCheck<int64, float>(float_);
+    return FloatingPointToIntConvertAndCheck<int64_t, float>(float_);
 
 
-  return GenericConvert<int64>();
+  return GenericConvert<int64_t>();
 }
 }
 
 
-util::StatusOr<uint64> DataPiece::ToUint64() const {
+util::StatusOr<uint64_t> DataPiece::ToUint64() const {
   if (type_ == TYPE_STRING)
   if (type_ == TYPE_STRING)
-    return StringToNumber<uint64>(safe_strtou64);
+    return StringToNumber<uint64_t>(safe_strtou64);
 
 
   if (type_ == TYPE_DOUBLE)
   if (type_ == TYPE_DOUBLE)
-    return FloatingPointToIntConvertAndCheck<uint64, double>(double_);
+    return FloatingPointToIntConvertAndCheck<uint64_t, double>(double_);
 
 
   if (type_ == TYPE_FLOAT)
   if (type_ == TYPE_FLOAT)
-    return FloatingPointToIntConvertAndCheck<uint64, float>(float_);
+    return FloatingPointToIntConvertAndCheck<uint64_t, float>(float_);
 
 
-  return GenericConvert<uint64>();
+  return GenericConvert<uint64_t>();
 }
 }
 
 
 util::StatusOr<double> DataPiece::ToDouble() const {
 util::StatusOr<double> DataPiece::ToDouble() const {
@@ -286,7 +289,7 @@ util::StatusOr<int> DataPiece::ToEnum(const google::protobuf::Enum* enum_type,
     if (value != nullptr) return value->number();
     if (value != nullptr) return value->number();
 
 
     // Check if int version of enum is sent as string.
     // Check if int version of enum is sent as string.
-    util::StatusOr<int32> int_value = ToInt32();
+    util::StatusOr<int32_t> int_value = ToInt32();
     if (int_value.ok()) {
     if (int_value.ok()) {
       if (const google::protobuf::EnumValue* enum_value =
       if (const google::protobuf::EnumValue* enum_value =
               FindEnumValueByNumberOrNull(enum_type, int_value.value())) {
               FindEnumValueByNumberOrNull(enum_type, int_value.value())) {
@@ -334,13 +337,13 @@ template <typename To>
 util::StatusOr<To> DataPiece::GenericConvert() const {
 util::StatusOr<To> DataPiece::GenericConvert() const {
   switch (type_) {
   switch (type_) {
     case TYPE_INT32:
     case TYPE_INT32:
-      return NumberConvertAndCheck<To, int32>(i32_);
+      return NumberConvertAndCheck<To, int32_t>(i32_);
     case TYPE_INT64:
     case TYPE_INT64:
-      return NumberConvertAndCheck<To, int64>(i64_);
+      return NumberConvertAndCheck<To, int64_t>(i64_);
     case TYPE_UINT32:
     case TYPE_UINT32:
-      return NumberConvertAndCheck<To, uint32>(u32_);
+      return NumberConvertAndCheck<To, uint32_t>(u32_);
     case TYPE_UINT64:
     case TYPE_UINT64:
-      return NumberConvertAndCheck<To, uint64>(u64_);
+      return NumberConvertAndCheck<To, uint64_t>(u64_);
     case TYPE_DOUBLE:
     case TYPE_DOUBLE:
       return NumberConvertAndCheck<To, double>(double_);
       return NumberConvertAndCheck<To, double>(double_);
     case TYPE_FLOAT:
     case TYPE_FLOAT:

+ 17 - 18
src/google/protobuf/util/internal/datapiece.h

@@ -31,6 +31,7 @@
 #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__
 #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__
 #define GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__
 #define GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__
 
 
+#include <cstdint>
 #include <string>
 #include <string>
 
 
 #include <google/protobuf/stubs/common.h>
 #include <google/protobuf/stubs/common.h>
@@ -75,13 +76,13 @@ class PROTOBUF_EXPORT DataPiece {
   };
   };
 
 
   // Constructors and Destructor
   // Constructors and Destructor
-  explicit DataPiece(const int32 value)
+  explicit DataPiece(const int32_t value)
       : type_(TYPE_INT32), i32_(value), use_strict_base64_decoding_(false) {}
       : type_(TYPE_INT32), i32_(value), use_strict_base64_decoding_(false) {}
-  explicit DataPiece(const int64 value)
+  explicit DataPiece(const int64_t value)
       : type_(TYPE_INT64), i64_(value), use_strict_base64_decoding_(false) {}
       : type_(TYPE_INT64), i64_(value), use_strict_base64_decoding_(false) {}
-  explicit DataPiece(const uint32 value)
+  explicit DataPiece(const uint32_t value)
       : type_(TYPE_UINT32), u32_(value), use_strict_base64_decoding_(false) {}
       : type_(TYPE_UINT32), u32_(value), use_strict_base64_decoding_(false) {}
-  explicit DataPiece(const uint64 value)
+  explicit DataPiece(const uint64_t value)
       : type_(TYPE_UINT64), u64_(value), use_strict_base64_decoding_(false) {}
       : type_(TYPE_UINT64), u64_(value), use_strict_base64_decoding_(false) {}
   explicit DataPiece(const double value)
   explicit DataPiece(const double value)
       : type_(TYPE_DOUBLE),
       : type_(TYPE_DOUBLE),
@@ -93,12 +94,12 @@ class PROTOBUF_EXPORT DataPiece {
       : type_(TYPE_BOOL), bool_(value), use_strict_base64_decoding_(false) {}
       : type_(TYPE_BOOL), bool_(value), use_strict_base64_decoding_(false) {}
   DataPiece(StringPiece value, bool use_strict_base64_decoding)
   DataPiece(StringPiece value, bool use_strict_base64_decoding)
       : type_(TYPE_STRING),
       : type_(TYPE_STRING),
-        str_(StringPiecePod::CreateFromStringPiece(value)),
+        str_(value),
         use_strict_base64_decoding_(use_strict_base64_decoding) {}
         use_strict_base64_decoding_(use_strict_base64_decoding) {}
   // Constructor for bytes. The second parameter is not used.
   // Constructor for bytes. The second parameter is not used.
   DataPiece(StringPiece value, bool dummy, bool use_strict_base64_decoding)
   DataPiece(StringPiece value, bool dummy, bool use_strict_base64_decoding)
       : type_(TYPE_BYTES),
       : type_(TYPE_BYTES),
-        str_(StringPiecePod::CreateFromStringPiece(value)),
+        str_(value),
         use_strict_base64_decoding_(use_strict_base64_decoding) {}
         use_strict_base64_decoding_(use_strict_base64_decoding) {}
 
 
   DataPiece(const DataPiece& r) : type_(r.type_) { InternalCopy(r); }
   DataPiece(const DataPiece& r) : type_(r.type_) { InternalCopy(r); }
@@ -125,16 +126,16 @@ class PROTOBUF_EXPORT DataPiece {
 
 
 
 
   // Parses, casts or converts the value stored in the DataPiece into an int32.
   // Parses, casts or converts the value stored in the DataPiece into an int32.
-  util::StatusOr<int32> ToInt32() const;
+  util::StatusOr<int32_t> ToInt32() const;
 
 
   // Parses, casts or converts the value stored in the DataPiece into a uint32.
   // Parses, casts or converts the value stored in the DataPiece into a uint32.
-  util::StatusOr<uint32> ToUint32() const;
+  util::StatusOr<uint32_t> ToUint32() const;
 
 
   // Parses, casts or converts the value stored in the DataPiece into an int64.
   // Parses, casts or converts the value stored in the DataPiece into an int64.
-  util::StatusOr<int64> ToInt64() const;
+  util::StatusOr<int64_t> ToInt64() const;
 
 
   // Parses, casts or converts the value stored in the DataPiece into a uint64.
   // Parses, casts or converts the value stored in the DataPiece into a uint64.
-  util::StatusOr<uint64> ToUint64() const;
+  util::StatusOr<uint64_t> ToUint64() const;
 
 
   // Parses, casts or converts the value stored in the DataPiece into a double.
   // Parses, casts or converts the value stored in the DataPiece into a double.
   util::StatusOr<double> ToDouble() const;
   util::StatusOr<double> ToDouble() const;
@@ -161,7 +162,7 @@ class PROTOBUF_EXPORT DataPiece {
   DataPiece();
   DataPiece();
 
 
   // Helper to create NULL or ENUM types.
   // Helper to create NULL or ENUM types.
-  DataPiece(Type type, int32 val)
+  DataPiece(Type type, int32_t val)
       : type_(type), i32_(val), use_strict_base64_decoding_(false) {}
       : type_(type), i32_(val), use_strict_base64_decoding_(false) {}
 
 
   // Same as the ToEnum() method above but with additional flag to ignore
   // Same as the ToEnum() method above but with additional flag to ignore
@@ -191,18 +192,16 @@ class PROTOBUF_EXPORT DataPiece {
   // Data type for this piece of data.
   // Data type for this piece of data.
   Type type_;
   Type type_;
 
 
-  typedef ::google::protobuf::internal::StringPiecePod StringPiecePod;
-
   // Stored piece of data.
   // Stored piece of data.
   union {
   union {
-    int32 i32_;
-    int64 i64_;
-    uint32 u32_;
-    uint64 u64_;
+    int32_t i32_;
+    int64_t i64_;
+    uint32_t u32_;
+    uint64_t u64_;
     double double_;
     double double_;
     float float_;
     float float_;
     bool bool_;
     bool bool_;
-    StringPiecePod str_;
+    StringPiece str_;
   };
   };
 
 
   // Uses a stricter version of base64 decoding for byte fields.
   // Uses a stricter version of base64 decoding for byte fields.

+ 15 - 12
src/google/protobuf/util/internal/default_value_objectwriter.cc

@@ -30,6 +30,7 @@
 
 
 #include <google/protobuf/util/internal/default_value_objectwriter.h>
 #include <google/protobuf/util/internal/default_value_objectwriter.h>
 
 
+#include <cstdint>
 #include <unordered_map>
 #include <unordered_map>
 
 
 #include <google/protobuf/util/internal/constants.h>
 #include <google/protobuf/util/internal/constants.h>
@@ -85,7 +86,7 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::RenderBool(
 }
 }
 
 
 DefaultValueObjectWriter* DefaultValueObjectWriter::RenderInt32(
 DefaultValueObjectWriter* DefaultValueObjectWriter::RenderInt32(
-    StringPiece name, int32 value) {
+    StringPiece name, int32_t value) {
   if (current_ == nullptr) {
   if (current_ == nullptr) {
     ow_->RenderInt32(name, value);
     ow_->RenderInt32(name, value);
   } else {
   } else {
@@ -95,7 +96,7 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::RenderInt32(
 }
 }
 
 
 DefaultValueObjectWriter* DefaultValueObjectWriter::RenderUint32(
 DefaultValueObjectWriter* DefaultValueObjectWriter::RenderUint32(
-    StringPiece name, uint32 value) {
+    StringPiece name, uint32_t value) {
   if (current_ == nullptr) {
   if (current_ == nullptr) {
     ow_->RenderUint32(name, value);
     ow_->RenderUint32(name, value);
   } else {
   } else {
@@ -105,7 +106,7 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::RenderUint32(
 }
 }
 
 
 DefaultValueObjectWriter* DefaultValueObjectWriter::RenderInt64(
 DefaultValueObjectWriter* DefaultValueObjectWriter::RenderInt64(
-    StringPiece name, int64 value) {
+    StringPiece name, int64_t value) {
   if (current_ == nullptr) {
   if (current_ == nullptr) {
     ow_->RenderInt64(name, value);
     ow_->RenderInt64(name, value);
   } else {
   } else {
@@ -115,7 +116,7 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::RenderInt64(
 }
 }
 
 
 DefaultValueObjectWriter* DefaultValueObjectWriter::RenderUint64(
 DefaultValueObjectWriter* DefaultValueObjectWriter::RenderUint64(
-    StringPiece name, uint64 value) {
+    StringPiece name, uint64_t value) {
   if (current_ == nullptr) {
   if (current_ == nullptr) {
     ow_->RenderUint64(name, value);
     ow_->RenderUint64(name, value);
   } else {
   } else {
@@ -445,19 +446,20 @@ DataPiece DefaultValueObjectWriter::CreateDefaultDataPieceForField(
     case google::protobuf::Field::TYPE_INT64:
     case google::protobuf::Field::TYPE_INT64:
     case google::protobuf::Field::TYPE_SINT64:
     case google::protobuf::Field::TYPE_SINT64:
     case google::protobuf::Field::TYPE_SFIXED64: {
     case google::protobuf::Field::TYPE_SFIXED64: {
-      return DataPiece(ConvertTo<int64>(
-          field.default_value(), &DataPiece::ToInt64, static_cast<int64>(0)));
+      return DataPiece(ConvertTo<int64_t>(
+          field.default_value(), &DataPiece::ToInt64, static_cast<int64_t>(0)));
     }
     }
     case google::protobuf::Field::TYPE_UINT64:
     case google::protobuf::Field::TYPE_UINT64:
     case google::protobuf::Field::TYPE_FIXED64: {
     case google::protobuf::Field::TYPE_FIXED64: {
-      return DataPiece(ConvertTo<uint64>(
-          field.default_value(), &DataPiece::ToUint64, static_cast<uint64>(0)));
+      return DataPiece(ConvertTo<uint64_t>(field.default_value(),
+                                           &DataPiece::ToUint64,
+                                           static_cast<uint64_t>(0)));
     }
     }
     case google::protobuf::Field::TYPE_INT32:
     case google::protobuf::Field::TYPE_INT32:
     case google::protobuf::Field::TYPE_SINT32:
     case google::protobuf::Field::TYPE_SINT32:
     case google::protobuf::Field::TYPE_SFIXED32: {
     case google::protobuf::Field::TYPE_SFIXED32: {
-      return DataPiece(ConvertTo<int32>(
-          field.default_value(), &DataPiece::ToInt32, static_cast<int32>(0)));
+      return DataPiece(ConvertTo<int32_t>(
+          field.default_value(), &DataPiece::ToInt32, static_cast<int32_t>(0)));
     }
     }
     case google::protobuf::Field::TYPE_BOOL: {
     case google::protobuf::Field::TYPE_BOOL: {
       return DataPiece(
       return DataPiece(
@@ -471,8 +473,9 @@ DataPiece DefaultValueObjectWriter::CreateDefaultDataPieceForField(
     }
     }
     case google::protobuf::Field::TYPE_UINT32:
     case google::protobuf::Field::TYPE_UINT32:
     case google::protobuf::Field::TYPE_FIXED32: {
     case google::protobuf::Field::TYPE_FIXED32: {
-      return DataPiece(ConvertTo<uint32>(
-          field.default_value(), &DataPiece::ToUint32, static_cast<uint32>(0)));
+      return DataPiece(ConvertTo<uint32_t>(field.default_value(),
+                                           &DataPiece::ToUint32,
+                                           static_cast<uint32_t>(0)));
     }
     }
     case google::protobuf::Field::TYPE_ENUM: {
     case google::protobuf::Field::TYPE_ENUM: {
       return FindEnumDefault(field, typeinfo, use_ints_for_enums);
       return FindEnumDefault(field, typeinfo, use_ints_for_enums);

Some files were not shown because too many files changed in this diff