[Lldb-commits] [lldb] [lldb] Add binary multiplication, division, remainder to DIL (PR #187281)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 10 09:54:59 PDT 2026


================
@@ -98,7 +109,62 @@ def test_arithmetic(self):
         # Check references and typedefs
         self.expect_var_path("ref + 1", value="3")
         self.expect_var_path("ref - 1l", value="1")
+        self.expect_var_path("ref * 2u", value="4")
+        self.expect_var_path("ref / 2ull", value="1")
+        self.expect_var_path("ref % 2", value="0")
         self.expect_var_path("my_ref + 1", value="3")
         self.expect_var_path("my_ref - 1", value="1")
+        self.expect_var_path("my_ref * 2", value="4")
+        self.expect_var_path("my_ref / 2", value="1")
+        self.expect_var_path("my_ref % 2", value="0")
         self.expect_var_path("ref + my_ref", value="4")
         self.expect_var_path("ref - my_ref", value="0")
+        self.expect_var_path("ref * my_ref", value="4")
+        self.expect_var_path("ref / my_ref", value="1")
+        self.expect_var_path("ref % my_ref", value="0")
+
+        # Check errors
+        self.expect(
+            "frame var -- '1 / 0'",
+            error=True,
+            substrs=["division by zero is undefined"],
+        )
+        self.expect(
+            "frame var -- '1 / uint_zero'",
+            error=True,
+            substrs=["division by zero is undefined"],
+        )
+        self.expect(
+            "frame var -- '1LL / 0 + 1'",
+            error=True,
+            substrs=["division by zero is undefined"],
+        )
+        self.expect(
+            "frame var -- '1 % 0'",
+            error=True,
+            substrs=["division by zero is undefined"],
+        )
+        self.expect(
+            "frame var -- '1 % uint_zero'",
+            error=True,
+            substrs=["division by zero is undefined"],
+        )
+        self.expect(
+            "frame var -- '*((int*) 0) + 1'",
+            error=True,
+            substrs=["invalid lhs value: parent is NULL"],
+        )
+        self.expect(
+            "frame var -- '1 / *((int*) 0)'",
+            error=True,
+            substrs=["invalid rhs value: parent is NULL"],
+        )
+
+        # Check that binary * is allowed only in full mode
+        frame = thread.GetFrameAtIndex(0)
----------------
Michael137 wrote:

Can we add tests for doing operations on enums?

https://github.com/llvm/llvm-project/pull/187281


More information about the lldb-commits mailing list