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