xref: /llvm-project/lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py (revision 9548dbedbc1b2bfb130c91df54e8007acb81e1b0)
1"""
2Test that LLDB correctly handles fields
3marked with [[no_unique_address]].
4"""
5
6import lldb
7from lldbsuite.test.decorators import *
8from lldbsuite.test.lldbtest import *
9from lldbsuite.test import lldbutil
10
11
12class NoUniqueAddressTestCase(TestBase):
13    def test(self):
14        self.build()
15        lldbutil.run_to_source_breakpoint(
16            self, "return 0", lldb.SBFileSpec("main.cpp", False)
17        )
18
19        # Qualified/unqualified lookup to templates in namespace
20        self.expect_expr(
21            "b1",
22            result_type="basic::Foo",
23            result_children=[ValueCheck(name="a", type="Empty")],
24        )
25
26        self.expect_expr(
27            "b2",
28            result_type="bases::Foo",
29            result_children=[
30                ValueCheck(
31                    type="bases::B", children=[ValueCheck(name="x", type="Empty")]
32                ),
33                ValueCheck(
34                    type="bases::A",
35                    children=[
36                        ValueCheck(name="c", type="long", value="1"),
37                        ValueCheck(name="d", type="long", value="2"),
38                    ],
39                ),
40                ValueCheck(
41                    type="bases::C", children=[ValueCheck(name="x", type="Empty")]
42                ),
43            ],
44        )
45        self.expect_expr(
46            "b3",
47            result_type="bases::Bar",
48            result_children=[
49                ValueCheck(
50                    type="bases::B", children=[ValueCheck(name="x", type="Empty")]
51                ),
52                ValueCheck(
53                    type="bases::C", children=[ValueCheck(name="x", type="Empty")]
54                ),
55                ValueCheck(
56                    type="bases::A",
57                    children=[
58                        ValueCheck(name="c", type="long", value="5"),
59                        ValueCheck(name="d", type="long", value="6"),
60                    ],
61                ),
62            ],
63        )
64
65        self.expect("frame var b1")
66        self.expect("frame var b2")
67        self.expect("frame var b3")
68