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 @@
1+ diff --git a/common/typeinfo.h b/common/typeinfo.h
2+ index 06a03c13d..9f5d77980 100644
3+ --- a/common/typeinfo.h
4+ +++ b/common/typeinfo.h
5+ @@ -80,7 +80,7 @@
6+ std::conjunction_v<common_internal::HasNativeTypeTraitsId<T>,
7+ std::negation<common_internal::HasCelTypeId<T>>>,
8+ TypeInfo>
9+ - TypeId(const T& t) {
10+ + TypeId(const T& t [[maybe_unused]]) {
11+ return NativeTypeTraits<absl::remove_cvref_t<T>>::Id(t);
12+ }
13+
14+ @@ -90,7 +90,7 @@
15+ std::negation<common_internal::HasCelTypeId<T>>,
16+ std::is_final<T>>,
17+ TypeInfo>
18+ - TypeId(const T& t) {
19+ + TypeId(const T& t [[maybe_unused]]) {
20+ return cel::TypeId<absl::remove_cvref_t<T>>();
21+ }
1922
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);
23+ @@ -99,7 +99,7 @@
24+ std::conjunction_v<std::negation<common_internal::HasNativeTypeTraitsId<T>>,
25+ common_internal::HasCelTypeId<T>>,
26+ TypeInfo>
27+ - TypeId(const T& t) {
28+ + TypeId(const T& t [[maybe_unused]]) {
29+ return CelTypeId(t);
30+ }
31+
32+ diff --git a/common/values/value_variant.h b/common/values/value_variant.h
33+ index 9876543ab..1234567cd 100644
34+ --- a/common/values/value_variant.h
35+ +++ b/common/values/value_variant.h
36+ @@ -739,7 +739,7 @@
37+ #pragma GCC diagnostic ignored "-Wclass-memaccess"
38+ #elif defined(__clang__)
39+ #pragma clang diagnostic push
40+ - #pragma clang diagnostic ignored "-Wnontrivial-memcall"
41+ + #pragma clang diagnostic ignored "-Wclass-memaccess"
42+ #endif
43+ alignas(ValueVariant) std::byte tmp[sizeof(ValueVariant)];
44+ // NOLINTNEXTLINE(bugprone-undefined-memory-manipulation)
3345diff --git a/common/value.h b/common/value.h
34- index 06a03c13d..9f5d77980 100644
46+ index abcdef123..987654fed 100644
3547--- a/common/value.h
3648+++ 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 {
49+ @@ -2726 ,7 +2726 ,7 @@
50+ const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
51+ google::protobuf::MessageFactory* absl_nonnull message_factory,
52+ google::protobuf::Arena* absl_nonnull arena) const {
4153- ABSL_DCHECK_GT(qualifiers.size(), 0);
4254+ ABSL_DCHECK_GT(static_cast<int>(qualifiers.size()), 0);
4355 ABSL_DCHECK(descriptor_pool != nullptr);
4456 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.
57+ ABSL_DCHECK(arena != nullptr);
0 commit comments