Remove code for handling global dtors
default instances are no longer deleted.
PiperOrigin-RevId: 573867065
diff --git a/src/google/protobuf/compiler/cpp/field_generators/message_field.cc b/src/google/protobuf/compiler/cpp/field_generators/message_field.cc
index 8ceb1e0..a7c7935 100644
--- a/src/google/protobuf/compiler/cpp/field_generators/message_field.cc
+++ b/src/google/protobuf/compiler/cpp/field_generators/message_field.cc
@@ -431,19 +431,15 @@
}
void SingularMessage::GenerateDestructorCode(io::Printer* p) const {
- if (opts_->opensource_runtime) {
- // TODO Remove this when we don't need to destruct default
- // instances. In google3 a default instance will never get deleted so we
- // don't need to worry about that but in opensource protobuf default
- // instances are deleted in shutdown process and we need to take special
- // care when handling them.
- p->Emit("if (this != internal_default_instance()) ");
- }
if (should_split()) {
- p->Emit("delete $cached_split_ptr$->$name$_;\n");
- return;
+ p->Emit(R"cc(
+ delete $cached_split_ptr$->$name$_;
+ )cc");
+ } else {
+ p->Emit(R"cc(
+ delete $field_$;
+ )cc");
}
- p->Emit("delete $field_$;\n");
}
using internal::cpp::HasHasbit;
diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc
index 1b18575..684bdd3 100644
--- a/src/google/protobuf/compiler/plugin.pb.cc
+++ b/src/google/protobuf/compiler/plugin.pb.cc
@@ -689,7 +689,7 @@
inline void CodeGeneratorRequest::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
_impl_.parameter_.Destroy();
- if (this != internal_default_instance()) delete _impl_.compiler_version_;
+ delete _impl_.compiler_version_;
_impl_.~Impl_();
}
@@ -1037,7 +1037,7 @@
_impl_.name_.Destroy();
_impl_.insertion_point_.Destroy();
_impl_.content_.Destroy();
- if (this != internal_default_instance()) delete _impl_.generated_code_info_;
+ delete _impl_.generated_code_info_;
_impl_.~Impl_();
}
diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc
index 140eadd..8e880a7 100644
--- a/src/google/protobuf/descriptor.pb.cc
+++ b/src/google/protobuf/descriptor.pb.cc
@@ -2640,8 +2640,8 @@
_impl_.name_.Destroy();
_impl_.package_.Destroy();
_impl_.syntax_.Destroy();
- if (this != internal_default_instance()) delete _impl_.options_;
- if (this != internal_default_instance()) delete _impl_.source_code_info_;
+ delete _impl_.options_;
+ delete _impl_.source_code_info_;
_impl_.~Impl_();
}
@@ -3208,7 +3208,7 @@
}
inline void DescriptorProto_ExtensionRange::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
- if (this != internal_default_instance()) delete _impl_.options_;
+ delete _impl_.options_;
_impl_.~Impl_();
}
@@ -3725,7 +3725,7 @@
inline void DescriptorProto::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
_impl_.name_.Destroy();
- if (this != internal_default_instance()) delete _impl_.options_;
+ delete _impl_.options_;
_impl_.~Impl_();
}
@@ -4547,7 +4547,7 @@
}
inline void ExtensionRangeOptions::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
- if (this != internal_default_instance()) delete _impl_.features_;
+ delete _impl_.features_;
_impl_.~Impl_();
}
@@ -4920,7 +4920,7 @@
_impl_.type_name_.Destroy();
_impl_.default_value_.Destroy();
_impl_.json_name_.Destroy();
- if (this != internal_default_instance()) delete _impl_.options_;
+ delete _impl_.options_;
_impl_.~Impl_();
}
@@ -5421,7 +5421,7 @@
inline void OneofDescriptorProto::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
_impl_.name_.Destroy();
- if (this != internal_default_instance()) delete _impl_.options_;
+ delete _impl_.options_;
_impl_.~Impl_();
}
@@ -5906,7 +5906,7 @@
inline void EnumDescriptorProto::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
_impl_.name_.Destroy();
- if (this != internal_default_instance()) delete _impl_.options_;
+ delete _impl_.options_;
_impl_.~Impl_();
}
@@ -6248,7 +6248,7 @@
inline void EnumValueDescriptorProto::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
_impl_.name_.Destroy();
- if (this != internal_default_instance()) delete _impl_.options_;
+ delete _impl_.options_;
_impl_.~Impl_();
}
@@ -6534,7 +6534,7 @@
inline void ServiceDescriptorProto::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
_impl_.name_.Destroy();
- if (this != internal_default_instance()) delete _impl_.options_;
+ delete _impl_.options_;
_impl_.~Impl_();
}
@@ -6846,7 +6846,7 @@
_impl_.name_.Destroy();
_impl_.input_type_.Destroy();
_impl_.output_type_.Destroy();
- if (this != internal_default_instance()) delete _impl_.options_;
+ delete _impl_.options_;
_impl_.~Impl_();
}
@@ -7312,7 +7312,7 @@
_impl_.php_namespace_.Destroy();
_impl_.php_metadata_namespace_.Destroy();
_impl_.ruby_package_.Destroy();
- if (this != internal_default_instance()) delete _impl_.features_;
+ delete _impl_.features_;
_impl_.~Impl_();
}
@@ -8128,7 +8128,7 @@
}
inline void MessageOptions::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
- if (this != internal_default_instance()) delete _impl_.features_;
+ delete _impl_.features_;
_impl_.~Impl_();
}
@@ -8781,7 +8781,7 @@
}
inline void FieldOptions::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
- if (this != internal_default_instance()) delete _impl_.features_;
+ delete _impl_.features_;
_impl_.~Impl_();
}
@@ -9308,7 +9308,7 @@
}
inline void OneofOptions::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
- if (this != internal_default_instance()) delete _impl_.features_;
+ delete _impl_.features_;
_impl_.~Impl_();
}
@@ -9585,7 +9585,7 @@
}
inline void EnumOptions::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
- if (this != internal_default_instance()) delete _impl_.features_;
+ delete _impl_.features_;
_impl_.~Impl_();
}
@@ -9935,7 +9935,7 @@
}
inline void EnumValueOptions::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
- if (this != internal_default_instance()) delete _impl_.features_;
+ delete _impl_.features_;
_impl_.~Impl_();
}
@@ -10258,7 +10258,7 @@
}
inline void ServiceOptions::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
- if (this != internal_default_instance()) delete _impl_.features_;
+ delete _impl_.features_;
_impl_.~Impl_();
}
@@ -10565,7 +10565,7 @@
}
inline void MethodOptions::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
- if (this != internal_default_instance()) delete _impl_.features_;
+ delete _impl_.features_;
_impl_.~Impl_();
}
@@ -11900,7 +11900,7 @@
}
inline void FeatureSetDefaults_FeatureSetEditionDefault::SharedDtor() {
ABSL_DCHECK(GetArena() == nullptr);
- if (this != internal_default_instance()) delete _impl_.features_;
+ delete _impl_.features_;
_impl_.~Impl_();
}