1import lldb 2from lldbsuite.test.decorators import * 3from lldbsuite.test.lldbtest import * 4from lldbsuite.test import lldbutil 5 6class TestCase(TestBase): 7 8 def test(self): 9 """Tests deferencing lvalue/rvalue references via LLDB's builtin type system.""" 10 self.build() 11 lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp")) 12 13 # Take an lvalue reference and call `Dereference` on the SBValue. 14 # The result should be `TTT` (and *not* for example the underlying type 15 # 'int'). 16 lref_val = self.expect_var_path("l_ref", type="TTT &") 17 self.assertEqual(lref_val.Dereference().GetType().GetName(), "TTT") 18 19 # Same as above for rvalue references. 20 rref_val = self.expect_var_path("r_ref", type="TTT &&") 21 self.assertEqual(rref_val.Dereference().GetType().GetName(), "TTT") 22 23 # Typedef to a reference should dereference to the underlying type. 24 td_val = self.expect_var_path("td_to_ref_type", type="td_int_ref") 25 self.assertEqual(td_val.Dereference().GetType().GetName(), "int") 26