45 lines · python
1"""2Tests that C++ expression evaluation can3disambiguate between rvalue and lvalue4reference-qualified functions.5"""6 7import lldb8from lldbsuite.test.decorators import *9from lldbsuite.test.lldbtest import *10from lldbsuite.test import lldbutil11 12 13class TestFunctionRefQualifiers(TestBase):14 def test(self):15 self.build()16 lldbutil.run_to_source_breakpoint(17 self, "Break here", lldb.SBFileSpec("main.cpp")18 )19 20 # const lvalue21 self.expect_expr("const_foo.func()", result_type="uint32_t", result_value="0")22 23 # const rvalue24 self.expect_expr(25 "static_cast<Foo const&&>(Foo{}).func()",26 result_type="int64_t",27 result_value="1",28 )29 30 # non-const lvalue31 self.expect_expr("foo.func()", result_type="uint32_t", result_value="2")32 33 # non-const rvalue34 self.expect_expr("Foo{}.func()", result_type="int64_t", result_value="3")35 36 self.filecheck("target modules dump ast", __file__)37 # CHECK: |-CXXMethodDecl {{.*}} func 'uint32_t () const &'38 # CHECK-NEXT: | `-AsmLabelAttr {{.*}}39 # CHECK-NEXT: |-CXXMethodDecl {{.*}} func 'int64_t () const &&'40 # CHECK-NEXT: | `-AsmLabelAttr {{.*}}41 # CHECK-NEXT: |-CXXMethodDecl {{.*}} func 'uint32_t () &'42 # CHECK-NEXT: | `-AsmLabelAttr {{.*}}43 # CHECK-NEXT: `-CXXMethodDecl {{.*}} func 'int64_t () &&'44 # CHECK-NEXT: `-AsmLabelAttr {{.*}}45