diff --git a/CHANGES.txt b/CHANGES.txt index 0ebbe6158d..12360dadc6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,9 @@ + +Unreleased version + * Handle reflection for message splitting. + * make metadata fields lazy. + * Extend visibility of plugin library to upb + 2022-05-27 version 21.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby) C++ diff --git a/java/core/src/main/java/com/google/protobuf/ByteString.java b/java/core/src/main/java/com/google/protobuf/ByteString.java index 480f85fd6d..3cf98162fe 100644 --- a/java/core/src/main/java/com/google/protobuf/ByteString.java +++ b/java/core/src/main/java/com/google/protobuf/ByteString.java @@ -385,8 +385,7 @@ public abstract class ByteString implements Iterable, Serializable { // String -> ByteString /** - * Returns a {@code ByteString} from a hexadecimal String. Alternative CharSequences should use - * {@link ByteStrings#decode(CharSequence, BaseEncoding)} + * Returns a {@code ByteString} from a hexadecimal String. * * @param hexString String of hexadecimal digits to create {@code ByteString} from. * @throws NumberFormatException if the hexString does not contain a parsable hex String. @@ -1130,13 +1129,6 @@ public abstract class ByteString implements Iterable, Serializable { return ByteString.copyFrom(flushedBuffers); } - /** Implement java.util.Arrays.copyOf() for jdk 1.5. */ - private byte[] copyArray(byte[] buffer, int length) { - byte[] result = new byte[length]; - System.arraycopy(buffer, 0, result, 0, Math.min(buffer.length, length)); - return result; - } - /** * Writes the complete contents of this byte array output stream to the specified output stream * argument. @@ -1159,7 +1151,7 @@ public abstract class ByteString implements Iterable, Serializable { byteString.writeTo(out); } - out.write(copyArray(cachedBuffer, cachedBufferPos)); + out.write(Arrays.copyOf(cachedBuffer, cachedBufferPos)); } /** @@ -1210,7 +1202,7 @@ public abstract class ByteString implements Iterable, Serializable { private void flushLastBuffer() { if (bufferPos < buffer.length) { if (bufferPos > 0) { - byte[] bufferCopy = copyArray(buffer, bufferPos); + byte[] bufferCopy = Arrays.copyOf(buffer, bufferPos); flushedBuffers.add(new LiteralByteString(bufferCopy)); } // We reuse this buffer for further writes. diff --git a/java/core/src/test/java/com/google/protobuf/SmallSortedMapTest.java b/java/core/src/test/java/com/google/protobuf/SmallSortedMapTest.java index fdeccc2f44..bb73a6b36a 100644 --- a/java/core/src/test/java/com/google/protobuf/SmallSortedMapTest.java +++ b/java/core/src/test/java/com/google/protobuf/SmallSortedMapTest.java @@ -34,6 +34,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static java.lang.Math.min; +import java.util.AbstractMap; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -48,52 +49,6 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class SmallSortedMapTest { - // java.util.AbstractMap.SimpleEntry is private in JDK 1.5. We re-implement it - // here for JDK 1.5 users. - private static class SimpleEntry implements Map.Entry { - private final K key; - private V value; - - SimpleEntry(K key, V value) { - this.key = key; - this.value = value; - } - - @Override - public K getKey() { - return key; - } - - @Override - public V getValue() { - return value; - } - - @Override - public V setValue(V value) { - V oldValue = this.value; - this.value = value; - return oldValue; - } - - private static boolean eq(Object o1, Object o2) { - return o1 == null ? o2 == null : o1.equals(o2); - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof Map.Entry)) { - return false; - } - Map.Entry e = (Map.Entry) o; - return eq(key, e.getKey()) && eq(value, e.getValue()); - } - - @Override - public int hashCode() { - return ((key == null) ? 0 : key.hashCode()) ^ ((value == null) ? 0 : value.hashCode()); - } - } @Test public void testPutAndGetArrayEntriesOnly() { @@ -242,8 +197,8 @@ public class SmallSortedMapTest { } Set> entrySet = map.entrySet(); for (int i = 0; i < 6; i++) { - assertThat(entrySet).contains(new SimpleEntry(i, i + 1)); - assertThat(entrySet).doesNotContain(new SimpleEntry(i, i)); + assertThat(entrySet).contains(new AbstractMap.SimpleEntry(i, i + 1)); + assertThat(entrySet).doesNotContain(new AbstractMap.SimpleEntry(i, i)); } } @@ -252,7 +207,7 @@ public class SmallSortedMapTest { SmallSortedMap map = SmallSortedMap.newInstanceForTest(3); Set> entrySet = map.entrySet(); for (int i = 0; i < 6; i++) { - Map.Entry entry = new SimpleEntry<>(i, i + 1); + Map.Entry entry = new AbstractMap.SimpleEntry<>(i, i + 1); assertThat(entrySet.add(entry)).isTrue(); assertThat(entrySet.add(entry)).isFalse(); } @@ -272,7 +227,7 @@ public class SmallSortedMapTest { assertThat(map.put(i, i + 1)).isNull(); } for (int i = 0; i < 6; i++) { - Map.Entry entry = new SimpleEntry<>(i, i + 1); + Map.Entry entry = new AbstractMap.SimpleEntry<>(i, i + 1); assertThat(entrySet.remove(entry)).isTrue(); assertThat(entrySet.remove(entry)).isFalse(); } diff --git a/python/google/protobuf/pyext/extension_dict.cc b/python/google/protobuf/pyext/extension_dict.cc index 66703da898..5e61dbf6b3 100644 --- a/python/google/protobuf/pyext/extension_dict.cc +++ b/python/google/protobuf/pyext/extension_dict.cc @@ -125,8 +125,9 @@ static void DeallocExtensionIterator(PyObject* _self) { ExtensionIterator* self = reinterpret_cast(_self); self->fields.clear(); Py_XDECREF(self->extension_dict); + freefunc tp_free = Py_TYPE(_self)->tp_free; self->~ExtensionIterator(); - Py_TYPE(_self)->tp_free(_self); + (*tp_free)(_self); } PyObject* subscript(ExtensionDict* self, PyObject* key) { diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index c02f9eb7f8..379991e24a 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -52,6 +52,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fany_2eproto::offsets[] PROTOBUF_S ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, _impl_.type_url_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, _impl_.value_), }; diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index 24b60497cd..24e118eebc 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -85,6 +85,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fapi_2eproto::offsets[] PROTOBUF_S ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.methods_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.options_), @@ -98,6 +100,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fapi_2eproto::offsets[] PROTOBUF_S ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.request_type_url_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.request_streaming_), @@ -111,13 +115,15 @@ const uint32_t TableStruct_google_2fprotobuf_2fapi_2eproto::offsets[] PROTOBUF_S ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, _impl_.root_), }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Api)}, - { 13, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Method)}, - { 26, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Mixin)}, + { 15, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Method)}, + { 30, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Mixin)}, }; static const ::_pb::Message* const file_default_instances[] = { diff --git a/src/google/protobuf/arenastring.cc b/src/google/protobuf/arenastring.cc index d886ddad66..d6bef1b273 100644 --- a/src/google/protobuf/arenastring.cc +++ b/src/google/protobuf/arenastring.cc @@ -86,7 +86,7 @@ const std::string& LazyString::Init() const { namespace { -#if defined(NDEBUG) || !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL +#if defined(NDEBUG) || !defined(GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL) class ScopedCheckPtrInvariants { public: @@ -102,7 +102,7 @@ inline TaggedStringPtr CreateString(ConstStringParam value) { return res; } -#if !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL +#ifndef GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL // Creates an arena allocated std::string value. TaggedStringPtr CreateArenaString(Arena& arena, ConstStringParam s) { @@ -123,7 +123,20 @@ void ArenaStringPtr::Set(ConstStringParam value, Arena* arena) { tagged_ptr_ = arena != nullptr ? CreateArenaString(*arena, value) : CreateString(value); } else { +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (arena == nullptr) { + GOOGLE_DCHECK(tagged_ptr_.IsAllocated()); + auto* old = tagged_ptr_.Get(); + tagged_ptr_ = CreateString(value); + delete old; + } else { + auto* old = UnsafeMutablePointer(); + tagged_ptr_ = CreateArenaString(*arena, value); + old->assign("garbagedata"); + } +#else // PROTOBUF_FORCE_COPY_DEFAULT_STRING UnsafeMutablePointer()->assign(value.data(), value.length()); +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } } diff --git a/src/google/protobuf/compiler/cpp/field.h b/src/google/protobuf/compiler/cpp/field.h index dd2a51a2fe..3fcbda371c 100644 --- a/src/google/protobuf/compiler/cpp/field.h +++ b/src/google/protobuf/compiler/cpp/field.h @@ -150,9 +150,6 @@ class FieldGenerator { // method, invoked by each of the generated constructors. virtual void GenerateConstructorCode(io::Printer* printer) const = 0; - // Generate initialization code for private members in the cold struct. - virtual void GenerateCreateSplitMessageCode(io::Printer* printer) const {} - // Generate any code that needs to go in the class's SharedDtor() method, // invoked by the destructor. // Most field types don't need this, so the default implementation is empty. diff --git a/src/google/protobuf/compiler/cpp/message.cc b/src/google/protobuf/compiler/cpp/message.cc index d3190fabc3..f4eb744e2f 100644 --- a/src/google/protobuf/compiler/cpp/message.cc +++ b/src/google/protobuf/compiler/cpp/message.cc @@ -1986,9 +1986,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { } if (ShouldSplit(descriptor_, options_)) { - format( - "static Impl_::Split* CreateSplitMessage(" - "::$proto_ns$::Arena* arena);\n"); format("friend struct $1$;\n", DefaultInstanceType(descriptor_, options_, /*split=*/true)); } @@ -2036,7 +2033,6 @@ void MessageGenerator::GenerateSchema(io::Printer* printer, int offset, GOOGLE_DCHECK(!IsMapEntryMessage(descriptor_)); inlined_string_indices_offset = has_offset + has_bit_indices_.size(); } - format("{ $1$, $2$, $3$, sizeof($classtype$)},\n", offset, has_offset, inlined_string_indices_offset); } @@ -2199,9 +2195,13 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { format( "void $classname$::PrepareSplitMessageForWrite() {\n" " if (IsSplitMessageDefault()) {\n" - " $split$ = CreateSplitMessage(GetArenaForAllocation());\n" + " void* chunk = " + "::PROTOBUF_NAMESPACE_ID::internal::CreateSplitMessageGeneric(" + "GetArenaForAllocation(), &$1$, sizeof(Impl_::Split));\n" + " $split$ = reinterpret_cast(chunk);\n" " }\n" - "}\n"); + "}\n", + DefaultInstanceName(descriptor_, options_, /*split=*/true)); } GenerateVerify(printer); @@ -2276,7 +2276,16 @@ std::pair MessageGenerator::GenerateOffsets( } else { format("~0u, // no _inlined_string_donated_\n"); } - const int kNumGenericOffsets = 6; // the number of fixed offsets above + if (ShouldSplit(descriptor_, options_)) { + format( + "PROTOBUF_FIELD_OFFSET($classtype$, $split$),\n" + "sizeof($classtype$::Impl_::Split),\n"); + } else { + format( + "~0u, // no _split_\n" + "~0u, // no sizeof(Split)\n"); + } + const int kNumGenericOffsets = 8; // the number of fixed offsets above const size_t offsets = kNumGenericOffsets + descriptor_->field_count() + descriptor_->real_oneof_decl_count(); size_t entries = offsets; @@ -2304,12 +2313,17 @@ std::pair MessageGenerator::GenerateOffsets( // offset of the field, so that the information is available when // reflectively accessing the field at run time. // - // Embed whether the field is eagerly verified lazy or inlined string to the - // LSB of the offset. + // We embed whether the field is cold to the MSB of the offset, and whether + // the field is eagerly verified lazy or inlined string to the LSB of the + // offset. + + if (ShouldSplit(field, options_)) { + format(" | ::_pbi::kSplitFieldOffsetMask /*split*/"); + } if (IsEagerlyVerifiedLazy(field, options_, scc_analyzer_)) { - format(" | 0x1u // eagerly verified lazy\n"); + format(" | 0x1u /*eagerly verified lazy*/"); } else if (IsStringInlined(field, options_)) { - format(" | 0x1u // inlined\n"); + format(" | 0x1u /*inlined*/"); } format(",\n"); } @@ -2470,45 +2484,6 @@ void MessageGenerator::GenerateSharedConstructorCode(io::Printer* printer) { format("}\n\n"); } -void MessageGenerator::GenerateCreateSplitMessage(io::Printer* printer) { - Formatter format(printer, variables_); - format( - "$classname$::Impl_::Split* " - "$classname$::CreateSplitMessage(::$proto_ns$::Arena* arena) {\n"); - format.Indent(); - const char* field_sep = " "; - const auto put_sep = [&] { - format("\n$1$ ", field_sep); - field_sep = ","; - }; - format( - "const size_t size = sizeof(Impl_::Split);\n" - "void* chunk = (arena == nullptr) ?\n" - " ::operator new(size) :\n" - " arena->AllocateAligned(size, alignof(Impl_::Split));\n" - "Impl_::Split* ptr = reinterpret_cast(chunk);\n" - "new (ptr) Impl_::Split{"); - format.Indent(); - for (const FieldDescriptor* field : optimized_order_) { - GOOGLE_DCHECK(!IsFieldStripped(field, options_)); - if (ShouldSplit(field, options_)) { - put_sep(); - field_generators_.get(field).GenerateAggregateInitializer(printer); - } - } - format.Outdent(); - format("};\n"); - for (const FieldDescriptor* field : optimized_order_) { - GOOGLE_DCHECK(!IsFieldStripped(field, options_)); - if (ShouldSplit(field, options_)) { - field_generators_.get(field).GenerateCreateSplitMessageCode(printer); - } - } - format("return ptr;\n"); - format.Outdent(); - format("}\n"); -} - void MessageGenerator::GenerateInitDefaultSplitInstance(io::Printer* printer) { if (!ShouldSplit(descriptor_, options_)) return; @@ -2947,10 +2922,6 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { // Generate the shared constructor code. GenerateSharedConstructorCode(printer); - if (ShouldSplit(descriptor_, options_)) { - GenerateCreateSplitMessage(printer); - } - // Generate the destructor. if (!HasSimpleBaseClass(descriptor_, options_)) { format( diff --git a/src/google/protobuf/compiler/cpp/message.h b/src/google/protobuf/compiler/cpp/message.h index 5bdfcb35e2..998ebdb242 100644 --- a/src/google/protobuf/compiler/cpp/message.h +++ b/src/google/protobuf/compiler/cpp/message.h @@ -119,7 +119,6 @@ class MessageGenerator { // default instance. void GenerateConstexprConstructor(io::Printer* printer); - void GenerateCreateSplitMessage(io::Printer* printer); void GenerateInitDefaultSplitInstance(io::Printer* printer); // Generate standard Message methods. diff --git a/src/google/protobuf/compiler/cpp/parse_function_generator.cc b/src/google/protobuf/compiler/cpp/parse_function_generator.cc index 91ceeeb257..3254b37581 100644 --- a/src/google/protobuf/compiler/cpp/parse_function_generator.cc +++ b/src/google/protobuf/compiler/cpp/parse_function_generator.cc @@ -93,7 +93,7 @@ bool IsFieldEligibleForFastParsing( if (field->is_map() || field->real_containing_oneof() || field->options().weak() || IsImplicitWeakField(field, options, scc_analyzer) || - IsLazy(field, options, scc_analyzer)) { + IsLazy(field, options, scc_analyzer) || ShouldSplit(field, options)) { return false; } @@ -313,6 +313,16 @@ TailCallTableInfo::TailCallTableInfo( ", _impl_._inlined_string_donated_)}"); } + // If this message is split, store the split pointer offset in the third + // auxiliary entry. + if (ShouldSplit(descriptor, options)) { + aux_entries.resize(4); // pad if necessary + aux_entries[2] = StrCat("_fl::Offset{offsetof(", + ClassName(descriptor), ", _impl_._split_)}"); + aux_entries[3] = StrCat("_fl::Offset{sizeof(", ClassName(descriptor), + "::Impl_::Split)}"); + } + // Fill in mini table entries. for (const FieldDescriptor* field : ordered_fields) { field_entries.push_back( @@ -919,14 +929,12 @@ void ParseFunctionGenerator::GenerateFastFieldEntries(Formatter& format) { if (info.func_name.empty()) { format("{::_pbi::TcParser::MiniParse, {}},\n"); } else { - bool cold = ShouldSplit(info.field, options_); + GOOGLE_CHECK(!ShouldSplit(info.field, options_)); format( "{$1$,\n" - " {$2$, $3$, $4$, PROTOBUF_FIELD_OFFSET($classname$$5$, $6$)}},\n", + " {$2$, $3$, $4$, PROTOBUF_FIELD_OFFSET($classname$, $5$)}},\n", info.func_name, info.coded_tag, info.hasbit_idx, info.aux_idx, - cold ? "::Impl_::Split" : "", - cold ? FieldName(info.field) + "_" - : FieldMemberName(info.field, /*cold=*/false)); + FieldMemberName(info.field, /*split=*/false)); } } } @@ -1067,6 +1075,10 @@ static void FormatFieldKind(Formatter& format, } } + if (ShouldSplit(field, options)) { + format(" | ::_fl::kSplitTrue"); + } + format(")"); } @@ -1081,11 +1093,14 @@ void ParseFunctionGenerator::GenerateFieldEntries(Formatter& format) { format("/* weak */ 0, 0, 0, 0"); } else { const OneofDescriptor* oneof = field->real_containing_oneof(); - bool cold = ShouldSplit(field, options_); - format("PROTOBUF_FIELD_OFFSET($classname$$1$, $2$), ", - cold ? "::Impl_::Split" : "", - cold ? FieldName(field) + "_" - : FieldMemberName(field, /*cold=*/false)); + bool split = ShouldSplit(field, options_); + if (split) { + format("PROTOBUF_FIELD_OFFSET($classname$::Impl_::Split, $1$), ", + FieldName(field) + "_"); + } else { + format("PROTOBUF_FIELD_OFFSET($classname$, $1$), ", + FieldMemberName(field, /*cold=*/false)); + } if (oneof) { format("$1$, ", oneof->index()); } else if (num_hasbits_ > 0 || IsMapEntryMessage(descriptor_)) { diff --git a/src/google/protobuf/compiler/cpp/string_field.cc b/src/google/protobuf/compiler/cpp/string_field.cc index 9e7c96d7ca..3c90dc001d 100644 --- a/src/google/protobuf/compiler/cpp/string_field.cc +++ b/src/google/protobuf/compiler/cpp/string_field.cc @@ -297,9 +297,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( if (descriptor_->default_value_string().empty()) { format( "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n" - " if ($field$.IsDefault()) {\n" - " $field$.Set(\"\", GetArenaForAllocation());\n" - " }\n" + " $field$.Set(\"\", GetArenaForAllocation());\n" "#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"); } format(" return p;\n"); @@ -445,21 +443,6 @@ void StringFieldGenerator::GenerateConstructorCode(io::Printer* printer) const { } } -void StringFieldGenerator::GenerateCreateSplitMessageCode( - io::Printer* printer) const { - GOOGLE_CHECK(ShouldSplit(descriptor_, options_)); - GOOGLE_CHECK(!inlined_); - Formatter format(printer, variables_); - format("ptr->$name$_.InitDefault();\n"); - if (IsString(descriptor_, options_) && - descriptor_->default_value_string().empty()) { - format( - "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n" - " ptr->$name$_.Set(\"\", GetArenaForAllocation());\n" - "#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"); - } -} - void StringFieldGenerator::GenerateCopyConstructorCode( io::Printer* printer) const { Formatter format(printer, variables_); @@ -554,13 +537,9 @@ void StringFieldGenerator::GenerateConstexprAggregateInitializer( format("/*decltype($field$)*/{nullptr, false}"); return; } - if (descriptor_->default_value_string().empty()) { - format( - "/*decltype($field$)*/{&::_pbi::fixed_address_empty_string, " - "::_pbi::ConstantInitialized{}}"); - } else { - format("/*decltype($field$)*/{nullptr, ::_pbi::ConstantInitialized{}}"); - } + format( + "/*decltype($field$)*/{&::_pbi::fixed_address_empty_string, " + "::_pbi::ConstantInitialized{}}"); } void StringFieldGenerator::GenerateAggregateInitializer( diff --git a/src/google/protobuf/compiler/cpp/string_field.h b/src/google/protobuf/compiler/cpp/string_field.h index db5f18bfb7..b1865ea67d 100644 --- a/src/google/protobuf/compiler/cpp/string_field.h +++ b/src/google/protobuf/compiler/cpp/string_field.h @@ -63,7 +63,6 @@ class StringFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const override; void GenerateSwappingCode(io::Printer* printer) const override; void GenerateConstructorCode(io::Printer* printer) const override; - void GenerateCreateSplitMessageCode(io::Printer* printer) const override; void GenerateCopyConstructorCode(io::Printer* printer) const override; void GenerateDestructorCode(io::Printer* printer) const override; void GenerateArenaDestructorCode(io::Printer* printer) const override; diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index def353e215..32bfac19a2 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -102,6 +102,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offset ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.major_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.minor_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.patch_), @@ -116,6 +118,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offset ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.file_to_generate_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.parameter_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.proto_file_), @@ -130,6 +134,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offset ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.insertion_point_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.content_), @@ -144,6 +150,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offset ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.error_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.supported_features_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.file_), @@ -152,10 +160,10 @@ const uint32_t TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offset ~0u, }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, 10, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::Version)}, - { 14, 24, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest)}, - { 28, 38, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File)}, - { 42, 51, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse)}, + { 0, 12, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::Version)}, + { 16, 28, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest)}, + { 32, 44, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File)}, + { 48, 59, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse)}, }; static const ::_pb::Message* const file_default_instances[] = { diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 1c4b0f6c00..a9a485f046 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -1140,9 +1140,7 @@ inline std::string* Version::release_suffix() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.suffix_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.suffix_.IsDefault()) { - _impl_.suffix_.Set("", GetArenaForAllocation()); - } + _impl_.suffix_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -1287,9 +1285,7 @@ inline std::string* CodeGeneratorRequest::release_parameter() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.parameter_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.parameter_.IsDefault()) { - _impl_.parameter_.Set("", GetArenaForAllocation()); - } + _impl_.parameter_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -1486,9 +1482,7 @@ inline std::string* CodeGeneratorResponse_File::release_name() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); - } + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -1554,9 +1548,7 @@ inline std::string* CodeGeneratorResponse_File::release_insertion_point() { _impl_._has_bits_[0] &= ~0x00000002u; auto* p = _impl_.insertion_point_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.insertion_point_.IsDefault()) { - _impl_.insertion_point_.Set("", GetArenaForAllocation()); - } + _impl_.insertion_point_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -1622,9 +1614,7 @@ inline std::string* CodeGeneratorResponse_File::release_content() { _impl_._has_bits_[0] &= ~0x00000004u; auto* p = _impl_.content_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.content_.IsDefault()) { - _impl_.content_.Set("", GetArenaForAllocation()); - } + _impl_.content_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -1781,9 +1771,7 @@ inline std::string* CodeGeneratorResponse::release_error() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.error_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.error_.IsDefault()) { - _impl_.error_.Set("", GetArenaForAllocation()); - } + _impl_.error_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 645096686d..257798e4ae 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -517,6 +517,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet, _impl_.file_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _internal_metadata_), @@ -524,6 +526,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.package_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.dependency_), @@ -554,6 +558,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.start_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.end_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.options_), @@ -566,6 +572,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.start_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.end_), 0, @@ -576,6 +584,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.field_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.extension_), @@ -602,6 +612,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _impl_.uninterpreted_option_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _internal_metadata_), @@ -609,6 +621,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.number_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.label_), @@ -637,6 +651,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.options_), 0, @@ -647,6 +663,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.start_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.end_), 0, @@ -657,6 +675,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.value_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.options_), @@ -673,6 +693,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.number_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.options_), @@ -685,6 +707,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.method_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.options_), @@ -697,6 +721,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.input_type_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.output_type_), @@ -715,6 +741,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_package_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_outer_classname_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_multiple_files_), @@ -763,6 +791,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.message_set_wire_format_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.no_standard_descriptor_accessor_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.deprecated_), @@ -779,6 +809,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.ctype_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.packed_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.jstype_), @@ -801,6 +833,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _impl_.uninterpreted_option_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _internal_metadata_), @@ -808,6 +842,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.allow_alias_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.deprecated_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.uninterpreted_option_), @@ -820,6 +856,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.deprecated_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.uninterpreted_option_), 0, @@ -830,6 +868,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.deprecated_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.uninterpreted_option_), 0, @@ -840,6 +880,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.deprecated_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.idempotency_level_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.uninterpreted_option_), @@ -852,6 +894,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.name_part_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.is_extension_), 0, @@ -862,6 +906,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.identifier_value_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.positive_int_value_), @@ -882,6 +928,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.path_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.span_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.leading_comments_), @@ -898,6 +946,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo, _impl_.location_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _internal_metadata_), @@ -905,6 +955,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.path_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.source_file_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.begin_), @@ -919,36 +971,38 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, _impl_.annotation_), }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet)}, - { 7, 25, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto)}, - { 37, 46, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange)}, - { 49, 57, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange)}, - { 59, 75, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto)}, - { 85, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions)}, - { 92, 109, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto)}, - { 120, 128, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto)}, - { 130, 138, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange)}, - { 140, 151, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto)}, - { 156, 165, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto)}, - { 168, 177, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto)}, - { 180, 192, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto)}, - { 198, 225, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileOptions)}, - { 246, 257, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MessageOptions)}, - { 262, 276, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldOptions)}, - { 284, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofOptions)}, - { 291, 300, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumOptions)}, - { 303, 311, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueOptions)}, - { 313, 321, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceOptions)}, - { 323, 332, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodOptions)}, - { 335, 343, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart)}, - { 345, 358, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption)}, - { 365, 376, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location)}, - { 381, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo)}, - { 388, 398, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation)}, - { 402, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo)}, + { 9, 29, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto)}, + { 41, 52, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange)}, + { 55, 65, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange)}, + { 67, 85, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto)}, + { 95, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions)}, + { 104, 123, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto)}, + { 134, 144, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto)}, + { 146, 156, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange)}, + { 158, 171, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto)}, + { 176, 187, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto)}, + { 190, 201, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto)}, + { 204, 218, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto)}, + { 224, 253, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileOptions)}, + { 274, 287, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MessageOptions)}, + { 292, 308, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldOptions)}, + { 316, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofOptions)}, + { 325, 336, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumOptions)}, + { 339, 349, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueOptions)}, + { 351, 361, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceOptions)}, + { 363, 374, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodOptions)}, + { 377, 387, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart)}, + { 389, 404, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption)}, + { 411, 424, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location)}, + { 429, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo)}, + { 438, 450, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation)}, + { 454, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo)}, }; static const ::_pb::Message* const file_default_instances[] = { diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 78df1d5124..b8710b274c 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -8626,9 +8626,7 @@ inline std::string* FileDescriptorProto::release_name() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); - } + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -8694,9 +8692,7 @@ inline std::string* FileDescriptorProto::release_package() { _impl_._has_bits_[0] &= ~0x00000002u; auto* p = _impl_.package_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.package_.IsDefault()) { - _impl_.package_.Set("", GetArenaForAllocation()); - } + _impl_.package_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -9271,9 +9267,7 @@ inline std::string* FileDescriptorProto::release_syntax() { _impl_._has_bits_[0] &= ~0x00000004u; auto* p = _impl_.syntax_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.syntax_.IsDefault()) { - _impl_.syntax_.Set("", GetArenaForAllocation()); - } + _impl_.syntax_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -9553,9 +9547,7 @@ inline std::string* DescriptorProto::release_name() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); - } + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -10114,9 +10106,7 @@ inline std::string* FieldDescriptorProto::release_name() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); - } + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -10268,9 +10258,7 @@ inline std::string* FieldDescriptorProto::release_type_name() { _impl_._has_bits_[0] &= ~0x00000004u; auto* p = _impl_.type_name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.type_name_.IsDefault()) { - _impl_.type_name_.Set("", GetArenaForAllocation()); - } + _impl_.type_name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -10336,9 +10324,7 @@ inline std::string* FieldDescriptorProto::release_extendee() { _impl_._has_bits_[0] &= ~0x00000002u; auto* p = _impl_.extendee_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.extendee_.IsDefault()) { - _impl_.extendee_.Set("", GetArenaForAllocation()); - } + _impl_.extendee_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -10404,9 +10390,7 @@ inline std::string* FieldDescriptorProto::release_default_value() { _impl_._has_bits_[0] &= ~0x00000008u; auto* p = _impl_.default_value_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.default_value_.IsDefault()) { - _impl_.default_value_.Set("", GetArenaForAllocation()); - } + _impl_.default_value_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -10500,9 +10484,7 @@ inline std::string* FieldDescriptorProto::release_json_name() { _impl_._has_bits_[0] &= ~0x00000010u; auto* p = _impl_.json_name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.json_name_.IsDefault()) { - _impl_.json_name_.Set("", GetArenaForAllocation()); - } + _impl_.json_name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -10690,9 +10672,7 @@ inline std::string* OneofDescriptorProto::release_name() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); - } + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -10912,9 +10892,7 @@ inline std::string* EnumDescriptorProto::release_name() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); - } + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -11229,9 +11207,7 @@ inline std::string* EnumValueDescriptorProto::release_name() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); - } + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -11419,9 +11395,7 @@ inline std::string* ServiceDescriptorProto::release_name() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); - } + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -11621,9 +11595,7 @@ inline std::string* MethodDescriptorProto::release_name() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); - } + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -11689,9 +11661,7 @@ inline std::string* MethodDescriptorProto::release_input_type() { _impl_._has_bits_[0] &= ~0x00000002u; auto* p = _impl_.input_type_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.input_type_.IsDefault()) { - _impl_.input_type_.Set("", GetArenaForAllocation()); - } + _impl_.input_type_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -11757,9 +11727,7 @@ inline std::string* MethodDescriptorProto::release_output_type() { _impl_._has_bits_[0] &= ~0x00000004u; auto* p = _impl_.output_type_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.output_type_.IsDefault()) { - _impl_.output_type_.Set("", GetArenaForAllocation()); - } + _impl_.output_type_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -11975,9 +11943,7 @@ inline std::string* FileOptions::release_java_package() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.java_package_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.java_package_.IsDefault()) { - _impl_.java_package_.Set("", GetArenaForAllocation()); - } + _impl_.java_package_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -12043,9 +12009,7 @@ inline std::string* FileOptions::release_java_outer_classname() { _impl_._has_bits_[0] &= ~0x00000002u; auto* p = _impl_.java_outer_classname_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.java_outer_classname_.IsDefault()) { - _impl_.java_outer_classname_.Set("", GetArenaForAllocation()); - } + _impl_.java_outer_classname_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -12224,9 +12188,7 @@ inline std::string* FileOptions::release_go_package() { _impl_._has_bits_[0] &= ~0x00000004u; auto* p = _impl_.go_package_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.go_package_.IsDefault()) { - _impl_.go_package_.Set("", GetArenaForAllocation()); - } + _impl_.go_package_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -12460,9 +12422,7 @@ inline std::string* FileOptions::release_objc_class_prefix() { _impl_._has_bits_[0] &= ~0x00000008u; auto* p = _impl_.objc_class_prefix_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.objc_class_prefix_.IsDefault()) { - _impl_.objc_class_prefix_.Set("", GetArenaForAllocation()); - } + _impl_.objc_class_prefix_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -12528,9 +12488,7 @@ inline std::string* FileOptions::release_csharp_namespace() { _impl_._has_bits_[0] &= ~0x00000010u; auto* p = _impl_.csharp_namespace_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.csharp_namespace_.IsDefault()) { - _impl_.csharp_namespace_.Set("", GetArenaForAllocation()); - } + _impl_.csharp_namespace_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -12596,9 +12554,7 @@ inline std::string* FileOptions::release_swift_prefix() { _impl_._has_bits_[0] &= ~0x00000020u; auto* p = _impl_.swift_prefix_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.swift_prefix_.IsDefault()) { - _impl_.swift_prefix_.Set("", GetArenaForAllocation()); - } + _impl_.swift_prefix_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -12664,9 +12620,7 @@ inline std::string* FileOptions::release_php_class_prefix() { _impl_._has_bits_[0] &= ~0x00000040u; auto* p = _impl_.php_class_prefix_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.php_class_prefix_.IsDefault()) { - _impl_.php_class_prefix_.Set("", GetArenaForAllocation()); - } + _impl_.php_class_prefix_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -12732,9 +12686,7 @@ inline std::string* FileOptions::release_php_namespace() { _impl_._has_bits_[0] &= ~0x00000080u; auto* p = _impl_.php_namespace_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.php_namespace_.IsDefault()) { - _impl_.php_namespace_.Set("", GetArenaForAllocation()); - } + _impl_.php_namespace_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -12800,9 +12752,7 @@ inline std::string* FileOptions::release_php_metadata_namespace() { _impl_._has_bits_[0] &= ~0x00000100u; auto* p = _impl_.php_metadata_namespace_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.php_metadata_namespace_.IsDefault()) { - _impl_.php_metadata_namespace_.Set("", GetArenaForAllocation()); - } + _impl_.php_metadata_namespace_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -12868,9 +12818,7 @@ inline std::string* FileOptions::release_ruby_package() { _impl_._has_bits_[0] &= ~0x00000200u; auto* p = _impl_.ruby_package_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.ruby_package_.IsDefault()) { - _impl_.ruby_package_.Set("", GetArenaForAllocation()); - } + _impl_.ruby_package_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -13767,9 +13715,7 @@ inline std::string* UninterpretedOption_NamePart::release_name_part() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.name_part_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_part_.IsDefault()) { - _impl_.name_part_.Set("", GetArenaForAllocation()); - } + _impl_.name_part_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -13907,9 +13853,7 @@ inline std::string* UninterpretedOption::release_identifier_value() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.identifier_value_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.identifier_value_.IsDefault()) { - _impl_.identifier_value_.Set("", GetArenaForAllocation()); - } + _impl_.identifier_value_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -14059,9 +14003,7 @@ inline std::string* UninterpretedOption::release_string_value() { _impl_._has_bits_[0] &= ~0x00000002u; auto* p = _impl_.string_value_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.string_value_.IsDefault()) { - _impl_.string_value_.Set("", GetArenaForAllocation()); - } + _impl_.string_value_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -14127,9 +14069,7 @@ inline std::string* UninterpretedOption::release_aggregate_value() { _impl_._has_bits_[0] &= ~0x00000004u; auto* p = _impl_.aggregate_value_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.aggregate_value_.IsDefault()) { - _impl_.aggregate_value_.Set("", GetArenaForAllocation()); - } + _impl_.aggregate_value_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -14293,9 +14233,7 @@ inline std::string* SourceCodeInfo_Location::release_leading_comments() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.leading_comments_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.leading_comments_.IsDefault()) { - _impl_.leading_comments_.Set("", GetArenaForAllocation()); - } + _impl_.leading_comments_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -14361,9 +14299,7 @@ inline std::string* SourceCodeInfo_Location::release_trailing_comments() { _impl_._has_bits_[0] &= ~0x00000002u; auto* p = _impl_.trailing_comments_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.trailing_comments_.IsDefault()) { - _impl_.trailing_comments_.Set("", GetArenaForAllocation()); - } + _impl_.trailing_comments_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } @@ -14599,9 +14535,7 @@ inline std::string* GeneratedCodeInfo_Annotation::release_source_file() { _impl_._has_bits_[0] &= ~0x00000001u; auto* p = _impl_.source_file_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.source_file_.IsDefault()) { - _impl_.source_file_.Set("", GetArenaForAllocation()); - } + _impl_.source_file_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index 72766bd3b4..94671ee6c9 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -47,6 +47,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fduration_2eproto::offsets[] PROTO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Duration, _impl_.seconds_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Duration, _impl_.nanos_), }; diff --git a/src/google/protobuf/dynamic_message.cc b/src/google/protobuf/dynamic_message.cc index 1c96ca2080..3940564583 100644 --- a/src/google/protobuf/dynamic_message.cc +++ b/src/google/protobuf/dynamic_message.cc @@ -808,8 +808,11 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( type_info->oneof_case_offset, type_info->size, type_info->weak_field_map_offset, - nullptr /* inlined_string_indices_ */, - 0 /* inlined_string_donated_offset_ */}; + nullptr, // inlined_string_indices_ + 0, // inlined_string_donated_offset_ + -1, // split_offset_ + -1, // sizeof_split_ + }; type_info->reflection.reset( new Reflection(type_info->type, schema, type_info->pool, this)); diff --git a/src/google/protobuf/dynamic_message.h b/src/google/protobuf/dynamic_message.h index 6fa64259ee..e318259e01 100644 --- a/src/google/protobuf/dynamic_message.h +++ b/src/google/protobuf/dynamic_message.h @@ -81,6 +81,9 @@ class DescriptorPool; // descriptor.h // encapsulates this "cache". All DynamicMessages of the same type created // from the same factory will share the same support data. Any Descriptors // used with a particular factory must outlive the factory. +// +// The thread safety for this class is subtle, see comments around GetPrototype +// for details class PROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory { public: // Construct a DynamicMessageFactory that will search for extensions in diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index 3a30776386..8af459dbf8 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -44,6 +44,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fempty_2eproto::offsets[] PROTOBUF ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Empty)}, diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index 7860bfbfed..8448013e6f 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -46,6 +46,8 @@ const uint32_t TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets[] P ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldMask, _impl_.paths_), }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index 53ca9acd32..aefec99081 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -1114,8 +1115,14 @@ void Reflection::InternalSwap(Message* lhs, Message* rhs) const { const FieldDescriptor* field = descriptor_->field(i); if (schema_.InRealOneof(field)) continue; if (schema_.IsFieldStripped(field)) continue; + if (schema_.IsSplit(field)) { + continue; + } UnsafeShallowSwapField(lhs, rhs, field); } + if (schema_.IsSplit()) { + std::swap(*MutableSplitField(lhs), *MutableSplitField(rhs)); + } const int oneof_decl_count = descriptor_->oneof_decl_count(); for (int i = 0; i < oneof_decl_count; i++) { const OneofDescriptor* oneof = descriptor_->oneof_decl(i); @@ -2437,13 +2444,34 @@ bool Reflection::SupportsUnknownEnumValues() const { template const Type& Reflection::GetRawNonOneof(const Message& message, const FieldDescriptor* field) const { + if (schema_.IsSplit(field)) { + return *GetConstPointerAtOffset( + GetSplitField(&message), schema_.GetFieldOffsetNonOneof(field)); + } return GetConstRefAtOffset(message, schema_.GetFieldOffsetNonOneof(field)); } +void Reflection::PrepareSplitMessageForWrite(Message* message) const { + void** split = MutableSplitField(message); + const void* default_split = GetSplitField(schema_.default_instance_); + if (*split == default_split) { + uint32_t size = schema_.SizeofSplit(); + Arena* arena = message->GetArenaForAllocation(); + *split = (arena == nullptr) ? ::operator new(size) + : arena->AllocateAligned(size); + memcpy(*split, default_split, size); + } +} + template Type* Reflection::MutableRawNonOneof(Message* message, const FieldDescriptor* field) const { + if (schema_.IsSplit(field)) { + PrepareSplitMessageForWrite(message); + return GetPointerAtOffset(*MutableSplitField(message), + schema_.GetFieldOffsetNonOneof(field)); + } return GetPointerAtOffset(message, schema_.GetFieldOffsetNonOneof(field)); } @@ -2451,6 +2479,11 @@ Type* Reflection::MutableRawNonOneof(Message* message, template Type* Reflection::MutableRaw(Message* message, const FieldDescriptor* field) const { + if (schema_.IsSplit(field)) { + PrepareSplitMessageForWrite(message); + return GetPointerAtOffset(*MutableSplitField(message), + schema_.GetFieldOffset(field)); + } return GetPointerAtOffset(message, schema_.GetFieldOffset(field)); } @@ -2875,9 +2908,11 @@ ReflectionSchema MigrationToReflectionSchema( MigrationSchema migration_schema) { ReflectionSchema result; result.default_instance_ = *default_instance; - // First 7 offsets are offsets to the special fields. The following offsets + // First 9 offsets are offsets to the special fields. The following offsets // are the proto fields. - result.offsets_ = offsets + migration_schema.offsets_index + 6; + // + // TODO(congliu): Find a way to not encode sizeof_split_ in offsets. + result.offsets_ = offsets + migration_schema.offsets_index + 8; result.has_bit_indices_ = offsets + migration_schema.has_bit_indices_index; result.has_bits_offset_ = offsets[migration_schema.offsets_index + 0]; result.metadata_offset_ = offsets[migration_schema.offsets_index + 1]; @@ -2887,6 +2922,8 @@ ReflectionSchema MigrationToReflectionSchema( result.weak_field_map_offset_ = offsets[migration_schema.offsets_index + 4]; result.inlined_string_donated_offset_ = offsets[migration_schema.offsets_index + 5]; + result.split_offset_ = offsets[migration_schema.offsets_index + 6]; + result.sizeof_split_ = offsets[migration_schema.offsets_index + 7]; result.inlined_string_indices_ = offsets + migration_schema.inlined_string_indices_index; return result; diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h index 334b2ccf1d..2e0b8098ba 100644 --- a/src/google/protobuf/generated_message_reflection.h +++ b/src/google/protobuf/generated_message_reflection.h @@ -72,6 +72,16 @@ class DefaultEmptyOneof; class ExtensionSet; // extension_set.h class WeakFieldMap; // weak_field_map.h +// Tag used on offsets for fields that don't have a real offset. +// For example, weak message fields go into the WeakFieldMap and not in an +// actual field. +constexpr uint32_t kInvalidFieldOffsetTag = 0x40000000u; + +// Mask used on offsets for split fields. +constexpr uint32_t kSplitFieldOffsetMask = 0x80000000u; +constexpr uint32_t kLazyMask = 0x1u; +constexpr uint32_t kInlinedMask = 0x1u; + // This struct describes the internal layout of the message, hence this is // used to act on the message reflectively. // default_instance: The default instance of the message. This is only @@ -234,6 +244,24 @@ struct ReflectionSchema { return false; } + bool IsSplit() const { return split_offset_ != -1; } + + bool IsSplit(const FieldDescriptor* field) const { + return split_offset_ != -1 && + (offsets_[field->index()] & kSplitFieldOffsetMask) != 0; + } + + // Byte offset of _split_. + uint32_t SplitOffset() const { + GOOGLE_DCHECK(IsSplit()); + return static_cast(split_offset_); + } + + uint32_t SizeofSplit() const { + GOOGLE_DCHECK(IsSplit()); + return static_cast(sizeof_split_); + } + bool HasWeakFields() const { return weak_field_map_offset_ > 0; } @@ -254,6 +282,8 @@ struct ReflectionSchema { int weak_field_map_offset_; const uint32_t* inlined_string_indices_; int inlined_string_donated_offset_; + int split_offset_; + int sizeof_split_; // We tag offset values to provide additional data about fields (such as // "unused" or "lazy" or "inlined"). @@ -261,15 +291,15 @@ struct ReflectionSchema { if (type == FieldDescriptor::TYPE_MESSAGE || type == FieldDescriptor::TYPE_STRING || type == FieldDescriptor::TYPE_BYTES) { - return v & 0xFFFFFFFEu; + return v & (~kSplitFieldOffsetMask) & (~kInlinedMask) & (~kLazyMask); } - return v; + return v & (~kSplitFieldOffsetMask); } static bool Inlined(uint32_t v, FieldDescriptor::Type type) { if (type == FieldDescriptor::TYPE_STRING || type == FieldDescriptor::TYPE_BYTES) { - return (v & 1u) != 0u; + return (v & kInlinedMask) != 0u; } else { // Non string/byte fields are not inlined. return false; @@ -312,13 +342,6 @@ struct PROTOBUF_EXPORT DescriptorTable { const ServiceDescriptor** file_level_service_descriptors; }; -enum { - // Tag used on offsets for fields that don't have a real offset. - // For example, weak message fields go into the WeakFieldMap and not in an - // actual field. - kInvalidFieldOffsetTag = 0x40000000u, -}; - // AssignDescriptors() pulls the compiled FileDescriptor from the DescriptorPool // and uses it to populate all of the global variables which store pointers to // the descriptor objects. It also constructs the reflection objects. It is diff --git a/src/google/protobuf/generated_message_tctable_impl.h b/src/google/protobuf/generated_message_tctable_impl.h index 53bdc76da6..1ea1250f8b 100644 --- a/src/google/protobuf/generated_message_tctable_impl.h +++ b/src/google/protobuf/generated_message_tctable_impl.h @@ -64,10 +64,11 @@ namespace internal { // |15 .. 8|7 .. 0| // +-----------------------+-----------------------+ // : . : . : . : . : . : . : 3|========| [3] FieldType -// : : : : : : 5|=====| : : [2] FieldCardinality -// : . : . : . : . 8|========| : . : . : [3] FieldRep -// : : : 10|=====| : : : : [2] TransformValidation -// : . : .12|=====| . : . : . : . : . : [2] FormatDiscriminator +// : : : : : : . 4|==| : : [1] FieldSplit +// : : : : : 6|=====| . : : [2] FieldCardinality +// : . : . : . : 9|========| . : . : . : [3] FieldRep +// : : :11|=====| : : : : : [2] TransformValidation +// : . :13|=====| : . : . : . : . : . : [2] FormatDiscriminator // +-----------------------+-----------------------+ // |15 .. 8|7 .. 0| // +-----------------------+-----------------------+ @@ -95,11 +96,21 @@ enum FieldKind : uint16_t { static_assert(kFkMap < (1 << kFkBits), "too many types"); +// Split (1 bit): +enum FieldSplit : uint16_t { + kSplitShift = kFkShift+ kFkBits, + kSplitBits = 1, + kSplitMask = ((1 << kSplitBits) - 1) << kSplitShift, + + kSplitFalse = 0, + kSplitTrue = 1 << kSplitShift, +}; + // Cardinality (2 bits): // These values determine how many values a field can have and its presence. // Packed fields are represented in FieldType. enum Cardinality : uint16_t { - kFcShift = kFkShift + kFkBits, + kFcShift = kSplitShift+ kSplitBits, kFcBits = 2, kFcMask = ((1 << kFcBits) - 1) << kFcShift, @@ -179,7 +190,7 @@ enum FormatDiscriminator : uint16_t { }; // Update this assertion (and comments above) when adding or removing bits: -static_assert(kFmtShift + kFmtBits == 12, "number of bits changed"); +static_assert(kFmtShift + kFmtBits == 13, "number of bits changed"); // This assertion should not change unless the storage width changes: static_assert(kFmtShift + kFmtBits <= 16, "too many bits"); @@ -549,14 +560,18 @@ class PROTOBUF_EXPORT TcParser final { static constexpr const uint32_t kMtSmallScanSize = 4; // Mini parsing: + template static const char* MpVarint(PROTOBUF_TC_PARAM_DECL); static const char* MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL); static const char* MpPackedVarint(PROTOBUF_TC_PARAM_DECL); + template static const char* MpFixed(PROTOBUF_TC_PARAM_DECL); static const char* MpRepeatedFixed(PROTOBUF_TC_PARAM_DECL); static const char* MpPackedFixed(PROTOBUF_TC_PARAM_DECL); + template static const char* MpString(PROTOBUF_TC_PARAM_DECL); static const char* MpRepeatedString(PROTOBUF_TC_PARAM_DECL); + template static const char* MpMessage(PROTOBUF_TC_PARAM_DECL); static const char* MpRepeatedMessage(PROTOBUF_TC_PARAM_DECL); static const char* MpMap(PROTOBUF_TC_PARAM_DECL); diff --git a/src/google/protobuf/generated_message_tctable_lite.cc b/src/google/protobuf/generated_message_tctable_lite.cc index b98b00c411..713114ec4f 100644 --- a/src/google/protobuf/generated_message_tctable_lite.cc +++ b/src/google/protobuf/generated_message_tctable_lite.cc @@ -315,24 +315,43 @@ const char* TcParser::MiniParse(PROTOBUF_TC_PARAM_DECL) { data.data = entry_offset << 32 | tag; using field_layout::FieldKind; - auto field_type = entry->type_card & FieldKind::kFkMask; + auto field_type = + entry->type_card & (+field_layout::kSplitMask | FieldKind::kFkMask); switch (field_type) { case FieldKind::kFkNone: PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); case FieldKind::kFkVarint: - PROTOBUF_MUSTTAIL return MpVarint(PROTOBUF_TC_PARAM_PASS); + PROTOBUF_MUSTTAIL return MpVarint(PROTOBUF_TC_PARAM_PASS); case FieldKind::kFkPackedVarint: PROTOBUF_MUSTTAIL return MpPackedVarint(PROTOBUF_TC_PARAM_PASS); case FieldKind::kFkFixed: - PROTOBUF_MUSTTAIL return MpFixed(PROTOBUF_TC_PARAM_PASS); + PROTOBUF_MUSTTAIL return MpFixed(PROTOBUF_TC_PARAM_PASS); case FieldKind::kFkPackedFixed: PROTOBUF_MUSTTAIL return MpPackedFixed(PROTOBUF_TC_PARAM_PASS); case FieldKind::kFkString: - PROTOBUF_MUSTTAIL return MpString(PROTOBUF_TC_PARAM_PASS); + PROTOBUF_MUSTTAIL return MpString(PROTOBUF_TC_PARAM_PASS); case FieldKind::kFkMessage: - PROTOBUF_MUSTTAIL return MpMessage(PROTOBUF_TC_PARAM_PASS); + PROTOBUF_MUSTTAIL return MpMessage(PROTOBUF_TC_PARAM_PASS); case FieldKind::kFkMap: PROTOBUF_MUSTTAIL return MpMap(PROTOBUF_TC_PARAM_PASS); + + case +field_layout::kSplitMask | FieldKind::kFkNone: + PROTOBUF_FALLTHROUGH_INTENDED; + case +field_layout::kSplitMask | FieldKind::kFkPackedVarint: + PROTOBUF_FALLTHROUGH_INTENDED; + case +field_layout::kSplitMask | FieldKind::kFkPackedFixed: + PROTOBUF_FALLTHROUGH_INTENDED; + case +field_layout::kSplitMask | FieldKind::kFkMap: + return Error(PROTOBUF_TC_PARAM_PASS); + + case +field_layout::kSplitMask | FieldKind::kFkVarint: + PROTOBUF_MUSTTAIL return MpVarint(PROTOBUF_TC_PARAM_PASS); + case +field_layout::kSplitMask | FieldKind::kFkFixed: + PROTOBUF_MUSTTAIL return MpFixed(PROTOBUF_TC_PARAM_PASS); + case +field_layout::kSplitMask | FieldKind::kFkString: + PROTOBUF_MUSTTAIL return MpString(PROTOBUF_TC_PARAM_PASS); + case +field_layout::kSplitMask | FieldKind::kFkMessage: + PROTOBUF_MUSTTAIL return MpMessage(PROTOBUF_TC_PARAM_PASS); default: return Error(PROTOBUF_TC_PARAM_PASS); } @@ -1387,6 +1406,43 @@ bool TcParser::ChangeOneof(const TcParseTableBase* table, return true; } +namespace { +enum { + kSplitOffsetIdx = 2, + kSplitSizeIdx = 3, +}; +uint32_t GetSplitOffset(const TcParseTableBase* table) { + return table->field_aux(kSplitOffsetIdx)->offset; +} + +uint32_t GetSizeofSplit(const TcParseTableBase* table) { + return table->field_aux(kSplitSizeIdx)->offset; +} + +void* MaybeGetSplitBase(MessageLite* msg, const bool is_split, + const TcParseTableBase* table, + ::google::protobuf::internal::ParseContext* ctx) { + void* out = msg; + if (is_split) { + const uint32_t split_offset = GetSplitOffset(table); + void* default_split = + TcParser::RefAt(table->default_instance, split_offset); + void*& split = TcParser::RefAt(msg, split_offset); + if (split == default_split) { + // Allocate split instance when needed. + uint32_t size = GetSizeofSplit(table); + Arena* arena = ctx->data().arena; + split = (arena == nullptr) ? ::operator new(size) + : arena->AllocateAligned(size); + memcpy(split, default_split, size); + } + out = split; + } + return out; +} +} // namespace + +template const char* TcParser::MpFixed(PROTOBUF_TC_PARAM_DECL) { const auto& entry = RefAt(table, data.entry_offset()); const uint16_t type_card = entry.type_card; @@ -1415,12 +1471,13 @@ const char* TcParser::MpFixed(PROTOBUF_TC_PARAM_DECL) { } else if (card == field_layout::kFcOneof) { ChangeOneof(table, entry, data.tag() >> 3, ctx, msg); } + void* const base = MaybeGetSplitBase(msg, is_split, table, ctx); // Copy the value: if (rep == field_layout::kRep64Bits) { - RefAt(msg, entry.offset) = UnalignedLoad(ptr); + RefAt(base, entry.offset) = UnalignedLoad(ptr); ptr += sizeof(uint64_t); } else { - RefAt(msg, entry.offset) = UnalignedLoad(ptr); + RefAt(base, entry.offset) = UnalignedLoad(ptr); ptr += sizeof(uint32_t); } PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS); @@ -1505,6 +1562,7 @@ const char* TcParser::MpPackedFixed(PROTOBUF_TC_PARAM_DECL) { PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS); } +template const char* TcParser::MpVarint(PROTOBUF_TC_PARAM_DECL) { const auto& entry = RefAt(table, data.entry_offset()); const uint16_t type_card = entry.type_card; @@ -1553,13 +1611,14 @@ const char* TcParser::MpVarint(PROTOBUF_TC_PARAM_DECL) { ChangeOneof(table, entry, data.tag() >> 3, ctx, msg); } + void* const base = MaybeGetSplitBase(msg, is_split, table, ctx); if (rep == field_layout::kRep64Bits) { - RefAt(msg, entry.offset) = tmp; + RefAt(base, entry.offset) = tmp; } else if (rep == field_layout::kRep32Bits) { - RefAt(msg, entry.offset) = static_cast(tmp); + RefAt(base, entry.offset) = static_cast(tmp); } else { GOOGLE_DCHECK_EQ(rep, static_cast(field_layout::kRep8Bits)); - RefAt(msg, entry.offset) = static_cast(tmp); + RefAt(base, entry.offset) = static_cast(tmp); } PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS); @@ -1700,6 +1759,7 @@ bool TcParser::MpVerifyUtf8(StringPiece wire_bytes, return true; } +template const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) { const auto& entry = RefAt(table, data.entry_offset()); const uint16_t type_card = entry.type_card; @@ -1730,9 +1790,10 @@ const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) { bool is_valid = false; Arena* arena = ctx->data().arena; + void* const base = MaybeGetSplitBase(msg, is_split, table, ctx); switch (rep) { case field_layout::kRepAString: { - auto& field = RefAt(msg, entry.offset); + auto& field = RefAt(base, entry.offset); if (need_init) field.InitDefault(); if (arena) { ptr = ctx->ReadArenaString(ptr, &field, arena); @@ -1798,6 +1859,7 @@ const char* TcParser::MpRepeatedString(PROTOBUF_TC_PARAM_DECL) { return ToParseLoop(PROTOBUF_TC_PARAM_PASS); } +template const char* TcParser::MpMessage(PROTOBUF_TC_PARAM_DECL) { const auto& entry = RefAt(table, data.entry_offset()); const uint16_t type_card = entry.type_card; @@ -1840,8 +1902,10 @@ const char* TcParser::MpMessage(PROTOBUF_TC_PARAM_DECL) { } else if (is_oneof) { need_init = ChangeOneof(table, entry, data.tag() >> 3, ctx, msg); } + + void* const base = MaybeGetSplitBase(msg, is_split, table, ctx); SyncHasbits(msg, hasbits, table); - MessageLite*& field = RefAt(msg, entry.offset); + MessageLite*& field = RefAt(base, entry.offset); if ((type_card & field_layout::kTvMask) == field_layout::kTvTable) { auto* inner_table = table->field_aux(&entry)->table; if (need_init || field == nullptr) { diff --git a/src/google/protobuf/io/tokenizer.h b/src/google/protobuf/io/tokenizer.h index ca2747b4ba..bb95c0f08e 100644 --- a/src/google/protobuf/io/tokenizer.h +++ b/src/google/protobuf/io/tokenizer.h @@ -148,11 +148,11 @@ class PROTOBUF_EXPORT Tokenizer { // Get the current token. This is updated when Next() is called. Before // the first call to Next(), current() has type TYPE_START and no contents. - const Token& current(); + const Token& current() const; // Return the previous token -- i.e. what current() returned before the // previous call to Next(). - const Token& previous(); + const Token& previous() const; // Advance to the next token. Returns false if the end of the input is // reached. @@ -422,9 +422,9 @@ class PROTOBUF_EXPORT Tokenizer { }; // inline methods ==================================================== -inline const Tokenizer::Token& Tokenizer::current() { return current_; } +inline const Tokenizer::Token& Tokenizer::current() const { return current_; } -inline const Tokenizer::Token& Tokenizer::previous() { return previous_; } +inline const Tokenizer::Token& Tokenizer::previous() const { return previous_; } inline void Tokenizer::ParseString(const std::string& text, std::string* output) { diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index 6cdc6c8393..3e044f742f 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -213,6 +213,16 @@ uint64_t Message::GetInvariantPerBuild(uint64_t salt) { return salt; } +namespace internal { +void* CreateSplitMessageGeneric(Arena* arena, void* default_split, + size_t size) { + void* split = + (arena == nullptr) ? ::operator new(size) : arena->AllocateAligned(size); + memcpy(split, default_split, size); + return split; +} +} // namespace internal + // ============================================================================= // MessageFactory diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index d20963bc67..82873885bb 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -203,12 +203,12 @@ struct Metadata { namespace internal { template -inline To* GetPointerAtOffset(Message* message, uint32_t offset) { +inline To* GetPointerAtOffset(void* message, uint32_t offset) { return reinterpret_cast(reinterpret_cast(message) + offset); } template -const To* GetConstPointerAtOffset(const Message* message, uint32_t offset) { +const To* GetConstPointerAtOffset(const void* message, uint32_t offset) { return reinterpret_cast(reinterpret_cast(message) + offset); } @@ -406,6 +406,9 @@ class PROTOBUF_EXPORT Message : public MessageLite { }; namespace internal { +// Creates and returns an allocation for a split message. +void* CreateSplitMessageGeneric(Arena* arena, void* default_split, size_t size); + // Forward-declare interfaces used to implement RepeatedFieldRef. // These are protobuf internals that users shouldn't care about. class RepeatedFieldAccessor; @@ -1029,6 +1032,10 @@ class PROTOBUF_EXPORT Reflection final { bool IsLazilyVerifiedLazyField(const FieldDescriptor* field) const; bool IsEagerlyVerifiedLazyField(const FieldDescriptor* field) const; + bool IsSplit(const FieldDescriptor* field) const { + return schema_.IsSplit(field); + } + friend class FastReflectionMessageMutator; friend bool internal::IsDescendant(Message& root, const Message& message); @@ -1174,6 +1181,14 @@ class PROTOBUF_EXPORT Reflection final { inline void SwapInlinedStringDonated(Message* lhs, Message* rhs, const FieldDescriptor* field) const; + // Returns the `_split_` pointer. Requires: IsSplit() == true. + inline const void* GetSplitField(const Message* message) const; + // Returns the address of the `_split_` pointer. Requires: IsSplit() == true. + inline void** MutableSplitField(Message* message) const; + + // Allocate the split instance if needed. + void PrepareSplitMessageForWrite(Message* message) const; + // Shallow-swap fields listed in fields vector of two messages. It is the // caller's responsibility to make sure shallow swap is safe. void UnsafeShallowSwapFields( @@ -1267,6 +1282,9 @@ class PROTOBUF_EXPORT Reflection final { }; // Abstract interface for a factory for message objects. +// +// The thread safety for this class is implementation dependent, see comments +// around GetPrototype for details class PROTOBUF_EXPORT MessageFactory { public: inline MessageFactory() {} @@ -1483,11 +1501,26 @@ bool Reflection::HasOneofField(const Message& message, static_cast(field->number())); } +const void* Reflection::GetSplitField(const Message* message) const { + GOOGLE_DCHECK(schema_.IsSplit()); + return *internal::GetConstPointerAtOffset(message, + schema_.SplitOffset()); +} + +void** Reflection::MutableSplitField(Message* message) const { + GOOGLE_DCHECK(schema_.IsSplit()); + return internal::GetPointerAtOffset(message, schema_.SplitOffset()); +} + template const Type& Reflection::GetRaw(const Message& message, const FieldDescriptor* field) const { GOOGLE_DCHECK(!schema_.InRealOneof(field) || HasOneofField(message, field)) << "Field = " << field->full_name(); + if (schema_.IsSplit(field)) { + return *internal::GetConstPointerAtOffset( + GetSplitField(&message), schema_.GetFieldOffset(field)); + } return internal::GetConstRefAtOffset(message, schema_.GetFieldOffset(field)); } diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index b32cda8ca2..0b463b8c6a 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -798,7 +798,7 @@ // Windows declares several inconvenient macro names. We #undef them and then // restore them in port_undef.inc. -#ifdef _MSC_VER +#ifdef _WIN32 #pragma push_macro("CREATE_NEW") #undef CREATE_NEW #pragma push_macro("DELETE") @@ -851,7 +851,7 @@ #undef STRICT #pragma push_macro("timezone") #undef timezone -#endif // _MSC_VER +#endif // _WIN32 #ifdef __APPLE__ // Inconvenient macro names from usr/include/math.h in some macOS SDKs. diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc index f8968d9a86..44663219f0 100644 --- a/src/google/protobuf/port_undef.inc +++ b/src/google/protobuf/port_undef.inc @@ -110,7 +110,7 @@ #endif // Restore macro that may have been #undef'd in port_def.inc. -#ifdef _MSC_VER +#ifdef _WIN32 #pragma pop_macro("CREATE_NEW") #pragma pop_macro("DELETE") #pragma pop_macro("DOUBLE_CLICK") diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index a74832f787..06b3353cc7 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -94,23 +94,6 @@ constexpr int RepeatedFieldLowerClampLimit() { constexpr int kRepeatedFieldUpperClampLimit = (std::numeric_limits::max() / 2) + 1; -template -inline int CalculateReserve(Iter begin, Iter end, std::forward_iterator_tag) { - return static_cast(std::distance(begin, end)); -} - -template -inline int CalculateReserve(Iter /*begin*/, Iter /*end*/, - std::input_iterator_tag /*unused*/) { - return -1; -} - -template -inline int CalculateReserve(Iter begin, Iter end) { - typedef typename std::iterator_traits::iterator_category Category; - return CalculateReserve(begin, end, Category()); -} - // Swaps two blocks of memory of size sizeof(T). template inline void SwapBlock(char* p, char* q) { @@ -722,13 +705,13 @@ inline Element* RepeatedField::Add() { template template inline void RepeatedField::Add(Iter begin, Iter end) { - int reserve = internal::CalculateReserve(begin, end); - if (reserve != -1) { - if (reserve == 0) { - return; - } + if (std::is_base_of< + std::forward_iterator_tag, + typename std::iterator_traits::iterator_category>::value) { + int additional = std::distance(begin, end); + if (additional == 0) return; - Reserve(reserve + size()); + Reserve(size() + additional); // TODO(ckennelly): The compiler loses track of the buffer freshly // allocated by Reserve() by the time we call elements, so it cannot // guarantee that elements does not alias [begin(), end()). @@ -736,7 +719,7 @@ inline void RepeatedField::Add(Iter begin, Iter end) { // If restrict is available, annotating the pointer obtained from elements() // causes this to lower to memcpy instead of memmove. std::copy(begin, end, elements() + size()); - current_size_ = reserve + size(); + current_size_ = size() + additional; } else { FastAdder fast_adder(this); for (; begin != end; ++begin) fast_adder.Add(*begin); diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index e7525e99cf..89118797ba 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -46,6 +46,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceContext, _impl_.file_name_), }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index 87c72d4aa4..43c1eae0a3 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -84,6 +84,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets[] PROTOBU ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse, key_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse, value_), 0, @@ -94,6 +96,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets[] PROTOBU ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct, _impl_.fields_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, _internal_metadata_), @@ -101,6 +105,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets[] PROTOBU PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, _impl_._oneof_case_[0]), ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) ::_pbi::kInvalidFieldOffsetTag, ::_pbi::kInvalidFieldOffsetTag, ::_pbi::kInvalidFieldOffsetTag, @@ -114,13 +120,15 @@ const uint32_t TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets[] PROTOBU ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ListValue, _impl_.values_), }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, 8, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse)}, - { 10, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Struct)}, - { 17, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Value)}, - { 30, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ListValue)}, + { 0, 10, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse)}, + { 12, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Struct)}, + { 21, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Value)}, + { 36, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ListValue)}, }; static const ::_pb::Message* const file_default_instances[] = { diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index 728a004389..09b1b176d6 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -47,6 +47,8 @@ const uint32_t TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets[] PROT ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Timestamp, _impl_.seconds_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Timestamp, _impl_.nanos_), }; diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index e29bbb83a1..4f76508f72 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -119,6 +119,8 @@ const uint32_t TableStruct_google_2fprotobuf_2ftype_2eproto::offsets[] PROTOBUF_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.fields_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.oneofs_), @@ -131,6 +133,8 @@ const uint32_t TableStruct_google_2fprotobuf_2ftype_2eproto::offsets[] PROTOBUF_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.kind_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.cardinality_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.number_), @@ -147,6 +151,8 @@ const uint32_t TableStruct_google_2fprotobuf_2ftype_2eproto::offsets[] PROTOBUF_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.enumvalue_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.options_), @@ -158,6 +164,8 @@ const uint32_t TableStruct_google_2fprotobuf_2ftype_2eproto::offsets[] PROTOBUF_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, _impl_.number_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, _impl_.options_), @@ -167,15 +175,17 @@ const uint32_t TableStruct_google_2fprotobuf_2ftype_2eproto::offsets[] PROTOBUF_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Option, _impl_.name_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Option, _impl_.value_), }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Type)}, - { 12, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Field)}, - { 28, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Enum)}, - { 39, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValue)}, - { 48, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Option)}, + { 14, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Field)}, + { 32, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Enum)}, + { 45, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValue)}, + { 56, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Option)}, }; static const ::_pb::Message* const file_default_instances[] = { diff --git a/src/google/protobuf/util/time_util_test.cc b/src/google/protobuf/util/time_util_test.cc index a741218c90..d17e096089 100644 --- a/src/google/protobuf/util/time_util_test.cc +++ b/src/google/protobuf/util/time_util_test.cc @@ -415,6 +415,7 @@ TEST(TimeUtilTest, IsTimestampValid) { } #ifdef PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet. +#ifndef NDEBUG TEST(TimeUtilTest, DurationBounds) { Duration overflow; @@ -426,38 +427,38 @@ TEST(TimeUtilTest, DurationBounds) { Duration underflow_nanos; underflow_nanos.set_nanos(TimeUtil::kDurationMinNanoseconds - 1); - EXPECT_DEBUG_DEATH({ TimeUtil::SecondsToDuration(overflow.seconds()); }, + EXPECT_DEATH({ TimeUtil::SecondsToDuration(overflow.seconds()); }, "Duration seconds"); - EXPECT_DEBUG_DEATH({ TimeUtil::SecondsToDuration(underflow.seconds()); }, + EXPECT_DEATH({ TimeUtil::SecondsToDuration(underflow.seconds()); }, "Duration seconds"); - EXPECT_DEBUG_DEATH( + EXPECT_DEATH( { TimeUtil::MinutesToDuration(overflow.seconds() / 60 + 1); }, "Duration minutes"); - EXPECT_DEBUG_DEATH( + EXPECT_DEATH( { TimeUtil::MinutesToDuration(underflow.seconds() / 60 - 1); }, "Duration minutes"); - EXPECT_DEBUG_DEATH( + EXPECT_DEATH( { TimeUtil::HoursToDuration(overflow.seconds() / 60 + 1); }, "Duration hours"); - EXPECT_DEBUG_DEATH( + EXPECT_DEATH( { TimeUtil::HoursToDuration(underflow.seconds() / 60 - 1); }, "Duration hours"); - EXPECT_DEBUG_DEATH({ TimeUtil::DurationToNanoseconds(overflow); }, + EXPECT_DEATH({ TimeUtil::DurationToNanoseconds(overflow); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::DurationToNanoseconds(underflow); }, + EXPECT_DEATH({ TimeUtil::DurationToNanoseconds(underflow); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::DurationToNanoseconds(overflow_nanos); }, + EXPECT_DEATH({ TimeUtil::DurationToNanoseconds(overflow_nanos); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::DurationToNanoseconds(underflow_nanos); }, + EXPECT_DEATH({ TimeUtil::DurationToNanoseconds(underflow_nanos); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::DurationToSeconds(overflow); }, + EXPECT_DEATH({ TimeUtil::DurationToSeconds(overflow); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::DurationToSeconds(underflow); }, + EXPECT_DEATH({ TimeUtil::DurationToSeconds(underflow); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::DurationToSeconds(overflow_nanos); }, + EXPECT_DEATH({ TimeUtil::DurationToSeconds(overflow_nanos); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::DurationToSeconds(underflow_nanos); }, + EXPECT_DEATH({ TimeUtil::DurationToSeconds(underflow_nanos); }, "outside of the valid range"); } @@ -471,43 +472,43 @@ TEST(TimeUtilTest, TimestampBounds) { Timestamp underflow_nanos; underflow_nanos.set_nanos(TimeUtil::kDurationMinNanoseconds - 1); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToNanoseconds(overflow); }, + EXPECT_DEATH({ TimeUtil::TimestampToNanoseconds(overflow); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToNanoseconds(underflow); }, + EXPECT_DEATH({ TimeUtil::TimestampToNanoseconds(underflow); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToNanoseconds(overflow_nanos); }, + EXPECT_DEATH({ TimeUtil::TimestampToNanoseconds(overflow_nanos); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToNanoseconds(underflow_nanos); }, + EXPECT_DEATH({ TimeUtil::TimestampToNanoseconds(underflow_nanos); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToMicroseconds(overflow); }, + EXPECT_DEATH({ TimeUtil::TimestampToMicroseconds(overflow); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToMicroseconds(underflow); }, + EXPECT_DEATH({ TimeUtil::TimestampToMicroseconds(underflow); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToMicroseconds(overflow_nanos); }, + EXPECT_DEATH({ TimeUtil::TimestampToMicroseconds(overflow_nanos); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToMicroseconds(underflow_nanos); }, + EXPECT_DEATH({ TimeUtil::TimestampToMicroseconds(underflow_nanos); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToMilliseconds(overflow); }, + EXPECT_DEATH({ TimeUtil::TimestampToMilliseconds(overflow); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToMilliseconds(underflow); }, + EXPECT_DEATH({ TimeUtil::TimestampToMilliseconds(underflow); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToMilliseconds(overflow_nanos); }, + EXPECT_DEATH({ TimeUtil::TimestampToMilliseconds(overflow_nanos); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToMilliseconds(underflow_nanos); }, + EXPECT_DEATH({ TimeUtil::TimestampToMilliseconds(underflow_nanos); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToSeconds(overflow); }, + EXPECT_DEATH({ TimeUtil::TimestampToSeconds(overflow); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToSeconds(underflow); }, + EXPECT_DEATH({ TimeUtil::TimestampToSeconds(underflow); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToSeconds(overflow_nanos); }, + EXPECT_DEATH({ TimeUtil::TimestampToSeconds(overflow_nanos); }, "outside of the valid range"); - EXPECT_DEBUG_DEATH({ TimeUtil::TimestampToSeconds(underflow_nanos); }, + EXPECT_DEATH({ TimeUtil::TimestampToSeconds(underflow_nanos); }, "outside of the valid range"); } - +#endif // !NDEBUG #endif // PROTOBUF_HAS_DEATH_TEST } // namespace diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc index 40ba60a492..7f78690e6e 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc @@ -150,6 +150,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets[] PROTO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DoubleValue, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FloatValue, _internal_metadata_), @@ -157,6 +159,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets[] PROTO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FloatValue, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int64Value, _internal_metadata_), @@ -164,6 +168,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets[] PROTO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int64Value, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt64Value, _internal_metadata_), @@ -171,6 +177,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets[] PROTO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt64Value, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int32Value, _internal_metadata_), @@ -178,6 +186,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets[] PROTO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int32Value, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt32Value, _internal_metadata_), @@ -185,6 +195,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets[] PROTO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt32Value, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BoolValue, _internal_metadata_), @@ -192,6 +204,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets[] PROTO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BoolValue, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::StringValue, _internal_metadata_), @@ -199,6 +213,8 @@ const uint32_t TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets[] PROTO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::StringValue, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BytesValue, _internal_metadata_), @@ -206,18 +222,20 @@ const uint32_t TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets[] PROTO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BytesValue, _impl_.value_), }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DoubleValue)}, - { 7, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FloatValue)}, - { 14, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Int64Value)}, - { 21, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UInt64Value)}, - { 28, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Int32Value)}, - { 35, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UInt32Value)}, - { 42, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::BoolValue)}, - { 49, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::StringValue)}, - { 56, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::BytesValue)}, + { 9, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FloatValue)}, + { 18, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Int64Value)}, + { 27, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UInt64Value)}, + { 36, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Int32Value)}, + { 45, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UInt32Value)}, + { 54, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::BoolValue)}, + { 63, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::StringValue)}, + { 72, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::BytesValue)}, }; static const ::_pb::Message* const file_default_instances[] = {