1import lldb 2from lldbsuite.test.decorators import * 3from lldbsuite.test.lldbtest import * 4from lldbsuite.test import lldbutil 5 6 7class TestFunctionQualifiers(TestBase): 8 def test(self): 9 self.build() 10 lldbutil.run_to_source_breakpoint( 11 self, "// break here", lldb.SBFileSpec("main.cpp") 12 ) 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( 25 "expr const_c.nonconst_func()", 26 error=True, 27 substrs=[ 28 "'this' argument to member function 'nonconst_func' has type 'const C', but function is not marked const" 29 ], 30 ) 31