diff options
author | vadim-xd <vadim-xd@yandex-team.com> | 2024-10-29 23:26:02 +0300 |
---|---|---|
committer | vadim-xd <vadim-xd@yandex-team.com> | 2024-10-29 23:37:18 +0300 |
commit | c0831b65c047f0894f63562b9da3024dfa779baf (patch) | |
tree | 81aded4973d6396774de89e8c5bc0796307628d5 /contrib | |
parent | fa653f89746744964114f44dce53c0f6ffb6deba (diff) | |
download | ydb-c0831b65c047f0894f63562b9da3024dfa779baf.tar.gz |
[protobuf] Restore methods with std::string_view
commit_hash:abb56697e948fac46777acec62a62b40767ea74d
Diffstat (limited to 'contrib')
11 files changed, 120 insertions, 130 deletions
diff --git a/contrib/libs/protobuf/patches/dont-use-string-view.patch b/contrib/libs/protobuf/patches/dont-use-string-view.patch deleted file mode 100644 index 084341c464..0000000000 --- a/contrib/libs/protobuf/patches/dont-use-string-view.patch +++ /dev/null @@ -1,56 +0,0 @@ -commit 4a6dd4d9aeb3e3f9c033d092c86d5be63ca8cba9 -author: nechda -date: 2024-08-08T14:02:13+03:00 - - [PROTOBUF] Dont use string_view - ---- contrib/libs/protobuf/src/google/protobuf/arenastring.cc (e2819444222a1e9154b9c7b701eff6427206db7c) -+++ contrib/libs/protobuf/src/google/protobuf/arenastring.cc (4a6dd4d9aeb3e3f9c033d092c86d5be63ca8cba9) -@@ -115,7 +115,7 @@ TaggedStringPtr CreateArenaString(Arena& arena, absl::string_view s) { - - } // namespace - --void ArenaStringPtr::Set(absl::string_view value, Arena* arena) { -+void ArenaStringPtr::Set(const TProtoStringType& value, Arena* arena) { - ScopedCheckPtrInvariants check(&tagged_ptr_); - if (IsDefault()) { - // If we're not on an arena, skip straight to a true string to avoid ---- contrib/libs/protobuf/src/google/protobuf/arenastring.h (e2819444222a1e9154b9c7b701eff6427206db7c) -+++ contrib/libs/protobuf/src/google/protobuf/arenastring.h (4a6dd4d9aeb3e3f9c033d092c86d5be63ca8cba9) -@@ -259,7 +259,7 @@ struct PROTOBUF_EXPORT ArenaStringPtr { - // instance known to not carry any heap allocated value. - inline void InitAllocated(TProtoStringType* str, Arena* arena); - -- void Set(absl::string_view value, Arena* arena); -+ void Set(const TProtoStringType& value, Arena* arena); - void Set(TProtoStringType&& value, Arena* arena); - template <typename... OverloadDisambiguator> - void Set(const TProtoStringType& value, Arena* arena); -@@ -410,15 +410,15 @@ inline void ArenaStringPtr::InitAllocated(TProtoStringType* str, Arena* arena) { - } - - inline void ArenaStringPtr::Set(const char* s, Arena* arena) { -- Set(absl::string_view{s}, arena); -+ Set(TProtoStringType{s}, arena); - } - - inline void ArenaStringPtr::Set(const char* s, size_t n, Arena* arena) { -- Set(absl::string_view{s, n}, arena); -+ Set(TProtoStringType(s, s + n), arena); - } - - inline void ArenaStringPtr::SetBytes(absl::string_view value, Arena* arena) { -- Set(value, arena); -+ Set(TProtoStringType(value.data(), value.size()), arena); - } - - template <> -@@ -439,7 +439,7 @@ inline void ArenaStringPtr::SetBytes(const char* s, Arena* arena) { - } - - inline void ArenaStringPtr::SetBytes(const void* p, size_t n, Arena* arena) { -- Set(absl::string_view{static_cast<const char*>(p), n}, arena); -+ Set(TProtoStringType(static_cast<const char*>(p), static_cast<const char*>(p) + n), arena); - } - - // Make sure rhs_arena allocated rhs, and lhs_arena allocated lhs. diff --git a/contrib/libs/protobuf/patches/dot-generate-string-view-setters.patch b/contrib/libs/protobuf/patches/dot-generate-string-view-setters.patch deleted file mode 100644 index 88ec297018..0000000000 --- a/contrib/libs/protobuf/patches/dot-generate-string-view-setters.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- contrib/libs/protobuf/src/google/protobuf/arenastring.h (d40b078e35f492f4ad417c8dd4a0103d4e577049) -+++ contrib/libs/protobuf/src/google/protobuf/arenastring.h (2babb01d30e285a96044041b98053d9edbb48b2a) -@@ -266,7 +266,6 @@ struct PROTOBUF_EXPORT ArenaStringPtr { - void Set(const char* s, Arena* arena); - void Set(const char* s, size_t n, Arena* arena); - -- void SetBytes(absl::string_view value, Arena* arena); - void SetBytes(TProtoStringType&& value, Arena* arena); - template <typename... OverloadDisambiguator> - void SetBytes(const TProtoStringType& value, Arena* arena); -@@ -417,10 +416,6 @@ inline void ArenaStringPtr::Set(const char* s, size_t n, Arena* arena) { - Set(TProtoStringType(s, s + n), arena); - } - --inline void ArenaStringPtr::SetBytes(absl::string_view value, Arena* arena) { -- Set(TProtoStringType(value.data(), value.size()), arena); --} -- - template <> - PROTOBUF_EXPORT void ArenaStringPtr::Set(const TProtoStringType& value, - Arena* arena); diff --git a/contrib/libs/protobuf/patches/fix-string-from-nullptr.patch b/contrib/libs/protobuf/patches/fix-string-from-nullptr.patch new file mode 100644 index 0000000000..27c1110066 --- /dev/null +++ b/contrib/libs/protobuf/patches/fix-string-from-nullptr.patch @@ -0,0 +1,19 @@ +commit 556f12d15e9e59a132af2d4605b7444c4e3b623e (wip) +author: vadim-xd +date: 2024-09-09T01:14:56+03:00 + + Fix ArenaStringPtr::Set(nullptr). + + TString(nullptr) is allowed (at least currently), string_view(nullptr) is UB. + +--- contrib/libs/protobuf/src/google/protobuf/arenastring.h (bff10d7f3e550777570ff58e01b9ae291d02490e) ++++ contrib/libs/protobuf/src/google/protobuf/arenastring.h (556f12d15e9e59a132af2d4605b7444c4e3b623e) +@@ -424,7 +424,7 @@ inline void ArenaStringPtr::InitAllocated(TProtoStringType* str, Arena* arena) { + } + + inline void ArenaStringPtr::Set(const char* s, Arena* arena) { +- Set(absl::string_view{s}, arena); ++ Set(TProtoStringType{s}, arena); + } + + inline void ArenaStringPtr::Set(const char* s, size_t n, Arena* arena) { diff --git a/contrib/libs/protobuf/patches/protoc-dont-generate-setters-with-string-view.patch b/contrib/libs/protobuf/patches/protoc-dont-generate-setters-with-string-view.patch deleted file mode 100644 index f2e020253a..0000000000 --- a/contrib/libs/protobuf/patches/protoc-dont-generate-setters-with-string-view.patch +++ /dev/null @@ -1,40 +0,0 @@ ---- a/src/google/protobuf/compiler/cpp/field_generators/string_field.cc (192810303a994f7cbd6bf596a3d56393bfefee6c) -+++ b/src/google/protobuf/compiler/cpp/field_generators/string_field.cc (2b6f1fdeb6f4d5c82840dbe69e4f0d3149c8fe5a) -@@ -781,13 +781,11 @@ void RepeatedString::GenerateAccessorDeclarations(io::Printer* p) const { - $DEPRECATED$ void $set_name$(int index, TProtoStringType&& value); - $DEPRECATED$ void $set_name$(int index, const char* value); - $DEPRECATED$ void $set_name$(int index, const $byte$* value, std::size_t size); -- $DEPRECATED$ void $set_name$(int index, absl::string_view value); - $DEPRECATED$ TProtoStringType* $add_name$(); - $DEPRECATED$ void $add_name$(const TProtoStringType& value); - $DEPRECATED$ void $add_name$(TProtoStringType&& value); - $DEPRECATED$ void $add_name$(const char* value); - $DEPRECATED$ void $add_name$(const $byte$* value, std::size_t size); -- $DEPRECATED$ void $add_name$(absl::string_view value); - $DEPRECATED$ const $pb$::RepeatedPtrField<TProtoStringType>& $name$() const; - $DEPRECATED$ $pb$::RepeatedPtrField<TProtoStringType>* $mutable_name$(); - -@@ -852,11 +850,6 @@ void RepeatedString::GenerateInlineAccessorDefinitions(io::Printer* p) const { - $annotate_set$; - // @@protoc_insertion_point(field_set_pointer:$pkg.Msg.field$) - } -- inline void $Msg$::set_$name$(int index, absl::string_view value) { -- $field_$.Mutable(index)->assign(value.data(), value.size()); -- $annotate_set$; -- // @@protoc_insertion_point(field_set_string_piece:$pkg.Msg.field$) -- } - inline TProtoStringType* $Msg$::_internal_add_$name$() { return $field_$.Add(); } - inline void $Msg$::add_$name$(const TProtoStringType& value) { - $field_$.Add()->assign(value); -@@ -879,11 +872,6 @@ void RepeatedString::GenerateInlineAccessorDefinitions(io::Printer* p) const { - $annotate_add$; - // @@protoc_insertion_point(field_add_pointer:$pkg.Msg.field$) - } -- inline void $Msg$::add_$name$(absl::string_view value) { -- $field_$.Add()->assign(value.data(), value.size()); -- $annotate_add$; -- // @@protoc_insertion_point(field_add_string_piece:$pkg.Msg.field$) -- } - inline const ::$proto_ns$::RepeatedPtrField<TProtoStringType>& - $Msg$::$name$() const { - $annotate_list$; diff --git a/contrib/libs/protobuf/patches/protoc-resolve-string-method-ambiguity.patch b/contrib/libs/protobuf/patches/protoc-resolve-string-method-ambiguity.patch new file mode 100644 index 0000000000..81df82ffae --- /dev/null +++ b/contrib/libs/protobuf/patches/protoc-resolve-string-method-ambiguity.patch @@ -0,0 +1,26 @@ +commit 3bc481cb6e0013371bdc01ae0aef7d85dc9abe1a (HEAD) +author: vadim-xd +date: 2024-10-28T13:19:23+03:00 + + Resolve ambiguity for repeated string methods + +--- a/src/google/protobuf/compiler/cpp/field_generators/string_field.cc (192810303a994f7cbd6bf596a3d56393bfefee6c) ++++ b/src/google/protobuf/compiler/cpp/field_generators/string_field.cc (3bc481cb6e0013371bdc01ae0aef7d85dc9abe1a) +@@ -782,12 +782,18 @@ void RepeatedString::GenerateAccessorDeclarations(io::Printer* p) const { + $DEPRECATED$ void $set_name$(int index, const char* value); + $DEPRECATED$ void $set_name$(int index, const $byte$* value, std::size_t size); + $DEPRECATED$ void $set_name$(int index, absl::string_view value); ++ $DEPRECATED$ void $set_name$(int index, std::string&& value) { ++ return $set_name$(index, TProtoStringType(std::move(value))); ++ } + $DEPRECATED$ TProtoStringType* $add_name$(); + $DEPRECATED$ void $add_name$(const TProtoStringType& value); + $DEPRECATED$ void $add_name$(TProtoStringType&& value); + $DEPRECATED$ void $add_name$(const char* value); + $DEPRECATED$ void $add_name$(const $byte$* value, std::size_t size); + $DEPRECATED$ void $add_name$(absl::string_view value); ++ $DEPRECATED$ void $add_name$(std::string&& value) { ++ return $add_name$(TProtoStringType(std::move(value))); ++ } + $DEPRECATED$ const $pb$::RepeatedPtrField<TProtoStringType>& $name$() const; + $DEPRECATED$ $pb$::RepeatedPtrField<TProtoStringType>* $mutable_name$(); diff --git a/contrib/libs/protobuf/patches/resolve-string-method-ambiguity.patch b/contrib/libs/protobuf/patches/resolve-string-method-ambiguity.patch new file mode 100644 index 0000000000..ad4f12f4e7 --- /dev/null +++ b/contrib/libs/protobuf/patches/resolve-string-method-ambiguity.patch @@ -0,0 +1,30 @@ +commit 4a55ea8892270807a046eb33fd5bc336b5fa93cb (HEAD) +author: vadim-xd +date: 2024-10-28T12:47:03+03:00 + + Resolve ambiguity in ArenaStringPtr methods with std::string&& + +--- contrib/libs/protobuf/src/google/protobuf/arenastring.h (e2819444222a1e9154b9c7b701eff6427206db7c) ++++ contrib/libs/protobuf/src/google/protobuf/arenastring.h (4a55ea8892270807a046eb33fd5bc336b5fa93cb) +@@ -266,6 +266,10 @@ struct PROTOBUF_EXPORT ArenaStringPtr { + void Set(const char* s, Arena* arena); + void Set(const char* s, size_t n, Arena* arena); + ++ void Set(std::string&& value, Arena* arena) { ++ return Set(TProtoStringType(std::move(value)), arena); ++ } ++ + void SetBytes(absl::string_view value, Arena* arena); + void SetBytes(TProtoStringType&& value, Arena* arena); + template <typename... OverloadDisambiguator> +@@ -273,6 +277,10 @@ struct PROTOBUF_EXPORT ArenaStringPtr { + void SetBytes(const char* s, Arena* arena); + void SetBytes(const void* p, size_t n, Arena* arena); + ++ void SetBytes(std::string&& value, Arena* arena) { ++ return SetBytes(TProtoStringType(std::move(value)), arena); ++ } ++ + template <typename RefWrappedType> + void Set(std::reference_wrapper<RefWrappedType> const_string_ref, + ::google::protobuf::Arena* arena) { diff --git a/contrib/libs/protobuf/patches/z_05_use_ref_count.patch b/contrib/libs/protobuf/patches/z_05_use_ref_count.patch index 391af0669c..1944eace13 100644 --- a/contrib/libs/protobuf/patches/z_05_use_ref_count.patch +++ b/contrib/libs/protobuf/patches/z_05_use_ref_count.patch @@ -1,14 +1,14 @@ --- contrib/libs/protobuf/src/google/protobuf/arenastring.cc (5de6c47c971aa5c751f17043b8ddf45bcc6daee0) +++ contrib/libs/protobuf/src/google/protobuf/arenastring.cc (c7e1b2fc457f6c68ed50780be734651758d4f548) -@@ -96,9 +96,9 @@ class ScopedCheckPtrInvariants { +@@ -96,9 +96,10 @@ class ScopedCheckPtrInvariants { #endif // NDEBUG || !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL // Creates a heap allocated TProtoStringType value. -inline TaggedStringPtr CreateString(absl::string_view value) { -+inline TaggedStringPtr CreateString(const TProtoStringType& value) { ++template <typename TArg> ++inline TaggedStringPtr CreateString(const TArg& value) { TaggedStringPtr res; - res.SetAllocated(new TProtoStringType(value.data(), value.length())); + res.SetAllocated(new TProtoStringType(value)); return res; } - diff --git a/contrib/libs/protobuf/src/google/protobuf/arenastring.cc b/contrib/libs/protobuf/src/google/protobuf/arenastring.cc index 4c4eb75da1..f466d542d9 100644 --- a/contrib/libs/protobuf/src/google/protobuf/arenastring.cc +++ b/contrib/libs/protobuf/src/google/protobuf/arenastring.cc @@ -96,7 +96,8 @@ class ScopedCheckPtrInvariants { #endif // NDEBUG || !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL // Creates a heap allocated TProtoStringType value. -inline TaggedStringPtr CreateString(const TProtoStringType& value) { +template <typename TArg> +inline TaggedStringPtr CreateString(const TArg& value) { TaggedStringPtr res; res.SetAllocated(new TProtoStringType(value)); return res; @@ -115,7 +116,7 @@ TaggedStringPtr CreateArenaString(Arena& arena, y_absl::string_view s) { } // namespace -void ArenaStringPtr::Set(const TProtoStringType& value, Arena* arena) { +void ArenaStringPtr::Set(y_absl::string_view value, Arena* arena) { ScopedCheckPtrInvariants check(&tagged_ptr_); if (IsDefault()) { // If we're not on an arena, skip straight to a true string to avoid diff --git a/contrib/libs/protobuf/src/google/protobuf/arenastring.h b/contrib/libs/protobuf/src/google/protobuf/arenastring.h index 62a1ae3d4a..edee6ef4cb 100644 --- a/contrib/libs/protobuf/src/google/protobuf/arenastring.h +++ b/contrib/libs/protobuf/src/google/protobuf/arenastring.h @@ -259,19 +259,28 @@ struct PROTOBUF_EXPORT ArenaStringPtr { // instance known to not carry any heap allocated value. inline void InitAllocated(TProtoStringType* str, Arena* arena); - void Set(const TProtoStringType& value, Arena* arena); + void Set(y_absl::string_view value, Arena* arena); void Set(TProtoStringType&& value, Arena* arena); template <typename... OverloadDisambiguator> void Set(const TProtoStringType& value, Arena* arena); void Set(const char* s, Arena* arena); void Set(const char* s, size_t n, Arena* arena); + void Set(std::string&& value, Arena* arena) { + return Set(TProtoStringType(std::move(value)), arena); + } + + void SetBytes(y_absl::string_view value, Arena* arena); void SetBytes(TProtoStringType&& value, Arena* arena); template <typename... OverloadDisambiguator> void SetBytes(const TProtoStringType& value, Arena* arena); void SetBytes(const char* s, Arena* arena); void SetBytes(const void* p, size_t n, Arena* arena); + void SetBytes(std::string&& value, Arena* arena) { + return SetBytes(TProtoStringType(std::move(value)), arena); + } + template <typename RefWrappedType> void Set(std::reference_wrapper<RefWrappedType> const_string_ref, ::google::protobuf::Arena* arena) { @@ -413,7 +422,11 @@ inline void ArenaStringPtr::Set(const char* s, Arena* arena) { } inline void ArenaStringPtr::Set(const char* s, size_t n, Arena* arena) { - Set(TProtoStringType(s, s + n), arena); + Set(y_absl::string_view{s, n}, arena); +} + +inline void ArenaStringPtr::SetBytes(y_absl::string_view value, Arena* arena) { + Set(value, arena); } template <> @@ -434,7 +447,7 @@ inline void ArenaStringPtr::SetBytes(const char* s, Arena* arena) { } inline void ArenaStringPtr::SetBytes(const void* p, size_t n, Arena* arena) { - Set(TProtoStringType(static_cast<const char*>(p), static_cast<const char*>(p) + n), arena); + Set(y_absl::string_view{static_cast<const char*>(p), n}, arena); } // Make sure rhs_arena allocated rhs, and lhs_arena allocated lhs. diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/string_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/string_field.cc index 11b5b83ea6..0da0e56609 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/string_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/string_field.cc @@ -781,11 +781,19 @@ void RepeatedString::GenerateAccessorDeclarations(io::Printer* p) const { $DEPRECATED$ void $set_name$(int index, TProtoStringType&& value); $DEPRECATED$ void $set_name$(int index, const char* value); $DEPRECATED$ void $set_name$(int index, const $byte$* value, std::size_t size); + $DEPRECATED$ void $set_name$(int index, y_absl::string_view value); + $DEPRECATED$ void $set_name$(int index, std::string&& value) { + return $set_name$(index, TProtoStringType(std::move(value))); + } $DEPRECATED$ TProtoStringType* $add_name$(); $DEPRECATED$ void $add_name$(const TProtoStringType& value); $DEPRECATED$ void $add_name$(TProtoStringType&& value); $DEPRECATED$ void $add_name$(const char* value); $DEPRECATED$ void $add_name$(const $byte$* value, std::size_t size); + $DEPRECATED$ void $add_name$(y_absl::string_view value); + $DEPRECATED$ void $add_name$(std::string&& value) { + return $add_name$(TProtoStringType(std::move(value))); + } $DEPRECATED$ const $pb$::RepeatedPtrField<TProtoStringType>& $name$() const; $DEPRECATED$ $pb$::RepeatedPtrField<TProtoStringType>* $mutable_name$(); @@ -850,6 +858,11 @@ void RepeatedString::GenerateInlineAccessorDefinitions(io::Printer* p) const { $annotate_set$; // @@protoc_insertion_point(field_set_pointer:$pkg.Msg.field$) } + inline void $Msg$::set_$name$(int index, y_absl::string_view value) { + $field_$.Mutable(index)->assign(value.data(), value.size()); + $annotate_set$; + // @@protoc_insertion_point(field_set_string_piece:$pkg.Msg.field$) + } inline TProtoStringType* $Msg$::_internal_add_$name$() { return $field_$.Add(); } inline void $Msg$::add_$name$(const TProtoStringType& value) { $field_$.Add()->assign(value); @@ -872,6 +885,11 @@ void RepeatedString::GenerateInlineAccessorDefinitions(io::Printer* p) const { $annotate_add$; // @@protoc_insertion_point(field_add_pointer:$pkg.Msg.field$) } + inline void $Msg$::add_$name$(y_absl::string_view value) { + $field_$.Add()->assign(value.data(), value.size()); + $annotate_add$; + // @@protoc_insertion_point(field_add_string_piece:$pkg.Msg.field$) + } inline const ::$proto_ns$::RepeatedPtrField<TProtoStringType>& $Msg$::$name$() const { $annotate_list$; diff --git a/contrib/tools/protoc/resources.json b/contrib/tools/protoc/resources.json index 2e78d6bf7f..bc895b2859 100644 --- a/contrib/tools/protoc/resources.json +++ b/contrib/tools/protoc/resources.json @@ -1,19 +1,19 @@ { "by_platform": { "darwin": { - "uri": "sbr:7039760192" + "uri": "sbr:7360495216" }, "darwin-arm64": { - "uri": "sbr:7039759830" + "uri": "sbr:7360493349" }, "linux": { - "uri": "sbr:7039760920" + "uri": "sbr:7360499157" }, "linux-aarch64": { - "uri": "sbr:7039760572" + "uri": "sbr:7360497335" }, "win32": { - "uri": "sbr:7039759509" + "uri": "sbr:7360491807" } } } |