aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc
diff options
context:
space:
mode:
authormikhnenko <mikhnenko@yandex-team.com>2024-06-25 08:50:35 +0300
committermikhnenko <mikhnenko@yandex-team.com>2024-06-25 09:00:27 +0300
commit509c9fc9e7b9c3b8be7307d72a4c966e5f9aa194 (patch)
tree4b8a6a44009906ac852e59efa0bc78bb12043a5b /contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc
parent7688f2313619a39a60ef3c2734d8efbc49a0a6db (diff)
downloadydb-509c9fc9e7b9c3b8be7307d72a4c966e5f9aa194.tar.gz
Update protobuf to 3.20.2 and pyprotobuf to 3.20.3
Если это pull-request что-то сломал, то: - если это тест с канонизацией и еще нет pr с переканонизацией, то переканонизируйте пожалуйста сами - проверьте, что тест не флапает - приходите в [DEVTOOLSSUPPORT](https://st.yandex-team.ru/createTicket?queue=DEVTOOLSSUPPORT) - там вам обязательно помогут 987be5ed151f827f7f292f32420470b04b71a91d
Diffstat (limited to 'contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc')
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc48
1 files changed, 26 insertions, 22 deletions
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc
index 5f167a4d01..895f094c70 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc
@@ -38,19 +38,19 @@
#include <memory>
#include <string>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/compiler/cpp/cpp_primitive_field.h>
#include <google/protobuf/compiler/cpp/cpp_string_field.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
#include <google/protobuf/compiler/cpp/cpp_enum_field.h>
#include <google/protobuf/compiler/cpp/cpp_map_field.h>
#include <google/protobuf/compiler/cpp/cpp_message_field.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
namespace google {
namespace protobuf {
@@ -81,7 +81,7 @@ TProtoStringType GenerateTemplateForOneofString(const FieldDescriptor* descripto
TProtoStringType field_name = google::protobuf::compiler::cpp::FieldName(descriptor);
TProtoStringType field_pointer =
descriptor->options().ctype() == google::protobuf::FieldOptions::STRING
- ? "$0.GetPointer()"
+ ? "$0.UnsafeGetPointer()"
: "$0";
if (descriptor->default_value_string().empty()) {
@@ -103,7 +103,7 @@ TProtoStringType GenerateTemplateForOneofString(const FieldDescriptor* descripto
return strings::Substitute(
StrCat("_internal_has_", field_name, "() ? ", field_pointer, " : ",
default_value_pointer),
- field_member, MakeDefaultName(descriptor));
+ field_member, MakeDefaultFieldName(descriptor));
}
TProtoStringType GenerateTemplateForSingleString(const FieldDescriptor* descriptor,
@@ -114,8 +114,8 @@ TProtoStringType GenerateTemplateForSingleString(const FieldDescriptor* descript
if (descriptor->options().ctype() == google::protobuf::FieldOptions::STRING) {
return strings::Substitute(
- "$0.IsDefault(nullptr) ? &$1.get() : $0.GetPointer()", field_member,
- MakeDefaultName(descriptor));
+ "$0.IsDefault() ? &$1.get() : $0.UnsafeGetPointer()", field_member,
+ MakeDefaultFieldName(descriptor));
}
return StrCat("&", field_member);
@@ -150,14 +150,12 @@ void AddAccessorAnnotations(const FieldDescriptor* descriptor,
google::protobuf::FileOptions::LITE_RUNTIME) {
return;
}
- TProtoStringType field_member = (*variables)["field_member"];
+ TProtoStringType field_member = (*variables)["field"];
const google::protobuf::OneofDescriptor* oneof_member =
descriptor->real_containing_oneof();
- if (oneof_member) {
- field_member = StrCat(oneof_member->name(), "_.", field_member);
- }
const TProtoStringType proto_ns = (*variables)["proto_ns"];
- const TProtoStringType substitute_template_prefix = " _tracker_.$1<$0>(this, ";
+ const TProtoStringType substitute_template_prefix =
+ StrCat(" ", (*variables)["tracker"], ".$1<$0>(this, ");
TProtoStringType prepared_template;
// Flat template is needed if the prepared one is introspecting the values
@@ -178,7 +176,7 @@ void AddAccessorAnnotations(const FieldDescriptor* descriptor,
} else if (descriptor->is_map()) {
prepared_template = "nullptr";
} else if (descriptor->type() == FieldDescriptor::TYPE_MESSAGE &&
- !descriptor->options().lazy()) {
+ !IsExplicitLazy(descriptor)) {
prepared_template = "nullptr";
} else if (descriptor->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
if (oneof_member) {
@@ -238,13 +236,15 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables,
const Options& options) {
SetCommonVars(options, variables);
+ SetCommonMessageDataVariables(variables);
+
(*variables)["ns"] = Namespace(descriptor, options);
(*variables)["name"] = FieldName(descriptor);
(*variables)["index"] = StrCat(descriptor->index());
(*variables)["number"] = StrCat(descriptor->number());
(*variables)["classname"] = ClassName(FieldScope(descriptor), false);
(*variables)["declared_type"] = DeclaredTypeMethodName(descriptor->type());
- (*variables)["field_member"] = FieldName(descriptor) + "_";
+ (*variables)["field"] = FieldMemberName(descriptor);
(*variables)["tag_size"] = StrCat(
WireFormat::TagSize(descriptor->number(), descriptor->type()));
@@ -254,7 +254,8 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
(*variables)["clear_hasbit"] = "";
if (HasHasbit(descriptor)) {
(*variables)["set_hasbit_io"] =
- "_Internal::set_has_" + FieldName(descriptor) + "(&_has_bits_);";
+ StrCat("_Internal::set_has_", FieldName(descriptor), "(&",
+ (*variables)["has_bits"], ");");
} else {
(*variables)["set_hasbit_io"] = "";
}
@@ -275,10 +276,10 @@ void FieldGenerator::SetHasBitIndex(arc_i32 has_bit_index) {
return;
}
variables_["set_hasbit"] = StrCat(
- "_has_bits_[", has_bit_index / 32, "] |= 0x",
+ variables_["has_bits"], "[", has_bit_index / 32, "] |= 0x",
strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8), "u;");
variables_["clear_hasbit"] = StrCat(
- "_has_bits_[", has_bit_index / 32, "] &= ~0x",
+ variables_["has_bits"], "[", has_bit_index / 32, "] &= ~0x",
strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8), "u;");
}
@@ -287,12 +288,17 @@ void FieldGenerator::SetInlinedStringIndex(arc_i32 inlined_string_index) {
GOOGLE_CHECK_EQ(inlined_string_index, -1);
return;
}
+ // The first bit is the tracking bit for on demand registering ArenaDtor.
+ GOOGLE_CHECK_GT(inlined_string_index, 0)
+ << "_inlined_string_donated_'s bit 0 is reserved for arena dtor tracking";
variables_["inlined_string_donated"] = StrCat(
- "(_inlined_string_donated_[", inlined_string_index / 32, "] & 0x",
+ "(", variables_["inlined_string_donated_array"], "[",
+ inlined_string_index / 32, "] & 0x",
strings::Hex(1u << (inlined_string_index % 32), strings::ZERO_PAD_8),
"u) != 0;");
variables_["donating_states_word"] =
- StrCat("_inlined_string_donated_[", inlined_string_index / 32, "]");
+ StrCat(variables_["inlined_string_donated_array"], "[",
+ inlined_string_index / 32, "]");
variables_["mask_for_undonate"] = StrCat(
"~0x", strings::Hex(1u << (inlined_string_index % 32), strings::ZERO_PAD_8),
"u");
@@ -303,8 +309,6 @@ void SetCommonOneofFieldVariables(
std::map<TProtoStringType, TProtoStringType>* variables) {
const TProtoStringType prefix = descriptor->containing_oneof()->name() + "_.";
(*variables)["oneof_name"] = descriptor->containing_oneof()->name();
- (*variables)["field_member"] =
- StrCat(prefix, (*variables)["name"], "_");
}
FieldGenerator::~FieldGenerator() {}