Rename FieldBeneratorBase::descriptor_ to field_.

PiperOrigin-RevId: 608825012
pull/15900/head
Protobuf Team Bot 9 months ago committed by Copybara-Service
parent b653a64514
commit 1f701a2ba9
  1. 56
      src/google/protobuf/compiler/cpp/field.cc
  2. 6
      src/google/protobuf/compiler/cpp/field.h
  3. 28
      src/google/protobuf/compiler/cpp/field_generators/cord_field.cc
  4. 5
      src/google/protobuf/compiler/cpp/field_generators/enum_field.cc
  5. 2
      src/google/protobuf/compiler/cpp/field_generators/map_field.cc
  6. 4
      src/google/protobuf/compiler/cpp/field_generators/message_field.cc
  7. 16
      src/google/protobuf/compiler/cpp/field_generators/primitive_field.cc
  8. 6
      src/google/protobuf/compiler/cpp/field_generators/string_field.cc
  9. 6
      src/google/protobuf/compiler/cpp/field_generators/string_view_field.cc

@ -109,14 +109,14 @@ std::vector<Sub> FieldVars(const FieldDescriptor* field, const Options& opts) {
return vars; return vars;
} }
FieldGeneratorBase::FieldGeneratorBase(const FieldDescriptor* descriptor, FieldGeneratorBase::FieldGeneratorBase(const FieldDescriptor* field,
const Options& options, const Options& options,
MessageSCCAnalyzer* scc) MessageSCCAnalyzer* scc)
: descriptor_(descriptor), options_(options) { : field_(field), options_(options) {
bool is_repeated_or_map = descriptor->is_repeated(); bool is_repeated_or_map = field->is_repeated();
should_split_ = ShouldSplit(descriptor, options); should_split_ = ShouldSplit(field, options);
is_oneof_ = descriptor->real_containing_oneof() != nullptr; is_oneof_ = field->real_containing_oneof() != nullptr;
switch (descriptor->cpp_type()) { switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_ENUM: case FieldDescriptor::CPPTYPE_ENUM:
case FieldDescriptor::CPPTYPE_INT32: case FieldDescriptor::CPPTYPE_INT32:
case FieldDescriptor::CPPTYPE_INT64: case FieldDescriptor::CPPTYPE_INT64:
@ -130,55 +130,55 @@ FieldGeneratorBase::FieldGeneratorBase(const FieldDescriptor* descriptor,
break; break;
case FieldDescriptor::CPPTYPE_STRING: case FieldDescriptor::CPPTYPE_STRING:
is_string_ = true; is_string_ = true;
string_type_ = descriptor->options().ctype(); string_type_ = field->options().ctype();
is_inlined_ = IsStringInlined(descriptor, options); is_inlined_ = IsStringInlined(field, options);
is_bytes_ = descriptor->type() == FieldDescriptor::TYPE_BYTES; is_bytes_ = field->type() == FieldDescriptor::TYPE_BYTES;
has_default_constexpr_constructor_ = is_repeated_or_map; has_default_constexpr_constructor_ = is_repeated_or_map;
break; break;
case FieldDescriptor::CPPTYPE_MESSAGE: case FieldDescriptor::CPPTYPE_MESSAGE:
is_message_ = true; is_message_ = true;
is_group_ = descriptor->type() == FieldDescriptor::TYPE_GROUP; is_group_ = field->type() == FieldDescriptor::TYPE_GROUP;
is_foreign_ = IsCrossFileMessage(descriptor); is_foreign_ = IsCrossFileMessage(field);
is_weak_ = IsImplicitWeakField(descriptor, options, scc); is_weak_ = IsImplicitWeakField(field, options, scc);
is_lazy_ = IsLazy(descriptor, options, scc); is_lazy_ = IsLazy(field, options, scc);
has_trivial_value_ = !(is_repeated_or_map || is_lazy_); has_trivial_value_ = !(is_repeated_or_map || is_lazy_);
has_default_constexpr_constructor_ = is_repeated_or_map || is_lazy_; has_default_constexpr_constructor_ = is_repeated_or_map || is_lazy_;
break; break;
} }
has_trivial_zero_default_ = CanInitializeByZeroing(descriptor, options, scc); has_trivial_zero_default_ = CanInitializeByZeroing(field, options, scc);
} }
void FieldGeneratorBase::GenerateMemberConstexprConstructor( void FieldGeneratorBase::GenerateMemberConstexprConstructor(
io::Printer* p) const { io::Printer* p) const {
ABSL_CHECK(!descriptor_->is_extension()); ABSL_CHECK(!field_->is_extension());
if (descriptor_->is_repeated()) { if (field_->is_repeated()) {
p->Emit("$name$_{}"); p->Emit("$name$_{}");
} else { } else {
p->Emit({{"default", DefaultValue(options_, descriptor_)}}, p->Emit({{"default", DefaultValue(options_, field_)}},
"$name$_{$default$}"); "$name$_{$default$}");
} }
} }
void FieldGeneratorBase::GenerateMemberConstructor(io::Printer* p) const { void FieldGeneratorBase::GenerateMemberConstructor(io::Printer* p) const {
ABSL_CHECK(!descriptor_->is_extension()); ABSL_CHECK(!field_->is_extension());
if (descriptor_->is_map()) { if (field_->is_map()) {
p->Emit("$name$_{visibility, arena}"); p->Emit("$name$_{visibility, arena}");
} else if (descriptor_->is_repeated()) { } else if (field_->is_repeated()) {
if (ShouldSplit(descriptor_, options_)) { if (ShouldSplit(field_, options_)) {
p->Emit("$name$_{}"); // RawPtr<Repeated> p->Emit("$name$_{}"); // RawPtr<Repeated>
} else { } else {
p->Emit("$name$_{visibility, arena}"); p->Emit("$name$_{visibility, arena}");
} }
} else { } else {
p->Emit({{"default", DefaultValue(options_, descriptor_)}}, p->Emit({{"default", DefaultValue(options_, field_)}},
"$name$_{$default$}"); "$name$_{$default$}");
} }
} }
void FieldGeneratorBase::GenerateMemberCopyConstructor(io::Printer* p) const { void FieldGeneratorBase::GenerateMemberCopyConstructor(io::Printer* p) const {
ABSL_CHECK(!descriptor_->is_extension()); ABSL_CHECK(!field_->is_extension());
if (descriptor_->is_repeated()) { if (field_->is_repeated()) {
p->Emit("$name$_{visibility, arena, from.$name$_}"); p->Emit("$name$_{visibility, arena, from.$name$_}");
} else { } else {
p->Emit("$name$_{from.$name$_}"); p->Emit("$name$_{from.$name$_}");
@ -186,14 +186,14 @@ void FieldGeneratorBase::GenerateMemberCopyConstructor(io::Printer* p) const {
} }
void FieldGeneratorBase::GenerateOneofCopyConstruct(io::Printer* p) const { void FieldGeneratorBase::GenerateOneofCopyConstruct(io::Printer* p) const {
ABSL_CHECK(!descriptor_->is_extension()) << "Not supported"; ABSL_CHECK(!field_->is_extension()) << "Not supported";
ABSL_CHECK(!descriptor_->is_repeated()) << "Not supported"; ABSL_CHECK(!field_->is_repeated()) << "Not supported";
ABSL_CHECK(!descriptor_->is_map()) << "Not supported"; ABSL_CHECK(!field_->is_map()) << "Not supported";
p->Emit("$field$ = from.$field$;\n"); p->Emit("$field$ = from.$field$;\n");
} }
void FieldGeneratorBase::GenerateAggregateInitializer(io::Printer* p) const { void FieldGeneratorBase::GenerateAggregateInitializer(io::Printer* p) const {
if (ShouldSplit(descriptor_, options_)) { if (ShouldSplit(field_, options_)) {
p->Emit(R"cc( p->Emit(R"cc(
decltype(Impl_::Split::$name$_){arena}, decltype(Impl_::Split::$name$_){arena},
)cc"); )cc");

@ -47,7 +47,7 @@ class FieldGeneratorBase {
// variable instead of calling GetArena()' // variable instead of calling GetArena()'
enum class GeneratorFunction { kMergeFrom }; enum class GeneratorFunction { kMergeFrom };
FieldGeneratorBase(const FieldDescriptor* descriptor, const Options& options, FieldGeneratorBase(const FieldDescriptor* field, const Options& options,
MessageSCCAnalyzer* scc_analyzer); MessageSCCAnalyzer* scc_analyzer);
FieldGeneratorBase(const FieldGeneratorBase&) = delete; FieldGeneratorBase(const FieldGeneratorBase&) = delete;
@ -142,7 +142,7 @@ class FieldGeneratorBase {
virtual void GenerateArenaDestructorCode(io::Printer* p) const { virtual void GenerateArenaDestructorCode(io::Printer* p) const {
ABSL_CHECK(NeedsArenaDestructor() == ArenaDtorNeeds::kNone) ABSL_CHECK(NeedsArenaDestructor() == ArenaDtorNeeds::kNone)
<< descriptor_->cpp_type_name(); << field_->cpp_type_name();
} }
// Generates constexpr member initialization code, e.g.: `foo_{5}`. // Generates constexpr member initialization code, e.g.: `foo_{5}`.
@ -191,7 +191,7 @@ class FieldGeneratorBase {
} }
protected: protected:
const FieldDescriptor* descriptor_; const FieldDescriptor* field_;
const Options& options_; const Options& options_;
MessageSCCAnalyzer* scc_; MessageSCCAnalyzer* scc_;
absl::flat_hash_map<absl::string_view, std::string> variables_; absl::flat_hash_map<absl::string_view, std::string> variables_;

@ -77,10 +77,10 @@ class CordFieldGenerator : public FieldGeneratorBase {
} }
void GenerateMemberConstexprConstructor(io::Printer* p) const override { void GenerateMemberConstexprConstructor(io::Printer* p) const override {
if (descriptor_->default_value_string().empty()) { if (field_->default_value_string().empty()) {
p->Emit("$name$_{}"); p->Emit("$name$_{}");
} else { } else {
p->Emit({{"Split", ShouldSplit(descriptor_, options_) ? "Split::" : ""}}, p->Emit({{"Split", ShouldSplit(field_, options_) ? "Split::" : ""}},
"$name$_{::absl::strings_internal::MakeStringConstant(" "$name$_{::absl::strings_internal::MakeStringConstant("
"$classname$::Impl_::$Split$_default_$name$_func_{})}"); "$classname$::Impl_::$Split$_default_$name$_func_{})}");
} }
@ -88,7 +88,7 @@ class CordFieldGenerator : public FieldGeneratorBase {
void GenerateMemberConstructor(io::Printer* p) const override { void GenerateMemberConstructor(io::Printer* p) const override {
auto vars = p->WithVars(variables_); auto vars = p->WithVars(variables_);
if (descriptor_->default_value_string().empty()) { if (field_->default_value_string().empty()) {
p->Emit("$name$_{}"); p->Emit("$name$_{}");
} else { } else {
p->Emit("$name$_{::absl::string_view($default$, $default_length$)}"); p->Emit("$name$_{::absl::string_view($default$, $default_length$)}");
@ -142,7 +142,7 @@ CordFieldGenerator::CordFieldGenerator(const FieldDescriptor* descriptor,
void CordFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const { void CordFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("::absl::Cord $name$_;\n"); format("::absl::Cord $name$_;\n");
if (!descriptor_->default_value_string().empty()) { if (!field_->default_value_string().empty()) {
format( format(
"struct _default_$name$_func_ {\n" "struct _default_$name$_func_ {\n"
" constexpr absl::string_view operator()() const {\n" " constexpr absl::string_view operator()() const {\n"
@ -156,18 +156,18 @@ void CordFieldGenerator::GenerateAccessorDeclarations(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
format("$deprecated_attr$const ::absl::Cord& ${1$$name$$}$() const;\n", format("$deprecated_attr$const ::absl::Cord& ${1$$name$$}$() const;\n",
descriptor_); field_);
format( format(
"$deprecated_attr$void ${1$set_$name$$}$(const ::absl::Cord& value);\n" "$deprecated_attr$void ${1$set_$name$$}$(const ::absl::Cord& value);\n"
"$deprecated_attr$void ${1$set_$name$$}$(::absl::string_view value);\n", "$deprecated_attr$void ${1$set_$name$$}$(::absl::string_view value);\n",
std::make_tuple(descriptor_, GeneratedCodeInfo::Annotation::SET)); std::make_tuple(field_, GeneratedCodeInfo::Annotation::SET));
format( format(
"private:\n" "private:\n"
"const ::absl::Cord& ${1$_internal_$name$$}$() const;\n" "const ::absl::Cord& ${1$_internal_$name$$}$() const;\n"
"void ${1$_internal_set_$name$$}$(const ::absl::Cord& value);\n" "void ${1$_internal_set_$name$$}$(const ::absl::Cord& value);\n"
"::absl::Cord* ${1$_internal_mutable_$name$$}$();\n" "::absl::Cord* ${1$_internal_mutable_$name$$}$();\n"
"public:\n", "public:\n",
descriptor_); field_);
} }
void CordFieldGenerator::GenerateInlineAccessorDefinitions( void CordFieldGenerator::GenerateInlineAccessorDefinitions(
@ -223,7 +223,7 @@ void CordFieldGenerator::GenerateInlineAccessorDefinitions(
void CordFieldGenerator::GenerateClearingCode(io::Printer* printer) const { void CordFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (descriptor_->default_value_string().empty()) { if (field_->default_value_string().empty()) {
format("$field$.Clear();\n"); format("$field$.Clear();\n");
} else { } else {
format("$field$ = ::absl::string_view($default$, $default_length$);\n"); format("$field$ = ::absl::string_view($default$, $default_length$);\n");
@ -243,7 +243,7 @@ void CordFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
void CordFieldGenerator::GenerateConstructorCode(io::Printer* printer) const { void CordFieldGenerator::GenerateConstructorCode(io::Printer* printer) const {
ABSL_CHECK(!should_split()); ABSL_CHECK(!should_split());
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (!descriptor_->default_value_string().empty()) { if (!field_->default_value_string().empty()) {
format("$field$ = ::absl::string_view($default$, $default_length$);\n"); format("$field$ = ::absl::string_view($default$, $default_length$);\n");
} }
} }
@ -259,9 +259,9 @@ void CordFieldGenerator::GenerateArenaDestructorCode(
void CordFieldGenerator::GenerateSerializeWithCachedSizesToArray( void CordFieldGenerator::GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { if (field_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForCord( GenerateUtf8CheckCodeForCord(
descriptor_, options_, false, field_, options_, false,
absl::Substitute("this->_internal_$0(), ", printer->LookupVar("name")), absl::Substitute("this->_internal_$0(), ", printer->LookupVar("name")),
format); format);
} }
@ -281,7 +281,7 @@ void CordFieldGenerator::GenerateByteSize(io::Printer* printer) const {
void CordFieldGenerator::GenerateConstexprAggregateInitializer( void CordFieldGenerator::GenerateConstexprAggregateInitializer(
io::Printer* p) const { io::Printer* p) const {
if (descriptor_->default_value_string().empty()) { if (field_->default_value_string().empty()) {
p->Emit(R"cc( p->Emit(R"cc(
/*decltype($field$)*/ {}, /*decltype($field$)*/ {},
)cc"); )cc");
@ -323,7 +323,7 @@ void CordOneofFieldGenerator::GeneratePrivateMembers(
void CordOneofFieldGenerator::GenerateStaticMembers( void CordOneofFieldGenerator::GenerateStaticMembers(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (!descriptor_->default_value_string().empty()) { if (!field_->default_value_string().empty()) {
format( format(
"struct _default_$name$_func_ {\n" "struct _default_$name$_func_ {\n"
" constexpr absl::string_view operator()() const {\n" " constexpr absl::string_view operator()() const {\n"
@ -407,7 +407,7 @@ void CordOneofFieldGenerator::GenerateInlineAccessorDefinitions(
void CordOneofFieldGenerator::GenerateNonInlineAccessorDefinitions( void CordOneofFieldGenerator::GenerateNonInlineAccessorDefinitions(
io::Printer* printer) const { io::Printer* printer) const {
Formatter format(printer, variables_); Formatter format(printer, variables_);
if (!descriptor_->default_value_string().empty()) { if (!field_->default_value_string().empty()) {
format( format(
"PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT " "PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT "
"const ::absl::Cord $classname$::$default_variable_field$(\n" "const ::absl::Cord $classname$::$default_variable_field$(\n"

@ -55,7 +55,7 @@ class SingularEnum : public FieldGeneratorBase {
public: public:
SingularEnum(const FieldDescriptor* field, const Options& opts, SingularEnum(const FieldDescriptor* field, const Options& opts,
MessageSCCAnalyzer* scc) MessageSCCAnalyzer* scc)
: FieldGeneratorBase(field, opts, scc), field_(field), opts_(&opts) {} : FieldGeneratorBase(field, opts, scc), opts_(&opts) {}
~SingularEnum() override = default; ~SingularEnum() override = default;
std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); } std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); }
@ -142,7 +142,6 @@ class SingularEnum : public FieldGeneratorBase {
void GenerateInlineAccessorDefinitions(io::Printer* p) const override; void GenerateInlineAccessorDefinitions(io::Printer* p) const override;
private: private:
const FieldDescriptor* field_;
const Options* opts_; const Options* opts_;
}; };
@ -221,7 +220,6 @@ class RepeatedEnum : public FieldGeneratorBase {
RepeatedEnum(const FieldDescriptor* field, const Options& opts, RepeatedEnum(const FieldDescriptor* field, const Options& opts,
MessageSCCAnalyzer* scc) MessageSCCAnalyzer* scc)
: FieldGeneratorBase(field, opts, scc), : FieldGeneratorBase(field, opts, scc),
field_(field),
opts_(&opts), opts_(&opts),
has_cached_size_(field_->is_packed() && has_cached_size_(field_->is_packed() &&
HasGeneratedMethods(field_->file(), opts) && HasGeneratedMethods(field_->file(), opts) &&
@ -369,7 +367,6 @@ class RepeatedEnum : public FieldGeneratorBase {
void GenerateByteSize(io::Printer* p) const override; void GenerateByteSize(io::Printer* p) const override;
private: private:
const FieldDescriptor* field_;
const Options* opts_; const Options* opts_;
bool has_cached_size_; bool has_cached_size_;
}; };

@ -76,7 +76,6 @@ class Map : public FieldGeneratorBase {
Map(const FieldDescriptor* field, const Options& opts, Map(const FieldDescriptor* field, const Options& opts,
MessageSCCAnalyzer* scc) MessageSCCAnalyzer* scc)
: FieldGeneratorBase(field, opts, scc), : FieldGeneratorBase(field, opts, scc),
field_(field),
key_(field->message_type()->map_key()), key_(field->message_type()->map_key()),
val_(field->message_type()->map_value()), val_(field->message_type()->map_value()),
opts_(&opts), opts_(&opts),
@ -168,7 +167,6 @@ class Map : public FieldGeneratorBase {
void GenerateByteSize(io::Printer* p) const override; void GenerateByteSize(io::Printer* p) const override;
private: private:
const FieldDescriptor* field_;
const FieldDescriptor* key_; const FieldDescriptor* key_;
const FieldDescriptor* val_; const FieldDescriptor* val_;
const Options* opts_; const Options* opts_;

@ -84,7 +84,6 @@ class SingularMessage : public FieldGeneratorBase {
SingularMessage(const FieldDescriptor* field, const Options& opts, SingularMessage(const FieldDescriptor* field, const Options& opts,
MessageSCCAnalyzer* scc) MessageSCCAnalyzer* scc)
: FieldGeneratorBase(field, opts, scc), : FieldGeneratorBase(field, opts, scc),
field_(field),
opts_(&opts), opts_(&opts),
has_required_(scc->HasRequiredFields(field->message_type())), has_required_(scc->HasRequiredFields(field->message_type())),
has_hasbit_(HasHasbit(field)) {} has_hasbit_(HasHasbit(field)) {}
@ -143,7 +142,6 @@ class SingularMessage : public FieldGeneratorBase {
private: private:
friend class OneofMessage; friend class OneofMessage;
const FieldDescriptor* field_;
const Options* opts_; const Options* opts_;
bool has_required_; bool has_required_;
bool has_hasbit_; bool has_hasbit_;
@ -689,7 +687,6 @@ class RepeatedMessage : public FieldGeneratorBase {
RepeatedMessage(const FieldDescriptor* field, const Options& opts, RepeatedMessage(const FieldDescriptor* field, const Options& opts,
MessageSCCAnalyzer* scc) MessageSCCAnalyzer* scc)
: FieldGeneratorBase(field, opts, scc), : FieldGeneratorBase(field, opts, scc),
field_(field),
opts_(&opts), opts_(&opts),
has_required_(scc->HasRequiredFields(field->message_type())) {} has_required_(scc->HasRequiredFields(field->message_type())) {}
@ -713,7 +710,6 @@ class RepeatedMessage : public FieldGeneratorBase {
void GenerateIsInitialized(io::Printer* p) const override; void GenerateIsInitialized(io::Printer* p) const override;
private: private:
const FieldDescriptor* field_;
const Options* opts_; const Options* opts_;
bool has_required_; bool has_required_;
}; };

@ -89,7 +89,7 @@ class SingularPrimitive final : public FieldGeneratorBase {
public: public:
SingularPrimitive(const FieldDescriptor* field, const Options& opts, SingularPrimitive(const FieldDescriptor* field, const Options& opts,
MessageSCCAnalyzer* scc) MessageSCCAnalyzer* scc)
: FieldGeneratorBase(field, opts, scc), field_(field), opts_(&opts) {} : FieldGeneratorBase(field, opts, scc), opts_(&opts) {}
~SingularPrimitive() override = default; ~SingularPrimitive() override = default;
std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); } std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); }
@ -164,7 +164,6 @@ class SingularPrimitive final : public FieldGeneratorBase {
void GenerateByteSize(io::Printer* p) const override; void GenerateByteSize(io::Printer* p) const override;
private: private:
const FieldDescriptor* field_;
const Options* opts_; const Options* opts_;
}; };
@ -239,10 +238,10 @@ void SingularPrimitive::GenerateInlineAccessorDefinitions(
void SingularPrimitive::GenerateSerializeWithCachedSizesToArray( void SingularPrimitive::GenerateSerializeWithCachedSizesToArray(
io::Printer* p) const { io::Printer* p) const {
if ((descriptor_->number() < 16) && if ((field_->number() < 16) &&
(descriptor_->type() == FieldDescriptor::TYPE_INT32 || (field_->type() == FieldDescriptor::TYPE_INT32 ||
descriptor_->type() == FieldDescriptor::TYPE_INT64 || field_->type() == FieldDescriptor::TYPE_INT64 ||
descriptor_->type() == FieldDescriptor::TYPE_ENUM)) { field_->type() == FieldDescriptor::TYPE_ENUM)) {
// Call special non-inlined routine with tag number hardcoded as a // Call special non-inlined routine with tag number hardcoded as a
// template parameter that handles the EnsureSpace and the writing // template parameter that handles the EnsureSpace and the writing
// of the tag+value to the array // of the tag+value to the array
@ -291,7 +290,7 @@ class RepeatedPrimitive final : public FieldGeneratorBase {
public: public:
RepeatedPrimitive(const FieldDescriptor* field, const Options& opts, RepeatedPrimitive(const FieldDescriptor* field, const Options& opts,
MessageSCCAnalyzer* scc) MessageSCCAnalyzer* scc)
: FieldGeneratorBase(field, opts, scc), field_(field), opts_(&opts) {} : FieldGeneratorBase(field, opts, scc), opts_(&opts) {}
~RepeatedPrimitive() override = default; ~RepeatedPrimitive() override = default;
std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); } std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); }
@ -421,7 +420,6 @@ class RepeatedPrimitive final : public FieldGeneratorBase {
)cc"); )cc");
} }
const FieldDescriptor* field_;
const Options* opts_; const Options* opts_;
}; };
@ -597,7 +595,7 @@ void RepeatedPrimitive::GenerateByteSize(io::Printer* p) const {
{ {
Sub{"data_size", Sub{"data_size",
[&] { [&] {
auto fixed_size = FixedSize(descriptor_->type()); auto fixed_size = FixedSize(field_->type());
if (fixed_size.has_value()) { if (fixed_size.has_value()) {
p->Emit({{"kFixed", *fixed_size}}, R"cc( p->Emit({{"kFixed", *fixed_size}}, R"cc(
std::size_t{$kFixed$} * std::size_t{$kFixed$} *

@ -68,7 +68,7 @@ class SingularString : public FieldGeneratorBase {
public: public:
SingularString(const FieldDescriptor* field, const Options& opts, SingularString(const FieldDescriptor* field, const Options& opts,
MessageSCCAnalyzer* scc) MessageSCCAnalyzer* scc)
: FieldGeneratorBase(field, opts, scc), field_(field), opts_(&opts) {} : FieldGeneratorBase(field, opts, scc), opts_(&opts) {}
~SingularString() override = default; ~SingularString() override = default;
std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); } std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); }
@ -201,7 +201,6 @@ class SingularString : public FieldGeneratorBase {
void ReleaseImpl(io::Printer* p) const; void ReleaseImpl(io::Printer* p) const;
void SetAllocatedImpl(io::Printer* p) const; void SetAllocatedImpl(io::Printer* p) const;
const FieldDescriptor* field_;
const Options* opts_; const Options* opts_;
}; };
@ -733,7 +732,7 @@ class RepeatedString : public FieldGeneratorBase {
public: public:
RepeatedString(const FieldDescriptor* field, const Options& opts, RepeatedString(const FieldDescriptor* field, const Options& opts,
MessageSCCAnalyzer* scc) MessageSCCAnalyzer* scc)
: FieldGeneratorBase(field, opts, scc), field_(field), opts_(&opts) {} : FieldGeneratorBase(field, opts, scc), opts_(&opts) {}
~RepeatedString() override = default; ~RepeatedString() override = default;
std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); } std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); }
@ -819,7 +818,6 @@ class RepeatedString : public FieldGeneratorBase {
void GenerateSerializeWithCachedSizesToArray(io::Printer* p) const override; void GenerateSerializeWithCachedSizesToArray(io::Printer* p) const override;
private: private:
const FieldDescriptor* field_;
const Options* opts_; const Options* opts_;
}; };

@ -67,7 +67,7 @@ class SingularStringView : public FieldGeneratorBase {
public: public:
SingularStringView(const FieldDescriptor* field, const Options& opts, SingularStringView(const FieldDescriptor* field, const Options& opts,
MessageSCCAnalyzer* scc) MessageSCCAnalyzer* scc)
: FieldGeneratorBase(field, opts, scc), field_(field), opts_(&opts) {} : FieldGeneratorBase(field, opts, scc), opts_(&opts) {}
~SingularStringView() override = default; ~SingularStringView() override = default;
std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); } std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); }
@ -198,7 +198,6 @@ class SingularStringView : public FieldGeneratorBase {
private: private:
bool EmptyDefault() const { return field_->default_value_string().empty(); } bool EmptyDefault() const { return field_->default_value_string().empty(); }
const FieldDescriptor* field_;
const Options* opts_; const Options* opts_;
}; };
@ -559,7 +558,7 @@ class RepeatedStringView : public FieldGeneratorBase {
public: public:
RepeatedStringView(const FieldDescriptor* field, const Options& opts, RepeatedStringView(const FieldDescriptor* field, const Options& opts,
MessageSCCAnalyzer* scc) MessageSCCAnalyzer* scc)
: FieldGeneratorBase(field, opts, scc), field_(field), opts_(&opts) {} : FieldGeneratorBase(field, opts, scc), opts_(&opts) {}
~RepeatedStringView() override = default; ~RepeatedStringView() override = default;
std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); } std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); }
@ -645,7 +644,6 @@ class RepeatedStringView : public FieldGeneratorBase {
void GenerateSerializeWithCachedSizesToArray(io::Printer* p) const override; void GenerateSerializeWithCachedSizesToArray(io::Printer* p) const override;
private: private:
const FieldDescriptor* field_;
const Options* opts_; const Options* opts_;
}; };

Loading…
Cancel
Save