https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/160149
>From 085e848344f5772b3d1481c24ca6471fe45c9138 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin <[email protected]> Date: Mon, 22 Sep 2025 20:05:57 +0500 Subject: [PATCH 1/2] [lldb] Use APSInt's right shift operator in Scalar --- lldb/source/Utility/Scalar.cpp | 20 +++----------------- lldb/unittests/Utility/ScalarTest.cpp | 3 +++ 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp index c8766bdf2aee7..f2c18cdd896da 100644 --- a/lldb/source/Utility/Scalar.cpp +++ b/lldb/source/Utility/Scalar.cpp @@ -471,24 +471,10 @@ bool Scalar::ShiftRightLogical(const Scalar &rhs) { } Scalar &Scalar::operator>>=(const Scalar &rhs) { - switch (m_type) { - case e_void: - case e_float: + if (m_type == e_int && rhs.m_type == e_int) + m_integer >>= rhs.m_integer.getZExtValue(); + else m_type = e_void; - break; - - case e_int: - switch (rhs.m_type) { - case e_void: - case e_float: - m_type = e_void; - break; - case e_int: - m_integer = m_integer.ashr(rhs.m_integer); - break; - } - break; - } return *this; } diff --git a/lldb/unittests/Utility/ScalarTest.cpp b/lldb/unittests/Utility/ScalarTest.cpp index 6d5caef42bee4..e6d7479b59fee 100644 --- a/lldb/unittests/Utility/ScalarTest.cpp +++ b/lldb/unittests/Utility/ScalarTest.cpp @@ -118,11 +118,14 @@ TEST(ScalarTest, RightShiftOperator) { int a = 0x00001000; int b = 0xFFFFFFFF; int c = 4; + unsigned d = 0xFFFFFFFF; Scalar a_scalar(a); Scalar b_scalar(b); Scalar c_scalar(c); + Scalar d_scalar(d); ASSERT_EQ(a >> c, a_scalar >> c_scalar); ASSERT_EQ(b >> c, b_scalar >> c_scalar); + ASSERT_EQ(d >> c, d_scalar >> c_scalar); } TEST(ScalarTest, GetBytes) { >From c91fdc810d0d59b53bc27f2a5c774c29c5eb6c0a Mon Sep 17 00:00:00 2001 From: Ilia Kuklin <[email protected]> Date: Mon, 22 Sep 2025 22:27:07 +0500 Subject: [PATCH 2/2] Add a test for unsigned short --- lldb/unittests/Utility/ScalarTest.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/unittests/Utility/ScalarTest.cpp b/lldb/unittests/Utility/ScalarTest.cpp index e6d7479b59fee..869a5809e6d14 100644 --- a/lldb/unittests/Utility/ScalarTest.cpp +++ b/lldb/unittests/Utility/ScalarTest.cpp @@ -119,13 +119,16 @@ TEST(ScalarTest, RightShiftOperator) { int b = 0xFFFFFFFF; int c = 4; unsigned d = 0xFFFFFFFF; + unsigned short e = 0xFFFF; Scalar a_scalar(a); Scalar b_scalar(b); Scalar c_scalar(c); Scalar d_scalar(d); + Scalar e_scalar(e); ASSERT_EQ(a >> c, a_scalar >> c_scalar); ASSERT_EQ(b >> c, b_scalar >> c_scalar); ASSERT_EQ(d >> c, d_scalar >> c_scalar); + ASSERT_EQ(e >> c, e_scalar >> c_scalar); } TEST(ScalarTest, GetBytes) { _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
