[Lldb-commits] [lldb] [LLDB] Add type casting to DIL, part 3 of 3 (PR #175061)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 10 01:41:54 PST 2026


================
@@ -233,3 +259,17 @@ def test_type_cast(self):
         self.expect_var_path("((int*)arr_2d)[1]", type="int", value="2")
         self.expect_var_path("((int*)arr_2d)[2]", type="int", value="3")
         self.expect_var_path("((int*)arr_2d[1])[1]", type="int", value="5")
+
+        # Test casting to user-defined type with same name as variable.
+
+        self.expect_var_path("myStruct", type="myName")
+        self.expect_var_path("myName", type="int", value="37")
+
+        # Here 'myName' is treated as a variable, not a type, so '(myName)'
+        # is parsed as a variable expression and 'InnerFoo' is unexpected,
+        # and a type cast is not attempted.
+        self.expect(
+            "frame variable '(myName)InnerFoo'",
+            error=True,
+            substrs=["expected 'eof', got: <'InnerFoo' (identifier)>"],
----------------
Michael137 wrote:

Something like about `myVariable` being a variable and not a type-name. I.e., give the user an indication of why this failed. Possibly `DILParser::ParseTypeId` needs to return a `llvm::Expected<CompilerType>`? Then we can propagate the error message (and an empty `CompilerType` is what we would return where we previously returned a `std::nullopt`. Does that make sense?

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


More information about the lldb-commits mailing list