Remove custom HasPreservingUnknownEnumSemantics method. C++ descriptor now provides is_closed() on EnumDescriptor, use that instead. PiperOrigin-RevId: 485307512
diff --git a/src/google/protobuf/compiler/objectivec/enum.cc b/src/google/protobuf/compiler/objectivec/enum.cc index 650d04d..286739f 100644 --- a/src/google/protobuf/compiler/objectivec/enum.cc +++ b/src/google/protobuf/compiler/objectivec/enum.cc
@@ -126,7 +126,7 @@ name_); printer->Indent(); - if (HasPreservingUnknownEnumSemantics(descriptor_->file())) { + if (!descriptor_->is_closed()) { // Include the unknown value. printer->Print( // clang-format off
diff --git a/src/google/protobuf/compiler/objectivec/enum_field.cc b/src/google/protobuf/compiler/objectivec/enum_field.cc index db4b35f..8372bce 100644 --- a/src/google/protobuf/compiler/objectivec/enum_field.cc +++ b/src/google/protobuf/compiler/objectivec/enum_field.cc
@@ -76,7 +76,7 @@ void EnumFieldGenerator::GenerateCFunctionDeclarations( io::Printer* printer) const { - if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) { + if (descriptor_->enum_type()->is_closed()) { return; } @@ -100,7 +100,9 @@ void EnumFieldGenerator::GenerateCFunctionImplementations( io::Printer* printer) const { - if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) return; + if (descriptor_->enum_type()->is_closed()) { + return; + } // clang-format off printer->Print(
diff --git a/src/google/protobuf/compiler/objectivec/helpers.h b/src/google/protobuf/compiler/objectivec/helpers.h index 56808a6..76766b2 100644 --- a/src/google/protobuf/compiler/objectivec/helpers.h +++ b/src/google/protobuf/compiler/objectivec/helpers.h
@@ -44,10 +44,6 @@ namespace compiler { namespace objectivec { -inline bool HasPreservingUnknownEnumSemantics(const FileDescriptor* file) { - return file->syntax() == FileDescriptor::SYNTAX_PROTO3; -} - // Escape C++ trigraphs by escaping question marks to "\?". std::string EscapeTrigraphs(absl::string_view to_escape);