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 self.build() 12 lldbutil.run_to_source_breakpoint(self,"// break here", lldb.SBFileSpec("main.cpp")) 13 14 # Test calling a function that has const/non-const overload. 15 self.expect_expr("c.func()", result_type="int", result_value="111") 16 self.expect_expr("const_c.func()", result_type="int", result_value="222") 17 18 # Call a function that is only const on a const/non-const instance. 19 self.expect_expr("c.const_func()", result_type="int", result_value="333") 20 self.expect_expr("const_c.const_func()", result_type="int", result_value="333") 21 22 # Call a function that is not const on a const/non-const instance. 23 self.expect_expr("c.nonconst_func()", result_type="int", result_value="444") 24 self.expect("expr const_c.nonconst_func()", error=True, 25 substrs=["'this' argument to member function 'nonconst_func' has type 'const C', but function is not marked const"]) 26