mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpiutil,glass,dlt] Replace libprotobuf with upb for dynamic decode (#7988)
libprotobuf is a very annoying dependency to deal with, and with the switch to nanopb for generated C++ code, libprotobuf is only used for dynamic decode in the GUI apps. libprotobuf has been swapped out with upb, a much smaller C-based library that supports reflection and can therefore do dynamic decode. This means we can remove the libprotobuf dependency and stop dealing with build issues because of it.
This commit is contained in:
@@ -1,269 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
from upstream_utils import Lib, walk_cwd_and_copy_if
|
||||
|
||||
protobuf_lite_sources = {
|
||||
Path("any_lite.cc"),
|
||||
Path("arena.cc"),
|
||||
Path("arenastring.cc"),
|
||||
Path("arenaz_sampler.cc"),
|
||||
Path("extension_set.cc"),
|
||||
Path("generated_enum_util.cc"),
|
||||
Path("generated_message_tctable_lite.cc"),
|
||||
Path("generated_message_util.cc"),
|
||||
Path("implicit_weak_message.cc"),
|
||||
Path("inlined_string_field.cc"),
|
||||
Path("io/coded_stream.cc"),
|
||||
Path("io/io_win32.cc"),
|
||||
Path("io/strtod.cc"),
|
||||
Path("io/zero_copy_stream.cc"),
|
||||
Path("io/zero_copy_stream_impl.cc"),
|
||||
Path("io/zero_copy_stream_impl_lite.cc"),
|
||||
Path("map.cc"),
|
||||
Path("message_lite.cc"),
|
||||
Path("parse_context.cc"),
|
||||
Path("repeated_field.cc"),
|
||||
Path("repeated_ptr_field.cc"),
|
||||
Path("stubs/bytestream.cc"),
|
||||
Path("stubs/common.cc"),
|
||||
Path("stubs/int128.cc"),
|
||||
Path("stubs/status.cc"),
|
||||
Path("stubs/statusor.cc"),
|
||||
Path("stubs/stringpiece.cc"),
|
||||
Path("stubs/stringprintf.cc"),
|
||||
Path("stubs/structurally_valid.cc"),
|
||||
Path("stubs/strutil.cc"),
|
||||
Path("stubs/time.cc"),
|
||||
Path("wire_format_lite.cc"),
|
||||
}
|
||||
|
||||
protobuf_lite_includes = {
|
||||
Path("google/protobuf/any.h"),
|
||||
Path("google/protobuf/arena.h"),
|
||||
Path("google/protobuf/arena_impl.h"),
|
||||
Path("google/protobuf/arenastring.h"),
|
||||
Path("google/protobuf/arenaz_sampler.h"),
|
||||
Path("google/protobuf/endian.h"),
|
||||
Path("google/protobuf/explicitly_constructed.h"),
|
||||
Path("google/protobuf/extension_set.h"),
|
||||
Path("google/protobuf/extension_set_inl.h"),
|
||||
Path("google/protobuf/generated_enum_util.h"),
|
||||
Path("google/protobuf/generated_message_tctable_decl.h"),
|
||||
Path("google/protobuf/generated_message_tctable_impl.h"),
|
||||
Path("google/protobuf/generated_message_util.h"),
|
||||
Path("google/protobuf/has_bits.h"),
|
||||
Path("google/protobuf/implicit_weak_message.h"),
|
||||
Path("google/protobuf/inlined_string_field.h"),
|
||||
Path("google/protobuf/io/coded_stream.h"),
|
||||
Path("google/protobuf/io/io_win32.h"),
|
||||
Path("google/protobuf/io/strtod.h"),
|
||||
Path("google/protobuf/io/zero_copy_stream.h"),
|
||||
Path("google/protobuf/io/zero_copy_stream_impl.h"),
|
||||
Path("google/protobuf/io/zero_copy_stream_impl_lite.h"),
|
||||
Path("google/protobuf/map.h"),
|
||||
Path("google/protobuf/map_entry_lite.h"),
|
||||
Path("google/protobuf/map_field_lite.h"),
|
||||
Path("google/protobuf/map_type_handler.h"),
|
||||
Path("google/protobuf/message_lite.h"),
|
||||
Path("google/protobuf/metadata_lite.h"),
|
||||
Path("google/protobuf/parse_context.h"),
|
||||
Path("google/protobuf/port.h"),
|
||||
Path("google/protobuf/repeated_field.h"),
|
||||
Path("google/protobuf/repeated_ptr_field.h"),
|
||||
Path("google/protobuf/stubs/bytestream.h"),
|
||||
Path("google/protobuf/stubs/callback.h"),
|
||||
Path("google/protobuf/stubs/casts.h"),
|
||||
Path("google/protobuf/stubs/common.h"),
|
||||
Path("google/protobuf/stubs/hash.h"),
|
||||
Path("google/protobuf/stubs/logging.h"),
|
||||
Path("google/protobuf/stubs/macros.h"),
|
||||
Path("google/protobuf/stubs/map_util.h"),
|
||||
Path("google/protobuf/stubs/mutex.h"),
|
||||
Path("google/protobuf/stubs/once.h"),
|
||||
Path("google/protobuf/stubs/platform_macros.h"),
|
||||
Path("google/protobuf/stubs/port.h"),
|
||||
Path("google/protobuf/stubs/status.h"),
|
||||
Path("google/protobuf/stubs/stl_util.h"),
|
||||
Path("google/protobuf/stubs/stringpiece.h"),
|
||||
Path("google/protobuf/stubs/strutil.h"),
|
||||
Path("google/protobuf/stubs/template_util.h"),
|
||||
Path("google/protobuf/wire_format_lite.h"),
|
||||
}
|
||||
protobuf_sources = {
|
||||
Path("any.cc"),
|
||||
Path("any.pb.cc"),
|
||||
Path("api.pb.cc"),
|
||||
Path("compiler/importer.cc"),
|
||||
Path("compiler/parser.cc"),
|
||||
Path("descriptor.cc"),
|
||||
Path("descriptor.pb.cc"),
|
||||
Path("descriptor_database.cc"),
|
||||
Path("duration.pb.cc"),
|
||||
Path("dynamic_message.cc"),
|
||||
Path("empty.pb.cc"),
|
||||
Path("extension_set_heavy.cc"),
|
||||
Path("field_mask.pb.cc"),
|
||||
Path("generated_message_bases.cc"),
|
||||
Path("generated_message_reflection.cc"),
|
||||
Path("generated_message_tctable_full.cc"),
|
||||
Path("io/gzip_stream.cc"),
|
||||
Path("io/printer.cc"),
|
||||
Path("io/tokenizer.cc"),
|
||||
Path("map_field.cc"),
|
||||
Path("message.cc"),
|
||||
Path("reflection_ops.cc"),
|
||||
Path("service.cc"),
|
||||
Path("source_context.pb.cc"),
|
||||
Path("struct.pb.cc"),
|
||||
Path("stubs/substitute.cc"),
|
||||
Path("text_format.cc"),
|
||||
Path("timestamp.pb.cc"),
|
||||
Path("type.pb.cc"),
|
||||
Path("unknown_field_set.cc"),
|
||||
Path("util/delimited_message_util.cc"),
|
||||
Path("util/field_comparator.cc"),
|
||||
Path("util/field_mask_util.cc"),
|
||||
Path("util/internal/datapiece.cc"),
|
||||
Path("util/internal/default_value_objectwriter.cc"),
|
||||
Path("util/internal/error_listener.cc"),
|
||||
Path("util/internal/field_mask_utility.cc"),
|
||||
Path("util/internal/json_escaping.cc"),
|
||||
Path("util/internal/json_objectwriter.cc"),
|
||||
Path("util/internal/json_stream_parser.cc"),
|
||||
Path("util/internal/object_writer.cc"),
|
||||
Path("util/internal/proto_writer.cc"),
|
||||
Path("util/internal/protostream_objectsource.cc"),
|
||||
Path("util/internal/protostream_objectwriter.cc"),
|
||||
Path("util/internal/type_info.cc"),
|
||||
Path("util/internal/utility.cc"),
|
||||
Path("util/json_util.cc"),
|
||||
Path("util/message_differencer.cc"),
|
||||
Path("util/time_util.cc"),
|
||||
Path("util/type_resolver_util.cc"),
|
||||
Path("wire_format.cc"),
|
||||
Path("wrappers.pb.cc"),
|
||||
}
|
||||
|
||||
protobuf_includes = {
|
||||
Path("google/protobuf/any.pb.h"),
|
||||
Path("google/protobuf/api.pb.h"),
|
||||
Path("google/protobuf/compiler/importer.h"),
|
||||
Path("google/protobuf/compiler/parser.h"),
|
||||
Path("google/protobuf/descriptor.h"),
|
||||
Path("google/protobuf/descriptor.pb.h"),
|
||||
Path("google/protobuf/descriptor_database.h"),
|
||||
Path("google/protobuf/duration.pb.h"),
|
||||
Path("google/protobuf/dynamic_message.h"),
|
||||
Path("google/protobuf/empty.pb.h"),
|
||||
Path("google/protobuf/field_access_listener.h"),
|
||||
Path("google/protobuf/field_mask.pb.h"),
|
||||
Path("google/protobuf/generated_enum_reflection.h"),
|
||||
Path("google/protobuf/generated_message_bases.h"),
|
||||
Path("google/protobuf/generated_message_reflection.h"),
|
||||
Path("google/protobuf/io/gzip_stream.h"),
|
||||
Path("google/protobuf/io/printer.h"),
|
||||
Path("google/protobuf/io/tokenizer.h"),
|
||||
Path("google/protobuf/map_entry.h"),
|
||||
Path("google/protobuf/map_field.h"),
|
||||
Path("google/protobuf/map_field_inl.h"),
|
||||
Path("google/protobuf/message.h"),
|
||||
Path("google/protobuf/metadata.h"),
|
||||
Path("google/protobuf/reflection.h"),
|
||||
Path("google/protobuf/reflection_internal.h"),
|
||||
Path("google/protobuf/reflection_ops.h"),
|
||||
Path("google/protobuf/service.h"),
|
||||
Path("google/protobuf/source_context.pb.h"),
|
||||
Path("google/protobuf/struct.pb.h"),
|
||||
Path("google/protobuf/text_format.h"),
|
||||
Path("google/protobuf/timestamp.pb.h"),
|
||||
Path("google/protobuf/type.pb.h"),
|
||||
Path("google/protobuf/unknown_field_set.h"),
|
||||
Path("google/protobuf/util/delimited_message_util.h"),
|
||||
Path("google/protobuf/util/field_comparator.h"),
|
||||
Path("google/protobuf/util/field_mask_util.h"),
|
||||
Path("google/protobuf/util/json_util.h"),
|
||||
Path("google/protobuf/util/message_differencer.h"),
|
||||
Path("google/protobuf/util/time_util.h"),
|
||||
Path("google/protobuf/util/type_resolver.h"),
|
||||
Path("google/protobuf/util/type_resolver_util.h"),
|
||||
Path("google/protobuf/wire_format.h"),
|
||||
Path("google/protobuf/wrappers.pb.h"),
|
||||
}
|
||||
|
||||
protobuf_internal_includes = {
|
||||
Path("google/protobuf/port_def.inc"),
|
||||
Path("google/protobuf/port_undef.inc"),
|
||||
Path("google/protobuf/stubs/int128.h"),
|
||||
Path("google/protobuf/stubs/mathutil.h"),
|
||||
Path("google/protobuf/stubs/statusor.h"),
|
||||
Path("google/protobuf/stubs/status_macros.h"),
|
||||
Path("google/protobuf/stubs/stringprintf.h"),
|
||||
Path("google/protobuf/stubs/substitute.h"),
|
||||
Path("google/protobuf/stubs/time.h"),
|
||||
Path("google/protobuf/util/internal/constants.h"),
|
||||
Path("google/protobuf/util/internal/datapiece.h"),
|
||||
Path("google/protobuf/util/internal/default_value_objectwriter.h"),
|
||||
Path("google/protobuf/util/internal/error_listener.h"),
|
||||
Path("google/protobuf/util/internal/field_mask_utility.h"),
|
||||
Path("google/protobuf/util/internal/json_escaping.h"),
|
||||
Path("google/protobuf/util/internal/json_objectwriter.h"),
|
||||
Path("google/protobuf/util/internal/json_stream_parser.h"),
|
||||
Path("google/protobuf/util/internal/location_tracker.h"),
|
||||
Path("google/protobuf/util/internal/object_location_tracker.h"),
|
||||
Path("google/protobuf/util/internal/object_source.h"),
|
||||
Path("google/protobuf/util/internal/object_writer.h"),
|
||||
Path("google/protobuf/util/internal/proto_writer.h"),
|
||||
Path("google/protobuf/util/internal/protostream_objectsource.h"),
|
||||
Path("google/protobuf/util/internal/protostream_objectwriter.h"),
|
||||
Path("google/protobuf/util/internal/structured_objectwriter.h"),
|
||||
Path("google/protobuf/util/internal/type_info.h"),
|
||||
Path("google/protobuf/util/internal/utility.h"),
|
||||
}
|
||||
|
||||
use_src_files = protobuf_lite_sources | protobuf_sources
|
||||
use_include_files = (
|
||||
protobuf_lite_includes | protobuf_includes | protobuf_internal_includes
|
||||
)
|
||||
|
||||
|
||||
def copy_upstream_src(wpilib_root: Path):
|
||||
upstream_root = Path(".").absolute()
|
||||
wpiutil = wpilib_root / "wpiutil"
|
||||
|
||||
# Delete old install
|
||||
for d in [
|
||||
"src/main/native/thirdparty/protobuf/src",
|
||||
"src/main/native/thirdparty/protobuf/include",
|
||||
]:
|
||||
shutil.rmtree(wpiutil / d, ignore_errors=True)
|
||||
|
||||
# Copy protobuf source files into allwpilib
|
||||
os.chdir(upstream_root / "src/google/protobuf")
|
||||
walk_cwd_and_copy_if(
|
||||
lambda dp, f: dp / f in use_src_files,
|
||||
wpiutil / "src/main/native/thirdparty/protobuf/src",
|
||||
)
|
||||
|
||||
# Copy protobuf header files into allwpilib
|
||||
os.chdir(upstream_root / "src")
|
||||
walk_cwd_and_copy_if(
|
||||
lambda dp, f: dp / f in use_include_files,
|
||||
wpiutil / "src/main/native/thirdparty/protobuf/include",
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
name = "protobuf"
|
||||
url = "https://github.com/protocolbuffers/protobuf"
|
||||
tag = "v3.21.12"
|
||||
|
||||
protobuf = Lib(name, url, tag, copy_upstream_src)
|
||||
protobuf.main()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,325 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Johnson <johnson.peter@gmail.com>
|
||||
Date: Sat, 10 Jun 2023 14:13:07 -0700
|
||||
Subject: [PATCH 01/15] Fix sign-compare warnings
|
||||
|
||||
---
|
||||
src/google/protobuf/compiler/importer.cc | 2 +-
|
||||
src/google/protobuf/compiler/parser.cc | 4 ++--
|
||||
src/google/protobuf/io/io_win32.cc | 2 +-
|
||||
src/google/protobuf/stubs/stringprintf.cc | 4 ++--
|
||||
src/google/protobuf/stubs/strutil.cc | 2 +-
|
||||
src/google/protobuf/stubs/substitute.cc | 2 +-
|
||||
src/google/protobuf/util/field_mask_util.cc | 2 +-
|
||||
src/google/protobuf/util/internal/datapiece.cc | 7 +++++++
|
||||
.../protobuf/util/internal/default_value_objectwriter.cc | 4 ++--
|
||||
.../protobuf/util/internal/default_value_objectwriter.h | 2 +-
|
||||
src/google/protobuf/util/internal/json_escaping.cc | 6 +++---
|
||||
src/google/protobuf/util/internal/json_objectwriter.h | 2 +-
|
||||
src/google/protobuf/util/internal/json_stream_parser.cc | 8 ++++----
|
||||
src/google/protobuf/util/internal/proto_writer.cc | 2 +-
|
||||
.../protobuf/util/internal/protostream_objectwriter.cc | 2 +-
|
||||
src/google/protobuf/util/internal/utility.cc | 2 +-
|
||||
src/google/protobuf/util/json_util.cc | 2 +-
|
||||
17 files changed, 31 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc
|
||||
index f1e26f8bdd1d3619acd8827f9a2a0e6b2acdd124..678e87eb03cc3959a1890327cd1e918cb1896fa3 100644
|
||||
--- a/src/google/protobuf/compiler/importer.cc
|
||||
+++ b/src/google/protobuf/compiler/importer.cc
|
||||
@@ -398,7 +398,7 @@ DiskSourceTree::DiskFileToVirtualFile(const std::string& disk_file,
|
||||
int mapping_index = -1;
|
||||
std::string canonical_disk_file = CanonicalizePath(disk_file);
|
||||
|
||||
- for (int i = 0; i < mappings_.size(); i++) {
|
||||
+ for (size_t i = 0; i < mappings_.size(); i++) {
|
||||
// Apply the mapping in reverse.
|
||||
if (ApplyMapping(canonical_disk_file, mappings_[i].disk_path,
|
||||
mappings_[i].virtual_path, virtual_file)) {
|
||||
diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc
|
||||
index 5bd37d147bc449444f875f89367a208a32a9146e..e36a4a74359fcace20c017f241d58930660b9381 100644
|
||||
--- a/src/google/protobuf/compiler/parser.cc
|
||||
+++ b/src/google/protobuf/compiler/parser.cc
|
||||
@@ -159,7 +159,7 @@ bool IsLowerUnderscore(const std::string& name) {
|
||||
}
|
||||
|
||||
bool IsNumberFollowUnderscore(const std::string& name) {
|
||||
- for (int i = 1; i < name.length(); i++) {
|
||||
+ for (size_t i = 1; i < name.length(); i++) {
|
||||
const char c = name[i];
|
||||
if (IsNumber(c) && name[i - 1] == '_') {
|
||||
return true;
|
||||
@@ -500,7 +500,7 @@ void Parser::LocationRecorder::AttachComments(
|
||||
if (!trailing->empty()) {
|
||||
location_->mutable_trailing_comments()->swap(*trailing);
|
||||
}
|
||||
- for (int i = 0; i < detached_comments->size(); ++i) {
|
||||
+ for (size_t i = 0; i < detached_comments->size(); ++i) {
|
||||
location_->add_leading_detached_comments()->swap((*detached_comments)[i]);
|
||||
}
|
||||
detached_comments->clear();
|
||||
diff --git a/src/google/protobuf/io/io_win32.cc b/src/google/protobuf/io/io_win32.cc
|
||||
index 4e8190880918f1ba155d75db76d6c1ee0b003247..78c07d0d771b9c227c6cd930fc91d272fd67500f 100644
|
||||
--- a/src/google/protobuf/io/io_win32.cc
|
||||
+++ b/src/google/protobuf/io/io_win32.cc
|
||||
@@ -198,7 +198,7 @@ wstring normalize(wstring path) {
|
||||
// Join all segments.
|
||||
bool first = true;
|
||||
std::wstringstream result;
|
||||
- for (int i = 0; i < segments.size(); ++i) {
|
||||
+ for (size_t i = 0; i < segments.size(); ++i) {
|
||||
if (!first) {
|
||||
result << L'\\';
|
||||
}
|
||||
diff --git a/src/google/protobuf/stubs/stringprintf.cc b/src/google/protobuf/stubs/stringprintf.cc
|
||||
index a6ad4c0da4080f5241c26176046a3add5247e25c..8b890f47c386f0d6b0ab9fd9928fae03edd076eb 100644
|
||||
--- a/src/google/protobuf/stubs/stringprintf.cc
|
||||
+++ b/src/google/protobuf/stubs/stringprintf.cc
|
||||
@@ -149,10 +149,10 @@ std::string StringPrintfVector(const char* format,
|
||||
// or displaying random chunks of memory to users.
|
||||
|
||||
const char* cstr[kStringPrintfVectorMaxArgs];
|
||||
- for (int i = 0; i < v.size(); ++i) {
|
||||
+ for (size_t i = 0; i < v.size(); ++i) {
|
||||
cstr[i] = v[i].c_str();
|
||||
}
|
||||
- for (int i = v.size(); i < GOOGLE_ARRAYSIZE(cstr); ++i) {
|
||||
+ for (size_t i = v.size(); i < GOOGLE_ARRAYSIZE(cstr); ++i) {
|
||||
cstr[i] = &string_printf_empty_block[0];
|
||||
}
|
||||
|
||||
diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc
|
||||
index 594c8eac6a6ebff6d8bc8cc8518e3fd521f24da1..3462e91ff273dc071628f06b91698a0f166514fc 100644
|
||||
--- a/src/google/protobuf/stubs/strutil.cc
|
||||
+++ b/src/google/protobuf/stubs/strutil.cc
|
||||
@@ -697,7 +697,7 @@ bool safe_parse_positive_int(std::string text, IntType *value_p) {
|
||||
IntType value = 0;
|
||||
const IntType vmax = std::numeric_limits<IntType>::max();
|
||||
assert(vmax > 0);
|
||||
- assert(vmax >= base);
|
||||
+ assert(static_cast<int>(vmax) >= base);
|
||||
const IntType vmax_over_base = vmax / base;
|
||||
const char* start = text.data();
|
||||
const char* end = start + text.size();
|
||||
diff --git a/src/google/protobuf/stubs/substitute.cc b/src/google/protobuf/stubs/substitute.cc
|
||||
index d301682ee3377760430839bc5d6530621333e48d..8c75b2562e43d9d4ade3ef187d38e2e81b43e2c7 100644
|
||||
--- a/src/google/protobuf/stubs/substitute.cc
|
||||
+++ b/src/google/protobuf/stubs/substitute.cc
|
||||
@@ -128,7 +128,7 @@ void SubstituteAndAppend(std::string* output, const char* format,
|
||||
}
|
||||
}
|
||||
|
||||
- GOOGLE_DCHECK_EQ(target - output->data(), output->size());
|
||||
+ GOOGLE_DCHECK_EQ(target - output->data(), static_cast<int>(output->size()));
|
||||
}
|
||||
|
||||
} // namespace strings
|
||||
diff --git a/src/google/protobuf/util/field_mask_util.cc b/src/google/protobuf/util/field_mask_util.cc
|
||||
index 700e59004a083c731477bcc0bb4d5c36d06f306c..9a40b851a9e51d30b286ff5d89707bf9f279d0c0 100644
|
||||
--- a/src/google/protobuf/util/field_mask_util.cc
|
||||
+++ b/src/google/protobuf/util/field_mask_util.cc
|
||||
@@ -366,7 +366,7 @@ void FieldMaskTree::RemovePath(const std::string& path,
|
||||
Node* node = &root_;
|
||||
const Descriptor* current_descriptor = descriptor;
|
||||
Node* new_branch_node = nullptr;
|
||||
- for (int i = 0; i < parts.size(); ++i) {
|
||||
+ for (size_t i = 0; i < parts.size(); ++i) {
|
||||
nodes[i] = node;
|
||||
const FieldDescriptor* field_descriptor =
|
||||
current_descriptor->FindFieldByName(parts[i]);
|
||||
diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc
|
||||
index 3e7aa84da7181e2ab270e181b9f63deb1905542f..56f4a18fa4afc64708938fa5352937cdd17b5747 100644
|
||||
--- a/src/google/protobuf/util/internal/datapiece.cc
|
||||
+++ b/src/google/protobuf/util/internal/datapiece.cc
|
||||
@@ -53,6 +53,10 @@ namespace {
|
||||
|
||||
template <typename To, typename From>
|
||||
util::StatusOr<To> ValidateNumberConversion(To after, From before) {
|
||||
+#ifdef __GNUC__
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
+#endif
|
||||
if (after == before &&
|
||||
MathUtil::Sign<From>(before) == MathUtil::Sign<To>(after)) {
|
||||
return after;
|
||||
@@ -62,6 +66,9 @@ util::StatusOr<To> ValidateNumberConversion(To after, From before) {
|
||||
: std::is_same<From, double>::value ? DoubleAsString(before)
|
||||
: FloatAsString(before));
|
||||
}
|
||||
+#ifdef __GNUC__
|
||||
+#pragma GCC diagnostic pop
|
||||
+#endif
|
||||
}
|
||||
|
||||
// For general conversion between
|
||||
diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.cc b/src/google/protobuf/util/internal/default_value_objectwriter.cc
|
||||
index 7f61cdafa7c771a69364c5e9c49667535b16d957..a7d4ce78bd47e0250def474df8937927be9ef116 100644
|
||||
--- a/src/google/protobuf/util/internal/default_value_objectwriter.cc
|
||||
+++ b/src/google/protobuf/util/internal/default_value_objectwriter.cc
|
||||
@@ -312,7 +312,7 @@ void DefaultValueObjectWriter::Node::PopulateChildren(
|
||||
std::unordered_map<std::string, int> orig_children_map;
|
||||
|
||||
// Creates a map of child nodes to speed up lookup.
|
||||
- for (int i = 0; i < children_.size(); ++i) {
|
||||
+ for (size_t i = 0; i < children_.size(); ++i) {
|
||||
InsertIfNotPresent(&orig_children_map, children_[i]->name_, i);
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ void DefaultValueObjectWriter::Node::PopulateChildren(
|
||||
new_children.push_back(child.release());
|
||||
}
|
||||
// Adds all leftover nodes in children_ to the beginning of new_child.
|
||||
- for (int i = 0; i < children_.size(); ++i) {
|
||||
+ for (size_t i = 0; i < children_.size(); ++i) {
|
||||
if (children_[i] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.h b/src/google/protobuf/util/internal/default_value_objectwriter.h
|
||||
index a9e1673fa1e4ed35ab6890a44eed1d362265d914..1a151ab25951f8b0e1c9c724253b16524b88530a 100644
|
||||
--- a/src/google/protobuf/util/internal/default_value_objectwriter.h
|
||||
+++ b/src/google/protobuf/util/internal/default_value_objectwriter.h
|
||||
@@ -154,7 +154,7 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
|
||||
bool preserve_proto_field_names, bool use_ints_for_enums,
|
||||
FieldScrubCallBack field_scrub_callback);
|
||||
virtual ~Node() {
|
||||
- for (int i = 0; i < children_.size(); ++i) {
|
||||
+ for (size_t i = 0; i < children_.size(); ++i) {
|
||||
delete children_[i];
|
||||
}
|
||||
}
|
||||
diff --git a/src/google/protobuf/util/internal/json_escaping.cc b/src/google/protobuf/util/internal/json_escaping.cc
|
||||
index e4fa8cf788642e4a9d9c0460c287b1c24891b9fa..c192ddca7aff3984ffcbf82e13585bdf34ad8aae 100644
|
||||
--- a/src/google/protobuf/util/internal/json_escaping.cc
|
||||
+++ b/src/google/protobuf/util/internal/json_escaping.cc
|
||||
@@ -179,7 +179,7 @@ bool ReadCodePoint(StringPiece str, int index, uint32_t* cp,
|
||||
// the last unicode code point.
|
||||
*num_read = 0;
|
||||
}
|
||||
- while (*num_left > 0 && index < str.size()) {
|
||||
+ while (*num_left > 0 && index < static_cast<int>(str.size())) {
|
||||
uint32_t ch = static_cast<uint8_t>(str[index++]);
|
||||
--(*num_left);
|
||||
++(*num_read);
|
||||
@@ -309,7 +309,7 @@ void JsonEscaping::Escape(strings::ByteSource* input,
|
||||
while (input->Available() > 0) {
|
||||
StringPiece str = input->Peek();
|
||||
StringPiece escaped;
|
||||
- int i = 0;
|
||||
+ size_t i = 0;
|
||||
int num_read;
|
||||
bool ok;
|
||||
bool cp_was_split = num_left > 0;
|
||||
@@ -349,7 +349,7 @@ void JsonEscaping::Escape(StringPiece input, strings::ByteSink* output) {
|
||||
const char* p = input.data();
|
||||
|
||||
bool can_skip_escaping = true;
|
||||
- for (int i = 0; i < len; i++) {
|
||||
+ for (size_t i = 0; i < len; i++) {
|
||||
char c = p[i];
|
||||
if (c < 0x20 || c >= 0x7F || c == '"' || c == '<' || c == '>' ||
|
||||
c == '\\') {
|
||||
diff --git a/src/google/protobuf/util/internal/json_objectwriter.h b/src/google/protobuf/util/internal/json_objectwriter.h
|
||||
index cb7dff6e9fe79858a73b2c7501106fe8d05ccac5..92348da3b5c3f07e6146136352f976c94fe54340 100644
|
||||
--- a/src/google/protobuf/util/internal/json_objectwriter.h
|
||||
+++ b/src/google/protobuf/util/internal/json_objectwriter.h
|
||||
@@ -102,7 +102,7 @@ class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
|
||||
if (!indent_string.empty()) {
|
||||
indent_char_ = indent_string[0];
|
||||
indent_count_ = indent_string.length();
|
||||
- for (int i = 1; i < indent_string.length(); i++) {
|
||||
+ for (size_t i = 1; i < indent_string.length(); i++) {
|
||||
if (indent_char_ != indent_string_[i]) {
|
||||
indent_char_ = '\0';
|
||||
indent_count_ = 0;
|
||||
diff --git a/src/google/protobuf/util/internal/json_stream_parser.cc b/src/google/protobuf/util/internal/json_stream_parser.cc
|
||||
index 5c34dbccafb9f40249ba3c0b7318b2e897f203dc..e786781f6de23c8a7ea282d061df6032111f6d21 100644
|
||||
--- a/src/google/protobuf/util/internal/json_stream_parser.cc
|
||||
+++ b/src/google/protobuf/util/internal/json_stream_parser.cc
|
||||
@@ -80,7 +80,7 @@ inline void ReplaceInvalidCodePoints(StringPiece str,
|
||||
const std::string& replacement,
|
||||
std::string* dst) {
|
||||
while (!str.empty()) {
|
||||
- int n_valid_bytes = internal::UTF8SpnStructurallyValid(str);
|
||||
+ size_t n_valid_bytes = internal::UTF8SpnStructurallyValid(str);
|
||||
StringPiece valid_part = str.substr(0, n_valid_bytes);
|
||||
StrAppend(dst, valid_part);
|
||||
|
||||
@@ -98,7 +98,7 @@ inline void ReplaceInvalidCodePoints(StringPiece str,
|
||||
|
||||
static bool ConsumeKey(StringPiece* input, StringPiece* key) {
|
||||
if (input->empty() || !IsLetter((*input)[0])) return false;
|
||||
- int len = 1;
|
||||
+ size_t len = 1;
|
||||
for (; len < input->size(); ++len) {
|
||||
if (!IsAlphanumeric((*input)[len])) {
|
||||
break;
|
||||
@@ -113,7 +113,7 @@ static bool ConsumeKey(StringPiece* input, StringPiece* key) {
|
||||
static bool ConsumeKeyPermissive(StringPiece* input,
|
||||
StringPiece* key) {
|
||||
if (input->empty() || !IsLetter((*input)[0])) return false;
|
||||
- int len = 1;
|
||||
+ size_t len = 1;
|
||||
for (; len < input->size(); ++len) {
|
||||
if (IsKeySeparator((*input)[len])) {
|
||||
break;
|
||||
@@ -946,7 +946,7 @@ util::Status JsonStreamParser::ParseKey() {
|
||||
JsonStreamParser::TokenType JsonStreamParser::GetNextTokenType() {
|
||||
SkipWhitespace();
|
||||
|
||||
- int size = p_.size();
|
||||
+ size_t size = p_.size();
|
||||
if (size == 0) {
|
||||
// If we ran out of data, report unknown and we'll place the previous parse
|
||||
// type onto the stack and try again when we have more data.
|
||||
diff --git a/src/google/protobuf/util/internal/proto_writer.cc b/src/google/protobuf/util/internal/proto_writer.cc
|
||||
index afa5e2e474b6960b8826a40b73615d5dffd971de..11b6df13d8f4f9506e828c39d6e74bc8acceb23d 100644
|
||||
--- a/src/google/protobuf/util/internal/proto_writer.cc
|
||||
+++ b/src/google/protobuf/util/internal/proto_writer.cc
|
||||
@@ -408,7 +408,7 @@ std::string ProtoWriter::ProtoElement::ToString() const {
|
||||
if (!ow_->IsRepeated(*(now->parent_field_)) ||
|
||||
now->parent()->parent_field_ != now->parent_field_) {
|
||||
std::string name = now->parent_field_->name();
|
||||
- int i = 0;
|
||||
+ size_t i = 0;
|
||||
while (i < name.size() &&
|
||||
(ascii_isalnum(name[i]) || name[i] == '_'))
|
||||
++i;
|
||||
diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc
|
||||
index ecb219e06e514b1a6ba0e3e343126a75852d0a1d..ce94cfcefb417203f80142c54003efea283f6a1c 100644
|
||||
--- a/src/google/protobuf/util/internal/protostream_objectwriter.cc
|
||||
+++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc
|
||||
@@ -378,7 +378,7 @@ void ProtoStreamObjectWriter::AnyWriter::StartAny(const DataPiece& value) {
|
||||
|
||||
// Now we know the proto type and can interpret all data fields we gathered
|
||||
// before the "@type" field.
|
||||
- for (int i = 0; i < uninterpreted_events_.size(); ++i) {
|
||||
+ for (size_t i = 0; i < uninterpreted_events_.size(); ++i) {
|
||||
uninterpreted_events_[i].Replay(this);
|
||||
}
|
||||
}
|
||||
diff --git a/src/google/protobuf/util/internal/utility.cc b/src/google/protobuf/util/internal/utility.cc
|
||||
index 918ee17d9b040ae1bf9d98e3f46f75770c471393..3c4ac086d594d67b334cbc1dc046c281cd59a374 100644
|
||||
--- a/src/google/protobuf/util/internal/utility.cc
|
||||
+++ b/src/google/protobuf/util/internal/utility.cc
|
||||
@@ -345,7 +345,7 @@ void DeleteWellKnownTypes() { delete well_known_types_; }
|
||||
|
||||
void InitWellKnownTypes() {
|
||||
well_known_types_ = new std::set<std::string>;
|
||||
- for (int i = 0; i < GOOGLE_ARRAYSIZE(well_known_types_name_array_); ++i) {
|
||||
+ for (size_t i = 0; i < GOOGLE_ARRAYSIZE(well_known_types_name_array_); ++i) {
|
||||
well_known_types_->insert(well_known_types_name_array_[i]);
|
||||
}
|
||||
google::protobuf::internal::OnShutdown(&DeleteWellKnownTypes);
|
||||
diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc
|
||||
index c39c10d87b7d8bf6fc18cae1ce459257c45945d6..a9b1c52a73c86d3e3655ba0748f2a82c68bd40ce 100644
|
||||
--- a/src/google/protobuf/util/json_util.cc
|
||||
+++ b/src/google/protobuf/util/json_util.cc
|
||||
@@ -64,7 +64,7 @@ ZeroCopyStreamByteSink::~ZeroCopyStreamByteSink() {
|
||||
|
||||
void ZeroCopyStreamByteSink::Append(const char* bytes, size_t len) {
|
||||
while (true) {
|
||||
- if (len <= buffer_size_) { // NOLINT
|
||||
+ if (static_cast<int>(len) <= buffer_size_) { // NOLINT
|
||||
memcpy(buffer_, bytes, len);
|
||||
buffer_ = static_cast<char*>(buffer_) + len;
|
||||
buffer_size_ -= len;
|
||||
@@ -1,22 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Johnson <johnson.peter@gmail.com>
|
||||
Date: Sat, 10 Jun 2023 14:41:39 -0700
|
||||
Subject: [PATCH 02/15] Remove redundant move
|
||||
|
||||
---
|
||||
src/google/protobuf/extension_set.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h
|
||||
index 0e6d0521104d7f721bdbad1dd593233b035c5b85..b5343689ef7c16442995746439bbe8928022c593 100644
|
||||
--- a/src/google/protobuf/extension_set.h
|
||||
+++ b/src/google/protobuf/extension_set.h
|
||||
@@ -714,7 +714,7 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
static KeyValueFunctor ForEach(Iterator begin, Iterator end,
|
||||
KeyValueFunctor func) {
|
||||
for (Iterator it = begin; it != end; ++it) func(it->first, it->second);
|
||||
- return std::move(func);
|
||||
+ return func;
|
||||
}
|
||||
|
||||
// Applies a functor to the <int, Extension&> pairs in sorted order.
|
||||
@@ -1,168 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Johnson <johnson.peter@gmail.com>
|
||||
Date: Sat, 10 Jun 2023 15:00:20 -0700
|
||||
Subject: [PATCH 03/15] Fix maybe-uninitialized warnings
|
||||
|
||||
---
|
||||
src/google/protobuf/arena.cc | 6 +++---
|
||||
src/google/protobuf/arena_impl.h | 4 ++--
|
||||
src/google/protobuf/extension_set_inl.h | 2 +-
|
||||
.../protobuf/generated_message_tctable_lite.cc | 16 ++++++++--------
|
||||
src/google/protobuf/io/coded_stream.cc | 2 +-
|
||||
5 files changed, 15 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc
|
||||
index 6ba508a5f0f3436d52ccc326cc932ceed3cd79fa..194404213ee5f6ad05b1e01f2bff23859d60dc56 100644
|
||||
--- a/src/google/protobuf/arena.cc
|
||||
+++ b/src/google/protobuf/arena.cc
|
||||
@@ -411,7 +411,7 @@ uint64_t ThreadSafeArena::Reset() {
|
||||
std::pair<void*, SerialArena::CleanupNode*>
|
||||
ThreadSafeArena::AllocateAlignedWithCleanup(size_t n,
|
||||
const std::type_info* type) {
|
||||
- SerialArena* arena;
|
||||
+ SerialArena* arena = nullptr;
|
||||
if (PROTOBUF_PREDICT_TRUE(!alloc_policy_.should_record_allocs() &&
|
||||
GetSerialArenaFast(&arena))) {
|
||||
return arena->AllocateAlignedWithCleanup(n, alloc_policy_.get());
|
||||
@@ -421,7 +421,7 @@ ThreadSafeArena::AllocateAlignedWithCleanup(size_t n,
|
||||
}
|
||||
|
||||
void ThreadSafeArena::AddCleanup(void* elem, void (*cleanup)(void*)) {
|
||||
- SerialArena* arena;
|
||||
+ SerialArena* arena = nullptr;
|
||||
if (PROTOBUF_PREDICT_FALSE(!GetSerialArenaFast(&arena))) {
|
||||
arena = GetSerialArenaFallback(&thread_cache());
|
||||
}
|
||||
@@ -433,7 +433,7 @@ void* ThreadSafeArena::AllocateAlignedFallback(size_t n,
|
||||
const std::type_info* type) {
|
||||
if (alloc_policy_.should_record_allocs()) {
|
||||
alloc_policy_.RecordAlloc(type, n);
|
||||
- SerialArena* arena;
|
||||
+ SerialArena* arena = nullptr;
|
||||
if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
|
||||
return arena->AllocateAligned(n, alloc_policy_.get());
|
||||
}
|
||||
diff --git a/src/google/protobuf/arena_impl.h b/src/google/protobuf/arena_impl.h
|
||||
index 76727688b558354be18f0c6576db1d4619348ef4..8af70c48f13feece7cf8580e71845ec267ddaddb 100644
|
||||
--- a/src/google/protobuf/arena_impl.h
|
||||
+++ b/src/google/protobuf/arena_impl.h
|
||||
@@ -482,7 +482,7 @@ class PROTOBUF_EXPORT ThreadSafeArena {
|
||||
|
||||
template <AllocationClient alloc_client = AllocationClient::kDefault>
|
||||
void* AllocateAligned(size_t n, const std::type_info* type) {
|
||||
- SerialArena* arena;
|
||||
+ SerialArena* arena = nullptr;
|
||||
if (PROTOBUF_PREDICT_TRUE(!alloc_policy_.should_record_allocs() &&
|
||||
GetSerialArenaFast(&arena))) {
|
||||
return arena->AllocateAligned<alloc_client>(n, AllocPolicy());
|
||||
@@ -492,7 +492,7 @@ class PROTOBUF_EXPORT ThreadSafeArena {
|
||||
}
|
||||
|
||||
void ReturnArrayMemory(void* p, size_t size) {
|
||||
- SerialArena* arena;
|
||||
+ SerialArena* arena = nullptr;
|
||||
if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
|
||||
arena->ReturnArrayMemory(p, size);
|
||||
}
|
||||
diff --git a/src/google/protobuf/extension_set_inl.h b/src/google/protobuf/extension_set_inl.h
|
||||
index e4e711721d4d8690e1e87fc8e31df1b5836d4fd7..50c04cd41feccf6cb5fda2740d6d4adb874645d7 100644
|
||||
--- a/src/google/protobuf/extension_set_inl.h
|
||||
+++ b/src/google/protobuf/extension_set_inl.h
|
||||
@@ -206,7 +206,7 @@ const char* ExtensionSet::ParseMessageSetItemTmpl(
|
||||
const char* ptr, const Msg* extendee, internal::InternalMetadata* metadata,
|
||||
internal::ParseContext* ctx) {
|
||||
std::string payload;
|
||||
- uint32_t type_id;
|
||||
+ uint32_t type_id = 0;
|
||||
enum class State { kNoTag, kHasType, kHasPayload, kDone };
|
||||
State state = State::kNoTag;
|
||||
|
||||
diff --git a/src/google/protobuf/generated_message_tctable_lite.cc b/src/google/protobuf/generated_message_tctable_lite.cc
|
||||
index 9993811dca3229edc766061c4a8d54933bcb0eba..2268b2be4d4c60c545765469549d73c6a468dac8 100644
|
||||
--- a/src/google/protobuf/generated_message_tctable_lite.cc
|
||||
+++ b/src/google/protobuf/generated_message_tctable_lite.cc
|
||||
@@ -770,7 +770,7 @@ PROTOBUF_NOINLINE const char* TcParser::SingularVarBigint(
|
||||
};
|
||||
volatile Spill spill = {data.data, msg, table, hasbits};
|
||||
|
||||
- uint64_t tmp;
|
||||
+ uint64_t tmp = 0;
|
||||
PROTOBUF_ASSUME(static_cast<int8_t>(*ptr) < 0);
|
||||
ptr = ParseVarint(ptr, &tmp);
|
||||
|
||||
@@ -845,7 +845,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedVarint(
|
||||
auto expected_tag = UnalignedLoad<TagType>(ptr);
|
||||
do {
|
||||
ptr += sizeof(TagType);
|
||||
- uint64_t tmp;
|
||||
+ uint64_t tmp = 0;
|
||||
ptr = ParseVarint(ptr, &tmp);
|
||||
if (ptr == nullptr) {
|
||||
return Error(PROTOBUF_TC_PARAM_PASS);
|
||||
@@ -1001,7 +1001,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularEnum(
|
||||
}
|
||||
const char* ptr2 = ptr; // Save for unknown enum case
|
||||
ptr += sizeof(TagType); // Consume tag
|
||||
- uint64_t tmp;
|
||||
+ uint64_t tmp = 0;
|
||||
ptr = ParseVarint(ptr, &tmp);
|
||||
if (ptr == nullptr) {
|
||||
return Error(PROTOBUF_TC_PARAM_PASS);
|
||||
@@ -1052,7 +1052,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedEnum(
|
||||
do {
|
||||
const char* ptr2 = ptr; // save for unknown enum case
|
||||
ptr += sizeof(TagType);
|
||||
- uint64_t tmp;
|
||||
+ uint64_t tmp = 0;
|
||||
ptr = ParseVarint(ptr, &tmp);
|
||||
if (ptr == nullptr) {
|
||||
return Error(PROTOBUF_TC_PARAM_PASS);
|
||||
@@ -1477,7 +1477,7 @@ const char* TcParser::MpVarint(PROTOBUF_TC_PARAM_DECL) {
|
||||
|
||||
// Parse the value:
|
||||
const char* ptr2 = ptr; // save for unknown enum case
|
||||
- uint64_t tmp;
|
||||
+ uint64_t tmp = 0;
|
||||
ptr = ParseVarint(ptr, &tmp);
|
||||
if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
|
||||
|
||||
@@ -1542,7 +1542,7 @@ const char* TcParser::MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL) {
|
||||
const char* ptr2 = ptr;
|
||||
uint32_t next_tag;
|
||||
do {
|
||||
- uint64_t tmp;
|
||||
+ uint64_t tmp = 0;
|
||||
ptr = ParseVarint(ptr2, &tmp);
|
||||
if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
|
||||
field.Add(is_zigzag ? WireFormatLite::ZigZagDecode64(tmp) : tmp);
|
||||
@@ -1554,7 +1554,7 @@ const char* TcParser::MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL) {
|
||||
const char* ptr2 = ptr;
|
||||
uint32_t next_tag;
|
||||
do {
|
||||
- uint64_t tmp;
|
||||
+ uint64_t tmp = 0;
|
||||
ptr = ParseVarint(ptr2, &tmp);
|
||||
if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
|
||||
if (is_validated_enum) {
|
||||
@@ -1575,7 +1575,7 @@ const char* TcParser::MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL) {
|
||||
const char* ptr2 = ptr;
|
||||
uint32_t next_tag;
|
||||
do {
|
||||
- uint64_t tmp;
|
||||
+ uint64_t tmp = 0;
|
||||
ptr = ParseVarint(ptr2, &tmp);
|
||||
if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
|
||||
field.Add(static_cast<bool>(tmp));
|
||||
diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc
|
||||
index 487e1b8a379b86bfa3097d68a64ee0a727d36cab..53997901f333292f71ac52e7f9c876bd918f7bf6 100644
|
||||
--- a/src/google/protobuf/io/coded_stream.cc
|
||||
+++ b/src/google/protobuf/io/coded_stream.cc
|
||||
@@ -462,7 +462,7 @@ int64_t CodedInputStream::ReadVarint32Fallback(uint32_t first_byte_or_zero) {
|
||||
(buffer_end_ > buffer_ && !(buffer_end_[-1] & 0x80))) {
|
||||
GOOGLE_DCHECK_NE(first_byte_or_zero, 0)
|
||||
<< "Caller should provide us with *buffer_ when buffer is non-empty";
|
||||
- uint32_t temp;
|
||||
+ uint32_t temp = 0;
|
||||
::std::pair<bool, const uint8_t*> p =
|
||||
ReadVarint32FromArray(first_byte_or_zero, buffer_, &temp);
|
||||
if (!p.first) return -1;
|
||||
@@ -1,38 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Johnson <johnson.peter@gmail.com>
|
||||
Date: Sat, 10 Jun 2023 15:03:38 -0700
|
||||
Subject: [PATCH 04/15] Fix coded_stream WriteRaw
|
||||
|
||||
---
|
||||
src/google/protobuf/implicit_weak_message.h | 2 +-
|
||||
src/google/protobuf/io/coded_stream.h | 4 ++--
|
||||
2 files changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/google/protobuf/implicit_weak_message.h b/src/google/protobuf/implicit_weak_message.h
|
||||
index b894ab4809090011f381828857d1674a6b7bff9b..c358c14c06f773d87f5089c75566a5a6fcba13e6 100644
|
||||
--- a/src/google/protobuf/implicit_weak_message.h
|
||||
+++ b/src/google/protobuf/implicit_weak_message.h
|
||||
@@ -100,7 +100,7 @@ class PROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite {
|
||||
if (data_ == nullptr) {
|
||||
return target;
|
||||
}
|
||||
- return stream->WriteRaw(data_->data(), static_cast<int>(data_->size()),
|
||||
+ return stream->WriteRaw(data_->data(), data_->size(),
|
||||
target);
|
||||
}
|
||||
|
||||
diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h
|
||||
index c8fc994f916d047c0a7b176e53c9e946ebd752de..6c0dd4ab4099d1d748957af8bfc5f8c59c2aa3d6 100644
|
||||
--- a/src/google/protobuf/io/coded_stream.h
|
||||
+++ b/src/google/protobuf/io/coded_stream.h
|
||||
@@ -677,8 +677,8 @@ class PROTOBUF_EXPORT EpsCopyOutputStream {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
- uint8_t* WriteRaw(const void* data, int size, uint8_t* ptr) {
|
||||
- if (PROTOBUF_PREDICT_FALSE(end_ - ptr < size)) {
|
||||
+ uint8_t* WriteRaw(const void* data, size_t size, uint8_t* ptr) {
|
||||
+ if (PROTOBUF_PREDICT_FALSE(end_ - ptr < static_cast<int>(size))) {
|
||||
return WriteRawFallback(data, size, ptr);
|
||||
}
|
||||
std::memcpy(ptr, data, size);
|
||||
@@ -1,36 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Johnson <johnson.peter@gmail.com>
|
||||
Date: Sat, 10 Jun 2023 15:13:45 -0700
|
||||
Subject: [PATCH 05/15] Suppress enum-enum conversion warning
|
||||
|
||||
---
|
||||
src/google/protobuf/generated_message_tctable_impl.h | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/src/google/protobuf/generated_message_tctable_impl.h b/src/google/protobuf/generated_message_tctable_impl.h
|
||||
index 21fa5332d39b24e0bdb6432f27183df743d512c6..5aceeb39ae24866e7258d62cf5b025df0ba20fc5 100644
|
||||
--- a/src/google/protobuf/generated_message_tctable_impl.h
|
||||
+++ b/src/google/protobuf/generated_message_tctable_impl.h
|
||||
@@ -180,6 +180,12 @@ static_assert(kFmtShift + kFmtBits == 12, "number of bits changed");
|
||||
// This assertion should not change unless the storage width changes:
|
||||
static_assert(kFmtShift + kFmtBits <= 16, "too many bits");
|
||||
|
||||
+#ifdef __GNUC__
|
||||
+#pragma GCC diagnostic push
|
||||
+#if __GNUC__ >= 12 || (__GNUC__ == 11 && __GNUC_MINOR__ >= 1)
|
||||
+#pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion"
|
||||
+#endif
|
||||
+#endif
|
||||
// Convenience aliases (16 bits, with format):
|
||||
enum FieldType : uint16_t {
|
||||
// Numeric types:
|
||||
@@ -232,6 +238,9 @@ enum FieldType : uint16_t {
|
||||
// Map types:
|
||||
kMap = kFkMap,
|
||||
};
|
||||
+#ifdef __GNUC__
|
||||
+#pragma GCC diagnostic pop
|
||||
+#endif
|
||||
|
||||
// clang-format on
|
||||
} // namespace field_layout
|
||||
@@ -1,23 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Johnson <johnson.peter@gmail.com>
|
||||
Date: Sat, 10 Jun 2023 15:16:46 -0700
|
||||
Subject: [PATCH 06/15] Fix noreturn function returning
|
||||
|
||||
---
|
||||
src/google/protobuf/generated_message_tctable_impl.h | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/src/google/protobuf/generated_message_tctable_impl.h b/src/google/protobuf/generated_message_tctable_impl.h
|
||||
index 5aceeb39ae24866e7258d62cf5b025df0ba20fc5..c80ac0cd299c126398329c780534156bb1536e15 100644
|
||||
--- a/src/google/protobuf/generated_message_tctable_impl.h
|
||||
+++ b/src/google/protobuf/generated_message_tctable_impl.h
|
||||
@@ -262,6 +262,9 @@ template <size_t align>
|
||||
#endif
|
||||
void AlignFail(uintptr_t address) {
|
||||
GOOGLE_LOG(FATAL) << "Unaligned (" << align << ") access at " << address;
|
||||
+#ifdef __GNUC__
|
||||
+ __builtin_unreachable();
|
||||
+#endif
|
||||
}
|
||||
|
||||
extern template void AlignFail<4>(uintptr_t);
|
||||
@@ -1,29 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Johnson <johnson.peter@gmail.com>
|
||||
Date: Sat, 10 Jun 2023 15:59:45 -0700
|
||||
Subject: [PATCH 07/15] Work around GCC 12 restrict warning compiler bug
|
||||
|
||||
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105329
|
||||
---
|
||||
src/google/protobuf/io/tokenizer.cc | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/src/google/protobuf/io/tokenizer.cc b/src/google/protobuf/io/tokenizer.cc
|
||||
index f9e07763e7362bd37267619336db841d0ae9df25..30d62ac9647b897c2e7c8ad43cd27ff0e08922a2 100644
|
||||
--- a/src/google/protobuf/io/tokenizer.cc
|
||||
+++ b/src/google/protobuf/io/tokenizer.cc
|
||||
@@ -585,7 +585,14 @@ Tokenizer::NextCommentStatus Tokenizer::TryConsumeCommentStart() {
|
||||
} else {
|
||||
// Oops, it was just a slash. Return it.
|
||||
current_.type = TYPE_SYMBOL;
|
||||
+#if defined(__GNUC__) && !defined(__clang__)
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wrestrict"
|
||||
+#endif
|
||||
current_.text = "/";
|
||||
+#if defined(__GNUC__) && !defined(__clang__)
|
||||
+#pragma GCC diagnostic pop
|
||||
+#endif
|
||||
current_.line = line_;
|
||||
current_.column = column_ - 1;
|
||||
current_.end_column = column_;
|
||||
@@ -1,24 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Johnson <johnson.peter@gmail.com>
|
||||
Date: Tue, 13 Jun 2023 23:56:15 -0700
|
||||
Subject: [PATCH 08/15] Disable MSVC switch warning
|
||||
|
||||
---
|
||||
src/google/protobuf/generated_message_reflection.cc | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc
|
||||
index 2a807e066bb748f214e008971309ef15473344b5..599dde80b671085d87ff1812929cafe8d2aecf75 100644
|
||||
--- a/src/google/protobuf/generated_message_reflection.cc
|
||||
+++ b/src/google/protobuf/generated_message_reflection.cc
|
||||
@@ -75,6 +75,10 @@ using google::protobuf::internal::RepeatedPtrFieldBase;
|
||||
using google::protobuf::internal::StringSpaceUsedExcludingSelfLong;
|
||||
using google::protobuf::internal::WrappedMutex;
|
||||
|
||||
+#ifdef _MSC_VER
|
||||
+#pragma warning(disable : 4065)
|
||||
+#endif
|
||||
+
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Johnson <johnson.peter@gmail.com>
|
||||
Date: Tue, 13 Jun 2023 23:58:50 -0700
|
||||
Subject: [PATCH 09/15] Disable unused function warning
|
||||
|
||||
---
|
||||
src/google/protobuf/generated_message_tctable_lite.cc | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/google/protobuf/generated_message_tctable_lite.cc b/src/google/protobuf/generated_message_tctable_lite.cc
|
||||
index 2268b2be4d4c60c545765469549d73c6a468dac8..23557a614752a9f0c93d8bd56724f3bc0f962185 100644
|
||||
--- a/src/google/protobuf/generated_message_tctable_lite.cc
|
||||
+++ b/src/google/protobuf/generated_message_tctable_lite.cc
|
||||
@@ -43,6 +43,10 @@
|
||||
#include <google/protobuf/port_def.inc>
|
||||
// clang-format on
|
||||
|
||||
+#ifdef __GNUC__
|
||||
+#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
+#endif
|
||||
+
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
@@ -1,95 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Johnson <johnson.peter@gmail.com>
|
||||
Date: Wed, 14 Jun 2023 00:02:26 -0700
|
||||
Subject: [PATCH 10/15] Disable pedantic warning
|
||||
|
||||
---
|
||||
src/google/protobuf/descriptor.h | 8 ++++++++
|
||||
src/google/protobuf/generated_message_reflection.cc | 2 ++
|
||||
src/google/protobuf/parse_context.h | 8 ++++++++
|
||||
src/google/protobuf/stubs/common.cc | 4 ++--
|
||||
4 files changed, 20 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h
|
||||
index 6e536e5705f8df4f7c13638d50c114cbfb92fb4a..bee3e32b9f1d5ba47b83d1e388716a3c3b6e82c6 100644
|
||||
--- a/src/google/protobuf/descriptor.h
|
||||
+++ b/src/google/protobuf/descriptor.h
|
||||
@@ -80,6 +80,10 @@
|
||||
#define PROTOBUF_EXPORT
|
||||
#endif
|
||||
|
||||
+#ifdef __GNUC__
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
+#endif
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
@@ -2434,6 +2438,10 @@ inline FileDescriptor::Syntax FileDescriptor::syntax() const {
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
+#ifdef __GNUC__
|
||||
+#pragma GCC diagnostic pop
|
||||
+#endif
|
||||
+
|
||||
#undef PROTOBUF_INTERNAL_CHECK_CLASS_SIZE
|
||||
#include <google/protobuf/port_undef.inc>
|
||||
|
||||
diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc
|
||||
index 599dde80b671085d87ff1812929cafe8d2aecf75..aaed21920908b329e22c2e0d92f69397996a9f93 100644
|
||||
--- a/src/google/protobuf/generated_message_reflection.cc
|
||||
+++ b/src/google/protobuf/generated_message_reflection.cc
|
||||
@@ -77,6 +77,8 @@ using google::protobuf::internal::WrappedMutex;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4065)
|
||||
+#elif defined(__GNUC__)
|
||||
+#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
|
||||
namespace google {
|
||||
diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h
|
||||
index 7aea50cdc385f0ed01b3989e12276494bf574939..97daae09cbff11fd3b4b99cee935aeb542c42eb4 100644
|
||||
--- a/src/google/protobuf/parse_context.h
|
||||
+++ b/src/google/protobuf/parse_context.h
|
||||
@@ -52,6 +52,10 @@
|
||||
// Must be included last.
|
||||
#include <google/protobuf/port_def.inc>
|
||||
|
||||
+#ifdef __GNUC__
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
+#endif
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
@@ -1020,6 +1024,10 @@ PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* UnknownFieldParse(
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
+#ifdef __GNUC__
|
||||
+#pragma GCC diagnostic pop
|
||||
+#endif
|
||||
+
|
||||
#include <google/protobuf/port_undef.inc>
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_PARSE_CONTEXT_H__
|
||||
diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc
|
||||
index e0a807ffbbc94d07176e20db230204384170607b..1423021b846966eb02d36c10df488f8aa0082a64 100644
|
||||
--- a/src/google/protobuf/stubs/common.cc
|
||||
+++ b/src/google/protobuf/stubs/common.cc
|
||||
@@ -277,11 +277,11 @@ LogHandler* SetLogHandler(LogHandler* new_func) {
|
||||
|
||||
LogSilencer::LogSilencer() {
|
||||
++internal::log_silencer_count_;
|
||||
-};
|
||||
+}
|
||||
|
||||
LogSilencer::~LogSilencer() {
|
||||
--internal::log_silencer_count_;
|
||||
-};
|
||||
+}
|
||||
|
||||
// ===================================================================
|
||||
// emulates google3/base/callback.cc
|
||||
@@ -1,35 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Johnson <johnson.peter@gmail.com>
|
||||
Date: Mon, 9 Oct 2023 19:28:08 -0700
|
||||
Subject: [PATCH 11/15] Avoid use of sprintf
|
||||
|
||||
---
|
||||
src/google/protobuf/stubs/strutil.cc | 14 +++++++++++---
|
||||
1 file changed, 11 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc
|
||||
index 3462e91ff273dc071628f06b91698a0f166514fc..58e03d0c4aa7c1b0337b5f650283f00117c12baa 100644
|
||||
--- a/src/google/protobuf/stubs/strutil.cc
|
||||
+++ b/src/google/protobuf/stubs/strutil.cc
|
||||
@@ -503,10 +503,18 @@ int CEscapeInternal(const char* src, int src_len, char* dest,
|
||||
(last_hex_escape && isxdigit(*src)))) {
|
||||
if (dest_len - used < 4) // need space for 4 letter escape
|
||||
return -1;
|
||||
- sprintf(dest + used, (use_hex ? "\\x%02x" : "\\%03o"),
|
||||
- static_cast<uint8_t>(*src));
|
||||
+ dest[used++] = '\\';
|
||||
+ if (use_hex) {
|
||||
+ constexpr char hexdigits[] = "0123456789abcdef";
|
||||
+ dest[used++] = 'x';
|
||||
+ dest[used++] = hexdigits[(static_cast<uint8_t>(*src) >> 4) & 0xf];
|
||||
+ dest[used++] = hexdigits[static_cast<uint8_t>(*src) & 0xf];
|
||||
+ } else {
|
||||
+ dest[used++] = '0' + ((static_cast<uint8_t>(*src) >> 6) & 0x3);
|
||||
+ dest[used++] = '0' + ((static_cast<uint8_t>(*src) >> 3) & 0x7);
|
||||
+ dest[used++] = '0' + (static_cast<uint8_t>(*src) & 0x7);
|
||||
+ }
|
||||
is_hex_escape = use_hex;
|
||||
- used += 4;
|
||||
} else {
|
||||
dest[used++] = *src; break;
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Tyler Veness <calcmogul@gmail.com>
|
||||
Date: Fri, 10 Nov 2023 14:17:53 -0800
|
||||
Subject: [PATCH 12/15] Suppress stringop-overflow warning false positives
|
||||
|
||||
---
|
||||
src/google/protobuf/io/coded_stream.h | 7 +++++++
|
||||
src/google/protobuf/unknown_field_set.cc | 7 +++++++
|
||||
2 files changed, 14 insertions(+)
|
||||
|
||||
diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h
|
||||
index 6c0dd4ab4099d1d748957af8bfc5f8c59c2aa3d6..f43b7ee044673b33410a3ebec6a501ff434d061d 100644
|
||||
--- a/src/google/protobuf/io/coded_stream.h
|
||||
+++ b/src/google/protobuf/io/coded_stream.h
|
||||
@@ -681,7 +681,14 @@ class PROTOBUF_EXPORT EpsCopyOutputStream {
|
||||
if (PROTOBUF_PREDICT_FALSE(end_ - ptr < static_cast<int>(size))) {
|
||||
return WriteRawFallback(data, size, ptr);
|
||||
}
|
||||
+#if __GNUC__ >= 12
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wstringop-overflow="
|
||||
+#endif // __GNUC__ >= 12
|
||||
std::memcpy(ptr, data, size);
|
||||
+#if __GNUC__ >= 12
|
||||
+#pragma GCC diagnostic pop
|
||||
+#endif // __GNUC__ >= 12
|
||||
return ptr + size;
|
||||
}
|
||||
// Writes the buffer specified by data, size to the stream. Possibly by
|
||||
diff --git a/src/google/protobuf/unknown_field_set.cc b/src/google/protobuf/unknown_field_set.cc
|
||||
index 74c358e9a22c5475bfaef6c5ac63b05fc61b7074..5f6f7a1a298321e562112fed576a7086bd57643c 100644
|
||||
--- a/src/google/protobuf/unknown_field_set.cc
|
||||
+++ b/src/google/protobuf/unknown_field_set.cc
|
||||
@@ -96,9 +96,16 @@ void UnknownFieldSet::MergeFromAndDestroy(UnknownFieldSet* other) {
|
||||
if (fields_.empty()) {
|
||||
fields_ = std::move(other->fields_);
|
||||
} else {
|
||||
+#if __GNUC__ >= 12
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wstringop-overflow="
|
||||
+#endif // __GNUC__ >= 12
|
||||
fields_.insert(fields_.end(),
|
||||
std::make_move_iterator(other->fields_.begin()),
|
||||
std::make_move_iterator(other->fields_.end()));
|
||||
+#if __GNUC__ >= 12
|
||||
+#pragma GCC diagnostic pop
|
||||
+#endif // __GNUC__ >= 12
|
||||
}
|
||||
other->fields_.clear();
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Thad House <thadhouse1@gmail.com>
|
||||
Date: Sun, 18 Aug 2024 22:43:37 -0700
|
||||
Subject: [PATCH 13/15] Switch descriptor to not use globals from header inline
|
||||
functions
|
||||
|
||||
---
|
||||
src/google/protobuf/descriptor.cc | 66 +++++++++++++++++++------------
|
||||
src/google/protobuf/descriptor.h | 20 +++++-----
|
||||
2 files changed, 51 insertions(+), 35 deletions(-)
|
||||
|
||||
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc
|
||||
index 5f3427dc72497b618c4dea3ec6985eeb39139349..5be05da4fb1c21fb1068ae7341cabef9dcf598a5 100644
|
||||
--- a/src/google/protobuf/descriptor.cc
|
||||
+++ b/src/google/protobuf/descriptor.cc
|
||||
@@ -791,31 +791,31 @@ class Symbol {
|
||||
const internal::SymbolBase* ptr_;
|
||||
};
|
||||
|
||||
-const FieldDescriptor::CppType
|
||||
- FieldDescriptor::kTypeToCppTypeMap[MAX_TYPE + 1] = {
|
||||
- static_cast<CppType>(0), // 0 is reserved for errors
|
||||
-
|
||||
- CPPTYPE_DOUBLE, // TYPE_DOUBLE
|
||||
- CPPTYPE_FLOAT, // TYPE_FLOAT
|
||||
- CPPTYPE_INT64, // TYPE_INT64
|
||||
- CPPTYPE_UINT64, // TYPE_UINT64
|
||||
- CPPTYPE_INT32, // TYPE_INT32
|
||||
- CPPTYPE_UINT64, // TYPE_FIXED64
|
||||
- CPPTYPE_UINT32, // TYPE_FIXED32
|
||||
- CPPTYPE_BOOL, // TYPE_BOOL
|
||||
- CPPTYPE_STRING, // TYPE_STRING
|
||||
- CPPTYPE_MESSAGE, // TYPE_GROUP
|
||||
- CPPTYPE_MESSAGE, // TYPE_MESSAGE
|
||||
- CPPTYPE_STRING, // TYPE_BYTES
|
||||
- CPPTYPE_UINT32, // TYPE_UINT32
|
||||
- CPPTYPE_ENUM, // TYPE_ENUM
|
||||
- CPPTYPE_INT32, // TYPE_SFIXED32
|
||||
- CPPTYPE_INT64, // TYPE_SFIXED64
|
||||
- CPPTYPE_INT32, // TYPE_SINT32
|
||||
- CPPTYPE_INT64, // TYPE_SINT64
|
||||
+static const FieldDescriptor::CppType
|
||||
+ kTypeToCppTypeMap[FieldDescriptor::MAX_TYPE + 1] = {
|
||||
+ static_cast<FieldDescriptor::CppType>(0), // 0 is reserved for errors
|
||||
+
|
||||
+ FieldDescriptor::CPPTYPE_DOUBLE, // TYPE_DOUBLE
|
||||
+ FieldDescriptor::CPPTYPE_FLOAT, // TYPE_FLOAT
|
||||
+ FieldDescriptor::CPPTYPE_INT64, // TYPE_INT64
|
||||
+ FieldDescriptor::CPPTYPE_UINT64, // TYPE_UINT64
|
||||
+ FieldDescriptor::CPPTYPE_INT32, // TYPE_INT32
|
||||
+ FieldDescriptor::CPPTYPE_UINT64, // TYPE_FIXED64
|
||||
+ FieldDescriptor::CPPTYPE_UINT32, // TYPE_FIXED32
|
||||
+ FieldDescriptor::CPPTYPE_BOOL, // TYPE_BOOL
|
||||
+ FieldDescriptor::CPPTYPE_STRING, // TYPE_STRING
|
||||
+ FieldDescriptor::CPPTYPE_MESSAGE, // TYPE_GROUP
|
||||
+ FieldDescriptor::CPPTYPE_MESSAGE, // TYPE_MESSAGE
|
||||
+ FieldDescriptor::CPPTYPE_STRING, // TYPE_BYTES
|
||||
+ FieldDescriptor::CPPTYPE_UINT32, // TYPE_UINT32
|
||||
+ FieldDescriptor::CPPTYPE_ENUM, // TYPE_ENUM
|
||||
+ FieldDescriptor::CPPTYPE_INT32, // TYPE_SFIXED32
|
||||
+ FieldDescriptor::CPPTYPE_INT64, // TYPE_SFIXED64
|
||||
+ FieldDescriptor::CPPTYPE_INT32, // TYPE_SINT32
|
||||
+ FieldDescriptor::CPPTYPE_INT64, // TYPE_SINT64
|
||||
};
|
||||
|
||||
-const char* const FieldDescriptor::kTypeToName[MAX_TYPE + 1] = {
|
||||
+static const char* const kTypeToName[FieldDescriptor::MAX_TYPE + 1] = {
|
||||
"ERROR", // 0 is reserved for errors
|
||||
|
||||
"double", // TYPE_DOUBLE
|
||||
@@ -838,7 +838,7 @@ const char* const FieldDescriptor::kTypeToName[MAX_TYPE + 1] = {
|
||||
"sint64", // TYPE_SINT64
|
||||
};
|
||||
|
||||
-const char* const FieldDescriptor::kCppTypeToName[MAX_CPPTYPE + 1] = {
|
||||
+static const char* const kCppTypeToName[FieldDescriptor::MAX_CPPTYPE + 1] = {
|
||||
"ERROR", // 0 is reserved for errors
|
||||
|
||||
"int32", // CPPTYPE_INT32
|
||||
@@ -853,7 +853,7 @@ const char* const FieldDescriptor::kCppTypeToName[MAX_CPPTYPE + 1] = {
|
||||
"message", // CPPTYPE_MESSAGE
|
||||
};
|
||||
|
||||
-const char* const FieldDescriptor::kLabelToName[MAX_LABEL + 1] = {
|
||||
+static const char* const kLabelToName[FieldDescriptor::MAX_LABEL + 1] = {
|
||||
"ERROR", // 0 is reserved for errors
|
||||
|
||||
"optional", // LABEL_OPTIONAL
|
||||
@@ -861,6 +861,22 @@ const char* const FieldDescriptor::kLabelToName[MAX_LABEL + 1] = {
|
||||
"repeated", // LABEL_REPEATED
|
||||
};
|
||||
|
||||
+const FieldDescriptor::CppType *FieldDescriptor::GetTypeToCppTypeMap() {
|
||||
+ return kTypeToCppTypeMap;
|
||||
+}
|
||||
+
|
||||
+const char* const *FieldDescriptor::GetTypeToName() {
|
||||
+ return kTypeToName;
|
||||
+}
|
||||
+
|
||||
+const char* const *FieldDescriptor::GetCppTypeToName() {
|
||||
+ return kCppTypeToName;
|
||||
+}
|
||||
+
|
||||
+const char* const *FieldDescriptor::GetLabelToName() {
|
||||
+ return kLabelToName;
|
||||
+}
|
||||
+
|
||||
const char* FileDescriptor::SyntaxName(FileDescriptor::Syntax syntax) {
|
||||
switch (syntax) {
|
||||
case SYNTAX_PROTO2:
|
||||
diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h
|
||||
index bee3e32b9f1d5ba47b83d1e388716a3c3b6e82c6..1cb2421b5362a757abe3735e15321e630b1cab3e 100644
|
||||
--- a/src/google/protobuf/descriptor.h
|
||||
+++ b/src/google/protobuf/descriptor.h
|
||||
@@ -976,13 +976,13 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
|
||||
mutable std::atomic<const Message*> default_generated_instance_;
|
||||
};
|
||||
|
||||
- static const CppType kTypeToCppTypeMap[MAX_TYPE + 1];
|
||||
+ static const CppType *GetTypeToCppTypeMap();
|
||||
|
||||
- static const char* const kTypeToName[MAX_TYPE + 1];
|
||||
+ static const char* const *GetTypeToName();
|
||||
|
||||
- static const char* const kCppTypeToName[MAX_CPPTYPE + 1];
|
||||
+ static const char* const *GetCppTypeToName();
|
||||
|
||||
- static const char* const kLabelToName[MAX_LABEL + 1];
|
||||
+ static const char* const *GetLabelToName();
|
||||
|
||||
// Must be constructed using DescriptorPool.
|
||||
FieldDescriptor() {}
|
||||
@@ -2392,27 +2392,27 @@ inline int MethodDescriptor::index() const {
|
||||
}
|
||||
|
||||
inline const char* FieldDescriptor::type_name() const {
|
||||
- return kTypeToName[type()];
|
||||
+ return GetTypeToName()[type()];
|
||||
}
|
||||
|
||||
inline FieldDescriptor::CppType FieldDescriptor::cpp_type() const {
|
||||
- return kTypeToCppTypeMap[type()];
|
||||
+ return GetTypeToCppTypeMap()[type()];
|
||||
}
|
||||
|
||||
inline const char* FieldDescriptor::cpp_type_name() const {
|
||||
- return kCppTypeToName[kTypeToCppTypeMap[type()]];
|
||||
+ return GetCppTypeToName()[GetTypeToCppTypeMap()[type()]];
|
||||
}
|
||||
|
||||
inline FieldDescriptor::CppType FieldDescriptor::TypeToCppType(Type type) {
|
||||
- return kTypeToCppTypeMap[type];
|
||||
+ return GetTypeToCppTypeMap()[type];
|
||||
}
|
||||
|
||||
inline const char* FieldDescriptor::TypeName(Type type) {
|
||||
- return kTypeToName[type];
|
||||
+ return GetTypeToName()[type];
|
||||
}
|
||||
|
||||
inline const char* FieldDescriptor::CppTypeName(CppType cpp_type) {
|
||||
- return kCppTypeToName[cpp_type];
|
||||
+ return GetCppTypeToName()[cpp_type];
|
||||
}
|
||||
|
||||
inline bool FieldDescriptor::IsTypePackable(Type field_type) {
|
||||
@@ -1,22 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: braykoff <99614905+Braykoff@users.noreply.github.com>
|
||||
Date: Mon, 23 Dec 2024 15:12:02 -0500
|
||||
Subject: [PATCH 14/15] Remove deprecated ATOMIC_VAR_INIT
|
||||
|
||||
---
|
||||
src/google/protobuf/stubs/common.cc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc
|
||||
index 1423021b846966eb02d36c10df488f8aa0082a64..a16668a5964398c85c0268d82f652cf3c6aa668e 100644
|
||||
--- a/src/google/protobuf/stubs/common.cc
|
||||
+++ b/src/google/protobuf/stubs/common.cc
|
||||
@@ -178,7 +178,7 @@ void NullLogHandler(LogLevel /* level */, const char* /* filename */,
|
||||
}
|
||||
|
||||
static LogHandler* log_handler_ = &DefaultLogHandler;
|
||||
-static std::atomic<int> log_silencer_count_ = ATOMIC_VAR_INIT(0);
|
||||
+static std::atomic<int> log_silencer_count_{0};
|
||||
|
||||
LogMessage& LogMessage::operator<<(const std::string& value) {
|
||||
message_ += value;
|
||||
115
upstream_utils/upb.py
Executable file
115
upstream_utils/upb.py
Executable file
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
from upstream_utils import (
|
||||
Lib,
|
||||
comment_out_invalid_includes,
|
||||
copy_to,
|
||||
walk_cwd_and_copy_if,
|
||||
)
|
||||
|
||||
|
||||
def copy_upstream_src(wpilib_root: Path):
|
||||
upstream_root = Path(".").absolute()
|
||||
wpiutil = wpilib_root / "wpiutil"
|
||||
|
||||
# Delete old install
|
||||
for d in [
|
||||
"src/main/native/thirdparty/upb/include",
|
||||
"src/main/native/thirdparty/upb/src",
|
||||
]:
|
||||
shutil.rmtree(wpiutil / d, ignore_errors=True)
|
||||
|
||||
os.chdir(upstream_root / "third_party/utf8_range")
|
||||
copy_to(
|
||||
[Path("utf8_range.h")],
|
||||
wpiutil / "src/main/native/thirdparty/upb/include",
|
||||
)
|
||||
copy_to(
|
||||
[
|
||||
Path("utf8_range.c"),
|
||||
Path("utf8_range_sse.inc"),
|
||||
Path("utf8_range_neon.inc"),
|
||||
],
|
||||
wpiutil / "src/main/native/thirdparty/upb/src",
|
||||
)
|
||||
# Change directory to upb to minimize the number of files to walk
|
||||
os.chdir(upstream_root / "upb")
|
||||
include_files = walk_cwd_and_copy_if(
|
||||
lambda dp, f: (
|
||||
len(dp.parts) >= 1
|
||||
and (
|
||||
dp.parts[0] == "base"
|
||||
or dp.parts[0] == "hash"
|
||||
or dp.parts[0] == "mem"
|
||||
or (
|
||||
dp.parts[0] == "message"
|
||||
and "compare" not in f
|
||||
and "promote" not in f
|
||||
and "accessors_split64" not in f
|
||||
)
|
||||
or dp.parts[0] == "mini_descriptor"
|
||||
or (dp.parts[0] == "mini_table" and "compat" not in f)
|
||||
or dp.parts[0] == "port"
|
||||
or dp.parts[0] == "reflection"
|
||||
or (
|
||||
dp.parts[0] == "wire"
|
||||
and "byte_size" not in f
|
||||
and "decode_fast" not in dp.parts
|
||||
and "test_util" not in dp.parts
|
||||
)
|
||||
)
|
||||
and "cmake" not in dp.parts
|
||||
)
|
||||
and (f.endswith(".h") or f.endswith(".inc"))
|
||||
or f == "generated_code_support.h",
|
||||
wpiutil / "src/main/native/thirdparty/upb/include/upb",
|
||||
)
|
||||
for f in include_files:
|
||||
comment_out_invalid_includes(
|
||||
f, [wpiutil / "src/main/native/thirdparty/upb/include"]
|
||||
)
|
||||
|
||||
walk_cwd_and_copy_if(
|
||||
lambda dp, f: (
|
||||
len(dp.parts) >= 1
|
||||
and (
|
||||
dp.parts[0] == "base"
|
||||
or dp.parts[0] == "hash"
|
||||
or dp.parts[0] == "mem"
|
||||
or (
|
||||
dp.parts[0] == "message"
|
||||
and "compare" not in f
|
||||
and "promote" not in f
|
||||
)
|
||||
or dp.parts[0] == "mini_descriptor"
|
||||
or (dp.parts[0] == "mini_table" and "compat" not in f)
|
||||
or dp.parts[0] == "port"
|
||||
or dp.parts[0] == "reflection"
|
||||
or (
|
||||
dp.parts[0] == "wire"
|
||||
and "byte_size" not in f
|
||||
and "decode_fast" not in dp.parts
|
||||
)
|
||||
)
|
||||
)
|
||||
and f.endswith(".c")
|
||||
and not f == "descriptor.upb_minitable.c",
|
||||
wpiutil / "src/main/native/thirdparty/upb/src",
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
name = "upb"
|
||||
url = "https://github.com/protocolbuffers/protobuf"
|
||||
tag = "v32.0"
|
||||
|
||||
upb = Lib(name, url, tag, copy_upstream_src)
|
||||
upb.main()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,77 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Gold856 <117957790+Gold856@users.noreply.github.com>
|
||||
Date: Sat, 24 May 2025 23:32:48 -0400
|
||||
Subject: [PATCH 1/5] Remove patches as they interfere with upstream_utils
|
||||
|
||||
---
|
||||
Disable_bundle_install.patch | 37 ------------------------------------
|
||||
Neverlink_jruby_jars.patch | 16 ----------------
|
||||
2 files changed, 53 deletions(-)
|
||||
delete mode 100644 Disable_bundle_install.patch
|
||||
delete mode 100644 Neverlink_jruby_jars.patch
|
||||
|
||||
diff --git a/Disable_bundle_install.patch b/Disable_bundle_install.patch
|
||||
deleted file mode 100644
|
||||
index baa83832f51813161ab98115a54583bc9dbea741..0000000000000000000000000000000000000000
|
||||
--- a/Disable_bundle_install.patch
|
||||
+++ /dev/null
|
||||
@@ -1,37 +0,0 @@
|
||||
-Subject: [PATCH] Disable bundle install
|
||||
----
|
||||
-Index: ruby/private/bundle_fetch.bzl
|
||||
-IDEA additional info:
|
||||
-Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||||
-<+>UTF-8
|
||||
-===================================================================
|
||||
-diff --git a/ruby/private/bundle_fetch.bzl b/ruby/private/bundle_fetch.bzl
|
||||
---- a/ruby/private/bundle_fetch.bzl (revision 075937d3f2e22d4657f5c4693e7405d8952ab209)
|
||||
-+++ b/ruby/private/bundle_fetch.bzl (date 1740971614385)
|
||||
-@@ -168,16 +168,16 @@
|
||||
- )
|
||||
-
|
||||
- # Fetch Bundler and define an `rb_gem_install()` target for it.
|
||||
-- _download_gem(repository_ctx, gemfile_lock.bundler, cache_path, gemfile_lock.bundler.sha256)
|
||||
-- gem_full_names.append(":%s" % gemfile_lock.bundler.full_name)
|
||||
-- gem_install_fragments.append(
|
||||
-- _GEM_INSTALL_BUILD_FRAGMENT.format(
|
||||
-- name = gemfile_lock.bundler.full_name,
|
||||
-- gem = gemfile_lock.bundler.filename,
|
||||
-- cache_path = cache_path,
|
||||
-- ruby = ruby_toolchain_attr,
|
||||
-- ),
|
||||
-- )
|
||||
-+# _download_gem(repository_ctx, gemfile_lock.bundler, cache_path, gemfile_lock.bundler.sha256)
|
||||
-+# gem_full_names.append(":%s" % gemfile_lock.bundler.full_name)
|
||||
-+# gem_install_fragments.append(
|
||||
-+# _GEM_INSTALL_BUILD_FRAGMENT.format(
|
||||
-+# name = gemfile_lock.bundler.full_name,
|
||||
-+# gem = gemfile_lock.bundler.filename,
|
||||
-+# cache_path = cache_path,
|
||||
-+# ruby = ruby_toolchain_attr,
|
||||
-+# ),
|
||||
-+# )
|
||||
-
|
||||
- # Create `bin` package with shims for gem executables.
|
||||
- # This allows targets to depend on `@bundle//bin:rake`
|
||||
diff --git a/Neverlink_jruby_jars.patch b/Neverlink_jruby_jars.patch
|
||||
deleted file mode 100644
|
||||
index 48ccca6c7cd656312620b912ff6f465059b63a53..0000000000000000000000000000000000000000
|
||||
--- a/Neverlink_jruby_jars.patch
|
||||
+++ /dev/null
|
||||
@@ -1,16 +0,0 @@
|
||||
-Index: ruby/private/download/BUILD.tpl
|
||||
-IDEA additional info:
|
||||
-Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||||
-<+>UTF-8
|
||||
-===================================================================
|
||||
-diff --git a/ruby/private/download/BUILD.tpl b/ruby/private/download/BUILD.tpl
|
||||
---- a/ruby/private/download/BUILD.tpl (revision 26e0ba621cb82933f28a59373cb6a7afe54fae95)
|
||||
-+++ b/ruby/private/download/BUILD.tpl (date 1745340325192)
|
||||
-@@ -33,6 +33,7 @@
|
||||
- ["dist/lib/**/*.jar"],
|
||||
- allow_empty = True,
|
||||
- ),
|
||||
-+ neverlink = True,
|
||||
- )
|
||||
-
|
||||
- rb_toolchain(
|
||||
@@ -0,0 +1,36 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Gold856 <117957790+Gold856@users.noreply.github.com>
|
||||
Date: Fri, 23 May 2025 23:57:11 -0400
|
||||
Subject: [PATCH 2/5] Set bootstrap stage to 0
|
||||
|
||||
---
|
||||
upb/port/def.inc | 2 ++
|
||||
upb/reflection/descriptor_bootstrap.h | 2 +-
|
||||
2 files changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/upb/port/def.inc b/upb/port/def.inc
|
||||
index d8ccc7b8ffe36d263a1f14731223ca8500ecb376..237aa87648661b05ce9a47fce00561bd2f262b13 100644
|
||||
--- a/upb/port/def.inc
|
||||
+++ b/upb/port/def.inc
|
||||
@@ -33,6 +33,8 @@
|
||||
#error upb requires C99 or C++17 or MSVC >= 2015.
|
||||
#endif
|
||||
|
||||
+#define UPB_BOOTSTRAP_STAGE 0
|
||||
+
|
||||
// Portable check for GCC minimum version:
|
||||
// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
|
||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
|
||||
diff --git a/upb/reflection/descriptor_bootstrap.h b/upb/reflection/descriptor_bootstrap.h
|
||||
index 8c501447e7ce4f7f404e075cb6be9301470ed0f9..ffb30ea949836dc0c9d1d3f73d0dfccc509e7d0d 100644
|
||||
--- a/upb/reflection/descriptor_bootstrap.h
|
||||
+++ b/upb/reflection/descriptor_bootstrap.h
|
||||
@@ -2,7 +2,7 @@
|
||||
#define GOOGLE_UPB_UPB_REFLECTION_DESCRIPTOR_BOOTSTRAP_H__
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
-
|
||||
+#define UPB_BOOTSTRAP_STAGE 0
|
||||
#if defined(UPB_BOOTSTRAP_STAGE) && UPB_BOOTSTRAP_STAGE == 0
|
||||
// This header is checked in.
|
||||
#include "upb/reflection/stage0/google/protobuf/descriptor.upb.h"
|
||||
@@ -0,0 +1,73 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Gold856 <117957790+Gold856@users.noreply.github.com>
|
||||
Date: Sat, 24 May 2025 23:17:42 -0400
|
||||
Subject: [PATCH 3/5] Replace global alloc struct with function
|
||||
|
||||
---
|
||||
upb/mem/alloc.c | 5 ++++-
|
||||
upb/mem/alloc.h | 8 ++++----
|
||||
upb/mem/arena.h | 4 ++--
|
||||
3 files changed, 10 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/upb/mem/alloc.c b/upb/mem/alloc.c
|
||||
index 3d70ee768c2473f84129e32c24c6cf3a7f78abef..bb1a635d2926fafa3b4f7dad677dbea482cea2ed 100644
|
||||
--- a/upb/mem/alloc.c
|
||||
+++ b/upb/mem/alloc.c
|
||||
@@ -25,4 +25,7 @@ static void* upb_global_allocfunc(upb_alloc* alloc, void* ptr, size_t oldsize,
|
||||
}
|
||||
}
|
||||
|
||||
-upb_alloc upb_alloc_global = {&upb_global_allocfunc};
|
||||
+upb_alloc alloc = {&upb_global_allocfunc};
|
||||
+upb_alloc* upb_alloc_global(void) {
|
||||
+ return &alloc;
|
||||
+}
|
||||
diff --git a/upb/mem/alloc.h b/upb/mem/alloc.h
|
||||
index 04da2337b498cd204b6d196e8b3ddc6ec9e66a7a..d4d7142569469868fd9a241bb0f0169b9918129f 100644
|
||||
--- a/upb/mem/alloc.h
|
||||
+++ b/upb/mem/alloc.h
|
||||
@@ -76,7 +76,7 @@ UPB_INLINE void upb_free_sized(upb_alloc* alloc, void* ptr, size_t size) {
|
||||
|
||||
// The global allocator used by upb. Uses the standard malloc()/free().
|
||||
|
||||
-extern upb_alloc upb_alloc_global;
|
||||
+upb_alloc* upb_alloc_global(void);
|
||||
|
||||
/* Functions that hard-code the global malloc.
|
||||
*
|
||||
@@ -84,14 +84,14 @@ extern upb_alloc upb_alloc_global;
|
||||
* allocator, like injecting out-of-memory faults in debug/testing builds. */
|
||||
|
||||
UPB_INLINE void* upb_gmalloc(size_t size) {
|
||||
- return upb_malloc(&upb_alloc_global, size);
|
||||
+ return upb_malloc(upb_alloc_global(), size);
|
||||
}
|
||||
|
||||
UPB_INLINE void* upb_grealloc(void* ptr, size_t oldsize, size_t size) {
|
||||
- return upb_realloc(&upb_alloc_global, ptr, oldsize, size);
|
||||
+ return upb_realloc(upb_alloc_global(), ptr, oldsize, size);
|
||||
}
|
||||
|
||||
-UPB_INLINE void upb_gfree(void* ptr) { upb_free(&upb_alloc_global, ptr); }
|
||||
+UPB_INLINE void upb_gfree(void* ptr) { upb_free(upb_alloc_global(), ptr); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
diff --git a/upb/mem/arena.h b/upb/mem/arena.h
|
||||
index 614ac2e043296a8993f0ac055040ea821c130fd9..24dd3830c2b0b6d403df132062e7a78903c201af 100644
|
||||
--- a/upb/mem/arena.h
|
||||
+++ b/upb/mem/arena.h
|
||||
@@ -78,11 +78,11 @@ uintptr_t upb_Arena_SpaceAllocated(const upb_Arena* a, size_t* fused_count);
|
||||
uint32_t upb_Arena_DebugRefCount(const upb_Arena* a);
|
||||
|
||||
UPB_API_INLINE upb_Arena* upb_Arena_New(void) {
|
||||
- return upb_Arena_Init(NULL, 0, &upb_alloc_global);
|
||||
+ return upb_Arena_Init(NULL, 0, upb_alloc_global());
|
||||
}
|
||||
|
||||
UPB_API_INLINE upb_Arena* upb_Arena_NewSized(size_t size_hint) {
|
||||
- return upb_Arena_Init(NULL, size_hint, &upb_alloc_global);
|
||||
+ return upb_Arena_Init(NULL, size_hint, upb_alloc_global());
|
||||
}
|
||||
|
||||
UPB_API_INLINE void* upb_Arena_Malloc(struct upb_Arena* a, size_t size);
|
||||
@@ -0,0 +1,23 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Gold856 <117957790+Gold856@users.noreply.github.com>
|
||||
Date: Mon, 26 May 2025 01:34:57 -0400
|
||||
Subject: [PATCH 4/5] Cast key to uint64_t before doing a bit shift This fixes
|
||||
compilation on Win32
|
||||
|
||||
---
|
||||
upb/hash/common.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/upb/hash/common.c b/upb/hash/common.c
|
||||
index ca0e488689e9cc54d143f505484497654d0f8c03..26c731764ce08f4e3f12900821fd1ebd1798da27 100644
|
||||
--- a/upb/hash/common.c
|
||||
+++ b/upb/hash/common.c
|
||||
@@ -95,7 +95,7 @@ typedef bool eqlfunc_t(upb_key k1, lookupkey_t k2);
|
||||
|
||||
static uint32_t upb_inthash(uintptr_t key) {
|
||||
if (sizeof(uintptr_t) == 8) {
|
||||
- return (uint32_t)key ^ (uint32_t)(key >> 32);
|
||||
+ return (uint32_t)key ^ (uint32_t)((uint64_t)(key) >> 32);
|
||||
} else {
|
||||
UPB_ASSERT(sizeof(uintptr_t) == 4);
|
||||
return (uint32_t)key;
|
||||
113
upstream_utils/upb_patches/0005-Suppress-warnings.patch
Normal file
113
upstream_utils/upb_patches/0005-Suppress-warnings.patch
Normal file
@@ -0,0 +1,113 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Gold856 <117957790+Gold856@users.noreply.github.com>
|
||||
Date: Mon, 26 May 2025 01:35:06 -0400
|
||||
Subject: [PATCH 5/5] Suppress warnings
|
||||
|
||||
---
|
||||
third_party/utf8_range/utf8_range.c | 2 +-
|
||||
upb/port/def.inc | 24 +++++++++++++++++++
|
||||
upb/port/undef.inc | 7 ++++++
|
||||
.../stage0/google/protobuf/descriptor.upb.c | 6 ++++-
|
||||
upb/wire/internal/decoder.h | 2 +-
|
||||
5 files changed, 38 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/third_party/utf8_range/utf8_range.c b/third_party/utf8_range/utf8_range.c
|
||||
index 049e2e21508cf368dab6cd49727ed2e413542f71..3eb4bd7c95df0ea2346987d78d8933872719b230 100644
|
||||
--- a/third_party/utf8_range/utf8_range.c
|
||||
+++ b/third_party/utf8_range/utf8_range.c
|
||||
@@ -20,11 +20,11 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
-
|
||||
#if defined(__GNUC__)
|
||||
#define FORCE_INLINE_ATTR __attribute__((always_inline)) inline
|
||||
#elif defined(_MSC_VER)
|
||||
#define FORCE_INLINE_ATTR __forceinline
|
||||
+#pragma warning (disable : 4141)
|
||||
#else
|
||||
#define FORCE_INLINE_ATTR inline
|
||||
#endif
|
||||
diff --git a/upb/port/def.inc b/upb/port/def.inc
|
||||
index 237aa87648661b05ce9a47fce00561bd2f262b13..50350e60cbbed1dfab186e7bf30ae821c378f027 100644
|
||||
--- a/upb/port/def.inc
|
||||
+++ b/upb/port/def.inc
|
||||
@@ -34,6 +34,30 @@
|
||||
#endif
|
||||
|
||||
#define UPB_BOOTSTRAP_STAGE 0
|
||||
+#if _WIN32
|
||||
+#pragma warning(push)
|
||||
+#pragma warning(disable : 4018 4047 4116 4146 4200 4244 4267 4334 4646 4789)
|
||||
+#elif defined(__clang__)
|
||||
+#pragma clang diagnostic push
|
||||
+#ifdef __cplusplus
|
||||
+#pragma clang diagnostic ignored "-Wc99-extensions"
|
||||
+#endif
|
||||
+#pragma clang diagnostic ignored "-Wsign-compare"
|
||||
+#pragma clang diagnostic ignored "-Wflexible-array-extensions"
|
||||
+#elif defined(__GNUC__)
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
|
||||
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
+#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
+#ifndef __cplusplus
|
||||
+#pragma GCC diagnostic ignored "-Wpointer-to-int-cast"
|
||||
+#endif
|
||||
+#pragma GCC diagnostic ignored "-Wclobbered"
|
||||
+#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
|
||||
+#pragma GCC diagnostic ignored "-Wstringop-overread"
|
||||
+#pragma GCC diagnostic ignored "-Wtype-limits"
|
||||
+#endif
|
||||
|
||||
// Portable check for GCC minimum version:
|
||||
// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
|
||||
diff --git a/upb/port/undef.inc b/upb/port/undef.inc
|
||||
index 764c81ce69fe63b956c97d337ba6d448c6ac70f9..b1cf7202b51dd350d49987e4e282461f9fa26399 100644
|
||||
--- a/upb/port/undef.inc
|
||||
+++ b/upb/port/undef.inc
|
||||
@@ -7,6 +7,13 @@
|
||||
|
||||
// This should #undef all macros #defined in def.inc
|
||||
|
||||
+#if _WIN32
|
||||
+#pragma warning(pop)
|
||||
+#elif defined(__clang__)
|
||||
+#pragma clang diagnostic pop
|
||||
+#elif defined(__GNUC__)
|
||||
+#pragma GCC diagnostic pop
|
||||
+#endif
|
||||
#undef UPB_SIZE
|
||||
#undef UPB_PTR_AT
|
||||
#undef UPB_SIZEOF_FLEX
|
||||
diff --git a/upb/reflection/stage0/google/protobuf/descriptor.upb.c b/upb/reflection/stage0/google/protobuf/descriptor.upb.c
|
||||
index 9595ce30983144322fc3616a674fce158abeb8a9..e2f59e7702a9bb1d36cfc6bba66bd350006c138f 100644
|
||||
--- a/upb/reflection/stage0/google/protobuf/descriptor.upb.c
|
||||
+++ b/upb/reflection/stage0/google/protobuf/descriptor.upb.c
|
||||
@@ -1,7 +1,11 @@
|
||||
#include <stddef.h>
|
||||
#include "upb/generated_code_support.h"
|
||||
#include "upb/reflection/descriptor_bootstrap.h"
|
||||
-
|
||||
+#ifdef __clang__
|
||||
+#pragma clang diagnostic ignored "-Wstrict-prototypes"
|
||||
+#elif defined(__GNUC__)
|
||||
+#pragma GCC diagnostic ignored "-Wstrict-prototypes"
|
||||
+#endif
|
||||
static upb_Arena* upb_BootstrapArena() {
|
||||
static upb_Arena* arena = NULL;
|
||||
if (!arena) arena = upb_Arena_New();
|
||||
diff --git a/upb/wire/internal/decoder.h b/upb/wire/internal/decoder.h
|
||||
index 8f5299d97323760a77d72247b6d1c90034b71194..3c59c6ee69caad2c280b6823079ed0e5ab122c48 100644
|
||||
--- a/upb/wire/internal/decoder.h
|
||||
+++ b/upb/wire/internal/decoder.h
|
||||
@@ -110,7 +110,7 @@ UPB_INLINE void _upb_Decoder_Trace(upb_Decoder* d, char event) {
|
||||
d->trace_ptr[1] = '\0';
|
||||
d->trace_ptr++;
|
||||
#endif
|
||||
-};
|
||||
+}
|
||||
|
||||
UPB_INLINE
|
||||
bool _upb_Decoder_VerifyUtf8Inline(const char* ptr, int len) {
|
||||
Reference in New Issue
Block a user