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-
141diff --git a/common/internal/byte_string.cc b/common/internal/byte_string.cc
152index e01c797f8..12345678a 100644
163--- a/common/internal/byte_string.cc
174+++ b/common/internal/byte_string.cc
18- @@ -104,6 +104,14 @@
5+ @@ -104,6 +104,13 @@
196
207 ByteString::ByteString(Allocator<> allocator, absl::string_view string) {
218 ABSL_DCHECK_LE(string.size(), max_size());
@@ -26,18 +13,48 @@ index e01c797f8..12345678a 100644
2613+ SetSmallEmpty(allocator.arena());
2714+ return;
2815+ }
29- +
3016 auto* arena = allocator.arena();
3117 if (string.size() <= kSmallByteStringCapacity) {
3218 SetSmall(arena, string);
33- diff --git a/common/value .h b/common/value .h
19+ diff --git a/common/typeinfo .h b/common/typeinfo .h
3420index 06a03c13d..9f5d77980 100644
21+ --- a/common/typeinfo.h
22+ +++ b/common/typeinfo.h
23+ @@ -80,7 +80,7 @@
24+ std::conjunction_v<common_internal::HasNativeTypeTraitsId<T>,
25+ std::negation<common_internal::HasCelTypeId<T>>>,
26+ TypeInfo>
27+ - TypeId(const T& t) {
28+ + TypeId(const T& t [[maybe_unused]]) {
29+ return NativeTypeTraits<absl::remove_cvref_t<T>>::Id(t);
30+ }
31+
32+ @@ -90,7 +90,7 @@
33+ std::negation<common_internal::HasCelTypeId<T>>,
34+ std::is_final<T>>,
35+ TypeInfo>
36+ - TypeId(const T& t) {
37+ + TypeId(const T& t [[maybe_unused]]) {
38+ return cel::TypeId<absl::remove_cvref_t<T>>();
39+ }
40+
41+ @@ -99,7 +99,7 @@
42+ std::conjunction_v<std::negation<common_internal::HasNativeTypeTraitsId<T>>,
43+ common_internal::HasCelTypeId<T>>,
44+ TypeInfo>
45+ - TypeId(const T& t) {
46+ + TypeId(const T& t [[maybe_unused]]) {
47+ return CelTypeId(t);
48+ }
49+
50+ diff --git a/common/value.h b/common/value.h
51+ index abcdef123..987654fed 100644
3552--- a/common/value.h
3653+++ 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 {
54+ @@ -2726 ,7 +2726 ,7 @@
55+ const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
56+ google::protobuf::MessageFactory* absl_nonnull message_factory,
57+ google::protobuf::Arena* absl_nonnull arena) const {
4158- ABSL_DCHECK_GT(qualifiers.size(), 0);
4259+ ABSL_DCHECK_GT(static_cast<int>(qualifiers.size()), 0);
4360 ABSL_DCHECK(descriptor_pool != nullptr);
@@ -47,42 +64,22 @@ diff --git a/common/values/value_variant.h b/common/values/value_variant.h
4764index 61c19ce5f..fc7969bc8 100644
4865--- a/common/values/value_variant.h
4966+++ 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
67+ @@ -737,9 +737,6 @@
68+ #if defined(__GNUC__) && !defined(__clang__)
69+ #pragma GCC diagnostic push
70+ #pragma GCC diagnostic ignored "-Wclass-memaccess"
71+ - #elif defined(__clang__)
72+ - #pragma clang diagnostic push
73+ - #pragma clang diagnostic ignored "-Wnontrivial-memcall"
74+ #endif
6175 alignas(ValueVariant) std::byte tmp[sizeof(ValueVariant)];
6276 // 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)
77+ @@ -751,8 +748,6 @@
6778 std::memcpy(std::addressof(rhs), tmp, sizeof(ValueVariant));
68- + #if defined(__GNUC__) && !defined(__clang__)
69- + #pragma GCC diagnostic pop
70- + #endif
79+ #if defined(__GNUC__) && !defined(__clang__)
80+ #pragma GCC diagnostic pop
81+ - #elif defined(__clang__)
82+ - #pragma clang diagnostic pop
83+ #endif
7184 } 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.
85+ SlowSwap(lhs, rhs, lhs_trivial, rhs_trivial);
0 commit comments