|
| 1 | +From d88b2a2d81e62335708057b3a044abada46de2a3 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Rohit Agrawal < [email protected]> |
| 3 | +Date: Tue, 6 May 2025 17:30:08 +0900 |
| 4 | +Subject: [PATCH] Patches for cel-cpp v0.11.0 |
| 5 | + |
| 6 | +Signed-off-by: Rohit Agrawal < [email protected]> |
| 7 | +--- |
| 8 | + common/internal/byte_string.cc | 8 ++++++++ |
| 9 | + common/value.h | 2 +- |
| 10 | + common/values/value_variant.h | 10 ++++++++++ |
| 11 | + runtime/type_registry.h | 4 ++-- |
| 12 | + 4 files changed, 21 insertions(+), 3 deletions(-) |
| 13 | + |
| 14 | +diff --git a/common/internal/byte_string.cc b/common/internal/byte_string.cc |
| 15 | +index e01c797f8..12345678a 100644 |
| 16 | +--- a/common/internal/byte_string.cc |
| 17 | ++++ b/common/internal/byte_string.cc |
| 18 | +@@ -104,6 +104,14 @@ |
| 19 | + |
| 20 | + ByteString::ByteString(Allocator<> allocator, absl::string_view string) { |
| 21 | + ABSL_DCHECK_LE(string.size(), max_size()); |
| 22 | ++ |
| 23 | ++ // Check for null data pointer in the string_view |
| 24 | ++ if (string.data() == nullptr) { |
| 25 | ++ // Handle null data by creating an empty ByteString |
| 26 | ++ SetSmallEmpty(allocator.arena()); |
| 27 | ++ return; |
| 28 | ++ } |
| 29 | ++ |
| 30 | + auto* arena = allocator.arena(); |
| 31 | + if (string.size() <= kSmallByteStringCapacity) { |
| 32 | + SetSmall(arena, string); |
| 33 | +diff --git a/common/value.h b/common/value.h |
| 34 | +index 06a03c13d..9f5d77980 100644 |
| 35 | +--- a/common/value.h |
| 36 | ++++ b/common/value.h |
| 37 | +@@ -2733,7 +2733,7 @@ |
| 38 | + absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool, |
| 39 | + absl::Nonnull<google::protobuf::MessageFactory*> message_factory, |
| 40 | + absl::Nonnull<google::protobuf::Arena*> arena) const { |
| 41 | +- ABSL_DCHECK_GT(qualifiers.size(), 0); |
| 42 | ++ ABSL_DCHECK_GT(static_cast<int>(qualifiers.size()), 0); |
| 43 | + ABSL_DCHECK(descriptor_pool != nullptr); |
| 44 | + ABSL_DCHECK(message_factory != nullptr); |
| 45 | + ABSL_DCHECK(arena != nullptr); |
| 46 | +diff --git a/common/values/value_variant.h b/common/values/value_variant.h |
| 47 | +index 61c19ce5f..fc7969bc8 100644 |
| 48 | +--- a/common/values/value_variant.h |
| 49 | ++++ b/common/values/value_variant.h |
| 50 | +@@ -732,6 +732,13 @@ |
| 51 | + const bool rhs_trivial = |
| 52 | + (rhs.flags_ & ValueFlags::kNonTrivial) == ValueFlags::kNone; |
| 53 | + if (lhs_trivial && rhs_trivial) { |
| 54 | ++ // We need to suppress the compiler warnings about memory manipulation. |
| 55 | ++ // The memcpy usage here is intentional for performance optimization |
| 56 | ++ // Only suppress this warning on GCC, as Clang doesn't have this warning |
| 57 | ++#if defined(__GNUC__) && !defined(__clang__) |
| 58 | ++#pragma GCC diagnostic push |
| 59 | ++#pragma GCC diagnostic ignored "-Wclass-memaccess" |
| 60 | ++#endif |
| 61 | + alignas(ValueVariant) std::byte tmp[sizeof(ValueVariant)]; |
| 62 | + // NOLINTNEXTLINE(bugprone-undefined-memory-manipulation) |
| 63 | + std::memcpy(tmp, std::addressof(lhs), sizeof(ValueVariant)); |
| 64 | +@@ -740,6 +747,9 @@ |
| 65 | + sizeof(ValueVariant)); |
| 66 | + // NOLINTNEXTLINE(bugprone-undefined-memory-manipulation) |
| 67 | + std::memcpy(std::addressof(rhs), tmp, sizeof(ValueVariant)); |
| 68 | ++#if defined(__GNUC__) && !defined(__clang__) |
| 69 | ++#pragma GCC diagnostic pop |
| 70 | ++#endif |
| 71 | + } else { |
| 72 | + SlowSwap(lhs, rhs, lhs_trivial, rhs_trivial); |
| 73 | + } |
| 74 | +diff --git a/runtime/type_registry.h b/runtime/type_registry.h |
| 75 | +index 2b247946c..3e5ad423b 100644 |
| 76 | +--- a/runtime/type_registry.h |
| 77 | ++++ b/runtime/type_registry.h |
| 78 | +@@ -77,8 +77,8 @@ |
| 79 | + // Move-only |
| 80 | + TypeRegistry(const TypeRegistry& other) = delete; |
| 81 | + TypeRegistry& operator=(TypeRegistry& other) = delete; |
| 82 | +- TypeRegistry(TypeRegistry&& other) = default; |
| 83 | +- TypeRegistry& operator=(TypeRegistry&& other) = default; |
| 84 | ++ TypeRegistry(TypeRegistry&& other) = delete; |
| 85 | ++ TypeRegistry& operator=(TypeRegistry&& other) = delete; |
| 86 | + |
| 87 | + // Registers a type such that it can be accessed by name, i.e. `type(foo) == |
| 88 | + // my_type`. Where `my_type` is the type being registered. |
0 commit comments