diff --git a/CHANGES.txt b/CHANGES.txt index 6491e2bf23f5c..13d5cbb8519c1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -87,6 +87,7 @@ Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) * Remove GetPointer() and explicit nullptr defaults. * add proto_h flag for speeding up large builds * Add missing overload for reference wrapped fields. + * Add MergedDescriptorDatabase::FindAllFileNames() 2022-01-28 version 3.19.4 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index e1d129f7033ed..05f51a05f68f6 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -27,8 +27,8 @@ namespace _pbi = _pb::internal; PROTOBUF_NAMESPACE_OPEN constexpr Any::Any( ::_pbi::ConstantInitialized) - : type_url_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + : type_url_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , _any_metadata_(&type_url_, &value_){} struct AnyDefaultTypeInternal { constexpr AnyDefaultTypeInternal() diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index f2baf912611a0..441f3aafb52ce 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -26,8 +26,8 @@ constexpr Api::Api( : methods_() , options_() , mixins_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , version_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , version_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , source_context_(nullptr) , syntax_(0) {} @@ -43,9 +43,9 @@ PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORIT constexpr Method::Method( ::_pbi::ConstantInitialized) : options_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , request_type_url_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , response_type_url_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , request_type_url_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , response_type_url_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , request_streaming_(false) , response_streaming_(false) , syntax_(0) @@ -61,8 +61,8 @@ struct MethodDefaultTypeInternal { PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodDefaultTypeInternal _Method_default_instance_; constexpr Mixin::Mixin( ::_pbi::ConstantInitialized) - : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , root_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){} + : name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , root_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}){} struct MixinDefaultTypeInternal { constexpr MixinDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index a9f000d35e227..b8d31fec015b0 100644 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h @@ -228,8 +228,8 @@ static_assert(std::is_trivial::value, // held, and the mutable and ownership invariants for each type. struct PROTOBUF_EXPORT ArenaStringPtr { ArenaStringPtr() = default; - explicit constexpr ArenaStringPtr( - ExplicitlyConstructedArenaString* default_value) + constexpr ArenaStringPtr(ExplicitlyConstructedArenaString* default_value, + ConstantInitialized) : tagged_ptr_(default_value) {} // Called from generated code / reflection runtime only. Resets value to point diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc index fa28c629c5830..49bacb776ea4f 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -530,9 +530,11 @@ void StringFieldGenerator::GenerateConstinitInitializer( return; } if (descriptor_->default_value_string().empty()) { - format("$name$_(&::$proto_ns$::internal::fixed_address_empty_string)"); + format( + "$name$_(&::_pbi::fixed_address_empty_string, " + "::_pbi::ConstantInitialized{})"); } else { - format("$name$_(nullptr)"); + format("$name$_(nullptr, ::_pbi::ConstantInitialized{})"); } } diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index e9fdbe8b036a0..37c1a54a48a03 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -24,7 +24,7 @@ PROTOBUF_NAMESPACE_OPEN namespace compiler { constexpr Version::Version( ::_pbi::ConstantInitialized) - : suffix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + : suffix_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , major_(0) , minor_(0) , patch_(0){} @@ -41,7 +41,7 @@ constexpr CodeGeneratorRequest::CodeGeneratorRequest( ::_pbi::ConstantInitialized) : file_to_generate_() , proto_file_() - , parameter_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , parameter_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , compiler_version_(nullptr){} struct CodeGeneratorRequestDefaultTypeInternal { constexpr CodeGeneratorRequestDefaultTypeInternal() @@ -54,9 +54,9 @@ struct CodeGeneratorRequestDefaultTypeInternal { PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; constexpr CodeGeneratorResponse_File::CodeGeneratorResponse_File( ::_pbi::ConstantInitialized) - : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , insertion_point_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , content_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + : name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , insertion_point_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , content_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , generated_code_info_(nullptr){} struct CodeGeneratorResponse_FileDefaultTypeInternal { constexpr CodeGeneratorResponse_FileDefaultTypeInternal() @@ -70,7 +70,7 @@ PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORIT constexpr CodeGeneratorResponse::CodeGeneratorResponse( ::_pbi::ConstantInitialized) : file_() - , error_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , error_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , supported_features_(uint64_t{0u}){} struct CodeGeneratorResponseDefaultTypeInternal { constexpr CodeGeneratorResponseDefaultTypeInternal() diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index b17b5843d5f80..7fed5405a7cc7 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -42,9 +42,9 @@ constexpr FileDescriptorProto::FileDescriptorProto( , extension_() , public_dependency_() , weak_dependency_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , syntax_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , package_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , syntax_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , options_(nullptr) , source_code_info_(nullptr){} struct FileDescriptorProtoDefaultTypeInternal { @@ -93,7 +93,7 @@ constexpr DescriptorProto::DescriptorProto( , oneof_decl_() , reserved_range_() , reserved_name_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , options_(nullptr){} struct DescriptorProtoDefaultTypeInternal { constexpr DescriptorProtoDefaultTypeInternal() @@ -118,11 +118,11 @@ struct ExtensionRangeOptionsDefaultTypeInternal { PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_; constexpr FieldDescriptorProto::FieldDescriptorProto( ::_pbi::ConstantInitialized) - : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , extendee_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , type_name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , default_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , json_name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + : name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , extendee_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , type_name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , default_value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , json_name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , options_(nullptr) , number_(0) , oneof_index_(0) @@ -142,7 +142,7 @@ struct FieldDescriptorProtoDefaultTypeInternal { PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; constexpr OneofDescriptorProto::OneofDescriptorProto( ::_pbi::ConstantInitialized) - : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + : name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , options_(nullptr){} struct OneofDescriptorProtoDefaultTypeInternal { constexpr OneofDescriptorProtoDefaultTypeInternal() @@ -171,7 +171,7 @@ constexpr EnumDescriptorProto::EnumDescriptorProto( : value_() , reserved_range_() , reserved_name_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , options_(nullptr){} struct EnumDescriptorProtoDefaultTypeInternal { constexpr EnumDescriptorProtoDefaultTypeInternal() @@ -184,7 +184,7 @@ struct EnumDescriptorProtoDefaultTypeInternal { PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; constexpr EnumValueDescriptorProto::EnumValueDescriptorProto( ::_pbi::ConstantInitialized) - : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + : name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , options_(nullptr) , number_(0){} struct EnumValueDescriptorProtoDefaultTypeInternal { @@ -199,7 +199,7 @@ PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORIT constexpr ServiceDescriptorProto::ServiceDescriptorProto( ::_pbi::ConstantInitialized) : method_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , options_(nullptr){} struct ServiceDescriptorProtoDefaultTypeInternal { constexpr ServiceDescriptorProtoDefaultTypeInternal() @@ -212,9 +212,9 @@ struct ServiceDescriptorProtoDefaultTypeInternal { PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; constexpr MethodDescriptorProto::MethodDescriptorProto( ::_pbi::ConstantInitialized) - : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , input_type_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , output_type_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + : name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , input_type_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , output_type_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , options_(nullptr) , client_streaming_(false) , server_streaming_(false){} @@ -230,16 +230,16 @@ PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORIT constexpr FileOptions::FileOptions( ::_pbi::ConstantInitialized) : uninterpreted_option_() - , java_package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , java_outer_classname_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , go_package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , objc_class_prefix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , csharp_namespace_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , swift_prefix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , php_class_prefix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , php_namespace_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , php_metadata_namespace_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , ruby_package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , java_package_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , java_outer_classname_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , go_package_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , objc_class_prefix_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , csharp_namespace_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , swift_prefix_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , php_class_prefix_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , php_namespace_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , php_metadata_namespace_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , ruby_package_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , java_multiple_files_(false) , java_generate_equals_and_hash_(false) , java_string_check_utf8_(false) @@ -366,7 +366,7 @@ struct MethodOptionsDefaultTypeInternal { PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; constexpr UninterpretedOption_NamePart::UninterpretedOption_NamePart( ::_pbi::ConstantInitialized) - : name_part_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + : name_part_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , is_extension_(false){} struct UninterpretedOption_NamePartDefaultTypeInternal { constexpr UninterpretedOption_NamePartDefaultTypeInternal() @@ -380,9 +380,9 @@ PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORIT constexpr UninterpretedOption::UninterpretedOption( ::_pbi::ConstantInitialized) : name_() - , identifier_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , string_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , aggregate_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , identifier_value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , string_value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , aggregate_value_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , positive_int_value_(uint64_t{0u}) , negative_int_value_(int64_t{0}) , double_value_(0){} @@ -402,8 +402,8 @@ constexpr SourceCodeInfo_Location::SourceCodeInfo_Location( , span_() , _span_cached_byte_size_(0) , leading_detached_comments_() - , leading_comments_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , trailing_comments_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){} + , leading_comments_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) + , trailing_comments_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}){} struct SourceCodeInfo_LocationDefaultTypeInternal { constexpr SourceCodeInfo_LocationDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} @@ -429,7 +429,7 @@ constexpr GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation( ::_pbi::ConstantInitialized) : path_() , _path_cached_byte_size_(0) - , source_file_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , source_file_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , begin_(0) , end_(0){} struct GeneratedCodeInfo_AnnotationDefaultTypeInternal { diff --git a/src/google/protobuf/descriptor_database.cc b/src/google/protobuf/descriptor_database.cc index be1afcb57c264..203000d67d0be 100644 --- a/src/google/protobuf/descriptor_database.cc +++ b/src/google/protobuf/descriptor_database.cc @@ -34,6 +34,7 @@ #include +#include #include #include @@ -1027,5 +1028,21 @@ bool MergedDescriptorDatabase::FindAllExtensionNumbers( } +bool MergedDescriptorDatabase::FindAllFileNames( + std::vector* output) { + bool implemented = false; + for (DescriptorDatabase* source : sources_) { + std::vector source_output; + if (source->FindAllFileNames(&source_output)) { + output->reserve(output->size() + source_output.size()); + for (auto& source : source_output) { + output->push_back(std::move(source)); + } + implemented = true; + } + } + return implemented; +} + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/descriptor_database.h b/src/google/protobuf/descriptor_database.h index 665e4ed8c971e..f4f06bbfa67d8 100644 --- a/src/google/protobuf/descriptor_database.h +++ b/src/google/protobuf/descriptor_database.h @@ -381,6 +381,10 @@ class PROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase { std::vector* output) override; + // This function is best-effort. Returns true if at least one underlying + // DescriptorDatabase returns true. + bool FindAllFileNames(std::vector* output) override; + private: std::vector sources_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MergedDescriptorDatabase); diff --git a/src/google/protobuf/descriptor_database_unittest.cc b/src/google/protobuf/descriptor_database_unittest.cc index 9e5cf5d8ce589..f58244808a1f8 100644 --- a/src/google/protobuf/descriptor_database_unittest.cc +++ b/src/google/protobuf/descriptor_database_unittest.cc @@ -799,6 +799,13 @@ TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) { } } +TEST_F(MergedDescriptorDatabaseTest, FindAllFileNames) { + std::vector files; + EXPECT_TRUE(forward_merged_.FindAllFileNames(&files)); + EXPECT_THAT(files, ::testing::UnorderedElementsAre("foo.proto", "bar.proto", + "baz.proto", "baz.proto")); +} + } // anonymous namespace } // namespace protobuf diff --git a/src/google/protobuf/map_field.h b/src/google/protobuf/map_field.h index 5bf54d4d4255a..2d8129d157340 100644 --- a/src/google/protobuf/map_field.h +++ b/src/google/protobuf/map_field.h @@ -338,7 +338,8 @@ class PROTOBUF_EXPORT MapFieldBase { // It uses a linker initialized mutex, so it is not compatible with regular // runtime instances. // Except in MSVC, where we can't have a constinit mutex. - explicit constexpr MapFieldBase(ConstantInitialized) + // NOLINTNEXTLINE(google-explicit-constructor) + constexpr MapFieldBase(ConstantInitialized) : arena_(nullptr), repeated_field_(nullptr), mutex_(GOOGLE_PROTOBUF_LINKER_INITIALIZED), @@ -497,7 +498,8 @@ class TypeDefinedMapFieldBase : public MapFieldBase { // This constructor is for constant initialized global instances. // It uses a linker initialized mutex, so it is not compatible with regular // runtime instances. - explicit constexpr TypeDefinedMapFieldBase(ConstantInitialized tag) + // NOLINTNEXTLINE(google-explicit-constructor) + constexpr TypeDefinedMapFieldBase(ConstantInitialized tag) : MapFieldBase(tag) {} explicit TypeDefinedMapFieldBase(Arena* arena) : MapFieldBase(arena) {} @@ -567,7 +569,8 @@ class MapField : public TypeDefinedMapFieldBase { // This constructor is for constant initialized global instances. // It uses a linker initialized mutex, so it is not compatible with regular // runtime instances. - explicit constexpr MapField(ConstantInitialized tag) + // NOLINTNEXTLINE(google-explicit-constructor) + constexpr MapField(ConstantInitialized tag) : TypeDefinedMapFieldBase(tag), impl_() {} explicit MapField(Arena* arena) : TypeDefinedMapFieldBase(arena), impl_(arena) {} diff --git a/src/google/protobuf/map_type_handler.h b/src/google/protobuf/map_type_handler.h index a04408050d1ab..c210c63db519a 100644 --- a/src/google/protobuf/map_type_handler.h +++ b/src/google/protobuf/map_type_handler.h @@ -591,7 +591,8 @@ inline bool MapTypeHandler::IsInitialized( constexpr auto \ MapTypeHandler::Constinit() \ ->TypeOnMemory { \ - return TypeOnMemory(&internal::fixed_address_empty_string); \ + return TypeOnMemory(&internal::fixed_address_empty_string, \ + ConstantInitialized{}); \ } \ template \ inline typename MapTypeHandler