Skip to content

Commit

Permalink
Automated rollback of commit 1cf2901.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 509929075
  • Loading branch information
mkruskal-google authored and copybara-github committed Feb 15, 2023
1 parent 4b1cd0d commit fc272ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/google/protobuf/generated_message_reflection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions src/google/protobuf/wire_format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit fc272ed

Please sign in to comment.