Automated rollback of commit 1cf2901a1d.

PiperOrigin-RevId: 509929075
pull/11942/head
Mike Kruskal 2 years ago committed by Copybara-Service
parent 4b1cd0dbe3
commit fc272edc0a
  1. 7
      src/google/protobuf/generated_message_reflection.cc
  2. 8
      src/google/protobuf/wire_format.cc

@ -1339,8 +1339,8 @@ void Reflection::ClearField(Message* message,
case FieldDescriptor::CPPTYPE_MESSAGE:
if (schema_.HasBitIndex(field) == static_cast<uint32_t>(-1)) {
// Some fields do not have hasbits and we need to set a message
// field to nullptr in order to indicate its un-presence.
// Proto3 does not have has-bits and we need to set a message field
// to nullptr in order to indicate its un-presence.
if (message->GetArenaForAllocation() == nullptr) {
delete *MutableRaw<Message*>(message, field);
}
@ -1554,7 +1554,8 @@ void CheckInOrder(const FieldDescriptor* field, uint32_t* last) {
namespace internal {
bool CreateUnknownEnumValues(const FieldDescriptor* field) {
return field->enum_type() == nullptr || !field->enum_type()->is_closed();
bool open_enum = false;
return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 || open_enum;
}
} // namespace internal
using internal::CreateUnknownEnumValues;

@ -412,7 +412,7 @@ bool WireFormat::ParseAndMergeMessageSetField(uint32_t field_number,
}
static bool StrictUtf8Check(const FieldDescriptor* field) {
return field->requires_utf8_validation();
return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3;
}
bool WireFormat::ParseAndMergeField(
@ -484,7 +484,8 @@ bool WireFormat::ParseAndMergeField(
if (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(
input, &value))
return false;
if (!field->enum_type()->is_closed()) {
if (message->GetDescriptor()->file()->syntax() ==
FileDescriptor::SYNTAX_PROTO3) {
message_reflection->AddEnumValue(message, field, value);
} else {
const EnumValueDescriptor* enum_value =
@ -868,7 +869,8 @@ const char* WireFormat::_InternalParseAndMergeField(
auto rep_enum =
reflection->MutableRepeatedFieldInternal<int>(msg, field);
bool open_enum = false;
if (!field->enum_type()->is_closed() || open_enum) {
if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ||
open_enum) {
ptr = internal::PackedEnumParser(rep_enum, ptr, ctx);
} else {
return ctx->ReadPackedVarint(

Loading…
Cancel
Save