When not in custom vtable mode, strip the initializer code via preprocessor.

The noop code was causing big .proto files to time out even though it had no
effect in the compilation after optimizing.

We tried avoiding the extra complexity of preprocessor checks on each use, but
it seems necessary for now.

PiperOrigin-RevId: 642691974
pull/17116/head
Protobuf Team Bot 6 months ago committed by Copybara-Service
parent 1f984453e8
commit 4dffa939d2
  1. 22
      src/google/protobuf/arena_unittest.cc
  2. 31
      src/google/protobuf/compiler/cpp/message.cc
  3. 13
      src/google/protobuf/compiler/java/java_features.pb.cc
  4. 68
      src/google/protobuf/compiler/plugin.pb.cc
  5. 13
      src/google/protobuf/cpp_features.pb.cc
  6. 553
      src/google/protobuf/descriptor.pb.cc
  7. 3
      src/google/protobuf/map_entry.h
  8. 3
      src/google/protobuf/map_test.inc
  9. 3
      src/google/protobuf/message.h
  10. 22
      src/google/protobuf/message_lite.h

@ -182,20 +182,21 @@ void TestCtorAndDtorTraits(std::vector<absl::string_view> def,
: std::conditional_t<arena_ctor, ArenaCtorBase, EmptyBase<0>>,
std::conditional_t<arena_dtor, ArenaDtorBase, EmptyBase<1>>,
Message {
TraitsProber() : Message(nullptr) { actions.push_back("()"); }
TraitsProber(const TraitsProber&) : Message(nullptr) {
TraitsProber() : Message(nullptr, nullptr) { actions.push_back("()"); }
TraitsProber(const TraitsProber&) : Message(nullptr, nullptr) {
actions.push_back("(const T&)");
}
explicit TraitsProber(int) : Message(nullptr) {
explicit TraitsProber(int) : Message(nullptr, nullptr) {
actions.push_back("(int)");
}
explicit TraitsProber(Arena* arena) : Message(nullptr) {
explicit TraitsProber(Arena* arena) : Message(nullptr, nullptr) {
actions.push_back("(Arena)");
}
TraitsProber(Arena* arena, const TraitsProber&) : Message(nullptr) {
TraitsProber(Arena* arena, const TraitsProber&)
: Message(nullptr, nullptr) {
actions.push_back("(Arena, const T&)");
}
TraitsProber(Arena* arena, int) : Message(nullptr) {
TraitsProber(Arena* arena, int) : Message(nullptr, nullptr) {
actions.push_back("(Arena, int)");
}
~TraitsProber() { actions.push_back("~()"); }
@ -519,9 +520,12 @@ class DispatcherTestProto : public Message {
using InternalArenaConstructable_ = void;
using DestructorSkippable_ = void;
// For the test below to construct.
explicit DispatcherTestProto(absl::in_place_t) : Message(nullptr) {}
explicit DispatcherTestProto(Arena*) : Message(nullptr) { ABSL_LOG(FATAL); }
DispatcherTestProto(Arena*, const DispatcherTestProto&) : Message(nullptr) {
explicit DispatcherTestProto(absl::in_place_t) : Message(nullptr, nullptr) {}
explicit DispatcherTestProto(Arena*) : Message(nullptr, nullptr) {
ABSL_LOG(FATAL);
}
DispatcherTestProto(Arena*, const DispatcherTestProto&)
: Message(nullptr, nullptr) {
ABSL_LOG(FATAL);
}
DispatcherTestProto* New(Arena*) const PROTOBUF_FINAL { ABSL_LOG(FATAL); }

@ -2143,9 +2143,14 @@ void MessageGenerator::GenerateClassMethods(io::Printer* p) {
}},
{"class_data", [&] { GenerateClassData(p); }}},
R"cc(
#if defined(PROTOBUF_CUSTOM_VTABLE)
$classname$::$classname$() : SuperType(_class_data_.base()) {}
$classname$::$classname$(::$proto_ns$::Arena* arena)
: SuperType(arena, _class_data_.base()) {}
#else // PROTOBUF_CUSTOM_VTABLE
$classname$::$classname$() : SuperType() {}
$classname$::$classname$(::$proto_ns$::Arena* arena) : SuperType(arena) {}
#endif // PROTOBUF_CUSTOM_VTABLE
$annotate_accessors$;
$verify$;
$class_data$;
@ -2859,7 +2864,12 @@ void MessageGenerator::GenerateConstexprConstructor(io::Printer* p) {
//~ gcc 12 (warning in gcc 13).
template <typename>
$constexpr$ $classname$::$classname$(::_pbi::ConstantInitialized)
: $base$(_class_data_.base()) {}
#if defined(PROTOBUF_CUSTOM_VTABLE)
: $base$(_class_data_.base()){}
#else // PROTOBUF_CUSTOM_VTABLE
: $base$() {
}
#endif // PROTOBUF_CUSTOM_VTABLE
)cc");
return;
}
@ -2881,8 +2891,13 @@ void MessageGenerator::GenerateConstexprConstructor(io::Printer* p) {
R"cc(
template <typename>
$constexpr$ $classname$::$classname$(::_pbi::ConstantInitialized)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: $superclass$(_class_data_.base()),
_impl_(::_pbi::ConstantInitialized()) {}
#else // PROTOBUF_CUSTOM_VTABLE
: $superclass$(),
#endif // PROTOBUF_CUSTOM_VTABLE
_impl_(::_pbi::ConstantInitialized()) {
}
)cc");
}
@ -3145,7 +3160,11 @@ void MessageGenerator::GenerateArenaEnabledCopyConstructor(io::Printer* p) {
::$proto_ns$::Arena* arena,
//~ force alignment
const $classname$& from)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: $superclass$(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: $superclass$(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
$classname$* const _this = this;
(void)_this;
_internal_metadata_.MergeFrom<$unknown_fields_type$>(
@ -3191,7 +3210,11 @@ void MessageGenerator::GenerateStructors(io::Printer* p) {
},
R"cc(
$classname$::$classname$(::$proto_ns$::Arena* arena)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: $superclass$(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: $superclass$(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
$ctor_body$;
// @@protoc_insertion_point(arena_constructor:$full_name$)
}
@ -3733,9 +3756,11 @@ void MessageGenerator::GenerateClassData(io::Printer* p) {
$on_demand_register_arena_dtor$,
$is_initialized$,
&$classname$::MergeImpl,
#if defined(PROTOBUF_CUSTOM_VTABLE)
$superclass$::GetDeleteImpl<$classname$>(),
$superclass$::GetNewImpl<$classname$>(),
$custom_vtable_methods$,
#endif // PROTOBUF_CUSTOM_VTABLE
PROTOBUF_FIELD_OFFSET($classname$, $cached_size$),
false,
},
@ -3768,9 +3793,11 @@ void MessageGenerator::GenerateClassData(io::Printer* p) {
$on_demand_register_arena_dtor$,
$is_initialized$,
&$classname$::MergeImpl,
#if defined(PROTOBUF_CUSTOM_VTABLE)
$superclass$::GetDeleteImpl<$classname$>(),
$superclass$::GetNewImpl<$classname$>(),
$custom_vtable_methods$,
#endif // PROTOBUF_CUSTOM_VTABLE
PROTOBUF_FIELD_OFFSET($classname$, $cached_size$),
true,
},

@ -33,8 +33,13 @@ inline constexpr JavaFeatures::Impl_::Impl_(
template <typename>
PROTOBUF_CONSTEXPR JavaFeatures::JavaFeatures(::_pbi::ConstantInitialized)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(_class_data_.base()),
_impl_(::_pbi::ConstantInitialized()) {}
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(),
#endif // PROTOBUF_CUSTOM_VTABLE
_impl_(::_pbi::ConstantInitialized()) {
}
struct JavaFeaturesDefaultTypeInternal {
PROTOBUF_CONSTEXPR JavaFeaturesDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~JavaFeaturesDefaultTypeInternal() {}
@ -151,7 +156,11 @@ class JavaFeatures::_Internal {
};
JavaFeatures::JavaFeatures(::google::protobuf::Arena* arena)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:pb.JavaFeatures)
}
@ -193,11 +202,13 @@ const ::google::protobuf::MessageLite::ClassDataFull
nullptr, // OnDemandRegisterArenaDtor
nullptr, // IsInitialized
&JavaFeatures::MergeImpl,
#if defined(PROTOBUF_CUSTOM_VTABLE)
::google::protobuf::Message::GetDeleteImpl<JavaFeatures>(),
::google::protobuf::Message::GetNewImpl<JavaFeatures>(),
::google::protobuf::Message::GetClearImpl<JavaFeatures>(),
::google::protobuf::Message::GetByteSizeLongImpl<JavaFeatures>(),
::google::protobuf::Message::GetSerializeImpl<JavaFeatures>(),
#endif // PROTOBUF_CUSTOM_VTABLE
PROTOBUF_FIELD_OFFSET(JavaFeatures, _impl_._cached_size_),
false,
},

@ -39,8 +39,13 @@ inline constexpr Version::Impl_::Impl_(
template <typename>
PROTOBUF_CONSTEXPR Version::Version(::_pbi::ConstantInitialized)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(_class_data_.base()),
_impl_(::_pbi::ConstantInitialized()) {}
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(),
#endif // PROTOBUF_CUSTOM_VTABLE
_impl_(::_pbi::ConstantInitialized()) {
}
struct VersionDefaultTypeInternal {
PROTOBUF_CONSTEXPR VersionDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~VersionDefaultTypeInternal() {}
@ -68,8 +73,13 @@ inline constexpr CodeGeneratorResponse_File::Impl_::Impl_(
template <typename>
PROTOBUF_CONSTEXPR CodeGeneratorResponse_File::CodeGeneratorResponse_File(::_pbi::ConstantInitialized)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(_class_data_.base()),
_impl_(::_pbi::ConstantInitialized()) {}
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(),
#endif // PROTOBUF_CUSTOM_VTABLE
_impl_(::_pbi::ConstantInitialized()) {
}
struct CodeGeneratorResponse_FileDefaultTypeInternal {
PROTOBUF_CONSTEXPR CodeGeneratorResponse_FileDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~CodeGeneratorResponse_FileDefaultTypeInternal() {}
@ -94,8 +104,13 @@ inline constexpr CodeGeneratorResponse::Impl_::Impl_(
template <typename>
PROTOBUF_CONSTEXPR CodeGeneratorResponse::CodeGeneratorResponse(::_pbi::ConstantInitialized)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(_class_data_.base()),
_impl_(::_pbi::ConstantInitialized()) {}
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(),
#endif // PROTOBUF_CUSTOM_VTABLE
_impl_(::_pbi::ConstantInitialized()) {
}
struct CodeGeneratorResponseDefaultTypeInternal {
PROTOBUF_CONSTEXPR CodeGeneratorResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~CodeGeneratorResponseDefaultTypeInternal() {}
@ -120,8 +135,13 @@ inline constexpr CodeGeneratorRequest::Impl_::Impl_(
template <typename>
PROTOBUF_CONSTEXPR CodeGeneratorRequest::CodeGeneratorRequest(::_pbi::ConstantInitialized)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(_class_data_.base()),
_impl_(::_pbi::ConstantInitialized()) {}
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(),
#endif // PROTOBUF_CUSTOM_VTABLE
_impl_(::_pbi::ConstantInitialized()) {
}
struct CodeGeneratorRequestDefaultTypeInternal {
PROTOBUF_CONSTEXPR CodeGeneratorRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~CodeGeneratorRequestDefaultTypeInternal() {}
@ -307,7 +327,11 @@ class Version::_Internal {
};
Version::Version(::google::protobuf::Arena* arena)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.Version)
}
@ -321,7 +345,11 @@ inline PROTOBUF_NDEBUG_INLINE Version::Impl_::Impl_(
Version::Version(
::google::protobuf::Arena* arena,
const Version& from)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
Version* const _this = this;
(void)_this;
_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(
@ -372,11 +400,13 @@ const ::google::protobuf::MessageLite::ClassDataFull
nullptr, // OnDemandRegisterArenaDtor
nullptr, // IsInitialized
&Version::MergeImpl,
#if defined(PROTOBUF_CUSTOM_VTABLE)
::google::protobuf::Message::GetDeleteImpl<Version>(),
::google::protobuf::Message::GetNewImpl<Version>(),
::google::protobuf::Message::GetClearImpl<Version>(),
::google::protobuf::Message::GetByteSizeLongImpl<Version>(),
::google::protobuf::Message::GetSerializeImpl<Version>(),
#endif // PROTOBUF_CUSTOM_VTABLE
PROTOBUF_FIELD_OFFSET(Version, _impl_._cached_size_),
false,
},
@ -618,7 +648,11 @@ void CodeGeneratorRequest::clear_source_file_descriptors() {
_impl_.source_file_descriptors_.Clear();
}
CodeGeneratorRequest::CodeGeneratorRequest(::google::protobuf::Arena* arena)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorRequest)
}
@ -635,7 +669,11 @@ inline PROTOBUF_NDEBUG_INLINE CodeGeneratorRequest::Impl_::Impl_(
CodeGeneratorRequest::CodeGeneratorRequest(
::google::protobuf::Arena* arena,
const CodeGeneratorRequest& from)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
CodeGeneratorRequest* const _this = this;
(void)_this;
_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(
@ -682,11 +720,13 @@ const ::google::protobuf::MessageLite::ClassDataFull
nullptr, // OnDemandRegisterArenaDtor
CodeGeneratorRequest::IsInitializedImpl,
&CodeGeneratorRequest::MergeImpl,
#if defined(PROTOBUF_CUSTOM_VTABLE)
::google::protobuf::Message::GetDeleteImpl<CodeGeneratorRequest>(),
::google::protobuf::Message::GetNewImpl<CodeGeneratorRequest>(),
::google::protobuf::Message::GetClearImpl<CodeGeneratorRequest>(),
::google::protobuf::Message::GetByteSizeLongImpl<CodeGeneratorRequest>(),
::google::protobuf::Message::GetSerializeImpl<CodeGeneratorRequest>(),
#endif // PROTOBUF_CUSTOM_VTABLE
PROTOBUF_FIELD_OFFSET(CodeGeneratorRequest, _impl_._cached_size_),
false,
},
@ -981,7 +1021,11 @@ void CodeGeneratorResponse_File::clear_generated_code_info() {
_impl_._has_bits_[0] &= ~0x00000008u;
}
CodeGeneratorResponse_File::CodeGeneratorResponse_File(::google::protobuf::Arena* arena)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorResponse.File)
}
@ -997,7 +1041,11 @@ inline PROTOBUF_NDEBUG_INLINE CodeGeneratorResponse_File::Impl_::Impl_(
CodeGeneratorResponse_File::CodeGeneratorResponse_File(
::google::protobuf::Arena* arena,
const CodeGeneratorResponse_File& from)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
CodeGeneratorResponse_File* const _this = this;
(void)_this;
_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(
@ -1045,11 +1093,13 @@ const ::google::protobuf::MessageLite::ClassDataFull
nullptr, // OnDemandRegisterArenaDtor
nullptr, // IsInitialized
&CodeGeneratorResponse_File::MergeImpl,
#if defined(PROTOBUF_CUSTOM_VTABLE)
::google::protobuf::Message::GetDeleteImpl<CodeGeneratorResponse_File>(),
::google::protobuf::Message::GetNewImpl<CodeGeneratorResponse_File>(),
::google::protobuf::Message::GetClearImpl<CodeGeneratorResponse_File>(),
::google::protobuf::Message::GetByteSizeLongImpl<CodeGeneratorResponse_File>(),
::google::protobuf::Message::GetSerializeImpl<CodeGeneratorResponse_File>(),
#endif // PROTOBUF_CUSTOM_VTABLE
PROTOBUF_FIELD_OFFSET(CodeGeneratorResponse_File, _impl_._cached_size_),
false,
},
@ -1297,7 +1347,11 @@ class CodeGeneratorResponse::_Internal {
};
CodeGeneratorResponse::CodeGeneratorResponse(::google::protobuf::Arena* arena)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorResponse)
}
@ -1312,7 +1366,11 @@ inline PROTOBUF_NDEBUG_INLINE CodeGeneratorResponse::Impl_::Impl_(
CodeGeneratorResponse::CodeGeneratorResponse(
::google::protobuf::Arena* arena,
const CodeGeneratorResponse& from)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
CodeGeneratorResponse* const _this = this;
(void)_this;
_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(
@ -1364,11 +1422,13 @@ const ::google::protobuf::MessageLite::ClassDataFull
nullptr, // OnDemandRegisterArenaDtor
nullptr, // IsInitialized
&CodeGeneratorResponse::MergeImpl,
#if defined(PROTOBUF_CUSTOM_VTABLE)
::google::protobuf::Message::GetDeleteImpl<CodeGeneratorResponse>(),
::google::protobuf::Message::GetNewImpl<CodeGeneratorResponse>(),
::google::protobuf::Message::GetClearImpl<CodeGeneratorResponse>(),
::google::protobuf::Message::GetByteSizeLongImpl<CodeGeneratorResponse>(),
::google::protobuf::Message::GetSerializeImpl<CodeGeneratorResponse>(),
#endif // PROTOBUF_CUSTOM_VTABLE
PROTOBUF_FIELD_OFFSET(CodeGeneratorResponse, _impl_._cached_size_),
false,
},

@ -33,8 +33,13 @@ inline constexpr CppFeatures::Impl_::Impl_(
template <typename>
PROTOBUF_CONSTEXPR CppFeatures::CppFeatures(::_pbi::ConstantInitialized)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(_class_data_.base()),
_impl_(::_pbi::ConstantInitialized()) {}
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(),
#endif // PROTOBUF_CUSTOM_VTABLE
_impl_(::_pbi::ConstantInitialized()) {
}
struct CppFeaturesDefaultTypeInternal {
PROTOBUF_CONSTEXPR CppFeaturesDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~CppFeaturesDefaultTypeInternal() {}
@ -146,7 +151,11 @@ class CppFeatures::_Internal {
};
CppFeatures::CppFeatures(::google::protobuf::Arena* arena)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::Message(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::Message(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:pb.CppFeatures)
}
@ -188,11 +197,13 @@ const ::google::protobuf::MessageLite::ClassDataFull
nullptr, // OnDemandRegisterArenaDtor
nullptr, // IsInitialized
&CppFeatures::MergeImpl,
#if defined(PROTOBUF_CUSTOM_VTABLE)
::google::protobuf::Message::GetDeleteImpl<CppFeatures>(),
::google::protobuf::Message::GetNewImpl<CppFeatures>(),
::google::protobuf::Message::GetClearImpl<CppFeatures>(),
::google::protobuf::Message::GetByteSizeLongImpl<CppFeatures>(),
::google::protobuf::Message::GetSerializeImpl<CppFeatures>(),
#endif // PROTOBUF_CUSTOM_VTABLE
PROTOBUF_FIELD_OFFSET(CppFeatures, _impl_._cached_size_),
false,
},

File diff suppressed because it is too large Load Diff

@ -85,6 +85,9 @@ class MapEntry : public Message {
using ValueOnMemory = typename ValueTypeHandler::TypeOnMemory;
public:
#if !defined(PROTOBUF_CUSTOM_VTABLE)
constexpr MapEntry() {}
#endif // PROTOBUF_CUSTOM_VTABLE
using Message::Message;
MapEntry(const MapEntry&) = delete;

@ -2324,7 +2324,8 @@ class MyMapEntry
internal::WireFormatLite::TYPE_INT32,
internal::WireFormatLite::TYPE_INT32> {
public:
constexpr MyMapEntry() : MyMapEntry::MapEntry(nullptr) {}
constexpr MyMapEntry()
: MyMapEntry::MapEntry(static_cast<ClassData*>(nullptr)) {}
MyMapEntry(Arena* arena) : MyMapEntry::MapEntry(arena, nullptr) {}
const ClassData* GetClassData() const { ABSL_CHECK(false); }
static bool ValidateKey(void*) { return true; }

@ -370,6 +370,9 @@ class PROTOBUF_EXPORT Message : public MessageLite {
const Reflection* GetReflection() const { return GetMetadata().reflection; }
protected:
#if !defined(PROTOBUF_CUSTOM_VTABLE)
constexpr Message() {}
#endif // PROTOBUF_CUSTOM_VTABLE
using MessageLite::MessageLite;
// Get a struct containing the metadata for the Message, which is used in turn

@ -650,6 +650,26 @@ class PROTOBUF_EXPORT MessageLite {
// char[] just beyond the ClassData.
bool is_lite;
// In normal mode we have the small constructor to avoid the cost in
// codegen.
#if !defined(PROTOBUF_CUSTOM_VTABLE)
constexpr ClassData(const internal::TcParseTableBase* tc_table,
void (*on_demand_register_arena_dtor)(MessageLite&,
Arena&),
bool (*is_initialized)(const MessageLite&),
void (*merge_to_from)(MessageLite& to,
const MessageLite& from_msg),
uint32_t cached_size_offset, bool is_lite)
: tc_table(tc_table),
on_demand_register_arena_dtor(on_demand_register_arena_dtor),
is_initialized(is_initialized),
merge_to_from(merge_to_from),
cached_size_offset(cached_size_offset),
is_lite(is_lite) {}
#endif // !PROTOBUF_CUSTOM_VTABLE
// But we always provide the full constructor even in normal mode to make
// helper code simpler.
constexpr ClassData(
const internal::TcParseTableBase* tc_table,
void (*on_demand_register_arena_dtor)(MessageLite&, Arena&),
@ -726,6 +746,8 @@ class PROTOBUF_EXPORT MessageLite {
explicit MessageLite(Arena* arena, const ClassData* data)
: _internal_metadata_(arena), _class_data_(data) {}
#else // PROTOBUF_CUSTOM_VTABLE
constexpr MessageLite() {}
explicit MessageLite(Arena* arena) : _internal_metadata_(arena) {}
explicit constexpr MessageLite(const ClassData*) {}
explicit MessageLite(Arena* arena, const ClassData*)
: _internal_metadata_(arena) {}

Loading…
Cancel
Save