Incremental migration of message.cc to Emit

PiperOrigin-RevId: 531238423
pull/12764/head
Matt Kulukundis 2 years ago committed by Copybara-Service
parent ef39d27a0f
commit fc01c2ec56
  1. 17
      src/google/protobuf/compiler/cpp/field.cc
  2. 31
      src/google/protobuf/compiler/cpp/field_generators/cord_field.cc
  3. 21
      src/google/protobuf/compiler/cpp/field_generators/enum_field.cc
  4. 18
      src/google/protobuf/compiler/cpp/field_generators/map_field.cc
  5. 14
      src/google/protobuf/compiler/cpp/field_generators/message_field.cc
  6. 28
      src/google/protobuf/compiler/cpp/field_generators/primitive_field.cc
  7. 27
      src/google/protobuf/compiler/cpp/field_generators/string_field.cc
  8. 437
      src/google/protobuf/compiler/cpp/message.cc
  9. 166
      src/google/protobuf/compiler/plugin.pb.cc
  10. 1378
      src/google/protobuf/descriptor.pb.cc

@ -39,7 +39,6 @@
#include <string>
#include <vector>
#include "absl/container/flat_hash_map.h"
#include "absl/log/absl_check.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
@ -112,18 +111,22 @@ std::vector<Sub> FieldVars(const FieldDescriptor* field, const Options& opts) {
}
void FieldGeneratorBase::GenerateAggregateInitializer(io::Printer* p) const {
Formatter format(p, variables_);
if (ShouldSplit(descriptor_, options_)) {
format("decltype(Impl_::Split::$name$_){arena}");
return;
p->Emit(R"cc(
decltype(Impl_::Split::$name$_){arena},
)cc");
} else {
p->Emit(R"cc(
decltype($field$){arena},
)cc");
}
format("decltype($field$){arena}");
}
void FieldGeneratorBase::GenerateConstexprAggregateInitializer(
io::Printer* p) const {
Formatter format(p, variables_);
format("/*decltype($field$)*/{}");
p->Emit(R"cc(
/*decltype($field$)*/ {},
)cc");
}
void FieldGeneratorBase::GenerateCopyAggregateInitializer(

@ -263,26 +263,31 @@ void CordFieldGenerator::GenerateByteSize(io::Printer* printer) const {
}
void CordFieldGenerator::GenerateConstexprAggregateInitializer(
io::Printer* printer) const {
Formatter format(printer, variables_);
io::Printer* p) const {
if (descriptor_->default_value_string().empty()) {
format("/*decltype($field$)*/{}");
p->Emit(R"cc(
/*decltype($field$)*/ {},
)cc");
} else {
format(
"/*decltype($field$)*/{::absl::strings_internal::MakeStringConstant(\n"
" $classname$::Impl_::$1$_default_$name$_func_{})}",
ShouldSplit(descriptor_, options_) ? "Split::" : "");
p->Emit(
{{"Split", ShouldSplit(descriptor_, options_) ? "Split::" : ""}},
R"cc(
/*decltype($field$)*/ {::absl::strings_internal::MakeStringConstant(
$classname$::Impl_::$Split$_default_$name$_func_{})},
)cc");
}
}
void CordFieldGenerator::GenerateAggregateInitializer(
io::Printer* printer) const {
Formatter format(printer, variables_);
void CordFieldGenerator::GenerateAggregateInitializer(io::Printer* p) const {
if (ShouldSplit(descriptor_, options_)) {
format("decltype(Impl_::Split::$name$_){}");
return;
p->Emit(R"cc(
decltype(Impl_::Split::$name$_){},
)cc");
} else {
p->Emit(R"cc(
decltype($field$){},
)cc");
}
format("decltype($field$){}");
}
// ===================================================================

@ -140,21 +140,20 @@ class SingularEnum : public FieldGeneratorBase {
void GenerateConstexprAggregateInitializer(io::Printer* p) const override {
p->Emit(R"cc(
/*decltype($field_$)*/ $kDefault$
/*decltype($field_$)*/ $kDefault$,
)cc");
}
void GenerateAggregateInitializer(io::Printer* p) const override {
if (ShouldSplit(descriptor_, options_)) {
p->Emit(R"cc(
decltype(Impl_::Split::$name$_) { $kDefault$ }
decltype(Impl_::Split::$name$_){$kDefault$},
)cc");
} else {
p->Emit(R"cc(
decltype($field_$){$kDefault$},
)cc");
return;
}
p->Emit(R"cc(
decltype($field_$) { $kDefault$ }
)cc");
}
void GenerateCopyAggregateInitializer(io::Printer* p) const override {
@ -284,24 +283,24 @@ class RepeatedEnum : public FieldGeneratorBase {
void GenerateConstexprAggregateInitializer(io::Printer* p) const override {
p->Emit(R"cc(
/*decltype($field_$)*/ {}
/*decltype($field_$)*/ {},
)cc");
if (has_cached_size_) {
p->Emit(R"cc(
, /*decltype($cached_size_$)*/ { 0 }
/*decltype($cached_size_$)*/ {0},
)cc");
}
}
void GenerateAggregateInitializer(io::Printer* p) const override {
p->Emit(R"cc(
decltype($field_$) { arena }
decltype($field_$){arena},
)cc");
if (has_cached_size_) {
// std::atomic has no copy constructor, which prevents explicit aggregate
// initialization pre-C++17.
p->Emit(R"cc(
, /*decltype($cached_size_$)*/ { 0 }
/*decltype($cached_size_$)*/ {0},
)cc");
}
}

@ -127,7 +127,9 @@ class Map : public FieldGeneratorBase {
}
void GenerateConstexprAggregateInitializer(io::Printer* p) const override {
p->Emit(R"cc(/* decltype($field_$) */ {})cc");
p->Emit(R"cc(
/* decltype($field_$) */ {},
)cc");
}
void GenerateCopyAggregateInitializer(io::Printer* p) const override {
@ -140,15 +142,15 @@ class Map : public FieldGeneratorBase {
if (ShouldSplit(field_, *opts_)) {
p->Emit(R"cc(
/* decltype($Msg$::Split::$name$_) */ {
$pbi$::ArenaInitialized(), arena
}
$pbi$::ArenaInitialized(),
arena,
},
)cc");
} else {
p->Emit(R"cc(
/* decltype($field_$) */ {$pbi$::ArenaInitialized(), arena},
)cc");
return;
}
p->Emit(R"cc(
/* decltype($field_$) */ { $pbi$::ArenaInitialized(), arena }
)cc");
}
void GenerateConstructorCode(io::Printer* p) const override {}

@ -501,7 +501,9 @@ void SingularMessage::GenerateIsInitialized(io::Printer* p) const {
void SingularMessage::GenerateConstexprAggregateInitializer(
io::Printer* p) const {
p->Emit("/*decltype($field_$)*/nullptr");
p->Emit(R"cc(
/*decltype($field_$)*/ nullptr,
)cc");
}
void SingularMessage::GenerateCopyAggregateInitializer(io::Printer* p) const {
@ -510,10 +512,14 @@ void SingularMessage::GenerateCopyAggregateInitializer(io::Printer* p) const {
void SingularMessage::GenerateAggregateInitializer(io::Printer* p) const {
if (ShouldSplit(field_, *opts_)) {
p->Emit("decltype(Impl_::Split::$name$_){nullptr}");
return;
p->Emit(R"cc(
decltype(Impl_::Split::$name$_){nullptr},
)cc");
} else {
p->Emit(R"cc(
decltype($field_$){nullptr},
)cc");
}
p->Emit("decltype($field_$){nullptr}");
}
class OneofMessage : public SingularMessage {

@ -167,13 +167,13 @@ class SingularPrimitive final : public FieldGeneratorBase {
void GenerateConstexprAggregateInitializer(io::Printer* p) const override {
p->Emit(R"cc(
/*decltype($field_$)*/ $kDefault$
/*decltype($field_$)*/ $kDefault$,
)cc");
}
void GenerateAggregateInitializer(io::Printer* p) const override {
p->Emit(R"cc(
decltype($field_$) { $kDefault$ }
decltype($field_$){$kDefault$},
)cc");
}
@ -343,17 +343,17 @@ class RepeatedPrimitive final : public FieldGeneratorBase {
void GenerateConstexprAggregateInitializer(io::Printer* p) const override {
p->Emit(R"cc(
/*decltype($field_$)*/ {}
/*decltype($field_$)*/ {},
)cc");
InitCachedSize(p);
GenerateCacheSizeInitializer(p);
}
void GenerateAggregateInitializer(io::Printer* p) const override {
ABSL_CHECK(!ShouldSplit(descriptor_, options_));
p->Emit(R"cc(
decltype($field_$) { arena }
decltype($field_$){arena},
)cc");
InitCachedSize(p);
GenerateCacheSizeInitializer(p);
}
void GenerateCopyAggregateInitializer(io::Printer* p) const override {
@ -361,7 +361,13 @@ class RepeatedPrimitive final : public FieldGeneratorBase {
p->Emit(R"cc(
decltype($field_$) { from.$field_$ }
)cc");
InitCachedSize(p);
if (HasCachedSize()) {
// std::atomic has no move constructor, which prevents explicit aggregate
// initialization pre-C++17.
p->Emit(R"cc(
, /* $_field_cached_byte_size_$ = */ { 0 }
)cc");
}
}
void GeneratePrivateMembers(io::Printer* p) const override;
@ -377,13 +383,13 @@ class RepeatedPrimitive final : public FieldGeneratorBase {
return is_packed_varint && HasGeneratedMethods(field_->file(), *opts_);
}
void InitCachedSize(io::Printer* p) const {
void GenerateCacheSizeInitializer(io::Printer* p) const {
if (!HasCachedSize()) return;
// std::atomic has no move constructor, which prevents explicit aggregate
// initialization pre-C++17.
p->Emit(R"(
,/* $_field_cached_byte_size_$ = */ { 0 }
)");
p->Emit(R"cc(
/* $_field_cached_byte_size_$ = */ {0},
)cc");
}
const FieldDescriptor* field_;

@ -665,34 +665,31 @@ void SingularString::GenerateConstexprAggregateInitializer(
io::Printer* p) const {
if (inlined_) {
p->Emit(R"cc(
/*decltype($field_$)*/ { nullptr, false }
/*decltype($field_$)*/ {nullptr, false},
)cc");
} else {
p->Emit(R"cc(
/*decltype($field_$)*/ {
&::_pbi::fixed_address_empty_string,
::_pbi::ConstantInitialized{},
},
)cc");
return;
}
p->Emit(R"cc(
/*decltype($field_$)*/ {
&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
}
)cc");
}
void SingularString::GenerateAggregateInitializer(io::Printer* p) const {
if (ShouldSplit(field_, options_)) {
ABSL_CHECK(!inlined_);
p->Emit(R"cc(
decltype(Impl_::Split::$name$_) {}
decltype(Impl_::Split::$name$_){},
)cc");
return;
}
if (!inlined_) {
} else if (!inlined_) {
p->Emit(R"cc(
decltype($field_$) {}
decltype($field_$){},
)cc");
} else {
p->Emit(R"cc(
decltype($field_$) { arena }
decltype($field_$){arena},
)cc");
}
}

@ -2220,129 +2220,162 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(io::Printer* p) {
void MessageGenerator::GenerateSharedConstructorCode(io::Printer* p) {
if (HasSimpleBaseClass(descriptor_, options_)) return;
Formatter format(p);
format(
"inline void $classname$::SharedCtor(::_pb::Arena* arena) {\n"
" (void)arena;\n");
format.Indent();
// Impl_ _impl_.
format("new (&_impl_) Impl_{");
format.Indent();
const char* field_sep = " ";
const auto put_sep = [&] {
format("\n$1$ ", field_sep);
field_sep = ",";
};
// Note: any fields without move/copy constructors can't be explicitly
// aggregate initialized pre-C++17.
if (descriptor_->extension_range_count() > 0) {
put_sep();
format("/*decltype($extensions$)*/{::_pbi::ArenaInitialized(), arena}");
}
if (!inlined_string_indices_.empty()) {
put_sep();
format("decltype($inlined_string_donated_array$){}");
}
bool need_to_emit_cached_size = !HasSimpleBaseClass(descriptor_, options_);
if (!has_bit_indices_.empty()) {
put_sep();
format("decltype($has_bits$){}");
if (need_to_emit_cached_size) {
put_sep();
format("/*decltype($cached_size$)*/{}");
need_to_emit_cached_size = false;
}
}
// Initialize member variables with arena constructor.
for (auto field : optimized_order_) {
if (ShouldSplit(field, options_)) {
continue;
}
put_sep();
field_generators_.get(field).GenerateAggregateInitializer(p);
}
if (ShouldSplit(descriptor_, options_)) {
put_sep();
// We can't assign the default split to this->split without the const_cast
// because the former is a const. The const_cast is safe because we don't
// intend to modify the default split through this pointer, and we also
// expect the default split to be in the rodata section which is protected
// from mutation.
format(
"decltype($split$){const_cast<Impl_::Split*>"
"(reinterpret_cast<const Impl_::Split*>(&$1$))}",
DefaultInstanceName(descriptor_, options_, /*split=*/true));
}
for (auto oneof : OneOfRange(descriptor_)) {
put_sep();
format("decltype(_impl_.$1$_){}", oneof->name());
}
if (need_to_emit_cached_size) {
put_sep();
format("/*decltype($cached_size$)*/{}");
}
if (descriptor_->real_oneof_decl_count() != 0) {
put_sep();
format("/*decltype($oneof_case$)*/{}");
}
if (num_weak_fields_ > 0) {
put_sep();
format("decltype($weak_field_map$){arena}");
}
if (IsAnyMessage(descriptor_, options_)) {
put_sep();
// AnyMetadata has no move constructor.
format("/*decltype($any_metadata$)*/{&_impl_.type_url_, &_impl_.value_}");
}
format.Outdent();
format("\n};\n");
if (!inlined_string_indices_.empty()) {
// Donate inline string fields.
format.Indent();
// The last bit is the tracking bit for registering ArenaDtor. The bit is 1
// means ArenaDtor is not registered on construction, and on demand register
// is needed.
format("if (arena != nullptr) {\n");
if (NeedsArenaDestructor() == ArenaDtorNeeds::kOnDemand) {
format(" $inlined_string_donated_array$[0] = ~0u;\n");
} else {
format(" $inlined_string_donated_array$[0] = 0xFFFFFFFEu;\n");
}
for (size_t i = 1; i < InlinedStringDonatedSize(); ++i) {
format(" $inlined_string_donated_array$[$1$] = ~0u;\n", i);
}
format("}\n");
format.Outdent();
}
for (const FieldDescriptor* field : optimized_order_) {
if (ShouldSplit(field, options_)) {
continue;
}
field_generators_.get(field).GenerateConstructorCode(p);
}
if (ShouldForceAllocationOnConstruction(descriptor_, options_)) {
format(
"#ifdef PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION\n"
"$mutable_unknown_fields$;\n"
"#endif // PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION\n");
}
for (auto oneof : OneOfRange(descriptor_)) {
format("clear_has_$1$();\n", oneof->name());
}
p->Emit(
{
{"impl_init",
[&] {
// Note: any fields without move/copy constructors can't be
// explicitly aggregate initialized pre-C++17.
if (descriptor_->extension_range_count() > 0) {
p->Emit(R"cc(
/*decltype($extensions$)*/ {::_pbi::ArenaInitialized(), arena},
)cc");
}
if (!inlined_string_indices_.empty()) {
p->Emit(R"cc(
decltype($inlined_string_donated_array$){},
)cc");
}
bool need_to_emit_cached_size =
!HasSimpleBaseClass(descriptor_, options_);
if (!has_bit_indices_.empty()) {
p->Emit(R"cc(
decltype($has_bits$){},
)cc");
if (need_to_emit_cached_size) {
p->Emit(R"cc(
/*decltype($cached_size$)*/ {},
)cc");
need_to_emit_cached_size = false;
}
}
format.Outdent();
format("}\n\n");
// Initialize member variables with arena constructor.
for (auto field : optimized_order_) {
if (ShouldSplit(field, options_)) {
continue;
}
field_generators_.get(field).GenerateAggregateInitializer(p);
}
if (ShouldSplit(descriptor_, options_)) {
// We can't assign the default split to this->split without the
// const_cast because the former is a const. The const_cast is
// safe because we don't intend to modify the default split
// through this pointer, and we also expect the default split to
// be in the rodata section which is protected from mutation.
p->Emit(
{{"instance", DefaultInstanceName(descriptor_, options_,
/*split=*/true)}},
R"cc(
decltype($split$){const_cast<Impl_::Split*>(
reinterpret_cast<const Impl_::Split*>(&$instance$))},
)cc");
}
for (auto oneof : OneOfRange(descriptor_)) {
p->Emit({{"name", oneof->name()}},
R"cc(
decltype(_impl_.$name$_){},
)cc");
}
if (need_to_emit_cached_size) {
p->Emit(R"cc(
/*decltype($cached_size$)*/ {},
)cc");
}
if (descriptor_->real_oneof_decl_count() != 0) {
p->Emit(R"cc(
/*decltype($oneof_case$)*/ {},
)cc");
}
if (num_weak_fields_ > 0) {
p->Emit(R"cc(
decltype($weak_field_map$){arena},
)cc");
}
if (IsAnyMessage(descriptor_, options_)) {
// AnyMetadata has no move constructor.
p->Emit(R"cc(
/*decltype($any_metadata$)*/ {&_impl_.type_url_,
&_impl_.value_},
)cc");
}
}},
{"inlined_strings_init",
[&] {
if (inlined_string_indices_.empty()) return;
// Donate inline string fields.
// The last bit is the tracking bit for registering ArenaDtor. The
// bit is 1 means ArenaDtor is not registered on construction, and
// on demand register is needed.
p->Emit(
{
{"mask",
NeedsArenaDestructor() == ArenaDtorNeeds::kOnDemand
? "~0u"
: "0xFFFFFFFEu"},
{"init_body",
[&] {
for (size_t i = 1; i < InlinedStringDonatedSize();
++i) {
p->Emit({{"i", i}},
R"cc(
$inlined_string_donated_array$[$i$] = ~0u;
)cc");
}
}},
},
R"cc(
if (arena != nullptr) {
$inlined_string_donated_array$[0] = $mask$;
$init_body$;
}
)cc");
}},
{"field_ctor_code",
[&] {
for (const FieldDescriptor* field : optimized_order_) {
if (ShouldSplit(field, options_)) {
continue;
}
field_generators_.get(field).GenerateConstructorCode(p);
}
}},
{"force_allocation",
[&] {
if (!ShouldForceAllocationOnConstruction(descriptor_, options_))
return;
p->Emit(R"cc(
//~ force alignment
#ifdef PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION
$mutable_unknown_fields$;
#endif // PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION
)cc");
}},
{"clear_oneofs",
[&] {
for (auto oneof : OneOfRange(descriptor_)) {
p->Emit({{"name", oneof->name()}},
R"cc(
clear_has_$name$();
)cc");
}
}},
},
R"cc(
inline void $classname$::SharedCtor(::_pb::Arena* arena) {
(void)arena;
new (&_impl_) Impl_{
$impl_init$,
};
$inlined_strings_init$;
$field_ctor_code$;
$force_allocation$;
$clear_oneofs$;
}
)cc");
}
void MessageGenerator::GenerateInitDefaultSplitInstance(io::Printer* p) {
@ -2350,15 +2383,9 @@ void MessageGenerator::GenerateInitDefaultSplitInstance(io::Printer* p) {
auto v = p->WithVars(ClassVars(descriptor_, options_));
auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
Formatter format(p);
const char* field_sep = " ";
const auto put_sep = [&] {
format("\n$1$ ", field_sep);
field_sep = ",";
};
p->Emit("\n");
for (const auto* field : optimized_order_) {
if (ShouldSplit(field, options_)) {
put_sep();
field_generators_.get(field).GenerateConstexprAggregateInitializer(p);
}
}
@ -2475,86 +2502,92 @@ void MessageGenerator::GenerateArenaDestructorCode(io::Printer* p) {
void MessageGenerator::GenerateConstexprConstructor(io::Printer* p) {
auto v = p->WithVars(ClassVars(descriptor_, options_));
auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
auto c = p->WithVars({{"constexpr", "PROTOBUF_CONSTEXPR"}});
Formatter format(p);
if (IsMapEntryMessage(descriptor_) || !HasImplData(descriptor_, options_)) {
format(
"PROTOBUF_CONSTEXPR $classname$::$classname$(\n"
" ::_pbi::ConstantInitialized) {}\n");
p->Emit(R"cc(
$constexpr$ $classname$::$classname$(::_pbi::ConstantInitialized) {}
)cc");
return;
}
format(
"PROTOBUF_CONSTEXPR $classname$::$classname$(\n"
" ::_pbi::ConstantInitialized)");
bool need_to_emit_cached_size = !HasSimpleBaseClass(descriptor_, options_);
format(": _impl_{");
format.Indent();
const char* field_sep = " ";
const auto put_sep = [&] {
format("\n$1$ ", field_sep);
field_sep = ",";
};
if (descriptor_->extension_range_count() > 0) {
put_sep();
format("/*decltype($extensions$)*/{}");
}
if (!inlined_string_indices_.empty()) {
put_sep();
format("/*decltype($inlined_string_donated_array$)*/{}");
}
if (!has_bit_indices_.empty()) {
put_sep();
format("/*decltype($has_bits$)*/{}");
if (need_to_emit_cached_size) {
put_sep();
format("/*decltype($cached_size$)*/{}");
need_to_emit_cached_size = false;
}
}
for (auto field : optimized_order_) {
if (ShouldSplit(field, options_)) {
continue;
}
put_sep();
field_generators_.get(field).GenerateConstexprAggregateInitializer(p);
}
if (ShouldSplit(descriptor_, options_)) {
put_sep();
format("/*decltype($split$)*/const_cast<Impl_::Split*>(&$1$._instance)",
DefaultInstanceName(descriptor_, options_, /*split=*/true));
}
for (auto oneof : OneOfRange(descriptor_)) {
put_sep();
format("/*decltype(_impl_.$1$_)*/{}", oneof->name());
}
if (need_to_emit_cached_size) {
put_sep();
format("/*decltype($cached_size$)*/{}");
}
if (descriptor_->real_oneof_decl_count() != 0) {
put_sep();
format("/*decltype($oneof_case$)*/{}");
}
if (num_weak_fields_) {
put_sep();
format("/*decltype($weak_field_map$)*/{}");
}
if (IsAnyMessage(descriptor_, options_)) {
put_sep();
format(
"/*decltype($any_metadata$)*/{&_impl_.type_url_, "
"&_impl_.value_}");
}
format.Outdent();
format("} {}\n");
p->Emit(
{
{"init_body",
[&] {
p->Emit("\n");
auto indent = p->WithIndent();
if (descriptor_->extension_range_count() > 0) {
p->Emit(R"cc(
/*decltype($extensions$)*/ {},
)cc");
}
if (!inlined_string_indices_.empty()) {
p->Emit(R"cc(
/*decltype($inlined_string_donated_array$)*/ {},
)cc");
}
if (!has_bit_indices_.empty()) {
p->Emit(R"cc(
/*decltype($has_bits$)*/ {},
)cc");
if (need_to_emit_cached_size) {
p->Emit(R"cc(
/*decltype($cached_size$)*/ {},
)cc");
need_to_emit_cached_size = false;
}
}
for (auto* field : optimized_order_) {
if (ShouldSplit(field, options_)) {
continue;
}
field_generators_.get(field)
.GenerateConstexprAggregateInitializer(p);
}
if (ShouldSplit(descriptor_, options_)) {
p->Emit({{"name", DefaultInstanceName(descriptor_, options_,
/*split=*/true)}},
R"cc(
/*decltype($split$)*/ const_cast<Impl_::Split*>(
&$name$._instance),
)cc");
}
for (auto* oneof : OneOfRange(descriptor_)) {
p->Emit({{"name", oneof->name()}},
R"cc(
/*decltype(_impl_.$name$_)*/ {},
)cc");
}
if (need_to_emit_cached_size) {
p->Emit(R"cc(
/*decltype($cached_size$)*/ {},
)cc");
}
if (descriptor_->real_oneof_decl_count() != 0) {
p->Emit(R"cc(
/*decltype($oneof_case$)*/ {},
)cc");
}
if (num_weak_fields_) {
p->Emit(R"cc(
/*decltype($weak_field_map$)*/ {},
)cc");
}
if (IsAnyMessage(descriptor_, options_)) {
p->Emit(R"cc(
/*decltype($any_metadata$)*/ {&_impl_.type_url_,
&_impl_.value_},
)cc");
}
}},
},
R"cc(
$constexpr$ $classname$::$classname$(::_pbi::ConstantInitialized)
: _impl_{$init_body$} {}
)cc");
}
void MessageGenerator::GenerateCopyConstructorBody(io::Printer* p) const {

@ -21,20 +21,18 @@ namespace _pbi = ::google::protobuf::internal;
namespace google {
namespace protobuf {
namespace compiler {
PROTOBUF_CONSTEXPR Version::Version(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.suffix_)*/ {
&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
}
, /*decltype(_impl_.major_)*/ 0
, /*decltype(_impl_.minor_)*/ 0
, /*decltype(_impl_.patch_)*/ 0
} {}
PROTOBUF_CONSTEXPR Version::Version(::_pbi::ConstantInitialized)
: _impl_{
/*decltype(_impl_._has_bits_)*/ {},
/*decltype(_impl_._cached_size_)*/ {},
/*decltype(_impl_.suffix_)*/ {
&::_pbi::fixed_address_empty_string,
::_pbi::ConstantInitialized{},
},
/*decltype(_impl_.major_)*/ 0,
/*decltype(_impl_.minor_)*/ 0,
/*decltype(_impl_.patch_)*/ 0,
} {}
struct VersionDefaultTypeInternal {
PROTOBUF_CONSTEXPR VersionDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~VersionDefaultTypeInternal() {}
@ -45,17 +43,18 @@ struct VersionDefaultTypeInternal {
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 VersionDefaultTypeInternal _Version_default_instance_;
PROTOBUF_CONSTEXPR CodeGeneratorRequest::CodeGeneratorRequest(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.file_to_generate_)*/{}
, /*decltype(_impl_.proto_file_)*/{}
, /*decltype(_impl_.parameter_)*/ {
&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
}
, /*decltype(_impl_.compiler_version_)*/nullptr} {}
PROTOBUF_CONSTEXPR CodeGeneratorRequest::CodeGeneratorRequest(::_pbi::ConstantInitialized)
: _impl_{
/*decltype(_impl_._has_bits_)*/ {},
/*decltype(_impl_._cached_size_)*/ {},
/*decltype(_impl_.file_to_generate_)*/ {},
/*decltype(_impl_.proto_file_)*/ {},
/*decltype(_impl_.parameter_)*/ {
&::_pbi::fixed_address_empty_string,
::_pbi::ConstantInitialized{},
},
/*decltype(_impl_.compiler_version_)*/ nullptr,
} {}
struct CodeGeneratorRequestDefaultTypeInternal {
PROTOBUF_CONSTEXPR CodeGeneratorRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~CodeGeneratorRequestDefaultTypeInternal() {}
@ -66,23 +65,24 @@ struct CodeGeneratorRequestDefaultTypeInternal {
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_;
PROTOBUF_CONSTEXPR CodeGeneratorResponse_File::CodeGeneratorResponse_File(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.name_)*/ {
&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
}
, /*decltype(_impl_.insertion_point_)*/ {
&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
}
, /*decltype(_impl_.content_)*/ {
&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
}
, /*decltype(_impl_.generated_code_info_)*/nullptr} {}
PROTOBUF_CONSTEXPR CodeGeneratorResponse_File::CodeGeneratorResponse_File(::_pbi::ConstantInitialized)
: _impl_{
/*decltype(_impl_._has_bits_)*/ {},
/*decltype(_impl_._cached_size_)*/ {},
/*decltype(_impl_.name_)*/ {
&::_pbi::fixed_address_empty_string,
::_pbi::ConstantInitialized{},
},
/*decltype(_impl_.insertion_point_)*/ {
&::_pbi::fixed_address_empty_string,
::_pbi::ConstantInitialized{},
},
/*decltype(_impl_.content_)*/ {
&::_pbi::fixed_address_empty_string,
::_pbi::ConstantInitialized{},
},
/*decltype(_impl_.generated_code_info_)*/ nullptr,
} {}
struct CodeGeneratorResponse_FileDefaultTypeInternal {
PROTOBUF_CONSTEXPR CodeGeneratorResponse_FileDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~CodeGeneratorResponse_FileDefaultTypeInternal() {}
@ -93,17 +93,17 @@ struct CodeGeneratorResponse_FileDefaultTypeInternal {
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_;
PROTOBUF_CONSTEXPR CodeGeneratorResponse::CodeGeneratorResponse(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.file_)*/{}
, /*decltype(_impl_.error_)*/ {
&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
}
, /*decltype(_impl_.supported_features_)*/ ::uint64_t{0u}
} {}
PROTOBUF_CONSTEXPR CodeGeneratorResponse::CodeGeneratorResponse(::_pbi::ConstantInitialized)
: _impl_{
/*decltype(_impl_._has_bits_)*/ {},
/*decltype(_impl_._cached_size_)*/ {},
/*decltype(_impl_.file_)*/ {},
/*decltype(_impl_.error_)*/ {
&::_pbi::fixed_address_empty_string,
::_pbi::ConstantInitialized{},
},
/*decltype(_impl_.supported_features_)*/ ::uint64_t{0u},
} {}
struct CodeGeneratorResponseDefaultTypeInternal {
PROTOBUF_CONSTEXPR CodeGeneratorResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~CodeGeneratorResponseDefaultTypeInternal() {}
@ -348,23 +348,18 @@ Version::Version(const Version& from)
inline void Version::SharedCtor(::_pb::Arena* arena) {
(void)arena;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.suffix_) {}
, decltype(_impl_.major_) { 0 }
, decltype(_impl_.minor_) { 0 }
, decltype(_impl_.patch_) { 0 }
decltype(_impl_._has_bits_){},
/*decltype(_impl_._cached_size_)*/ {},
decltype(_impl_.suffix_){},
decltype(_impl_.major_){0},
decltype(_impl_.minor_){0},
decltype(_impl_.patch_){0},
};
_impl_.suffix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.suffix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
Version::~Version() {
// @@protoc_insertion_point(destructor:google.protobuf.compiler.Version)
if (auto *arena = _internal_metadata_.DeleteReturnArena<::google::protobuf::UnknownFieldSet>()) {
@ -680,20 +675,18 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)
inline void CodeGeneratorRequest::SharedCtor(::_pb::Arena* arena) {
(void)arena;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.file_to_generate_){arena}
, decltype(_impl_.proto_file_){arena}
, decltype(_impl_.parameter_) {}
, decltype(_impl_.compiler_version_){nullptr}
decltype(_impl_._has_bits_){},
/*decltype(_impl_._cached_size_)*/ {},
decltype(_impl_.file_to_generate_){arena},
decltype(_impl_.proto_file_){arena},
decltype(_impl_.parameter_){},
decltype(_impl_.compiler_version_){nullptr},
};
_impl_.parameter_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.parameter_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
CodeGeneratorRequest::~CodeGeneratorRequest() {
// @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorRequest)
if (auto *arena = _internal_metadata_.DeleteReturnArena<::google::protobuf::UnknownFieldSet>()) {
@ -1050,15 +1043,12 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon
inline void CodeGeneratorResponse_File::SharedCtor(::_pb::Arena* arena) {
(void)arena;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.name_) {}
, decltype(_impl_.insertion_point_) {}
, decltype(_impl_.content_) {}
, decltype(_impl_.generated_code_info_){nullptr}
decltype(_impl_._has_bits_){},
/*decltype(_impl_._cached_size_)*/ {},
decltype(_impl_.name_){},
decltype(_impl_.insertion_point_){},
decltype(_impl_.content_){},
decltype(_impl_.generated_code_info_){nullptr},
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
@ -1073,7 +1063,6 @@ inline void CodeGeneratorResponse_File::SharedCtor(::_pb::Arena* arena) {
_impl_.content_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
CodeGeneratorResponse_File::~CodeGeneratorResponse_File() {
// @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorResponse.File)
if (auto *arena = _internal_metadata_.DeleteReturnArena<::google::protobuf::UnknownFieldSet>()) {
@ -1397,20 +1386,17 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
inline void CodeGeneratorResponse::SharedCtor(::_pb::Arena* arena) {
(void)arena;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.file_){arena}
, decltype(_impl_.error_) {}
, decltype(_impl_.supported_features_) { ::uint64_t{0u} }
decltype(_impl_._has_bits_){},
/*decltype(_impl_._cached_size_)*/ {},
decltype(_impl_.file_){arena},
decltype(_impl_.error_){},
decltype(_impl_.supported_features_){::uint64_t{0u}},
};
_impl_.error_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.error_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
CodeGeneratorResponse::~CodeGeneratorResponse() {
// @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorResponse)
if (auto *arena = _internal_metadata_.DeleteReturnArena<::google::protobuf::UnknownFieldSet>()) {

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save