1 """ 2 Tests that rvalue references are supported in C++ 3 """ 4 5 import lldb 6 from lldbtest import * 7 import lldbutil 8 9 class RvalueReferencesTestCase(TestBase): 10 11 mydir = os.path.join("lang", "cpp", "rvalue-references") 12 13 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 14 #rdar://problem/11479676 15 @expectedFailureClang 16 @dsym_test 17 def test_with_dsym_and_run_command(self): 18 """Test that rvalues are supported in the C++ expression parser""" 19 self.buildDsym() 20 self.static_method_commands() 21 22 #rdar://problem/11479676 23 @expectedFailureClang # pr16762: Expression evaluation of an rvalue-reference does not show the correct type. 24 @expectedFailureGcc # GCC (4.7) does not emit correct DWARF tags for rvalue-references 25 @expectedFailureIcc # ICC (13.1, 14-beta) do not emit DW_TAG_rvalue_reference_type. 26 @dwarf_test 27 def test_with_dwarf_and_run_command(self): 28 """Test that rvalues are supported in the C++ expression parser""" 29 self.buildDwarf() 30 self.static_method_commands() 31 32 def setUp(self): 33 TestBase.setUp(self) 34 35 def set_breakpoint(self, line): 36 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", line, num_expected_locations=1, loc_exact=True) 37 38 def static_method_commands(self): 39 """Test that rvalues are supported in the C++ expression parser""" 40 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) 41 42 self.set_breakpoint(line_number('main.cpp', '// breakpoint 1')) 43 self.set_breakpoint(line_number('main.cpp', '// breakpoint 2')) 44 45 self.runCmd("process launch", RUN_SUCCEEDED) 46 47 # Note that clang as of r187480 doesn't emit DW_TAG_const_type, unlike gcc 4.8.1 48 # With gcc 4.8.1, lldb reports the type as (int &&const) 49 self.expect("frame variable i", 50 startstr = "(int &&", 51 substrs = ["i = 0x", "&i = 3"]) 52 53 self.expect("expression -- i", 54 startstr = "(int &&", 55 substrs = ["3"]) 56 57 self.expect("breakpoint delete 1") 58 59 self.runCmd("process continue") 60 61 self.expect("expression -- foo(2)") 62 63 self.expect("expression -- int &&j = 3; foo(j)", 64 error = True) 65 66 self.expect("expression -- int &&k = 6; k", 67 startstr = "(int) $1 = 6") 68 69 if __name__ == '__main__': 70 import atexit 71 lldb.SBDebugger.Initialize() 72 atexit.register(lambda: lldb.SBDebugger.Terminate()) 73 unittest2.main() 74