diff --git a/src/google/protobuf/compiler/cpp/field.cc b/src/google/protobuf/compiler/cpp/field.cc index c333a5818b..c01c9019ac 100644 --- a/src/google/protobuf/compiler/cpp/field.cc +++ b/src/google/protobuf/compiler/cpp/field.cc @@ -87,8 +87,8 @@ std::vector FieldVars(const FieldDescriptor* field, const Options& opts) { {"deprecated_attr", DeprecatedAttribute(opts, field)}, Sub("WeakDescriptorSelfPin", UsingImplicitWeakDescriptor(field->file(), opts) - ? absl::StrCat( - StrongReferenceToType(field->containing_type(), opts), ";") + ? absl::StrCat("::", ProtobufNamespace(opts), + "::internal::StrongReference(default_instance());") : "") .WithSuffix(";"), }; 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 3a3c25f1a6..ad3706fbe3 100644 --- a/src/google/protobuf/compiler/cpp/field_generators/message_field.cc +++ b/src/google/protobuf/compiler/cpp/field_generators/message_field.cc @@ -72,8 +72,9 @@ std::vector Vars(const FieldDescriptor* field, const Options& opts, {"_weak", weak ? "_weak" : ""}, Sub("StrongRef", !weak ? "" - : absl::StrCat( - StrongReferenceToType(field->message_type(), opts), ";")) + : absl::Substitute("::google::protobuf::internal::StrongReference(" + "reinterpret_cast($1));\n", + qualified_type, default_ref)) .WithSuffix(";"), }; } diff --git a/src/google/protobuf/compiler/cpp/file.cc b/src/google/protobuf/compiler/cpp/file.cc index 80ea05577a..909901dc46 100644 --- a/src/google/protobuf/compiler/cpp/file.cc +++ b/src/google/protobuf/compiler/cpp/file.cc @@ -1264,10 +1264,13 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* p) { if (UsingImplicitWeakDescriptor(file_, options_)) { for (auto* pinned : GetMessagesToPinGloballyForWeakDescriptors(file_)) { static_initializers_.push_back([this, pinned](auto* p) { - p->Emit({{"pin", StrongReferenceToType(pinned, options_)}}, - R"cc( - $pin$, - )cc"); + p->Emit( + { + {"default", QualifiedDefaultInstanceName(pinned, options_)}, + }, + R"cc( + ::_pbi::StrongPointer(&$default$), + )cc"); }); } } diff --git a/src/google/protobuf/compiler/cpp/helpers.cc b/src/google/protobuf/compiler/cpp/helpers.cc index 7c792a7898..ec96b94962 100644 --- a/src/google/protobuf/compiler/cpp/helpers.cc +++ b/src/google/protobuf/compiler/cpp/helpers.cc @@ -1489,13 +1489,6 @@ bool UsingImplicitWeakDescriptor(const FileDescriptor* file, !options.opensource_runtime; } -std::string StrongReferenceToType(const Descriptor* desc, - const Options& options) { - const auto name = QualifiedDefaultInstanceName(desc, options); - return absl::StrFormat("::%s::internal::StrongPointer()", - ProtobufNamespace(options), name, name); -} - std::string WeakDescriptorDataSection(absl::string_view prefix, const Descriptor* descriptor, int index_in_file_messages, diff --git a/src/google/protobuf/compiler/cpp/helpers.h b/src/google/protobuf/compiler/cpp/helpers.h index de5f8beb65..996b7654a3 100644 --- a/src/google/protobuf/compiler/cpp/helpers.h +++ b/src/google/protobuf/compiler/cpp/helpers.h @@ -786,11 +786,7 @@ void ListAllTypesForServices(const FileDescriptor* fd, bool UsingImplicitWeakDescriptor(const FileDescriptor* file, const Options& options); -// Generates a strong reference to the message in `desc`, as a statement. -std::string StrongReferenceToType(const Descriptor* desc, - const Options& options); - -// Generates the section name to be used for a data object when using implicit +// Generate the section name to be used for a data object when using implicit // weak descriptors. The prefix determines the kind of object and the section it // will be merged into afterwards. // See `UsingImplicitWeakDescriptor` above. diff --git a/src/google/protobuf/compiler/cpp/message.cc b/src/google/protobuf/compiler/cpp/message.cc index 463f31a37f..7d76580144 100644 --- a/src/google/protobuf/compiler/cpp/message.cc +++ b/src/google/protobuf/compiler/cpp/message.cc @@ -489,7 +489,8 @@ std::vector ClassVars(const Descriptor* desc, Options opts) { Sub("WeakDescriptorSelfPin", UsingImplicitWeakDescriptor(desc->file(), opts) - ? absl::StrCat(StrongReferenceToType(desc, opts), ";") + ? absl::StrCat("::", ProtobufNamespace(opts), + "::internal::StrongReference(default_instance());") : "") .WithSuffix(";"), }; @@ -2028,10 +2029,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) { $decl_oneof_has$; $decl_data$; $post_loop_handler$; - - static constexpr const void* _raw_default_instance_ = - &_$classname$_default_instance_; - friend class ::$proto_ns$::MessageLite; friend class ::$proto_ns$::Arena; template @@ -3529,10 +3526,9 @@ void MessageGenerator::GenerateClassData(io::Printer* p) { const auto pin_weak_descriptor = [&] { if (!UsingImplicitWeakDescriptor(descriptor_->file(), options_)) return; - p->Emit({{"pin", StrongReferenceToType(descriptor_, options_)}}, - R"cc( - $pin$; - )cc"); + p->Emit(R"cc( + ::_pbi::StrongPointer(&_$classname$_default_instance_); + )cc"); // For CODE_SIZE types, we need to pin the submessages too. // SPEED types will pin them via the TcParse table automatically. @@ -3540,11 +3536,11 @@ void MessageGenerator::GenerateClassData(io::Printer* p) { for (int i = 0; i < descriptor_->field_count(); ++i) { auto* field = descriptor_->field(i); if (field->type() != field->TYPE_MESSAGE) continue; - p->Emit( - {{"pin", StrongReferenceToType(field->message_type(), options_)}}, - R"cc( - $pin$; - )cc"); + p->Emit({{"sub_default_name", QualifiedDefaultInstanceName( + field->message_type(), options_)}}, + R"cc( + ::_pbi::StrongPointer(&$sub_default_name$); + )cc"); } }; p->Emit( diff --git a/src/google/protobuf/compiler/java/java_features.pb.h b/src/google/protobuf/compiler/java/java_features.pb.h index 0a23849dd5..7639b46a36 100644 --- a/src/google/protobuf/compiler/java/java_features.pb.h +++ b/src/google/protobuf/compiler/java/java_features.pb.h @@ -275,10 +275,6 @@ class PROTOC_EXPORT JavaFeatures final : public ::google::protobuf::Message 1, 2, 1, 0, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_JavaFeatures_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 3e05bc9c24..9004a78476 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -302,10 +302,6 @@ class PROTOC_EXPORT Version final : public ::google::protobuf::Message 2, 4, 0, 47, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_Version_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -535,10 +531,6 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : public ::google::protobuf 2, 4, 1, 86, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_CodeGeneratorResponse_File_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -791,10 +783,6 @@ class PROTOC_EXPORT CodeGeneratorResponse final : public ::google::protobuf::Mes 3, 5, 1, 60, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_CodeGeneratorResponse_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -1054,10 +1042,6 @@ class PROTOC_EXPORT CodeGeneratorRequest final : public ::google::protobuf::Mess 3, 5, 3, 79, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_CodeGeneratorRequest_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template diff --git a/src/google/protobuf/cpp_features.pb.h b/src/google/protobuf/cpp_features.pb.h index 457cafe689..c66cb833ef 100644 --- a/src/google/protobuf/cpp_features.pb.h +++ b/src/google/protobuf/cpp_features.pb.h @@ -277,10 +277,6 @@ class PROTOBUF_EXPORT CppFeatures final : public ::google::protobuf::Message 1, 2, 1, 0, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_CppFeatures_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 1a7b918f4d..a4b08a0f19 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -860,10 +860,6 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final : public ::google::prot 1, 2, 0, 62, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_UninterpretedOption_NamePart_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -1124,10 +1120,6 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final : public ::google::protobuf: 3, 5, 0, 106, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_SourceCodeInfo_Location_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -1383,10 +1375,6 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : public ::google::prot 3, 5, 1, 64, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_GeneratedCodeInfo_Annotation_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -1578,10 +1566,6 @@ class PROTOBUF_EXPORT FieldOptions_EditionDefault final : public ::google::proto 1, 2, 1, 57, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_FieldOptions_EditionDefault_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -2111,10 +2095,6 @@ class PROTOBUF_EXPORT FeatureSet final : public ::google::protobuf::Message 3, 6, 6, 0, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_FeatureSet_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -2349,10 +2329,6 @@ class PROTOBUF_EXPORT ExtensionRangeOptions_Declaration final : public ::google: 3, 5, 0, 71, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_ExtensionRangeOptions_Declaration_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -2537,10 +2513,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : public ::goo 1, 2, 0, 0, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_EnumDescriptorProto_EnumReservedRange_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -2722,10 +2694,6 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : public ::google::pro 1, 2, 0, 0, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_DescriptorProto_ReservedRange_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -2992,10 +2960,6 @@ class PROTOBUF_EXPORT UninterpretedOption final : public ::google::protobuf::Mes 3, 7, 1, 75, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_UninterpretedOption_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -3177,10 +3141,6 @@ class PROTOBUF_EXPORT SourceCodeInfo final : public ::google::protobuf::Message 0, 1, 1, 0, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_SourceCodeInfo_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -3355,10 +3315,6 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : public ::google::protobuf::Messa 0, 1, 1, 0, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_GeneratedCodeInfo_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -3542,10 +3498,6 @@ class PROTOBUF_EXPORT FeatureSetDefaults_FeatureSetEditionDefault final : public 1, 2, 2, 0, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_FeatureSetDefaults_FeatureSetEditionDefault_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -3928,10 +3880,6 @@ class PROTOBUF_EXPORT ServiceOptions final : public ::google::protobuf::Message 2, 3, 2, 0, 12> _table_; - - static constexpr const void* _raw_default_instance_ = - &_ServiceOptions_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -4304,10 +4252,6 @@ class PROTOBUF_EXPORT OneofOptions final : public ::google::protobuf::Message 2, 2, 2, 0, 7> _table_; - - static constexpr const void* _raw_default_instance_ = - &_OneofOptions_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -4723,10 +4667,6 @@ class PROTOBUF_EXPORT MethodOptions final : public ::google::protobuf::Message 3, 4, 3, 0, 12> _table_; - - static constexpr const void* _raw_default_instance_ = - &_MethodOptions_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -5160,10 +5100,6 @@ class PROTOBUF_EXPORT MessageOptions final : public ::google::protobuf::Message 3, 7, 2, 0, 7> _table_; - - static constexpr const void* _raw_default_instance_ = - &_MessageOptions_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -5848,10 +5784,6 @@ class PROTOBUF_EXPORT FileOptions final : public ::google::protobuf::Message 5, 21, 3, 202, 12> _table_; - - static constexpr const void* _raw_default_instance_ = - &_FileOptions_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -6476,10 +6408,6 @@ class PROTOBUF_EXPORT FieldOptions final : public ::google::protobuf::Message 4, 13, 7, 0, 7> _table_; - - static constexpr const void* _raw_default_instance_ = - &_FieldOptions_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -6692,10 +6620,6 @@ class PROTOBUF_EXPORT FeatureSetDefaults final : public ::google::protobuf::Mess 1, 3, 3, 0, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_FeatureSetDefaults_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -7117,10 +7041,6 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : public ::google::protobuf::M 3, 4, 4, 0, 12> _table_; - - static constexpr const void* _raw_default_instance_ = - &_ExtensionRangeOptions_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -7518,10 +7438,6 @@ class PROTOBUF_EXPORT EnumValueOptions final : public ::google::protobuf::Messag 3, 4, 2, 0, 7> _table_; - - static constexpr const void* _raw_default_instance_ = - &_EnumValueOptions_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -7931,10 +7847,6 @@ class PROTOBUF_EXPORT EnumOptions final : public ::google::protobuf::Message 3, 5, 2, 0, 7> _table_; - - static constexpr const void* _raw_default_instance_ = - &_EnumOptions_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -8130,10 +8042,6 @@ class PROTOBUF_EXPORT OneofDescriptorProto final : public ::google::protobuf::Me 1, 2, 1, 49, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_OneofDescriptorProto_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -8385,10 +8293,6 @@ class PROTOBUF_EXPORT MethodDescriptorProto final : public ::google::protobuf::M 3, 6, 1, 71, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_MethodDescriptorProto_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -8771,10 +8675,6 @@ class PROTOBUF_EXPORT FieldDescriptorProto final : public ::google::protobuf::Me 4, 11, 3, 96, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_FieldDescriptorProto_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -8987,10 +8887,6 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final : public ::google::protobuf 2, 3, 1, 53, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_EnumValueDescriptorProto_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -9189,10 +9085,6 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : public ::google::pr 2, 3, 1, 0, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_DescriptorProto_ExtensionRange_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -9403,10 +9295,6 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final : public ::google::protobuf:: 2, 3, 2, 51, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_ServiceDescriptorProto_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -9665,10 +9553,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto final : public ::google::protobuf::Mes 3, 5, 3, 61, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_EnumDescriptorProto_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -10020,10 +9904,6 @@ class PROTOBUF_EXPORT DescriptorProto final : public ::google::protobuf::Message 4, 10, 8, 65, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_DescriptorProto_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -10426,10 +10306,6 @@ class PROTOBUF_EXPORT FileDescriptorProto final : public ::google::protobuf::Mes 4, 13, 7, 79, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_FileDescriptorProto_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template @@ -10616,10 +10492,6 @@ class PROTOBUF_EXPORT FileDescriptorSet final : public ::google::protobuf::Messa 0, 1, 1, 0, 2> _table_; - - static constexpr const void* _raw_default_instance_ = - &_FileDescriptorSet_default_instance_; - friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; template diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc index 0c79714560..e33d22fc4b 100644 --- a/src/google/protobuf/generated_message_util.cc +++ b/src/google/protobuf/generated_message_util.cc @@ -69,8 +69,7 @@ extern const char __start_pb_defaults; extern const char __stop_pb_defaults; } static void InitWeakDefaults() { - // force link the dummy entry. - StrongPointer(); + StrongPointer(&dummy_weak_default); // force link the dummy entry. // We don't know the size of each object, but we know the layout of the tail. // It contains a WeakDescriptorDefaultTail object. // As such, we iterate the section backwards. diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index 525dedf1aa..aa46aa9b79 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -1412,7 +1412,7 @@ const T* DynamicCastToGenerated(const Message* from) { (void)unused; #if PROTOBUF_RTTI - internal::StrongReferenceToType(); + internal::StrongReference(T::default_instance()); return dynamic_cast(from); #else bool ok = from != nullptr && @@ -1451,7 +1451,7 @@ T& DynamicCastToGenerated(Message& from) { // instance T and T is a type derived from base Message class. template const T* DownCastToGenerated(const Message* from) { - internal::StrongReferenceToType(); + internal::StrongReference(T::default_instance()); ABSL_DCHECK(DynamicCastToGenerated(from) == from) << "Cannot downcast " << from->GetTypeName() << " to " << T::default_instance().GetTypeName(); @@ -1499,7 +1499,7 @@ T& DownCastToGenerated(Message& from) { // of loops (on x86-64 it compiles into two "mov" instructions). template void LinkMessageReflection() { - internal::StrongReferenceToType(); + internal::StrongReference(T::default_instance); } // ============================================================================= diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index e7cdf17330..1f5a6b7c88 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -675,26 +675,6 @@ class PROTOBUF_EXPORT MessageLite { void LogInitializationErrorMessage() const; bool MergeFromImpl(io::CodedInputStream* input, ParseFlags parse_flags); - - template - static constexpr auto GetStrongPointerForTypeImpl(int) { - return ptr; - } - template - static constexpr auto GetStrongPointerForTypeImpl(char) { - return &T::default_instance; - } - // Return a pointer we can use to make a strong reference to a type. - // Ideally, this is a pointer to the default instance. - // If we can't get that, then we use a pointer to the `default_instance` - // function. The latter always works but pins the function artificially into - // the binary so we avoid it. - template - static constexpr auto GetStrongPointerForType() { - return GetStrongPointerForTypeImpl(0); - } - template - friend void internal::StrongReferenceToType(); }; namespace internal { diff --git a/src/google/protobuf/port.h b/src/google/protobuf/port.h index 84ce175886..2c332f4481 100644 --- a/src/google/protobuf/port.h +++ b/src/google/protobuf/port.h @@ -39,7 +39,7 @@ class MessageLite; namespace internal { template -inline PROTOBUF_ALWAYS_INLINE void StrongPointer(T* var) { +void StrongPointer(T* var) { #if defined(__GNUC__) asm("" : : "r"(var)); #else @@ -48,32 +48,6 @@ inline PROTOBUF_ALWAYS_INLINE void StrongPointer(T* var) { #endif } -// Similar to the overload above, but optimized for constant inputs. -template -inline PROTOBUF_ALWAYS_INLINE void StrongPointer() { -#if defined(__x86_64__) && defined(__linux__) && !defined(__APPLE__) && \ - defined(__clang__) && __clang_major__ >= 19 && \ - !defined(PROTOBUF_INTERNAL_TEMPORARY_STRONG_POINTER_OPT_OUT) - // This injects a relocation in the code path without having to run code, but - // we can only do it with a newer clang. - asm(".reloc ., BFD_RELOC_NONE, %p0" ::"Ws"(ptr)); -#else - StrongPointer(ptr); -#endif -} - -template -inline PROTOBUF_ALWAYS_INLINE void StrongReferenceToType() { - constexpr auto ptr = T::template GetStrongPointerForType(); -#if defined(__cpp_nontype_template_args) && \ - __cpp_nontype_template_args >= 201411L - // We can only use `ptr` as a template parameter since C++17 - return StrongPointer(); -#else - return StrongPointer(ptr); -#endif -} - // See comments on `AllocateAtLeast` for information on size returning new. struct SizedPtr {