xref: /llvm-project/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py (revision 07ffb7e294767b74e43f90e9ab3d713da929b907)
1"""
2Tests that we correctly track AST layout info
3(specifically alignment) when moving AST nodes
4between ClangASTImporter instances (in this case,
5from pch to executable to expression AST).
6"""
7
8import lldb
9import os
10from lldbsuite.test.decorators import *
11from lldbsuite.test.lldbtest import *
12from lldbsuite.test import lldbutil
13
14
15class TestPchAlignment(TestBase):
16    @add_test_categories(["gmodules"])
17    def test_expr(self):
18        self.build()
19        lldbutil.run_to_source_breakpoint(
20            self, "return data", lldb.SBFileSpec("main.cpp")
21        )
22
23        self.expect(
24            "frame variable data",
25            substrs=["row = 1", "col = 2", "row = 3", "col = 4", "stride = 5"],
26        )
27
28    @add_test_categories(["gmodules"])
29    def test_frame_var(self):
30        self.build()
31        lldbutil.run_to_source_breakpoint(
32            self, "return data", lldb.SBFileSpec("main.cpp")
33        )
34
35        self.expect_expr(
36            "data",
37            result_type="MatrixData",
38            result_children=[
39                ValueCheck(
40                    name="section",
41                    children=[
42                        ValueCheck(
43                            name="origin",
44                            children=[
45                                ValueCheck(name="row", value="1"),
46                                ValueCheck(name="col", value="2"),
47                            ],
48                        ),
49                        ValueCheck(
50                            name="size",
51                            children=[
52                                ValueCheck(name="row", value="3"),
53                                ValueCheck(name="col", value="4"),
54                            ],
55                        ),
56                    ],
57                ),
58                ValueCheck(name="stride", value="5"),
59            ],
60        )
61