diff mbox series

[meta-oe] leveldb: Fix cast warnings seen with clang-21

Message ID 20250728213732.3992327-1-raj.khem@gmail.com
State New
Headers show
Series [meta-oe] leveldb: Fix cast warnings seen with clang-21 | expand

Commit Message

Khem Raj July 28, 2025, 9:37 p.m. UTC
backport needed patch for googletest

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...instead-of-ImplicitCast_-for-charact.patch | 49 +++++++++++++++++++
 meta-oe/recipes-dbs/leveldb/leveldb_1.23.bb   |  1 +
 2 files changed, 50 insertions(+)
 create mode 100644 meta-oe/recipes-dbs/leveldb/leveldb/0001-Use-static_cast-instead-of-ImplicitCast_-for-charact.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-dbs/leveldb/leveldb/0001-Use-static_cast-instead-of-ImplicitCast_-for-charact.patch b/meta-oe/recipes-dbs/leveldb/leveldb/0001-Use-static_cast-instead-of-ImplicitCast_-for-charact.patch
new file mode 100644
index 0000000000..7a06630918
--- /dev/null
+++ b/meta-oe/recipes-dbs/leveldb/leveldb/0001-Use-static_cast-instead-of-ImplicitCast_-for-charact.patch
@@ -0,0 +1,49 @@ 
+From fa8438ae6b70c57010177de47a9f13d7041a6328 Mon Sep 17 00:00:00 2001
+From: Abseil Team <absl-team@google.com>
+Date: Mon, 19 May 2025 09:01:54 -0700
+Subject: [PATCH] Use static_cast instead of ImplicitCast_ for character
+ conversions
+
+Clang has recently added "warnings when mixing different charN_t types" [1].
+The rationale is that "charN_t represent code units of different UTF encodings.
+Therefore the values of 2 different charN_t objects do not represent the same
+characters."
+
+Note that the warning here may be legitimate - from https://github.com/google/googletest/issues/4762:
+"[...] This is incorrect for values that do not represent valid codepoints."
+
+For the time being, silence the warning by being more explicit about the
+conversion being intentional by using static_cast.
+
+Link: https://github.com/llvm/llvm-project/pull/138708 [1]
+PiperOrigin-RevId: 760644157
+Change-Id: I2e6cc1871975455cecac8731b2f93fd5beeaf0e1
+
+Upstream-Status: Backport [https://github.com/google/googletest/commit/fa8438ae6b70c57010177de47a9f13d7041a6328]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ third_party/googletest/googletest/include/gtest/gtest-printers.h | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+Index: leveldb-1.23/third_party/googletest/googletest/include/gtest/gtest-printers.h
+===================================================================
+--- leveldb-1.23.orig/third_party/googletest/googletest/include/gtest/gtest-printers.h
++++ leveldb-1.23/third_party/googletest/googletest/include/gtest/gtest-printers.h
+@@ -471,11 +471,15 @@ GTEST_API_ void PrintTo(wchar_t wc, ::st
+ 
+ GTEST_API_ void PrintTo(char32_t c, ::std::ostream* os);
+ inline void PrintTo(char16_t c, ::std::ostream* os) {
+-  PrintTo(ImplicitCast_<char32_t>(c), os);
++ // TODO(b/418738869): Incorrect for values not representing valid codepoints.
++ // Also see https://github.com/google/googletest/issues/4762.
++ PrintTo(static_cast<char32_t>(c), os);
+ }
+ #ifdef __cpp_char8_t
+ inline void PrintTo(char8_t c, ::std::ostream* os) {
+-  PrintTo(ImplicitCast_<char32_t>(c), os);
++  // TODO(b/418738869): Incorrect for values not representing valid codepoints.
++  // Also see https://github.com/google/googletest/issues/4762.
++  PrintTo(static_cast<char32_t>(c), os);
+ }
+ #endif
+ 
diff --git a/meta-oe/recipes-dbs/leveldb/leveldb_1.23.bb b/meta-oe/recipes-dbs/leveldb/leveldb_1.23.bb
index 1ccf115793..90e0785e54 100644
--- a/meta-oe/recipes-dbs/leveldb/leveldb_1.23.bb
+++ b/meta-oe/recipes-dbs/leveldb/leveldb_1.23.bb
@@ -7,6 +7,7 @@  LIC_FILES_CHKSUM = "file://LICENSE;md5=92d1b128950b11ba8495b64938fc164d"
 SRC_URI = "gitsm://github.com/google/${BPN}.git;branch=main;protocol=https \
     file://0001-CMakeLists.txt-fix-googletest-related-options.patch \
     file://0001-Fix-printing-64-bit-integer-types.patch \
+    file://0001-Use-static_cast-instead-of-ImplicitCast_-for-charact.patch \
     file://run-ptest \
 "